From owner-freebsd-net@FreeBSD.ORG Tue Dec 12 14:00:32 2006 Return-Path: X-Original-To: freebsd-net@freebsd.org Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7D4A816A4A7 for ; Tue, 12 Dec 2006 14:00:32 +0000 (UTC) (envelope-from max@love2party.net) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.188]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1BCC543CF5 for ; Tue, 12 Dec 2006 13:57:16 +0000 (GMT) (envelope-from max@love2party.net) Received: from [88.64.181.169] (helo=amd64.laiers.local) by mrelayeu.kundenserver.de (node=mrelayeu2) with ESMTP (Nemesis), id 0MKwtQ-1Gu89H1MNF-0006pS; Tue, 12 Dec 2006 14:58:26 +0100 From: Max Laier Organization: FreeBSD To: freebsd-net@freebsd.org Date: Tue, 12 Dec 2006 14:58:15 +0100 User-Agent: KMail/1.9.4 References: <20061212111134.J91892@maildrop.int.zabbadoz.net> In-Reply-To: <20061212111134.J91892@maildrop.int.zabbadoz.net> X-Face: ,,8R(x[kmU]tKN@>gtH1yQE4aslGdu+2]; R]*pL,U>^H?)gW@49@wdJ`H<=?utf-8?q?=25=7D*=5FBD=0A=09U=5For=3D=5CmOZf764=26nYj=3DJYbR1PW0ud?=>|!~,,CPC.1-D$FG@0h3#'5"k{V]a~.<=?utf-8?q?mZ=7D44=23Se=7Em=0A=09Fe=7E=5C=5DX5B=5D=5Fxj?=(ykz9QKMw_l0C2AQ]}Ym8)fU MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart2462898.WnuSPXM266"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200612121458.21401.max@love2party.net> X-Provags-ID: kundenserver.de abuse@kundenserver.de login:61c499deaeeba3ba5be80f48ecc83056 Cc: "Bjoern A. Zeeb" Subject: Re: ip6_sprintf patch X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Dec 2006 14:00:32 -0000 --nextPart2462898.WnuSPXM266 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Tuesday 12 December 2006 13:22, Bjoern A. Zeeb wrote: > Hi, > > I have a patch sitting around for quite some time that I'd like to > commit if noone has any objections. It tries to print the addresses > in a more common/readable format eliminating leading zeros like > in :0001 -> :1. > > You can also fetch it from here: > http://sources.zabbadoz.net/freebsd/ipv6/patches/20060611-01.diff > > ! > ! http://perforce.freebsd.org/chv.cgi?CH=3D98978 > ! > =3D=3D=3D=3D //depot/user/bz/fast_ipsec/src/sys/netinet6/in6.c#4 - > /local/building/freebsd/p4/v6_fast_ipsec/src/sys/netinet6/in6.c =3D=3D=3D= =3D > --- /tmp/tmp.47236.0 Sun Jun 11 11:48:05 2006 > +++ /local/building/freebsd/p4/v6_fast_ipsec/src/sys/netinet6/in6.c Sun > Jun 11 11:47:16 2006 @@ -1852,7 +1852,7 @@ > char *cp; > const u_int16_t *a =3D (const u_int16_t *)addr; > const u_int8_t *d; > - int dcolon =3D 0; > + int dcolon =3D 0, zero =3D 0; > > cp =3D ip6buf; > > @@ -1880,14 +1880,31 @@ > continue; > } > d =3D (const u_char *)a; > - *cp++ =3D digits[*d >> 4]; > - *cp++ =3D digits[*d++ & 0xf]; > - *cp++ =3D digits[*d >> 4]; > - *cp++ =3D digits[*d & 0xf]; > + /* Try to eliminate leading zeros in printout like in :0001. */ > + zero =3D 1; > + *cp =3D digits[*d >> 4]; > + if (*cp !=3D '0') { > + zero =3D 0; > + cp++; > + } > + *cp =3D digits[*d++ & 0xf]; > + if (zero =3D=3D 0 || (*cp !=3D '0')) { > + zero =3D 0; > + cp++; > + } > + *cp =3D digits[*d >> 4]; > + if (zero =3D=3D 0 || (*cp !=3D '0')) { > + zero =3D 0; > + cp++; > + } > + *cp =3D digits[*d & 0xf]; > + if (zero =3D=3D 0 || (*cp !=3D '0')) > + cp++; This last if is redundant as we check for "(u_int16_t)0" at the very=20 begining. If we didn't, you should still get rid of the if-check here as=20 we might otherwise have more than one "::" in the address. > *cp++ =3D ':'; > a++; > } > *--cp =3D '\0'; > + > return (ip6buf); > } Otherwise the diff seems fine. =2D-=20 /"\ Best regards, | mlaier@freebsd.org \ / Max Laier | ICQ #67774661 X http://pf4freebsd.love2party.net/ | mlaier@EFnet / \ ASCII Ribbon Campaign | Against HTML Mail and News --nextPart2462898.WnuSPXM266 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (FreeBSD) iD8DBQBFfrV9XyyEoT62BG0RAlodAJ9Rc85Wk4q+0wLAXUwlsNxA4+Q0LgCfan/6 /0WWaZ/rhMHN3Oi8bgE1t5k= =BSp+ -----END PGP SIGNATURE----- --nextPart2462898.WnuSPXM266--