X-Git-Url: https://git.distorted.org.uk/~mdw/zone/blobdiff_plain/32ebbe9b0fcc1a698c6ffec760259c5f7e953a9d..78d11eb172a3cf0ae51133eb13c9a7635d30ad84:/net.lisp diff --git a/net.lisp b/net.lisp index c8852f9..7480b3c 100644 --- a/net.lisp +++ b/net.lisp @@ -156,8 +156,8 @@ (eq (class-of addr-a) (class-of addr-b)))) (defun guess-address-class (str &key (start 0) (end nil)) - (declare (ignore str start end)) - 'ip4addr) + (cond ((position #\: str :start start :end end) 'ip6addr) + (t 'ip4addr))) (defgeneric parse-partial-ipaddr (class str &key start end min max) (:method ((object t) str &rest keywords) @@ -244,7 +244,7 @@ (let ((w (ipaddr-width addr))) (if (<= 0 mask w) (integer-netmask w mask) - (error "Mask out of range."))))) + (error "Prefix length out of range."))))) (export 'mask-ipaddr) (defun mask-ipaddr (addr mask) @@ -315,7 +315,7 @@ (print-unreadable-object (ipn stream :type t) (write-string (ipnet-string ipn) stream))) -(defun parse-subnet (class width max str &key (start 0) (end nil)) +(defun parse-subnet (class width max str &key (start 0) (end nil)) "Parse a subnet description from a (substring of) STR." (setf-default end (length str)) (let ((sl (position #\/ str :start start :end end))) @@ -376,6 +376,7 @@ (export 'string-subipnet) (defun string-subipnet (ipn str &key (start 0) (end nil)) + "Parse an IP subnet from a parent net IPN and a suffix string STR." (setf str (stringify str)) (let* ((addr-class (extract-class-name (ipnet-net ipn))) (width (ipaddr-width addr-class))