version 1.34, 2007/09/11 18:16:48 |
version 1.35, 2007/12/14 18:35:46 |
|
|
#include <sys/ioctl.h> |
#include <sys/ioctl.h> |
#include <sys/mbuf.h> |
#include <sys/mbuf.h> |
#include <sys/protosw.h> |
#include <sys/protosw.h> |
|
#include <sys/sysctl.h> |
|
|
#include <net/route.h> |
#include <net/route.h> |
#include <net/if.h> |
#include <net/if.h> |
|
|
#include <stdio.h> |
#include <stdio.h> |
#include <string.h> |
#include <string.h> |
#include <unistd.h> |
#include <unistd.h> |
|
#include <errno.h> |
#include "netstat.h" |
#include "netstat.h" |
|
|
#ifdef INET6 |
|
|
|
struct socket sockb; |
struct socket sockb; |
|
|
char *inet6name(struct in6_addr *); |
char *inet6name(struct in6_addr *); |
|
|
* Dump IP6 statistics structure. |
* Dump IP6 statistics structure. |
*/ |
*/ |
void |
void |
ip6_stats(u_long off, char *name) |
ip6_stats(char *name) |
{ |
{ |
struct ip6stat ip6stat; |
struct ip6stat ip6stat; |
int first, i; |
int first, i; |
struct protoent *ep; |
struct protoent *ep; |
const char *n; |
const char *n; |
|
int mib[] = { CTL_NET, AF_INET6, IPPROTO_IPV6, IPV6CTL_STATS }; |
|
size_t len = sizeof(ip6stat); |
|
|
if (off == 0) |
if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), |
|
&ip6stat, &len, NULL, 0) == -1) { |
|
if (errno != ENOPROTOOPT) |
|
warn(name); |
return; |
return; |
|
} |
|
|
kread(off, &ip6stat, sizeof (ip6stat)); |
|
printf("%s:\n", name); |
printf("%s:\n", name); |
|
|
#define p(f, m) if (ip6stat.f || sflag <= 1) \ |
#define p(f, m) if (ip6stat.f || sflag <= 1) \ |
printf(m, (unsigned long long)ip6stat.f, plural(ip6stat.f)) |
printf(m, (unsigned long long)ip6stat.f, plural(ip6stat.f)) |
#define p1(f, m) if (ip6stat.f || sflag <= 1) \ |
#define p1(f, m) if (ip6stat.f || sflag <= 1) \ |
|
|
* Dump ICMPv6 statistics. |
* Dump ICMPv6 statistics. |
*/ |
*/ |
void |
void |
icmp6_stats(u_long off, char *name) |
icmp6_stats(char *name) |
{ |
{ |
struct icmp6stat icmp6stat; |
struct icmp6stat icmp6stat; |
int i, first; |
int i, first; |
|
int mib[] = { CTL_NET, AF_INET6, IPPROTO_ICMPV6, ICMPV6CTL_STATS }; |
|
size_t len = sizeof(icmp6stat); |
|
|
if (off == 0) |
if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), |
|
&icmp6stat, &len, NULL, 0) == -1) { |
|
if (errno != ENOPROTOOPT) |
|
warn(name); |
return; |
return; |
kread(off, &icmp6stat, sizeof (icmp6stat)); |
} |
printf("%s:\n", name); |
|
|
|
|
printf("%s:\n", name); |
#define p(f, m) if (icmp6stat.f || sflag <= 1) \ |
#define p(f, m) if (icmp6stat.f || sflag <= 1) \ |
printf(m, (unsigned long long)icmp6stat.f, plural(icmp6stat.f)) |
printf(m, (unsigned long long)icmp6stat.f, plural(icmp6stat.f)) |
#define p_5(f, m) if (icmp6stat.f || sflag <= 1) \ |
#define p_5(f, m) if (icmp6stat.f || sflag <= 1) \ |
|
|
* Dump PIM statistics structure. |
* Dump PIM statistics structure. |
*/ |
*/ |
void |
void |
pim6_stats(u_long off, char *name) |
pim6_stats(char *name) |
{ |
{ |
struct pim6stat pim6stat; |
struct pim6stat pim6stat; |
|
int mib[] = { CTL_NET, AF_INET6, IPPROTO_PIM, PIM6CTL_STATS }; |
|
size_t len = sizeof(pim6stat); |
|
|
if (off == 0) |
if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), |
|
&pim6stat, &len, NULL, 0) == -1) { |
|
if (errno != ENOPROTOOPT) |
|
warn(name); |
return; |
return; |
kread(off, &pim6stat, sizeof(pim6stat)); |
} |
printf("%s:\n", name); |
|
|
|
|
printf("%s:\n", name); |
#define p(f, m) if (pim6stat.f || sflag <= 1) \ |
#define p(f, m) if (pim6stat.f || sflag <= 1) \ |
printf(m, (unsigned long long)pim6stat.f, plural(pim6stat.f)) |
printf(m, (unsigned long long)pim6stat.f, plural(pim6stat.f)) |
|
|
|
|
* Dump raw ip6 statistics structure. |
* Dump raw ip6 statistics structure. |
*/ |
*/ |
void |
void |
rip6_stats(u_long off, char *name) |
rip6_stats(char *name) |
{ |
{ |
struct rip6stat rip6stat; |
struct rip6stat rip6stat; |
u_int64_t delivered; |
u_int64_t delivered; |
|
int mib[] = { CTL_NET, AF_INET6, IPPROTO_RAW, RIPV6CTL_STATS }; |
|
size_t len = sizeof(rip6stat); |
|
|
if (off == 0) |
if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), |
|
&rip6stat, &len, NULL, 0) == -1) { |
|
if (errno != ENOPROTOOPT) |
|
warn(name); |
return; |
return; |
kread(off, &rip6stat, sizeof(rip6stat)); |
} |
|
|
printf("%s:\n", name); |
printf("%s:\n", name); |
|
|
#define p(f, m) if (rip6stat.f || sflag <= 1) \ |
#define p(f, m) if (rip6stat.f || sflag <= 1) \ |
|
|
tcp6cb.ts_recent, tcp6cb.ts_recent_age, tcp6cb.last_ack_sent); |
tcp6cb.ts_recent, tcp6cb.ts_recent_age, tcp6cb.last_ack_sent); |
} |
} |
#endif |
#endif |
|
|
#endif /*INET6*/ |
|