Module Name: src Committed By: oki Date: Wed Apr 7 22:59:15 UTC 2010
Modified Files: src/sys/netinet6: in6.c Log Message: ip6_sprintf: compress the zeros of representation of the IPv6 address. see RFC4291 section 2.2 item 2. To generate a diff of this commit: cvs rdiff -u -r1.154 -r1.155 src/sys/netinet6/in6.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/netinet6/in6.c diff -u src/sys/netinet6/in6.c:1.154 src/sys/netinet6/in6.c:1.155 --- src/sys/netinet6/in6.c:1.154 Sat Sep 19 13:11:02 2009 +++ src/sys/netinet6/in6.c Wed Apr 7 22:59:15 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: in6.c,v 1.154 2009/09/19 13:11:02 christos Exp $ */ +/* $NetBSD: in6.c,v 1.155 2010/04/07 22:59:15 oki Exp $ */ /* $KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $ */ /* @@ -62,7 +62,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.154 2009/09/19 13:11:02 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.155 2010/04/07 22:59:15 oki Exp $"); #include "opt_inet.h" #include "opt_pfil_hooks.h" @@ -1873,6 +1873,7 @@ { static char ip6buf[8][48]; int i; + char *bp; char *cp; const u_int16_t *a = (const u_int16_t *)addr; const u_int8_t *d; @@ -1905,9 +1906,16 @@ continue; } d = (const u_char *)a; - *cp++ = hexdigits[*d >> 4]; - *cp++ = hexdigits[*d++ & 0xf]; - *cp++ = hexdigits[*d >> 4]; + bp = cp; + *cp = hexdigits[*d >> 4]; + if (*cp != '0') + cp++; + *cp = hexdigits[*d++ & 0xf]; + if (cp != bp || *cp != '0') + cp++; + *cp = hexdigits[*d >> 4]; + if (cp != bp || *cp != '0') + cp++; *cp++ = hexdigits[*d & 0xf]; *cp++ = ':'; a++;