[cl-net-snmp-cvs] r76 - in trunk: . asn.1 mib smi snmp

ctian at common-lisp.net ctian at common-lisp.net
Wed Oct 17 16:08:21 UTC 2007


Author: ctian
Date: Wed Oct 17 12:08:20 2007
New Revision: 76

Added:
   trunk/mib/print-oid.lisp
Modified:
   trunk/asn.1/asn.1-domain.lisp
   trunk/asn.1/package.lisp
   trunk/mib/package.lisp
   trunk/mib/tree.lisp
   trunk/net-snmp.asd
   trunk/smi/oid.lisp
   trunk/smi/package.lisp
   trunk/snmp/package.lisp
Log:
custom oid display, short package names

Modified: trunk/asn.1/asn.1-domain.lisp
==============================================================================
--- trunk/asn.1/asn.1-domain.lisp	(original)
+++ trunk/asn.1/asn.1-domain.lisp	Wed Oct 17 12:08:20 2007
@@ -1,6 +1,6 @@
 ;;; This file was generated by Zebu (Version 3.5.5)
 
-(IN-PACKAGE "COM.NETEASE.ASN.1")
+(IN-PACKAGE "ASN.1")
 (REQUIRE "zebu-package")
 (USE-PACKAGE "ZEBU")
 

Modified: trunk/asn.1/package.lisp
==============================================================================
--- trunk/asn.1/package.lisp	(original)
+++ trunk/asn.1/package.lisp	Wed Oct 17 12:08:20 2007
@@ -1,7 +1,6 @@
 (in-package :snmp.system)
 
-(defpackage com.netease.asn.1
-  (:nicknames asn.1)
+(defpackage asn.1
   (:use :common-lisp
         #+lispworks :stream #+sbcl :sb-gray #+clisp :gray
         :zebu)

Modified: trunk/mib/package.lisp
==============================================================================
--- trunk/mib/package.lisp	(original)
+++ trunk/mib/package.lisp	Wed Oct 17 12:08:20 2007
@@ -1,7 +1,6 @@
 (in-package :snmp.system)
 
-(defpackage :com.netease.mib
-  (:nicknames mib)
+(defpackage mib
   (:use :common-lisp
         :asn.1 :smi :zebu)
   (:export *mib-tree* *mib-index*

Added: trunk/mib/print-oid.lisp
==============================================================================
--- (empty file)
+++ trunk/mib/print-oid.lisp	Wed Oct 17 12:08:20 2007
@@ -0,0 +1,21 @@
+(in-package :mib)
+
+(defmethod print-object ((obj object-id) stream)
+  (with-slots (rev-ids rev-names) obj
+    (print-unreadable-object (obj stream :type t)
+      (when *oid-print-id*
+        (let ((part-1 (reverse rev-ids)))
+          (format stream "~A~{.~A~}" (car part-1) (cdr part-1))))
+      (when (and *oid-print-id* *oid-print-name*)
+        (format stream " ("))
+      (when *oid-print-name*
+        (let ((part-2 (if rev-names
+                        (reverse rev-names)
+                        (resolve (reverse rev-ids)))))
+          (when *oid-print-short*
+            (setf part-2 (nthcdr (- (oid-length obj) *oid-print-length*) part-2)))
+          (format stream "~A~{.~A~}"
+                  (car part-2)
+                  (cdr part-2))))
+      (when (and *oid-print-id* *oid-print-name*)
+        (format stream ")")))))

Modified: trunk/mib/tree.lisp
==============================================================================
--- trunk/mib/tree.lisp	(original)
+++ trunk/mib/tree.lisp	Wed Oct 17 12:08:20 2007
@@ -85,19 +85,6 @@
                                                 (tree-id (gethash (first names) *mib-index*)))))
           (t nil))))
 
-(defmethod print-object ((obj object-id) stream)
-  (with-slots (rev-ids rev-names) obj
-    (print-unreadable-object (obj stream :type t)
-      (let ((part-1 (reverse rev-ids))
-            (part-2 (if rev-names
-                        (reverse rev-names)
-                      (resolve (reverse rev-ids)))))
-        (format stream "~A~{.~A~} {~A~{.~A~}}"
-                (car part-1)
-                (cdr part-1)
-                (car part-2)
-                (cdr part-2))))))
-
 (defun parse-mib (file &key (verbose nil))
   (let ((*comment-start* "--")
         (*comment-brackets* '(("/*" . "*/")))

Modified: trunk/net-snmp.asd
==============================================================================
--- trunk/net-snmp.asd	(original)
+++ trunk/net-snmp.asd	Wed Oct 17 12:08:20 2007
@@ -2,8 +2,7 @@
 
 (in-package :cl-user)
 
-(defpackage com.netease.snmp.system
-  (:nicknames snmp.system)
+(defpackage snmp.system
   (:use :common-lisp :asdf)
   (:export #+lispworks make-fli-templates))
 
@@ -11,7 +10,7 @@
 
 (defsystem net-snmp
   :description "Simple Network Manangement Protocol"
-  :version "1.1"
+  :version "1.2"
   :author "Chun Tian (binghe) <binghe.lisp at gmail.com>"
   :depends-on (:cl-fad          ; for directory and file
                :cl-ppcre        ; for oid resolve
@@ -46,6 +45,7 @@
                 :components ((:file "package")
 			     (:file "tree"      :depends-on ("package"))
 			     (:file "build"     :depends-on ("tree"))
+                             (:file "print-oid" :depends-on ("tree"))
 			     #+lispworks
 			     (:file "browser"   :depends-on ("tree")))
 		:depends-on (smi))

Modified: trunk/smi/oid.lisp
==============================================================================
--- trunk/smi/oid.lisp	(original)
+++ trunk/smi/oid.lisp	Wed Oct 17 12:08:20 2007
@@ -4,6 +4,11 @@
 
 (in-package :smi)
 
+(defvar *oid-print-name* t)
+(defvar *oid-print-id* nil)
+(defvar *oid-print-short* t)
+(defvar *oid-print-length* 2)
+
 (defclass object-id ()
   ((rev-ids :initform nil :type list :reader oid-revid :initarg :id)
    (rev-names :initform nil :type list :reader oid-name :initarg :name)

Modified: trunk/smi/package.lisp
==============================================================================
--- trunk/smi/package.lisp	(original)
+++ trunk/smi/package.lisp	Wed Oct 17 12:08:20 2007
@@ -1,13 +1,15 @@
 (in-package :snmp.system)
 
-(defpackage com.netease.smi
-  (:nicknames smi)
+(defpackage smi
   (:use :common-lisp :asn.1 #-(and lispworks win32) :net.sockets)
   (:export ;; general
            value-of general-type plain-value
            ;; object-id
            object-id oid make-object-id rev-ids rev-names
+	   oid-length oid-revid oid-name
            oid-<
+           *oid-print-name* *oid-print-id* *oid-print-short*
+           *oid-print-length*
            ;; pdu
            get-request-pdu
            get-next-request-pdu
@@ -43,4 +45,4 @@
 (defmethod plain-value ((object general-type))
   (value-of object))
 
-(defparameter *version* 2)
+(defparameter *version* 3)

Modified: trunk/snmp/package.lisp
==============================================================================
--- trunk/snmp/package.lisp	(original)
+++ trunk/snmp/package.lisp	Wed Oct 17 12:08:20 2007
@@ -1,8 +1,8 @@
 (in-package :snmp.system)
 
-(defpackage :com.netease.snmp
-  (:nicknames snmp)
-  (:use :common-lisp :smi :asn.1 :mib #-win32 :net.sockets #-win32 :io.streams)
+(defpackage snmp
+  (:use :common-lisp :smi :asn.1 :mib
+	#-win32 :net.sockets #-win32 :io.streams)
   (:export v1-session v2c-session v3-session make-session
            *default-version* *default-community* *default-port*
            snmp-get snmp-walk))



More information about the Cl-net-snmp-cvs mailing list