Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/route When dumping the routing table, use getnameinfo()...
details: https://anonhg.NetBSD.org/src/rev/aad4d98cc59f
branches: trunk
changeset: 515870:aad4d98cc59f
user: bjh21 <bjh21%NetBSD.org@localhost>
date: Sat Oct 06 18:32:45 2001 +0000
description:
When dumping the routing table, use getnameinfo() to print link-layer
addresses rather than doing it ourselves and falling back to link_ntoa().
diffstat:
sbin/route/show.c | 39 ++++++---------------------------------
1 files changed, 6 insertions(+), 33 deletions(-)
diffs (65 lines):
diff -r 8dd58223896d -r aad4d98cc59f sbin/route/show.c
--- a/sbin/route/show.c Sat Oct 06 17:05:29 2001 +0000
+++ b/sbin/route/show.c Sat Oct 06 18:32:45 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: show.c,v 1.17 2001/01/27 04:49:35 itojun Exp $ */
+/* $NetBSD: show.c,v 1.18 2001/10/06 18:32:45 bjh21 Exp $ */
/*
* Copyright (c) 1983, 1988, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "from: @(#)route.c 8.3 (Berkeley) 3/9/94";
#else
-__RCSID("$NetBSD: show.c,v 1.17 2001/01/27 04:49:35 itojun Exp $");
+__RCSID("$NetBSD: show.c,v 1.18 2001/10/06 18:32:45 bjh21 Exp $");
#endif
#endif /* not lint */
@@ -256,42 +256,15 @@
{
char workbuf[128], *cplim;
char *cp = workbuf;
- int cplen = 0, len;
switch(sa->sa_family) {
case AF_LINK:
- {
- struct sockaddr_dl *sdl = (struct sockaddr_dl *)sa;
-
- if (sdl->sdl_nlen == 0 && sdl->sdl_alen == 0 &&
- sdl->sdl_slen == 0)
- (void)snprintf(workbuf, sizeof workbuf, "link#%d",
- sdl->sdl_index);
- else switch (sdl->sdl_type) {
- case IFT_ETHER:
- {
- int i;
- u_char *lla = (u_char *)sdl->sdl_data +
- sdl->sdl_nlen;
-
- cplim = "";
- for (i = 0; i < sdl->sdl_alen; i++, lla++) {
- len = snprintf(cp, sizeof(workbuf) - cplen,
- "%s%x", cplim, *lla);
- cp += len;
- cplen += len;
- cplim = ":";
- }
- cp = workbuf;
- break;
- }
- default:
- cp = link_ntoa(sdl);
- break;
- }
+ if (getnameinfo(sa, sa->sa_len, workbuf, sizeof(workbuf),
+ NULL, 0, NI_NUMERICHOST) != 0)
+ strncpy(workbuf, "invalid", sizeof(workbuf));
+ cp = workbuf;
break;
- }
case AF_INET:
{
Home |
Main Index |
Thread Index |
Old Index