Print Ethernet and FDDI addresses in the same format as ether_ntoa().

From Matt Thomas <matt@3am-software.com>
This commit is contained in:
thorpej 1997-03-26 01:49:44 +00:00
parent a285d77f82
commit 87ca1d62e0
3 changed files with 25 additions and 12 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: if.c,v 1.19 1996/06/07 21:43:26 thorpej Exp $ */
/* $NetBSD: if.c,v 1.20 1997/03/26 01:51:25 thorpej Exp $ */
/*
* Copyright (c) 1983, 1988, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "from: @(#)if.c 8.2 (Berkeley) 2/21/94";
#else
static char *rcsid = "$NetBSD: if.c,v 1.19 1996/06/07 21:43:26 thorpej Exp $";
static char *rcsid = "$NetBSD: if.c,v 1.20 1997/03/26 01:51:25 thorpej Exp $";
#endif
#endif /* not lint */
@ -47,6 +47,7 @@ static char *rcsid = "$NetBSD: if.c,v 1.19 1996/06/07 21:43:26 thorpej Exp $";
#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>
@ -142,6 +143,8 @@ intpr(interval, ifnetaddr)
printf("%-11.11s ", "none");
printf("%-15.15s ", "none");
} else {
char hexsep = '.'; /* for hexprint */
const char *hexfmt = "%x%c"; /* for hexprint */
if (kread(ifaddraddr, (char *)&ifaddr, sizeof ifaddr)) {
ifaddraddr = 0;
continue;
@ -206,6 +209,9 @@ intpr(interval, ifnetaddr)
struct sockaddr_dl *sdl =
(struct sockaddr_dl *)sa;
cp = (char *)LLADDR(sdl);
if (sdl->sdl_type == IFT_FDDI
|| sdl->sdl_type == IFT_ETHER)
hexsep = ':', hexfmt = "%02x%c";
n = sdl->sdl_alen;
}
m = printf("%-11.11s ", "<Link>");
@ -218,8 +224,8 @@ intpr(interval, ifnetaddr)
cp = sa->sa_data;
hexprint:
while (--n >= 0)
m += printf("%x%c", *cp++ & 0xff,
n > 0 ? '.' : ' ');
m += printf(hexfmt, *cp++ & 0xff,
n > 0 ? hexsep : ' ');
m = 30 - m;
while (m-- > 0)
putchar(' ');

View File

@ -1,4 +1,4 @@
/* $NetBSD: route.c,v 1.19 1997/03/18 03:40:10 mycroft Exp $ */
/* $NetBSD: route.c,v 1.20 1997/03/26 01:51:27 thorpej Exp $ */
/*
* Copyright (c) 1983, 1988, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "from: @(#)route.c 8.3 (Berkeley) 3/9/94";
#else
static char *rcsid = "$NetBSD: route.c,v 1.19 1997/03/18 03:40:10 mycroft Exp $";
static char *rcsid = "$NetBSD: route.c,v 1.20 1997/03/26 01:51:27 thorpej Exp $";
#endif
#endif /* not lint */
@ -397,6 +397,7 @@ p_sockaddr(sa, mask, flags, width)
sdl->sdl_slen == 0)
(void) sprintf(workbuf, "link#%d", sdl->sdl_index);
else switch (sdl->sdl_type) {
case IFT_FDDI:
case IFT_ETHER:
{
register int i;
@ -405,7 +406,7 @@ p_sockaddr(sa, mask, flags, width)
cplim = "";
for (i = 0; i < sdl->sdl_alen; i++, lla++) {
cp += sprintf(cp, "%s%x", cplim, *lla);
cp += sprintf(cp, "%s%02x", cplim, *lla);
cplim = ":";
}
cp = workbuf;

View File

@ -1,4 +1,4 @@
/* $NetBSD: arp.c,v 1.17 1997/03/15 18:37:27 is Exp $ */
/* $NetBSD: arp.c,v 1.18 1997/03/26 01:49:44 thorpej Exp $ */
/*
* Copyright (c) 1984, 1993
@ -44,7 +44,7 @@ static char copyright[] =
#ifndef lint
/* static char sccsid[] = "@(#)arp.c 8.3 (Berkeley) 4/28/95"; */
static char *rcsid = "$NetBSD: arp.c,v 1.17 1997/03/15 18:37:27 is Exp $";
static char *rcsid = "$NetBSD: arp.c,v 1.18 1997/03/26 01:49:44 thorpej Exp $";
#endif /* not lint */
/*
@ -446,13 +446,19 @@ sdl_print(sdl)
{
int i;
u_int8_t *p;
const char *hexfmt = "%x";
if (sdl->sdl_type == IFT_ETHER || sdl->sdl_type == IFT_FDDI)
hexfmt = "%02x";
i = sdl->sdl_alen;
p = LLADDR(sdl);
(void)printf("%x", *p);
while (--i > 0)
(void)printf(":%x", *++p);
(void)printf(hexfmt, *p);
while (--i > 0) {
putchar(':');
(void)printf(hexfmt, *++p);
}
}
int