From: Mark Wooding Date: Fri, 25 Apr 2014 21:37:17 +0000 (+0100) Subject: Merge branch 'master' of git.distorted.org.uk:~mdw/publish/public-git/zone X-Git-Url: https://git.distorted.org.uk/~mdw/zone/commitdiff_plain/804882ca1c12315b7943c6f71f7bb43866a7a301?hp=fffebf35970307ed798db324a9399e31c241b02d Merge branch 'master' of git.distorted.org.uk:~mdw/publish/public-git/zone * 'master' of git.distorted.org.uk:~mdw/publish/public-git/zone: addr-family-ipv6.lisp (ipaddr-string): Ignore trivial runs of zeros. addr-family-ipv6.lisp (ipaddr-string): Use IPv4 notation if appropriate. addr-family-ipv6.lisp (ipaddr-string): Upend the conditional. --- diff --git a/addr-family-ipv6.lisp b/addr-family-ipv6.lisp index 3c37907..5ed014e 100644 --- a/addr-family-ipv6.lisp +++ b/addr-family-ipv6.lisp @@ -157,7 +157,8 @@ ;; Third step: output the two parts of the address either side of the ;; longest zero run. If there are no zero words in the address, just - ;; write the whole thing. + ;; write the whole thing. There's a special case here for the + ;; IPv6-mapped IPv4 address space ::ffff:0.0.0.0/96. (with-output-to-string (out) (flet ((chunk (start end) (when (< start end) @@ -167,12 +168,23 @@ (incf i) (when (>= i end) (return)) (write-char #\: out)))))) - (cond (best-start + (cond ((< best-length 2) + (chunk 0 8)) + ((and (= best-start 0) + (or (and (= best-length 5) + (= (aref words 5) #xffff)) + (= best-length 6))) + (let ((v4addr (make-instance 'ip4addr + :addr (ldb (byte 32 0) addr)))) + (write-string "::" out) + (when (= best-length 5) + (chunk 5 6) + (write-char #\: out)) + (write-string (ipaddr-string v4addr) out))) + (t (chunk 0 best-start) (write-string "::" out) - (chunk (+ best-start best-length) 8)) - (t - (chunk 0 8))))))) + (chunk (+ best-start best-length) 8))))))) ;;;-------------------------------------------------------------------------- ;;; IPv6 networks.