NDP Ethernet address display
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.orig2011-01-07 19:16:17.0 -0500 +++ /usr/src/usr.sbin/ndp/ndp.c 2011-01-07 19:15:36.0 -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)); -Boris ___ freebsd-net@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-net To unsubscribe, send any mail to freebsd-net-unsubscr...@freebsd.org
Re: NDP Ethernet address display
On Jan 7, 2011, at 4:26 PM, Boris Kochergin wrote: 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: +1. MAC addresses should be displayed as two-byte-zero-padded sequences :-) Regards, -- -Chuck ___ freebsd-net@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-net To unsubscribe, send any mail to freebsd-net-unsubscr...@freebsd.org
Re: NDP Ethernet address display
On 8 January 2011 03:26, Boris Kochergin sp...@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.0 -0500 +++ /usr/src/usr.sbin/ndp/ndp.c 2011-01-07 19:15:36.0 -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 ___ freebsd-net@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-net To unsubscribe, send any mail to freebsd-net-unsubscr...@freebsd.org
Re: NDP Ethernet address display
On 01/07/11 20:26, Sergey Kandaurov wrote: On 8 January 2011 03:26, Boris Kocherginsp...@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.orig2011-01-07 19:16:17.0 -0500 +++ /usr/src/usr.sbin/ndp/ndp.c 2011-01-07 19:15:36.0 -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). Sure. -Boris --- /usr/src/usr.sbin/ndp/ndp.c.orig2011-01-07 19:16:17.0 -0500 +++ /usr/src/usr.sbin/ndp/ndp.c 2011-01-07 21:00:20.0 -0500 @@ -80,6 +80,7 @@ #include sys/socket.h #include sys/sysctl.h #include sys/time.h +#include sys/types.h #include sys/queue.h #include net/if.h @@ -824,12 +825,12 @@ struct sockaddr_dl *sdl; { static char hbuf[NI_MAXHOST]; - u_char *cp; if (sdl-sdl_alen) { - cp = (u_char *)LLADDR(sdl); - snprintf(hbuf, sizeof(hbuf), %x:%x:%x:%x:%x:%x, - cp[0], cp[1], cp[2], cp[3], cp[4], cp[5]); + if (getnameinfo((struct sockaddr *)(void *)sdl, + (socklen_t)sdl-sdl_len, + hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST) != 0) + snprintf(hbuf, sizeof(hbuf), invalid); } else snprintf(hbuf, sizeof(hbuf), (incomplete)); ___ freebsd-net@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-net To unsubscribe, send any mail to freebsd-net-unsubscr...@freebsd.org
Re: NDP Ethernet address display
On 01/07/11 21:09, Doug Barton wrote: On 01/07/2011 18:01, Boris Kochergin wrote: - snprintf(hbuf, sizeof(hbuf), %x:%x:%x:%x:%x:%x, There are numerous examples of this string in the tree. Some of them seem like they may be correct, but many of them are obviously printing out mac addresses and should be converted, one way or another: http://dougbarton.us/mac-padding.txt In any case, thanks to Xin for fixing this one so quickly. :) Doug The sscanf() calls are definitely fine. I made sure to test that bit in ndp(8). Thanks, Xin! -Boris ___ freebsd-net@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-net To unsubscribe, send any mail to freebsd-net-unsubscr...@freebsd.org