Add netlink address class
authorStelian Ionescu <sionescu@cddr.org>
Sun, 5 May 2013 01:23:09 +0000 (5 03:23 +0200)
committerStelian Ionescu <sionescu@cddr.org>
Sun, 5 May 2013 01:23:09 +0000 (5 03:23 +0200)
src/sockets/address.lisp
src/sockets/pkgdcl.lisp

index 9852543..d5478e3 100644 (file)
@@ -35,6 +35,10 @@ ADDRESS-NAME reader."))
 (unset-method-docstring #'abstract-address-p () '(local-address))
 (set-function-docstring 'abstract-address-p "Return T if ADDRESS is a LOCAL-ADDRESS that lives in the abstract namespace.")
 
+(defclass netlink-address (address)
+  ((multicast-groups :initform 0 :initarg :multicast-groups
+                     :reader netlink-address-multicast-groups)))
+
 (defmethod initialize-instance :after ((address local-address) &key)
   (with-slots (name) address
     (etypecase name
@@ -347,6 +351,9 @@ returned unmodified."
   (format nil "~:[~;@~]~S" (abstract-address-p address)
           (address-name address)))
 
+(defmethod address-to-string ((address netlink-address))
+  (format nil "~A" (netlink-address-multicast-groups address)))
+
 (defmethod print-object ((address inet-address) stream)
   (let ((namestring (address-to-string address)))
     (if (or *print-readably* *print-escape*)
@@ -358,6 +365,11 @@ returned unmodified."
     (format stream "Unix socket address: ~A"
             (address-to-string address))))
 
+(defmethod print-object ((address netlink-address) stream)
+  (print-unreadable-object (address stream :type nil :identity nil)
+    (format stream "Netlink socket address: ~A"
+            (address-to-string address))))
+
 ;;;; Reader Macro
 
 (define-literal-reader ip (stream)
index c1a91d9..7ea7e0f 100644 (file)
@@ -62,6 +62,7 @@
    #:ipv4-address
    #:ipv6-address
    #:local-address
+   #+linux #:netlink-address
 
    ;; Address Functions
    #:address-name
@@ -71,6 +72,7 @@
    #:copy-address
    #:ensure-address
    #:make-address
+   #+linux #:netlink-address-multicast-groups
 
    ;; Well-known Addresses
    #:+ipv4-loopback+