Author: ehuelsmann Date: Fri Jan 19 18:53:45 2007 New Revision: 184
Modified: usocket/trunk/package.lisp usocket/trunk/usocket.lisp Log: Add ip comparison functions ip= and ip/=.
Modified: usocket/trunk/package.lisp ============================================================================== --- usocket/trunk/package.lisp (original) +++ usocket/trunk/package.lisp Fri Jan 19 18:53:45 2007 @@ -30,11 +30,13 @@ #:socket #:socket-stream
- #:host-byte-order ; IPv4 utility functions + #:host-byte-order ; IP(v4) utility functions #:hbo-to-dotted-quad #:hbo-to-vector-quad #:vector-quad-to-dotted-quad #:dotted-quad-to-vector-quad + #:ip= + #:ip/=
#:socket-condition ; conditions #:socket-error ; errors
Modified: usocket/trunk/usocket.lisp ============================================================================== --- usocket/trunk/usocket.lisp (original) +++ usocket/trunk/usocket.lisp Fri Jan 19 18:53:45 2007 @@ -121,7 +121,7 @@ ,@body))
;; -;; IPv4 utility functions +;; IP(v4) utility functions ;;
(defun list-of-strings-to-integers (list) @@ -173,6 +173,29 @@ (+ (* (aref vector 0) 256 256 256) (* (aref vector 1) 256 256) (* (aref vector 2) 256) (aref vector 3)))
+(defmethod host-byte-order ((int integer)) + int) + +(defun host-to-hostname (host) + "Translate a string or vector quad to a stringified hostname." + (etypecase host + (string host) + ((vector t 4) (vector-quad-to-dotted-quad host)) + (integer (hbo-to-dotted-quad host)))) + +(defun ip= (ip1 ip2) + (etypecase ip1 + (string (string= ip1 (host-to-hostname ip2))) + ((vector t 4) (or (eq ip1 ip2) + (and (= (aref ip1 0) (aref ip2 0)) + (= (aref ip1 1) (aref ip2 1)) + (= (aref ip1 2) (aref ip2 2)) + (= (aref ip1 3) (aref ip2 3))))) + (integer (= ip1 (host-byte-order ip2))))) + +(defun ip/= (ip1 ip2) + (not (ip= ip1 ip2))) + ;; ;; DNS helper functions ;; @@ -210,13 +233,6 @@ ((vector t 4) (host-byte-order host)) (integer host))))
-(defun host-to-hostname (host) - "Translate a string or vector quad to a stringified hostname." - (etypecase host - (string host) - ((vector t 4) (vector-quad-to-dotted-quad host)) - (integer (hbo-to-dotted-quad host)))) - ;; ;; Setting of documentation for backend defined functions ;;