diff options
author | Linus Nordberg <linus@nordu.net> | 2009-08-21 16:47:09 +0200 |
---|---|---|
committer | Linus Nordberg <linus@nordu.net> | 2009-08-21 16:47:09 +0200 |
commit | 373afd140a28eb706282fd4891e2e75b507b18aa (patch) | |
tree | 9b0cb9e70871936cbc94511df8401c3d460741d6 /src/defs.lisp | |
parent | c64ce57afa8700c52937cfbfd2669a383804e01b (diff) |
Restructure and add bgpview.
There's one package, BGP-LOGGER, defined in src/package.lisp.
There are two systems, BGPSTORE and BGPVIEW, defined in bgpstore.asd
and bgpview.asd respectively.
The package exports START-BGPSTORE, START-BGPVIEW and their STOP-
counterparts.
Diffstat (limited to 'src/defs.lisp')
-rw-r--r-- | src/defs.lisp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/defs.lisp b/src/defs.lisp new file mode 100644 index 0000000..a02a7e9 --- /dev/null +++ b/src/defs.lisp @@ -0,0 +1,55 @@ +;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- + +(in-package :bgp-logger) + +;; FIXME: Remove password. +(defparameter *db-spec* '("bgpstore" "bgpstore" "bgpstore" "localhost" )) + +;; 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 () + ((id :col-type serial) + (timestamp :col-type integer :accessor timestamp :initform 0) + (precision-time :col-type (or db-null smallint) :accessor precision-time :initform 0) + (prefix :col-type cidr :accessor prefix :initarg :prefix) + (label :col-type string ;FIXME: smallint or enum + :accessor label :initarg :label + :documentation "1-NANN, 2-WITH, 3-DANN, 4-DUPW, 5-DPATH, 6-SPATH") + (path :col-type (or db-null integer[]) :accessor path :initform "{}") + (nexthop :col-type (or db-null inet) :accessor nexthop :initform "0.0.0.0") + (bgp-octets :col-type string :accessor bgp-octets)) ; FIXME: binary to save space. + (:metaclass dao-class) + (:keys id)) + +;; Database. +;; Create table by evaluating +;; (connect-toplevel "bgpstore" "bgpstore" "bgpstore" "localhost") +;; (execute (dao-table-definition 'bgp-message)) + +;; XML. +;; node elements have dom:tag-name +;; text elements have dom:data + +;(defun prefix-pair (node)) + +(defun new-bgp-message (templ pref) + (let ((msg (make-instance 'bgp-message + :prefix (car pref) + :label (cadr pref)))) + ;; FIXME: Use accessor functions. + ;; FIXME2: Move this to a method of the class. + (setf (slot-value msg 'timestamp) (slot-value templ 'timestamp) + (slot-value msg 'precision-time) (slot-value templ 'precision-time) + (slot-value msg 'path) (slot-value templ 'path) + (slot-value msg 'nexthop) (slot-value templ 'nexthop) + (slot-value msg 'bgp-octets) (slot-value templ 'bgp-octets)) + msg)) |