From: Hasso Tepper Date: Thu, 31 May 2007 11:38:37 +0000 (+0000) Subject: Add ip6 and icmp6 displays to systat(1). X-Git-Tag: v2.0.1~2952 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/0adc6530199f99d19d3077ceeaa94124ac59b765 Add ip6 and icmp6 displays to systat(1). Obtained-from: FreeBSD --- diff --git a/usr.bin/systat/Makefile b/usr.bin/systat/Makefile index 7b0420b729..96346ac8f0 100644 --- a/usr.bin/systat/Makefile +++ b/usr.bin/systat/Makefile @@ -1,11 +1,11 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 -# $DragonFly: src/usr.bin/systat/Makefile,v 1.3 2004/12/22 11:01:49 joerg Exp $ +# $DragonFly: src/usr.bin/systat/Makefile,v 1.4 2007/05/31 11:38:36 hasso Exp $ PROG= systat -CFLAGS+=-I${.CURDIR}/../../sys +CFLAGS+=-DINET6 -I${.CURDIR}/../../sys SRCS= cmds.c cmdtab.c convtbl.c devs.c fetch.c ifcmds.c ifstat.c iostat.c \ keyboard.c main.c mbufs.c netcmds.c netstat.c pigs.c swap.c icmp.c \ - mode.c ip.c tcp.c vmstat.c + mode.c ip.c tcp.c vmstat.c ip6.c icmp6.c DPADD= ${LIBCURSES} ${LIBTERMCAP} ${LIBM} ${LIBKVM} ${LIBDEVSTAT} ${LIBKINFO} LDADD= -lcurses -ltermcap -lm -lkvm -ldevstat -lkinfo BINGRP= kmem diff --git a/usr.bin/systat/cmdtab.c b/usr.bin/systat/cmdtab.c index d534b9a882..61333748a4 100644 --- a/usr.bin/systat/cmdtab.c +++ b/usr.bin/systat/cmdtab.c @@ -32,7 +32,7 @@ * * @(#)cmdtab.c 8.1 (Berkeley) 6/6/93 * $FreeBSD: src/usr.bin/systat/cmdtab.c,v 1.5 1999/08/28 01:05:59 peter Exp $ - * $DragonFly: src/usr.bin/systat/cmdtab.c,v 1.3 2003/11/08 09:30:32 asmodai Exp $ + * $DragonFly: src/usr.bin/systat/cmdtab.c,v 1.4 2007/05/31 11:38:36 hasso Exp $ */ #include "systat.h" @@ -70,6 +70,12 @@ struct cmdtab cmdtab[] = { { "ifstat", showifstat, fetchifstat, labelifstat, initifstat, openifstat, closeifstat, cmdifstat, 0, CF_LOADAV }, + { "ip6", showip6, fetchip6, labelip6, + initip6, openip6, closeip6, cmdmode, + resetip6, CF_LOADAV }, + { "icmp6", showicmp6, fetchicmp6, labelicmp6, + initicmp6, openicmp6, closeicmp6, cmdmode, + reseticmp6, CF_LOADAV }, { 0 } }; struct cmdtab *curcmd = &cmdtab[0]; diff --git a/usr.bin/systat/extern.h b/usr.bin/systat/extern.h index be18197229..a8df8edc2e 100644 --- a/usr.bin/systat/extern.h +++ b/usr.bin/systat/extern.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)extern.h 8.1 (Berkeley) 6/6/93 - * $DragonFly: src/usr.bin/systat/extern.h,v 1.5 2003/11/08 09:30:32 asmodai Exp $ + * $DragonFly: src/usr.bin/systat/extern.h,v 1.6 2007/05/31 11:38:36 hasso Exp $ */ #include @@ -74,7 +74,9 @@ int checkport(struct inpcb *); void closeiostat(WINDOW *); void closeifstat(WINDOW *); void closeicmp(WINDOW *); +void closeicmp6(WINDOW *); void closeip(WINDOW *); +void closeip6(WINDOW *); void closekre(WINDOW *); void closembufs(WINDOW *); void closenetstat(WINDOW *); @@ -93,8 +95,10 @@ int dkinit(void); int dkcmd(char *, char *); void error(const char *fmt, ...) __printflike(1, 2); void fetchicmp(void); +void fetchicmp6(void); void fetchifstat(void); void fetchip(void); +void fetchip6(void); void fetchiostat(void); void fetchkre(void); void fetchmbufs(void); @@ -103,8 +107,10 @@ void fetchpigs(void); void fetchswap(void); void fetchtcp(void); int initicmp(void); +int initicmp6(void); int initifstat(void); int initip(void); +int initip6(void); int initiostat(void); int initkre(void); int initmbufs(void); @@ -115,8 +121,10 @@ int inittcp(void); int keyboard(void); int kvm_ckread(void *, void *, int); void labelicmp(void); +void labelicmp6(void); void labelifstat(void); void labelip(void); +void labelip6(void); void labeliostat(void); void labelkre(void); void labelmbufs(void); @@ -129,8 +137,10 @@ void load(void); int netcmd(char *, char *); void nlisterr(struct nlist []); WINDOW *openicmp(void); +WINDOW *openicmp6(void); WINDOW *openifstat(void); WINDOW *openip(void); +WINDOW *openip6(void); WINDOW *openiostat(void); WINDOW *openkre(void); WINDOW *openmbufs(void); @@ -140,11 +150,15 @@ WINDOW *openswap(void); WINDOW *opentcp(void); int prefix(char *, char *); void reseticmp(void); +void reseticmp6(void); void resetip(void); +void resetip6(void); void resettcp(void); void showicmp(void); +void showicmp6(void); void showifstat(void); void showip(void); +void showip6(void); void showiostat(void); void showkre(void); void showmbufs(void); diff --git a/usr.bin/systat/icmp6.c b/usr.bin/systat/icmp6.c new file mode 100644 index 0000000000..eb9f2d71ca --- /dev/null +++ b/usr.bin/systat/icmp6.c @@ -0,0 +1,277 @@ +/*- + * Copyright (c) 1980, 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)mbufs.c 8.1 (Berkeley) 6/6/93 + * $FreeBSD: src/usr.bin/systat/icmp6.c,v 1.3 2006/04/30 04:47:23 bde Exp $ + * $DragonFly: src/usr.bin/systat/icmp6.c,v 1.1 2007/05/31 11:38:36 hasso Exp $ + */ + +#include + +#ifdef INET6 +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include "systat.h" +#include "extern.h" +#include "mode.h" + +static struct icmp6stat icmp6stat, initstat, oldstat; + +/*- +--0 1 2 3 4 5 6 7 +--0123456789012345678901234567890123456789012345678901234567890123456789012345 +00 ICMPv6 Input ICMPv6 Output +01999999999 total messages 999999999 total messages +02999999999 with bad code 999999999 errors generated +03999999999 with bad length 999999999 suppressed - original too short +04999999999 with bad checksum 999999999 suppressed - original was ICMP +05999999999 with insufficient data 999999999 responses sent +06 +07 Input Histogram Output Histogram +08999999999 echo response 999999999 echo response +09999999999 echo request 999999999 echo request +10999999999 destination unreachable 999999999 destination unreachable +11999999999 redirect 999999999 redirect +12999999999 time-to-live exceeded 999999999 time-to-line exceeded +13999999999 parameter problem 999999999 parameter problem +14999999999 neighbor solicitation 999999999 neighbor solicitation +15999999999 neighbor advertisment 999999999 neighbor advertisment +16999999999 router advertisement 999999999 router solicitation +17 +18 +--0123456789012345678901234567890123456789012345678901234567890123456789012345 +--0 1 2 3 4 5 6 7 +*/ + +WINDOW * +openicmp6(void) +{ + return (subwin(stdscr, LINES-4-1, 0, 4, 0)); +} + +void +closeicmp6(w) + WINDOW *w; +{ + if (w == NULL) + return; + wclear(w); + wrefresh(w); + delwin(w); +} + +void +labelicmp6(void) +{ + wmove(wnd, 0, 0); wclrtoeol(wnd); +#define L(row, str) mvwprintw(wnd, row, 10, str) +#define R(row, str) mvwprintw(wnd, row, 45, str); + L(1, "ICMPv6 Input"); R(1, "ICMPv6 Output"); + L(2, "total messages"); R(2, "total messages"); + L(3, "with bad code"); R(3, "errors generated"); + L(4, "with bad length"); R(4, "suppressed - original too short"); + L(5, "with bad checksum"); R(5, "suppressed - original was ICMP"); + L(6, "with insufficient data"); R(6, "responses sent"); + + L(8, "Input Histogram"); R(8, "Output Histogram"); +#define B(row, str) L(row, str); R(row, str) + B(9, "echo response"); + B(10, "echo request"); + B(11, "destination unreachable"); + B(12, "redirect"); + B(13, "time-to-live exceeded"); + B(14, "parameter problem"); + B(15, "neighbor solicitation"); + B(16, "neighbor advertisment"); + L(17, "router advertisement"); R(17, "router solicitation"); +#undef L +#undef R +#undef B +} + +static void +domode(struct icmp6stat *ret) +{ + const struct icmp6stat *sub; + int i, divisor = 1; + + switch(currentmode) { + case display_RATE: + sub = &oldstat; + divisor = naptime; + break; + case display_DELTA: + sub = &oldstat; + break; + case display_SINCE: + sub = &initstat; + break; + default: + *ret = icmp6stat; + return; + } +#define DO(stat) ret->stat = (icmp6stat.stat - sub->stat) / divisor + DO(icp6s_error); + DO(icp6s_tooshort); + DO(icp6s_canterror); + for (i = 0; i <= ICMP6_MAXTYPE; i++) { + DO(icp6s_outhist[i]); + } + DO(icp6s_badcode); + DO(icp6s_tooshort); + DO(icp6s_checksum); + DO(icp6s_badlen); + DO(icp6s_reflect); + for (i = 0; i <= ICMP6_MAXTYPE; i++) { + DO(icp6s_inhist[i]); + } +#undef DO +} + +void +showicmp6(void) +{ + struct icmp6stat stats; + u_long totalin, totalout; + int i; + + memset(&stats, 0, sizeof stats); + domode(&stats); + for (i = totalin = totalout = 0; i <= ICMP6_MAXTYPE; i++) { + totalin += stats.icp6s_inhist[i]; + totalout += stats.icp6s_outhist[i]; + } + totalin += stats.icp6s_badcode + stats.icp6s_badlen + + stats.icp6s_checksum + stats.icp6s_tooshort; + mvwprintw(wnd, 2, 0, "%9lu", totalin); + mvwprintw(wnd, 2, 35, "%9lu", totalout); + +#define DO(stat, row, col) \ + mvwprintw(wnd, row, col, "%9lu", stats.stat) + + DO(icp6s_badcode, 3, 0); + DO(icp6s_badlen, 4, 0); + DO(icp6s_checksum, 5, 0); + DO(icp6s_tooshort, 6, 0); + DO(icp6s_error, 3, 35); + DO(icp6s_tooshort, 4, 35); + DO(icp6s_canterror, 5, 35); + DO(icp6s_reflect, 6, 35); +#define DO2(type, row) DO(icp6s_inhist[type], row, 0); DO(icp6s_outhist[type], \ + row, 35) + DO2(ICMP6_ECHO_REPLY, 9); + DO2(ICMP6_ECHO_REQUEST, 10); + DO2(ICMP6_DST_UNREACH, 11); + DO2(ND_REDIRECT, 12); + DO2(ICMP6_TIME_EXCEEDED, 13); + DO2(ICMP6_PARAM_PROB, 14); + DO2(ND_NEIGHBOR_SOLICIT, 15); + DO2(ND_NEIGHBOR_ADVERT, 16); + DO(icp6s_inhist[ND_ROUTER_SOLICIT], 17, 0); + DO(icp6s_outhist[ND_ROUTER_ADVERT], 17, 35); +#undef DO +#undef DO2 +} + +int +initicmp6(void) +{ + size_t len; + int name[4]; + + name[0] = CTL_NET; + name[1] = PF_INET6; + name[2] = IPPROTO_ICMPV6; + name[3] = ICMPV6CTL_STATS; + + len = 0; + if (sysctl(name, 4, 0, &len, 0, 0) < 0) { + error("sysctl getting icmp6stat size failed"); + return 0; + } + if (len > sizeof icmp6stat) { + error("icmp6stat structure has grown--recompile systat!"); + return 0; + } + if (sysctl(name, 4, &initstat, &len, 0, 0) < 0) { + error("sysctl getting icmp6stat size failed"); + return 0; + } + oldstat = initstat; + return 1; +} + +void +reseticmp6(void) +{ + size_t len; + int name[4]; + + name[0] = CTL_NET; + name[1] = PF_INET6; + name[2] = IPPROTO_ICMPV6; + name[3] = ICMPV6CTL_STATS; + + len = sizeof initstat; + if (sysctl(name, 4, &initstat, &len, 0, 0) < 0) { + error("sysctl getting icmp6stat size failed"); + } + oldstat = initstat; +} + +void +fetchicmp6(void) +{ + int name[4]; + size_t len; + + oldstat = icmp6stat; + name[0] = CTL_NET; + name[1] = PF_INET6; + name[2] = IPPROTO_ICMPV6; + name[3] = ICMPV6CTL_STATS; + len = sizeof icmp6stat; + + if (sysctl(name, 4, &icmp6stat, &len, 0, 0) < 0) + return; +} + +#endif diff --git a/usr.bin/systat/ip6.c b/usr.bin/systat/ip6.c new file mode 100644 index 0000000000..8d24c2cd40 --- /dev/null +++ b/usr.bin/systat/ip6.c @@ -0,0 +1,299 @@ +/*- + * Copyright (c) 1980, 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)mbufs.c 8.1 (Berkeley) 6/6/93 + * $FreeBSD: src/usr.bin/systat/ip6.c,v 1.3 2006/04/30 04:47:23 bde Exp $ + * $DragonFly: src/usr.bin/systat/ip6.c,v 1.1 2007/05/31 11:38:36 hasso Exp $ + */ + +#include + +#ifdef INET6 +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include "systat.h" +#include "extern.h" +#include "mode.h" + +static struct ip6stat curstat, initstat, oldstat; + +/*- +--0 1 2 3 4 5 6 7 +--0123456789012345678901234567890123456789012345678901234567890123456789012345 +00 IPv6 Input IPv6 Output +019999999 total packets received 999999999 total packets sent +029999999 - too short for header 999999999 - generated locally +039999999 - too short for data 999999999 - output drops +049999999 - with invalid version 999999999 output fragments generated +059999999 total fragments received 999999999 - fragmentation failed +069999999 - fragments dropped 999999999 destinations unreachable +079999999 - fragments timed out 999999999 packets output via raw IP +089999999 - fragments overflown +099999999 - packets reassembled ok Input next-header histogram +109999999 packets forwarded 999999999 - destination options +119999999 - unreachable dests 999999999 - hop-by-hop options +129999999 - redirects generated 999999999 - IPv4 +139999999 option errors 999999999 - TCP +149999999 unwanted multicasts 999999999 - UDP +159999999 delivered to upper layer 999999999 - IPv6 +169999999 bad scope packets 999999999 - routing header +179999999 address selection failed 999999999 - fragmentation header +18 999999999 - ICMP6 +19 999999999 - none +--0123456789012345678901234567890123456789012345678901234567890123456789012345 +--0 1 2 3 4 5 6 7 +*/ + +WINDOW * +openip6(void) +{ + return (subwin(stdscr, LINES-4-1, 0, 4, 0)); +} + +void +closeip6(w) + WINDOW *w; +{ + if (w == NULL) + return; + wclear(w); + wrefresh(w); + delwin(w); +} + +void +labelip6(void) +{ + wmove(wnd, 0, 0); wclrtoeol(wnd); +#define L(row, str) mvwprintw(wnd, row, 10, str) +#define R(row, str) mvwprintw(wnd, row, 45, str); + L(1, "IPv6 Input"); R(1, "IPv6 Output"); + L(2, "total packets received"); R(2, "total packets sent"); + L(3, "- too short for header"); R(3, "- generated locally"); + L(4, "- too short for data"); R(4, "- output drops"); + L(5, "- with invalid version"); R(5, "output fragments generated"); + L(6, "total fragments received"); R(6, "- fragmentation failed"); + L(7, "- fragments dropped"); R(7, "destinations unreachable"); + L(8, "- fragments timed out"); R(8, "packets output via raw IP"); + L(9, "- fragments overflown"); + L(10, "- packets reassembled ok"); R(10, "Input next-header histogram"); + L(11, "packets forwarded"); R(11, " - destination options"); + L(12, "- unreachable dests"); R(12, " - hop-by-hop options"); + L(13, "- redirects generated"); R(13, " - IPv4"); + L(14, "option errors"); R(14, " - TCP"); + L(15, "unwanted multicasts"); R(15, " - UDP"); + L(16, "delivered to upper layer"); R(16, " - IPv6"); + L(17, "bad scope packets"); R(17, " - routing header"); + L(18, "address selection failed"); R(18, " - fragmentation header"); + R(19, " - ICMP6"); + R(20, " - none"); +#undef L +#undef R +} + +static void +domode(struct ip6stat *ret) +{ + const struct ip6stat *sub; + int divisor = 1, i; + + switch(currentmode) { + case display_RATE: + sub = &oldstat; + divisor = naptime; + break; + case display_DELTA: + sub = &oldstat; + break; + case display_SINCE: + sub = &initstat; + break; + default: + *ret = curstat; + return; + } +#define DO(stat) ret->stat = (curstat.stat - sub->stat) / divisor + DO(ip6s_total); + DO(ip6s_tooshort); + DO(ip6s_toosmall); + DO(ip6s_fragments); + DO(ip6s_fragdropped); + DO(ip6s_fragtimeout); + DO(ip6s_fragoverflow); + DO(ip6s_forward); + DO(ip6s_cantforward); + DO(ip6s_redirectsent); + DO(ip6s_delivered); + DO(ip6s_localout); + DO(ip6s_odropped); + DO(ip6s_reassembled); + DO(ip6s_fragmented); + DO(ip6s_ofragments); + DO(ip6s_cantfrag); + DO(ip6s_badoptions); + DO(ip6s_noroute); + DO(ip6s_badvers); + DO(ip6s_rawout); + DO(ip6s_notmember); + for (i = 0; i < 256; i++) + DO(ip6s_nxthist[i]); + DO(ip6s_badscope); + DO(ip6s_sources_none); +#undef DO +} + +void +showip6(void) +{ + struct ip6stat stats; + u_long totalout; + + domode(&stats); + totalout = stats.ip6s_forward + stats.ip6s_localout; + +#define DO(stat, row, col) \ + mvwprintw(wnd, row, col, "%9lu", stats.stat) + + DO(ip6s_total, 2, 0); + mvwprintw(wnd, 2, 35, "%9lu", totalout); + DO(ip6s_tooshort, 3, 0); + DO(ip6s_localout, 3, 35); + DO(ip6s_toosmall, 4, 0); + DO(ip6s_odropped, 4, 35); + DO(ip6s_badvers, 5, 0); + DO(ip6s_ofragments, 5, 35); + DO(ip6s_fragments, 6, 0); + DO(ip6s_cantfrag, 6, 35); + DO(ip6s_fragdropped, 7, 0); + DO(ip6s_noroute, 7, 35); + DO(ip6s_fragtimeout, 8, 0); + DO(ip6s_rawout, 8, 35); + DO(ip6s_fragoverflow, 9, 0); + DO(ip6s_reassembled, 10, 0); + DO(ip6s_forward, 11, 0); + DO(ip6s_nxthist[IPPROTO_DSTOPTS], 11, 35); + DO(ip6s_cantforward, 12, 0); + DO(ip6s_nxthist[IPPROTO_HOPOPTS], 12, 35); + DO(ip6s_redirectsent, 13, 0); + DO(ip6s_nxthist[IPPROTO_IPV4], 13, 35); + DO(ip6s_badoptions, 14, 0); + DO(ip6s_nxthist[IPPROTO_TCP], 14, 35); + DO(ip6s_notmember, 15, 0); + DO(ip6s_nxthist[IPPROTO_UDP], 15, 35); + DO(ip6s_delivered, 16, 0); + DO(ip6s_nxthist[IPPROTO_IPV6], 16, 35); + DO(ip6s_badscope, 17, 0); + DO(ip6s_nxthist[IPPROTO_ROUTING], 17, 35); + DO(ip6s_sources_none, 18, 0); + DO(ip6s_nxthist[IPPROTO_FRAGMENT], 18, 35); + DO(ip6s_nxthist[IPPROTO_ICMPV6], 19, 35); + DO(ip6s_nxthist[IPPROTO_NONE], 20, 35); +#undef DO +} + +int +initip6(void) +{ + size_t len; + int name[4]; + + name[0] = CTL_NET; + name[1] = PF_INET6; + name[2] = IPPROTO_IPV6; + name[3] = IPV6CTL_STATS; + + len = 0; + if (sysctl(name, 4, 0, &len, 0, 0) < 0) { + error("sysctl getting ip6stat size failed"); + return 0; + } + if (len > sizeof curstat) { + error("ip6stat structure has grown--recompile systat!"); + return 0; + } + if (sysctl(name, 4, &initstat, &len, 0, 0) < 0) { + error("sysctl getting ip6stat failed"); + return 0; + } + oldstat = initstat; + return 1; +} + +void +resetip6(void) +{ + size_t len; + int name[4]; + + name[0] = CTL_NET; + name[1] = PF_INET6; + name[2] = IPPROTO_IPV6; + name[3] = IPV6CTL_STATS; + + len = sizeof initstat; + if (sysctl(name, 4, &initstat, &len, 0, 0) < 0) { + error("sysctl getting ipstat failed"); + } + + oldstat = initstat; +} + +void +fetchip6(void) +{ + int name[4]; + size_t len; + + oldstat = curstat; + name[0] = CTL_NET; + name[1] = PF_INET6; + name[2] = IPPROTO_IPV6; + name[3] = IPV6CTL_STATS; + len = sizeof curstat; + + if (sysctl(name, 4, &curstat, &len, 0, 0) < 0) + return; +} + +#endif diff --git a/usr.bin/systat/netstat.c b/usr.bin/systat/netstat.c index d7ef17f35f..1163652183 100644 --- a/usr.bin/systat/netstat.c +++ b/usr.bin/systat/netstat.c @@ -32,7 +32,7 @@ * * @(#)netstat.c 8.1 (Berkeley) 6/6/93 * $FreeBSD: src/usr.bin/systat/netstat.c,v 1.13 1999/08/30 08:18:08 peter Exp $ - * $DragonFly: src/usr.bin/systat/netstat.c,v 1.8 2004/12/20 11:03:16 joerg Exp $ + * $DragonFly: src/usr.bin/systat/netstat.c,v 1.9 2007/05/31 11:38:36 hasso Exp $ */ /* @@ -50,6 +50,9 @@ #include #include #include +#ifdef INET6 +#include +#endif #include #include #include diff --git a/usr.bin/systat/systat.1 b/usr.bin/systat/systat.1 index 07c89ed250..9186eaa9b8 100644 --- a/usr.bin/systat/systat.1 +++ b/usr.bin/systat/systat.1 @@ -31,9 +31,9 @@ .\" .\" @(#)systat.1 8.2 (Berkeley) 12/30/93 .\" $FreeBSD: src/usr.bin/systat/systat.1,v 1.23.2.9 2002/12/29 16:35:40 schweikh Exp $ -.\" $DragonFly: src/usr.bin/systat/systat.1,v 1.4 2006/02/17 19:39:11 swildner Exp $ +.\" $DragonFly: src/usr.bin/systat/systat.1,v 1.5 2007/05/31 11:38:37 hasso Exp $ .\" -.Dd September 9, 1997 +.Dd May 31, 2007 .Dt SYSTAT 1 .Os .Sh NAME @@ -89,9 +89,11 @@ flag expects .Ar display to be one of: .Ic icmp , +.Ic icmp6 , .Ic ifstat , .Ic iostat , .Ic ip , +.Ic ip6 , .Ic mbufs , .Ic netstat , .Ic pigs , @@ -197,6 +199,11 @@ mode. The .Ic mode command with no argument will display the current mode in the command line. +.It Ic icmp6 +This display is like the +.Ic icmp +display, +but displays statistics for IPv6 ICMP. .It Ic ip Otherwise identical to the .Ic icmp @@ -205,6 +212,13 @@ display, except that it displays and .Tn UDP statistics. +.It Ic ip6 +Like the +.Ic ip +display, +except that it displays +.Tn IPv6 +statics. .It Ic tcp Like .Ic icmp , @@ -512,7 +526,9 @@ For port names. .Xr netstat 1 , .Xr kvm 3 , .Xr icmp 4 , +.Xr icmp6 4 , .Xr ip 4 , +.Xr ip6 4 , .Xr tcp 4 , .Xr udp 4 , .Xr iostat 8 ,