diff options
author | shin <shin@FreeBSD.org> | 1999-12-28 02:37:14 +0000 |
---|---|---|
committer | shin <shin@FreeBSD.org> | 1999-12-28 02:37:14 +0000 |
commit | 8c2ccb59caf882ac518eda1f570ea731d4466216 (patch) | |
tree | ec4d4f8bd121d60c04c8119810151af20c92b20b /usr.bin/netstat | |
parent | b39a79861ddfb250e941d89c255bcb8cda9481dc (diff) | |
download | FreeBSD-src-8c2ccb59caf882ac518eda1f570ea731d4466216.zip FreeBSD-src-8c2ccb59caf882ac518eda1f570ea731d4466216.tar.gz |
Getaddrinfo(), getnameinfo(), and etc support in libc/net.
Several udp and raw apps IPv6 support.
Reviewed by: freebsd-arch, cvs-committers
Obtained from: KAME project
Diffstat (limited to 'usr.bin/netstat')
-rw-r--r-- | usr.bin/netstat/Makefile | 2 | ||||
-rw-r--r-- | usr.bin/netstat/inet6.c | 13 | ||||
-rw-r--r-- | usr.bin/netstat/main.c | 2 | ||||
-rw-r--r-- | usr.bin/netstat/route.c | 42 |
4 files changed, 12 insertions, 47 deletions
diff --git a/usr.bin/netstat/Makefile b/usr.bin/netstat/Makefile index ad7d824..792797c 100644 --- a/usr.bin/netstat/Makefile +++ b/usr.bin/netstat/Makefile @@ -12,6 +12,6 @@ BINGRP= kmem BINMODE=2555 DPADD= ${LIBKVM} ${LIBIPX} ${LIBNETGRAPH} LDADD= -lkvm -lipx -lnetgraph -CFLAGS+= -DINET6 +CFLAGS+=-DINET6 .include <bsd.prog.mk> diff --git a/usr.bin/netstat/inet6.c b/usr.bin/netstat/inet6.c index 154ee32..02c2fbf 100644 --- a/usr.bin/netstat/inet6.c +++ b/usr.bin/netstat/inet6.c @@ -390,23 +390,14 @@ ip6_stats(off, name) printf("\tMbuf statistics:\n"); printf("\t\t%lu one mbuf\n", ip6stat.ip6s_m1); for (first = 1, i = 0; i < 32; i++) { + char ifbuf[IFNAMSIZ]; if (ip6stat.ip6s_m2m[i] != 0) { if (first) { printf("\t\ttwo or more mbuf:\n"); first = 0; } - printf("\t\t\t" -#ifdef notyet - "%s" -#else - "if%d" -#endif - "= %ld\n", -#ifdef notyet + printf("\t\t\t%s= %ld\n", if_indextoname(i, ifbuf), -#else - i, -#endif ip6stat.ip6s_m2m[i]); } } diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c index 5bf9759..c0e4381 100644 --- a/usr.bin/netstat/main.c +++ b/usr.bin/netstat/main.c @@ -129,11 +129,11 @@ static struct nlist nl[] = { { "_ip6stat" }, #define N_ICMP6STAT 29 { "_icmp6stat" }, -#ifdef notyet #define N_IPSECSTAT 30 { "_ipsecstat" }, #define N_IPSEC6STAT 31 { "_ipsec6stat" }, +#ifdef notyet #define N_PIM6STAT 32 { "_pim6stat" }, #define N_MRT6PROTO 33 diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c index 1dce615..69fb8e8 100644 --- a/usr.bin/netstat/route.c +++ b/usr.bin/netstat/route.c @@ -605,7 +605,7 @@ p_rtentry(rt) WID_DST); p_sockaddr(kgetsa(rt->rt_gateway), NULL, RTF_HOST, #ifdef INET6 - kgetsa(rt->rt_gateway)->sa_family == AF_INET6 ? WID_GW6 : + addr.u_sa.sa_family == AF_INET6 ? WID_GW6 : #endif WID_GW); p_flags(rt->rt_flags, "%-6.6s "); @@ -763,16 +763,17 @@ netname6(sa6, mask) u_char *p = (u_char *)mask; u_char *lim; int masklen, illegal = 0; -#ifdef notyet int flag = NI_WITHSCOPEID; -#endif if (mask) { for (masklen = 0, lim = p + 16; p < lim; p++) { + if (*p == 0xff) + masklen += 8; + else + break; + } + if (p < lim) { switch (*p) { - case 0xff: - masklen += 8; - break; case 0xfe: masklen += 7; break; @@ -810,14 +811,10 @@ netname6(sa6, mask) if (masklen == 0 && IN6_IS_ADDR_UNSPECIFIED(&sa6->sin6_addr)) return("default"); -#ifdef notyet if (nflag) flag |= NI_NUMERICHOST; getnameinfo((struct sockaddr *)sa6, sa6->sin6_len, line, sizeof(line), NULL, 0, flag); -#else - inet_ntop(AF_INET6, (void *)&sa6->sin6_addr, line, sizeof(line)); -#endif if (nflag) sprintf(&line[strlen(line)], "/%d", masklen); @@ -829,37 +826,14 @@ char * routename6(sa6) struct sockaddr_in6 *sa6; { -#ifdef notyet + static char line[MAXHOSTNAMELEN + 1]; int flag = NI_WITHSCOPEID; if (nflag) flag |= NI_NUMERICHOST; -#else - register char *cp; -#endif - static char line[MAXHOSTNAMELEN + 1]; - struct hostent *hp; -#ifdef notyet getnameinfo((struct sockaddr *)sa6, sa6->sin6_len, line, sizeof(line), NULL, 0, flag); -#else - cp = 0; - if (!nflag) { - hp = gethostbyaddr((char *)&sa6->sin6_addr, - sizeof(sa6->sin6_addr), AF_INET6); - if (hp) { - cp = hp->h_name; - trimdomain(cp); - } - } - if (cp) { - strncpy(line, cp, sizeof(line) - 1); - line[sizeof(line) - 1] = '\0'; - } else - inet_ntop(AF_INET6, (void *)&sa6->sin6_addr, line, - sizeof(line)); -#endif return line; } |