;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- ;; Copyright 2009, NORDUnet A/S. ;; ;; This file is part of Eduroam-stats. ;; ;; Eduroam-stats is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 2 of the License, or ;; (at your option) any later version. ;; ;; Eduroam-stats is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with Eduroam-stats. If not, see . (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))