Date: Sat, 8 Jan 2011 04:26:37 +0300 From: Sergey Kandaurov <pluknet@gmail.com> To: Boris Kochergin <spawk@acm.poly.edu> Cc: freebsd-net@freebsd.org Subject: Re: NDP Ethernet address display Message-ID: <AANLkTinhoqTsjrgYqZZVFJ610L7eHqfjU-vzPVqcHXpt@mail.gmail.com> In-Reply-To: <4D27AF1D.2030505@acm.poly.edu> References: <4D27AF1D.2030505@acm.poly.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
On 8 January 2011 03:26, Boris Kochergin <spawk@acm.poly.edu> wrote:
> Hi. I noticed that ndp(8) doesn't zero-pad Ethernet addresses, which is
> inconsistent with arp(8):
>
> # ndp -an
> ...
> 2001:470:897b::1 0:30:48:b1:1b:9c em0 permanent R
>
> # arp -an
> ...
> ? (128.238.9.201) at 00:30:48:b1:1b:9c on em0 permanent [ethernet]
>
> As everything else I can think of zero-pads them, this makes it a little
> annoying to grep for addresses, etc. Is this intentional? It is the case in
> 7.x through CURRENT and the fix is quite simple:
>
> --- /usr/src/usr.sbin/ndp/ndp.c.orig 2011-01-07 19:16:17.000000000 -0500
> +++ /usr/src/usr.sbin/ndp/ndp.c 2011-01-07 19:15:36.000000000 -0500
> @@ -828,7 +828,7 @@
>
> if (sdl->sdl_alen) {
> cp = (u_char *)LLADDR(sdl);
> - snprintf(hbuf, sizeof(hbuf), "%x:%x:%x:%x:%x:%x",
> + snprintf(hbuf, sizeof(hbuf),
> "%02x:%02x:%02x:%02x:%02x:%02x",
> cp[0], cp[1], cp[2], cp[3], cp[4], cp[5]);
> } else
> snprintf(hbuf, sizeof(hbuf), "(incomplete)");
>
Or rather use getnameinfo() for that as NetBSD/KAME does, and
NetBSD's getnameinfo() AF_LINK support was merged at 6.3 time.
(See ndp.c#rev1.87 at KAME, ndp.c#rev1.35 at NetBSD).
--
wbr,
pluknet
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTinhoqTsjrgYqZZVFJ610L7eHqfjU-vzPVqcHXpt>
