Subject: bin/2473: netstat prints etheraddrs with .'s
To: None <gnats-bugs@NetBSD.ORG>
From: John Hawkinson <jhawk@mit.edu>
List: netbsd-bugs
Date: 05/26/1996 18:24:38
>Number: 2473
>Category: bin
>Synopsis: netstat prints etheraddrs with .'s
>Confidential: yes
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Sun May 26 18:35:01 1996
>Last-Modified:
>Originator: John Hawkinson
>Organization:
MIT SIPB
>Release: 26 May 1996
>Environment:
System: NetBSD zorkmid.mit.edu 1.1B NetBSD 1.1B (ZORKMID) #25: Sat May 25 03:27:32 EDT 1996 root@:/u1/usr/src/sys/arch/i386/compile/ZORKMID i386
>Description:
netstat(1) -i prints ethernet addresses delimitted
with periods (.) instead of colons (:). This form
is different from that used by most system utilities
(eg: tcpdump, ethers(5), functions in ethers(3),
etc.). This is not serious, but is slightly annoying
when tring to cut-and-paste into other programs.
It could be argued that the standard format should
be changed to period-delimitted, but this seems wasteful
given the number of other programs and operating systems
(and even standard labelling) that use the colon-delimitted
syntax.
>How-To-Repeat:
Run "netstat -i" and try to paste the results into tcpdump:
bobbi-harlow# netstat -i | sed -n 2p
ep0 1500 <Link> 0.a0.24.66.d6.2 596763 6 21027 0 0
bobbi-harlow# tcpdump ether host 0.a0.24.66.d6.2
tcpdump: illegal link layer address
>Fix:
netstat should not be using homegrown function like "hexprint"
to format these addresses. By rights it should use
link_ntoa(3), however that has the undesired side effect of
prepending the interface name, and further delimits with
periods, anyhow. I didn't replace "hexprint" with link_ntoa()
because its output so inappropriate -- the documentation
implies that the link_ntoa() formatting may change in the
future, anyhow.
Perhaps IFT_FDDI should be special-cased along with
IFT_ETHER?
*** if.c 1996/05/26 20:47:11 1.1
--- if.c 1996/05/26 22:08:45
***************
*** 47,52 ****
--- 47,53 ----
#include <net/if.h>
#include <net/if_dl.h>
+ #include <net/if_types.h>
#include <netinet/in.h>
#include <netinet/in_var.h>
#include <netns/ns.h>
***************
*** 205,215 ****
{
struct sockaddr_dl *sdl =
(struct sockaddr_dl *)sa;
! cp = (char *)LLADDR(sdl);
! n = sdl->sdl_alen;
}
! m = printf("%-11.11s ", "<Link>");
! goto hexprint;
default:
m = printf("(%d)", sa->sa_family);
for (cp = sa->sa_len + (char *)sa;
--- 206,222 ----
{
struct sockaddr_dl *sdl =
(struct sockaddr_dl *)sa;
! m = printf("%-11.11s ", "<Link>");
! if (sdl->sdl_type == IFT_ETHER)
! printf("%-17.17s ",
! ether_ntoa(LLADDR(sdl)));
! else {
! cp = (char *)LLADDR(sdl);
! n = sdl->sdl_alen;
! goto hexprint;
! }
}
! break;
default:
m = printf("(%d)", sa->sa_family);
for (cp = sa->sa_len + (char *)sa;
>Audit-Trail:
>Unformatted: