[cl-net-snmp-cvs] r61 - in trunk: . asn.1 smi snmp
ctian at common-lisp.net
ctian at common-lisp.net
Thu Sep 27 16:36:17 UTC 2007
Author: ctian
Date: Thu Sep 27 12:36:16 2007
New Revision: 61
Added:
trunk/asn.1/devel.lisp
trunk/smi/message.lisp
trunk/snmp/constants.lisp
trunk/snmp/session.lisp
Removed:
trunk/constants.lisp
Modified:
trunk/asn.1/syntax.lisp
trunk/net-snmp.asd
trunk/smi/ipaddr.lisp
trunk/smi/package.lisp
trunk/snmp/package.lisp
Log:
SNMP Module
Added: trunk/asn.1/devel.lisp
==============================================================================
--- (empty file)
+++ trunk/asn.1/devel.lisp Thu Sep 27 12:36:16 2007
@@ -0,0 +1,7 @@
+(in-package :asn.1)
+
+(defun update-syntax (&optional (zb *asn.1-syntax-source*) (tab *asn.1-syntax*))
+ (let ((*warn-conflicts* t)
+ (*allow-conflicts* t))
+ (zebu-compile-file zb :output-file tab)
+ (zebu-load-file tab)))
Modified: trunk/asn.1/syntax.lisp
==============================================================================
--- trunk/asn.1/syntax.lisp (original)
+++ trunk/asn.1/syntax.lisp Thu Sep 27 12:36:16 2007
@@ -16,11 +16,5 @@
(DECLARE (IGNORE LEVEL))
(FORMAT STREAM "<GPF>"))
-(defun update-syntax (&optional (zb *asn.1-syntax-source*) (tab *asn.1-syntax*))
- (let ((*warn-conflicts* t)
- (*allow-conflicts* t))
- (zebu-compile-file zb :output-file tab)
- (zebu-load-file tab)))
-
(eval-when (:load-toplevel :execute)
(zebu-load-file *asn.1-syntax*))
Modified: trunk/net-snmp.asd
==============================================================================
--- trunk/net-snmp.asd (original)
+++ trunk/net-snmp.asd Thu Sep 27 12:36:16 2007
@@ -10,15 +10,14 @@
(defsystem net-snmp
:description "Simple Network Manangement Protocol"
- :version "0.7"
+ :version "0.8"
:author "Chun Tian (binghe) <binghe.lisp at gmail.com>"
:depends-on (:cl-fad ; for directory and file
:cl-ppcre ; for oid resolve
:ironclad ; for v3 support
- :net-telent-date ; for time conv
- #-win32 :iolib ; for network
- :zebu ; for mib parse
- :zebu-compiler) ; for asn.1 syntax compile
+ :net-telent-date ; for time convert
+ #-(and lispworks win32) :iolib
+ :zebu) ; for mib parse
:components (;; ASN.1
(:module asn.1
:components ((:file "package")
@@ -34,7 +33,8 @@
(:file "ipaddr" :depends-on ("package"))
(:file "oid" :depends-on ("package"))
(:file "pdu" :depends-on ("package"))
- (:file "bulk-pdu" :depends-on ("pdu")))
+ (:file "bulk-pdu" :depends-on ("pdu"))
+ (:file "message" :depends-on ("package")))
:depends-on (asn.1))
;; MIB
(:module mib
@@ -46,27 +46,20 @@
:depends-on (smi))
;; SNMP
(:module snmp
- :components ((:file "package"))
+ :components ((:file "package")
+ (:file "constants" :depends-on ("package"))
+ (:file "session" :depends-on ("constants")))
:depends-on (asn.1 smi mib))))
-;; (:file "package")
-;; (:file "constants" :depends-on ("package"))
-;; (:file "typedefs" :depends-on ("constants"))
-;; (:file "snmp-api" :depends-on ("typedefs"))
-;; (:file "load" :depends-on ("snmp-api"))
-;; (:file "asn1" :depends-on ("load"))
-;; (:file "classes" :depends-on ("asn1"))))
-
-(defsystem sabrina
- :description "Sabrina - Update server status into database"
+(defsystem net-snmp-devel
+ :description "SNMP Develop"
:version "0.1"
:author "Chun Tian (binghe) <binghe.lisp at gmail.com>"
:depends-on (:net-snmp
- :hunchentoot
- :clsql-postgresql)
- :components ((:file "sabrina")
- (:file "zilong" :depends-on ("sabrina"))
- (:file "prettyhell" :depends-on ("sabrina"))))
+ :zebu-compiler) ; for asn.1 syntax compile
+ :components (;; ASN.1
+ (:module asn.1
+ :components ((:file "devel")))))
;; (fli:start-collecting-template-info)
;;(defun make-fli-templates ()
Modified: trunk/smi/ipaddr.lisp
==============================================================================
--- trunk/smi/ipaddr.lisp (original)
+++ trunk/smi/ipaddr.lisp Thu Sep 27 12:36:16 2007
@@ -1,2 +1,3 @@
(in-package :smi)
+;;; We use net.sockets:sockaddr class as ipaddr type.
Added: trunk/smi/message.lisp
==============================================================================
--- (empty file)
+++ trunk/smi/message.lisp Thu Sep 27 12:36:16 2007
@@ -0,0 +1,23 @@
+(in-package :smi)
+
+(defclass message ()
+ ((version :type integer
+ :initarg :version
+ :reader version)
+ (community :type string
+ :initarg :community
+ :reader comminity)
+ (data :initarg :data
+ :reader data)))
+
+(defmethod ber-encode ((value message))
+ (with-slots (version community data) value
+ (ber-encode (list version community data))))
+
+(defmethod decode-message (stream)
+ (declare (type stream stream))
+ (destructuring-bind (version community pdu) (ber-decode stream)
+ (make-instance 'message
+ :version version
+ :community community
+ :data pdu)))
Modified: trunk/smi/package.lisp
==============================================================================
--- trunk/smi/package.lisp (original)
+++ trunk/smi/package.lisp Thu Sep 27 12:36:16 2007
@@ -2,7 +2,7 @@
(defpackage com.netease.smi
(:nicknames smi)
- (:use :common-lisp :asn.1)
+ (:use :common-lisp :asn.1 #-(and lispworks win32) :net.sockets)
(:export object-id oid make-object-id rev-ids rev-names
get-request-pdu
get-next-request-pdu
@@ -10,7 +10,9 @@
set-request-pdu
inform-request-pdu
snmpv2-trap-pdu
- report-pdu))
+ report-pdu
+ message
+ decode-message))
(in-package :smi)
Added: trunk/snmp/constants.lisp
==============================================================================
--- (empty file)
+++ trunk/snmp/constants.lisp Thu Sep 27 12:36:16 2007
@@ -0,0 +1,98 @@
+(in-package :snmp)
+
+(defconstant +min-oid-len+ 2)
+(defconstant +max-oid-len+ 128)
+
+(defconstant +usm-auth-ku-len+ 32)
+(defconstant +usm-priv-ku-len+ 32)
+
+(defconstant +asn-boolean+ #x01)
+(defconstant +asn-integer+ #x02)
+(defconstant +asn-bit-str+ #x03)
+(defconstant +asn-octet-str+ #x04)
+(defconstant +asn-null+ #x05)
+(defconstant +asn-object-id+ #x06)
+(defconstant +asn-sequence+ #x10)
+(defconstant +asn-set+ #x11)
+
+(defconstant +asn-universal+ #b00000000)
+(defconstant +asn-application+ #b01000000)
+(defconstant +asn-context+ #b10000000)
+(defconstant +asn-private+ #b11000000)
+
+(defconstant +asn-primitive+ #b00000000)
+(defconstant +asn-constructor+ #b00100000)
+
+;; defined types (from the SMI, RFC 1157)
+(defconstant +asn-ipaddress+ (logior +asn-application+ 0))
+(defconstant +asn-counter+ (logior +asn-application+ 1))
+(defconstant +asn-gauge+ (logior +asn-application+ 2))
+(defconstant +asn-unsigned+ (logior +asn-application+ 2))
+(defconstant +asn-timeticks+ (logior +asn-application+ 3))
+(defconstant +asn-opaque+ (logior +asn-application+ 4))
+
+;; defined types (from the SMI, RFC 1442)
+(defconstant +asn-nsap+ (logior +asn-application+ 5))
+(defconstant +asn-counter64+ (logior +asn-application+ 6))
+(defconstant +asn-uinteger+ (logior +asn-application+ 7))
+
+(defconstant +asn-float+ (logior +asn-application+ 8))
+(defconstant +asn-double+ (logior +asn-application+ 9))
+
+;;; from snmp.h
+(defconstant +snmp-version-1+ 0)
+(defconstant +snmp-version-2c+ 1)
+(defconstant +snmp-version-3+ 3)
+
+(defconstant +snmp-sec-model-any+ 0)
+(defconstant +snmp-sec-model-snmpv1+ 1)
+(defconstant +snmp-sec-model-snmpv2c+ 2)
+(defconstant +snmp-sec-model-usm+ 3)
+
+(defconstant +snmp-sec-level-noauth+ 1)
+(defconstant +snmp-sec-level-authnopriv+ 2)
+(defconstant +snmp-sec-level-authpriv+ 3)
+
+;; PDU types in SNMPv1, SNMPsec, SNMPv2p, SNMPv2c, SNMPv2u, SNMPv2*, and SNMPv3
+(defconstant +snmp-msg-get+
+ (logior +asn-context+ +asn-constructor+ 0))
+
+(defconstant +snmp-msg-getnext+
+ (logior +asn-context+ +asn-constructor+ 1))
+
+(defconstant +snmp-msg-response+
+ (logior +asn-context+ +asn-constructor+ 2))
+
+(defconstant +snmp-msg-set+
+ (logior +asn-context+ +asn-constructor+ 3))
+
+;; PDU types in SNMPv1 and SNMPsec
+(defconstant +snmp-msg-trap+
+ (logior +asn-context+ +asn-constructor+ 4))
+
+;; PDU types in SNMPv2p, SNMPv2c, SNMPv2u, SNMPv2*, and SNMPv3
+(defconstant +snmp-msg-getbulk+
+ (logior +asn-context+ +asn-constructor+ 5))
+
+(defconstant +snmp-msg-inform+
+ (logior +asn-context+ +asn-constructor+ 6))
+
+(defconstant +snmp-msg-trap2+
+ (logior +asn-context+ +asn-constructor+ 7))
+
+;; PDU types in SNMPv2u, SNMPv2*, and SNMPv3
+(defconstant +snmp-msg-report+
+ (logior +asn-context+ +asn-constructor+ 8))
+
+;;; from snmp_client.h
+(defconstant +snmp-stat-success+ 0)
+(defconstant +snmp-stat-error+ 1)
+(defconstant +snmp-stat-timeout+ 2)
+
+(defconstant +snmp-err-success+ 0)
+(defconstant +snmp-err-noerror+ 0)
+(defconstant +snmp-err-toobig+ 1)
+(defconstant +snmp-err-nosuchname+ 2)
+(defconstant +snmp-err-badvalue+ 3)
+(defconstant +snmp-err-readonly+ 4)
+(defconstant +snmp-err-generr+ 5)
Modified: trunk/snmp/package.lisp
==============================================================================
--- trunk/snmp/package.lisp (original)
+++ trunk/snmp/package.lisp Thu Sep 27 12:36:16 2007
@@ -3,6 +3,6 @@
(defpackage :com.netease.snmp
(:nicknames snmp)
(:use :common-lisp)
- (:export ))
+ (:export v1-session v2c-session v3-session))
(in-package :snmp)
Added: trunk/snmp/session.lisp
==============================================================================
--- (empty file)
+++ trunk/snmp/session.lisp Thu Sep 27 12:36:16 2007
@@ -0,0 +1,33 @@
+(in-package :snmp)
+
+(defclass session ()
+ ((peername :reader peername
+ :initarg :peername
+ :type string)
+ (version :reader version
+ :initarg :version
+ :type integer
+ :initform +snmp-version-2c+)))
+
+(defclass v1-session (session)
+ ((community :reader community
+ :initarg :community
+ :type string
+ :initform "public")))
+
+(defclass v2c-session (v1-session) ())
+
+(defclass v3-session (session)
+ ((security-name :reader security-name
+ :initarg :security-name
+ :type string)
+ (security-level :reader security-level
+ :initarg :security-level
+ :type integer
+ :initform +snmp-sec-level-authnopriv+)
+ (security-auth-proto :reader security-auth-proto
+ :initarg :security-auth-proto
+ :type (member :hmac-md5 :hmac-sha1)
+ :initform :hmac-md5)
+ (passphrase :initarg :passphrase
+ :type string)))
More information about the Cl-net-snmp-cvs
mailing list