blob: 4674638b009deb38e7ba1d42147dcef6c61b3e8b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
;; http://common-lisp.net/project/postmodern/
(defparameter *xmlns* "urn:ietf:params:xml:ns:xfb-0.1")
(defparameter *version* 0.1)
;; XML attributes, all required:
;; (xmlns :col-type string :initform *xmlns*)
;; (version :col-type string :initform *version*)
;; (length :col-type string :initarg length)
; (require 'postmodern)
; (use-package 'postmodern)
(defclass bgp-message ()
(
;;TIME
(timestamp :col-type integer)
(datetime :col-type (or db-null string))
(precision_time :col-type (or db-null integer))
;; PEERING
(src_addr :col-type string)
(dst_addr :col-type string)
(src_port :col-type string)
(dst_port :col-type string)
(src_as :col-type (or db-null string))
(dst_as :col-type (or db-null string))
;; OCTET_MSG
(oct-marker :col-type string)
(oct-length :col-type integer)
(oct-type :col-type integer) ; FIXME: is there an enum or small integer?
(oct-octets :col-type string)
;; ASCII_MSG
(asc-marker :col-type string)
(asc-length :col-type integer)
(asc-type :col-type integer) ; FIXME: is there an enum or small integer?
)
(:metaclass dao-class)
(:keys timestamp))
;; (connect-toplevel "linus" "linus" "" "localhost")
;; (execute (dao-table-definition 'bgp-message))
;; BGP_MESSAGE {TIME {TIMESTAMP {1245842681} DATETIME {2009-06-24T11:24:41Z} PRECISION_TIME {185} } PEERING {SRC_ADDR {193.10.255.88} SRC_PORT {179} SRC_AS {2603} DST_ADDR {193.10.252.3} DST_PORT {179} DST_AS {2603} } ASCII_MSG {MARKER {FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF} LENGTH {87} TYPE {UPDATE} UPDATE {WITHDRAWN_LEN {24} WITHDRAWN {PREFIX {92.46.244/23} PREFIX {95.59.2/23} PREFIX {95.59.4/22} PREFIX {95.59.8/23} PREFIX {89.218.218/23} PREFIX {89.218.220/23} } PATH_ATTRIBUTES_LEN {36} PATH_ATTRIBUTES {ATTRIBUTE {FLAGS {TRANSITIVE {} } LENGTH {1} TYPE {ORIGIN} ORIGIN {IGP} } ATTRIBUTE {FLAGS {TRANSITIVE {} } LENGTH {8} TYPE {AS_PATH} AS_PATH {AS {1299} AS {702} AS {3216} } } ATTRIBUTE {FLAGS {TRANSITIVE {} } LENGTH {4} TYPE {NEXT_HOP} NEXT_HOP {213.248.97.93} } ATTRIBUTE {FLAGS {TRANSITIVE {} } LENGTH {4} TYPE {LOCAL_PREF} LOCAL_PREF {80} } ATTRIBUTE {FLAGS {OPTIONAL {} TRANSITIVE {} } LENGTH {4} TYPE {COMMUNITIES} COMMUNITIES {COMMUNITY {AS {2603} VALUE {666} } } } } NLRI {PREFIX {95.30.48/22} } } } OCTET_MSG {MARKER {FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF} LENGTH {87} TYPE {UPDATE} OCTETS {FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0057020018175C2EF4175F3B02165F3B04175F3B081759DADA1759DADC0024400101004002080203051302BE0C90400304D5F8615D40050400000050C008040A2B029A165F1E30} } }
(defun new-entry (xml-doc)
"Return a fresh BGP-MESSAGE built from XML-DOC (array of unsigned bytes)."
(let ((s (cxml:make-source xml-doc))
(e (make-instance 'bgp-message))
(cur-ctxt nil)
(cur-name nil))
(do ((key (klacks:peek s) (klacks:peek s)))
((null key) e)
(case key
(:start-element (let ((tag (klacks:current-qname s)))
(setf cur-ctxt (cond
((string= tag "OCTET_MSG") "OCT-")
((string= tag "ASCII_MSG") "ASC-")
(t cur-ctxt)))
(setf cur-name (concatenate 'string cur-ctxt tag))))
(:end-element (let ((tag (klacks:current-qname s)))
(when *debug2* (print tag))
(setf cur-ctxt (cond
((string= tag "OCTET_MSG") nil)
((string= tag "ASCII_MSG") nil)
(t cur-ctxt)))
(setf cur-name nil)))
(:characters (progn
(when *debug2* (format t "cur-name: ~A, cur-ctxt: ~A~%" cur-name cur-ctxt))
(setf (slot-value e (intern cur-name))
(klacks:current-characters s)))))
(klacks:consume s))))
|