From 373afd140a28eb706282fd4891e2e75b507b18aa Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Fri, 21 Aug 2009 16:47:09 +0200 Subject: 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. --- src/defs.lisp | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/defs.lisp (limited to 'src/defs.lisp') 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)) -- cgit v1.1