2 * SPDX-License-Identifier: BSD-3-Clause
4 * Copyright (c) 1980, 1992, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #include <sys/cdefs.h>
34 __FBSDID("$FreeBSD$");
37 static const char sccsid[] = "@(#)mbufs.c 8.1 (Berkeley) 6/6/93";
41 "Id: mbufs.c,v 1.5 1997/02/24 20:59:03 wollman Exp"
45 #include <sys/param.h>
46 #include <sys/types.h>
47 #include <sys/socket.h>
48 #include <sys/sysctl.h>
50 #include <netinet/in.h>
51 #include <netinet/in_systm.h>
52 #include <netinet/ip.h>
53 #include <netinet6/ip6_var.h>
63 static struct ip6stat curstat, initstat, oldstat;
67 --0123456789012345678901234567890123456789012345678901234567890123456789012345
68 00 IPv6 Input IPv6 Output
69 019999999 total packets received 999999999 total packets sent
70 029999999 - too short for header 999999999 - generated locally
71 039999999 - too short for data 999999999 - output drops
72 049999999 - with invalid version 999999999 output fragments generated
73 059999999 total fragments received 999999999 - fragmentation failed
74 069999999 - fragments dropped 999999999 destinations unreachable
75 079999999 - fragments timed out 999999999 packets output via raw IP
76 089999999 - fragments overflown
77 099999999 - packets reassembled ok Input next-header histogram
78 109999999 packets forwarded 999999999 - destination options
79 119999999 - unreachable dests 999999999 - hop-by-hop options
80 129999999 - redirects generated 999999999 - IPv4
81 139999999 option errors 999999999 - TCP
82 149999999 unwanted multicasts 999999999 - UDP
83 159999999 delivered to upper layer 999999999 - IPv6
84 169999999 bad scope packets 999999999 - routing header
85 179999999 address selection failed 999999999 - fragmentation header
88 --0123456789012345678901234567890123456789012345678901234567890123456789012345
95 return (subwin(stdscr, LINES-3-1, 0, MAINWIN_ROW, 0));
111 wmove(wnd, 0, 0); wclrtoeol(wnd);
112 #define L(row, str) mvwprintw(wnd, row, 10, str)
113 #define R(row, str) mvwprintw(wnd, row, 45, str);
114 L(0, "IPv6 Input"); R(0, "IPv6 Output");
115 L(1, "total packets received"); R(1, "total packets sent");
116 L(2, "- too short for header"); R(2, "- generated locally");
117 L(3, "- too short for data"); R(3, "- output drops");
118 L(4, "- with invalid version"); R(4, "output fragments generated");
119 L(5, "total fragments received"); R(5, "- fragmentation failed");
120 L(6, "- fragments dropped"); R(6, "destinations unreachable");
121 L(7, "- fragments timed out"); R(7, "packets output via raw IP");
122 L(8, "- fragments overflown");
123 L(9, "- packets reassembled ok"); R(9, "Input next-header histogram");
124 L(10, "packets forwarded"); R(10, " - destination options");
125 L(11, "- unreachable dests"); R(11, " - hop-by-hop options");
126 L(12, "- redirects generated"); R(12, " - IPv4");
127 L(13, "option errors"); R(13, " - TCP");
128 L(14, "unwanted multicasts"); R(14, " - UDP");
129 L(15, "delivered to upper layer"); R(15, " - IPv6");
130 L(16, "bad scope packets"); R(16, " - routing header");
131 L(17, "address selection failed"); R(17, " - fragmentation header");
139 domode(struct ip6stat *ret)
141 const struct ip6stat *sub;
144 switch(currentmode) {
147 divisor = (delay > 1000000) ? delay / 1000000 : 1;
159 #define DO(stat) ret->stat = (curstat.stat - sub->stat) / divisor
164 DO(ip6s_fragdropped);
165 DO(ip6s_fragtimeout);
166 DO(ip6s_fragoverflow);
168 DO(ip6s_cantforward);
169 DO(ip6s_redirectsent);
173 DO(ip6s_reassembled);
182 for (i = 0; i < 256; i++)
185 DO(ip6s_sources_none);
192 struct ip6stat stats;
196 totalout = stats.ip6s_forward + stats.ip6s_localout;
198 #define DO(stat, row, col) \
199 mvwprintw(wnd, row, col, "%9lu", stats.stat)
201 DO(ip6s_total, 1, 0);
202 mvwprintw(wnd, 1, 35, "%9lu", totalout);
203 DO(ip6s_tooshort, 2, 0);
204 DO(ip6s_localout, 2, 35);
205 DO(ip6s_toosmall, 3, 0);
206 DO(ip6s_odropped, 3, 35);
207 DO(ip6s_badvers, 4, 0);
208 DO(ip6s_ofragments, 4, 35);
209 DO(ip6s_fragments, 5, 0);
210 DO(ip6s_cantfrag, 5, 35);
211 DO(ip6s_fragdropped, 6, 0);
212 DO(ip6s_noroute, 6, 35);
213 DO(ip6s_fragtimeout, 7, 0);
214 DO(ip6s_rawout, 7, 35);
215 DO(ip6s_fragoverflow, 8, 0);
216 DO(ip6s_reassembled, 9, 0);
217 DO(ip6s_forward, 10, 0);
218 DO(ip6s_nxthist[IPPROTO_DSTOPTS], 10, 35);
219 DO(ip6s_cantforward, 11, 0);
220 DO(ip6s_nxthist[IPPROTO_HOPOPTS], 11, 35);
221 DO(ip6s_redirectsent, 12, 0);
222 DO(ip6s_nxthist[IPPROTO_IPV4], 12, 35);
223 DO(ip6s_badoptions, 13, 0);
224 DO(ip6s_nxthist[IPPROTO_TCP], 13, 35);
225 DO(ip6s_notmember, 14, 0);
226 DO(ip6s_nxthist[IPPROTO_UDP], 14, 35);
227 DO(ip6s_delivered, 15, 0);
228 DO(ip6s_nxthist[IPPROTO_IPV6], 15, 35);
229 DO(ip6s_badscope, 16, 0);
230 DO(ip6s_nxthist[IPPROTO_ROUTING], 16, 35);
231 DO(ip6s_sources_none, 17, 0);
232 DO(ip6s_nxthist[IPPROTO_FRAGMENT], 17, 35);
233 DO(ip6s_nxthist[IPPROTO_ICMPV6], 18, 35);
234 DO(ip6s_nxthist[IPPROTO_NONE], 19, 35);
246 name[2] = IPPROTO_IPV6;
247 name[3] = IPV6CTL_STATS;
250 if (sysctl(name, 4, 0, &len, 0, 0) < 0) {
251 error("sysctl getting ip6stat size failed");
254 if (len > sizeof curstat) {
255 error("ip6stat structure has grown--recompile systat!");
258 if (sysctl(name, 4, &initstat, &len, 0, 0) < 0) {
259 error("sysctl getting ip6stat failed");
274 name[2] = IPPROTO_IPV6;
275 name[3] = IPV6CTL_STATS;
277 len = sizeof initstat;
278 if (sysctl(name, 4, &initstat, &len, 0, 0) < 0) {
279 error("sysctl getting ipstat failed");
294 name[2] = IPPROTO_IPV6;
295 name[3] = IPV6CTL_STATS;
296 len = sizeof curstat;
298 if (sysctl(name, 4, &curstat, &len, 0, 0) < 0)