1175061Sobrien/*-
21590Srgrimes * Copyright (c) 1992, 1993
31590Srgrimes *	Regents of the University of California.  All rights reserved.
41590Srgrimes *
51590Srgrimes * Redistribution and use in source and binary forms, with or without
61590Srgrimes * modification, are permitted provided that the following conditions
71590Srgrimes * are met:
81590Srgrimes * 1. Redistributions of source code must retain the above copyright
91590Srgrimes *    notice, this list of conditions and the following disclaimer.
101590Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111590Srgrimes *    notice, this list of conditions and the following disclaimer in the
121590Srgrimes *    documentation and/or other materials provided with the distribution.
131590Srgrimes * 4. Neither the name of the University nor the names of its contributors
141590Srgrimes *    may be used to endorse or promote products derived from this software
151590Srgrimes *    without specific prior written permission.
161590Srgrimes *
171590Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
181590Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
191590Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
201590Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
211590Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
221590Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
231590Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241590Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
251590Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
261590Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
271590Srgrimes * SUCH DAMAGE.
281590Srgrimes *
291590Srgrimes *	@(#)netstat.h	8.2 (Berkeley) 1/4/94
3052419Sjulian * $FreeBSD$
311590Srgrimes */
321590Srgrimes
331590Srgrimes#include <sys/cdefs.h>
341590Srgrimes
3574311Sdesextern int	Aflag;	/* show addresses of protocol control block */
3674311Sdesextern int	aflag;	/* show all sockets (including servers) */
3774311Sdesextern int	bflag;	/* show i/f total bytes in/out */
3874311Sdesextern int	dflag;	/* show i/f dropped packets */
3974311Sdesextern int	gflag;	/* show group (multicast) routing or stats */
40149254Sglebiusextern int	hflag;	/* show counters in human readable format */
4174311Sdesextern int	iflag;	/* show interfaces */
4274311Sdesextern int	Lflag;	/* show size of listen queues */
4374311Sdesextern int	mflag;	/* show memory stats */
44202060Sdelphijextern int	noutputs;	/* how much outputs before we exit */
4578238Sassarextern int	numeric_addr;	/* show addresses numerically */
4678238Sassarextern int	numeric_port;	/* show ports numerically */
4774311Sdesextern int	rflag;	/* show routing tables (or routing stats) */
48281161Shirenextern int	Rflag;	/* show flowid / RSS information */
4974311Sdesextern int	sflag;	/* show protocol statistics */
50215434Sgnnextern int	Tflag;  /* show TCP control block info */
5174311Sdesextern int	Wflag;	/* wide display */
52182602Sobrienextern int	xflag;	/* extended display, includes all socket buffer info */
5378667Sruextern int	zflag;	/* zero stats */
541590Srgrimes
5574311Sdesextern int	interval; /* repeat interval for i/f stats */
561590Srgrimes
5774311Sdesextern char	*interface; /* desired i/f for stats, or NULL for all i/fs */
5874311Sdesextern int	unit;	/* unit number for above */
591590Srgrimes
60171465Sjhbextern int	live;	/* true if we are examining a live system */
611590Srgrimes
62263335Sglebiusstruct nlist;
63293307Smarkjint	fetch_stats(const char *sysctlname, u_long addr, void *stats,
64293307Smarkj	    size_t len, int (*kreadfn)(u_long, void *, size_t));
65171465Sjhbint	kread(u_long addr, void *buf, size_t size);
66263478Sglebiusuint64_t kread_counter(u_long addr);
67253083Saeint	kread_counters(u_long addr, void *buf, size_t size);
68263335Sglebiusint	kresolve_list(struct nlist *);
69160787Syarconst char *plural(uintmax_t);
70160787Syarconst char *plurales(uintmax_t);
71160787Syarconst char *pluralies(uintmax_t);
721590Srgrimes
73204202Srwatsonstruct sockaddr;
74204202Srwatsonstruct socket;
75204202Srwatsonstruct xsocket;
76171465Sjhbint	sotoxsocket(struct socket *, struct xsocket *);
77171465Sjhbvoid	protopr(u_long, const char *, int, int);
78171465Sjhbvoid	tcp_stats(u_long, const char *, int, int);
79171465Sjhbvoid	udp_stats(u_long, const char *, int, int);
80170461Srrs#ifdef SCTP
81171465Sjhbvoid	sctp_protopr(u_long, const char *, int, int);
82171465Sjhbvoid	sctp_stats(u_long, const char *, int, int);
83170461Srrs#endif
84196797Sgnnvoid	arp_stats(u_long, const char *, int, int);
85171465Sjhbvoid	ip_stats(u_long, const char *, int, int);
86171465Sjhbvoid	icmp_stats(u_long, const char *, int, int);
87171465Sjhbvoid	igmp_stats(u_long, const char *, int, int);
88171465Sjhbvoid	pim_stats(u_long, const char *, int, int);
89175061Sobrienvoid	carp_stats(u_long, const char *, int, int);
90175061Sobrienvoid	pfsync_stats(u_long, const char *, int, int);
9154263Sshin#ifdef IPSEC
92171465Sjhbvoid	ipsec_stats(u_long, const char *, int, int);
93175061Sobrienvoid	esp_stats(u_long, const char *, int, int);
94175061Sobrienvoid	ah_stats(u_long, const char *, int, int);
95175061Sobrienvoid	ipcomp_stats(u_long, const char *, int, int);
9654263Sshin#endif
9754263Sshin
9854263Sshin#ifdef INET6
99171465Sjhbvoid	ip6_stats(u_long, const char *, int, int);
100123949Sbdevoid	ip6_ifstats(char *);
101171465Sjhbvoid	icmp6_stats(u_long, const char *, int, int);
102123949Sbdevoid	icmp6_ifstats(char *);
103171465Sjhbvoid	pim6_stats(u_long, const char *, int, int);
104171465Sjhbvoid	rip6_stats(u_long, const char *, int, int);
105263335Sglebiusvoid	mroute6pr(void);
106263335Sglebiusvoid	mrt6_stats(void);
10762584Sitojun
10862584Sitojunstruct sockaddr_in6;
10962584Sitojunstruct in6_addr;
110217642Sumevoid in6_fillscopeid(struct sockaddr_in6 *);
111123949Sbdechar *routename6(struct sockaddr_in6 *);
112123949Sbdeconst char *netname6(struct sockaddr_in6 *, struct in6_addr *);
113123949Sbdevoid	inet6print(struct in6_addr *, int, const char *, int);
11454263Sshin#endif /*INET6*/
11554263Sshin
11662605Sitojun#ifdef IPSEC
117171465Sjhbvoid	pfkey_stats(u_long, const char *, int, int);
11862605Sitojun#endif
11962605Sitojun
120152378Srwatsonvoid	mbpr(void *, u_long);
1211590Srgrimes
122204499Srwatsonvoid	netisr_stats(void *);
123204202Srwatson
124123949Sbdevoid	hostpr(u_long, u_long);
125123949Sbdevoid	impstats(u_long, u_long);
1261590Srgrimes
127263335Sglebiusvoid	intpr(int, void (*)(char *), int);
1281590Srgrimes
129123949Sbdevoid	pr_rthdr(int);
130123949Sbdevoid	pr_family(int);
131263335Sglebiusvoid	rt_stats(void);
132262743Sglebiusvoid	flowtable_stats(void);
133123949Sbdechar	*ipx_pnet(struct sockaddr *);
134123949Sbdechar	*ipx_phost(struct sockaddr *);
135123949Sbdechar	*ns_phost(struct sockaddr *);
136123949Sbdevoid	upHex(char *);
1371590Srgrimes
138176099Smariuschar	*routename(in_addr_t);
139261207Sglebiuschar	*netname(in_addr_t, in_addr_t);
140123949Sbdechar	*atalk_print(struct sockaddr *, int);
141123949Sbdechar	*atalk_print2(struct sockaddr *, struct sockaddr *, int);
142123949Sbdechar	*ipx_print(struct sockaddr *);
143123949Sbdechar	*ns_print(struct sockaddr *);
144263335Sglebiusvoid	routepr(int, int);
1451590Srgrimes
146171465Sjhbvoid	ipxprotopr(u_long, const char *, int, int);
147171465Sjhbvoid	spx_stats(u_long, const char *, int, int);
148171465Sjhbvoid	ipx_stats(u_long, const char *, int, int);
149171465Sjhbvoid	ipxerr_stats(u_long, const char *, int, int);
15011819Sjulian
151171465Sjhbvoid	nsprotopr(u_long, const char *, int, int);
152171465Sjhbvoid	spp_stats(u_long, const char *, int, int);
153171465Sjhbvoid	idp_stats(u_long, const char *, int, int);
154171465Sjhbvoid	nserr_stats(u_long, const char *, int, int);
1551590Srgrimes
156171465Sjhbvoid	atalkprotopr(u_long, const char *, int, int);
157171465Sjhbvoid	ddp_stats(u_long, const char *, int, int);
15816178Sjulian
159183242Ssam#ifdef NETGRAPH
160171465Sjhbvoid	netgraphprotopr(u_long, const char *, int, int);
161183242Ssam#endif
16252419Sjulian
163197777Srwatsonvoid	unixpr(u_long, u_long, u_long, u_long, u_long);
1641590Srgrimes
165171465Sjhbvoid	esis_stats(u_long, const char *, int, int);
166171465Sjhbvoid	clnp_stats(u_long, const char *, int, int);
167171465Sjhbvoid	cltp_stats(u_long, const char *, int, int);
168171465Sjhbvoid	iso_protopr(u_long, const char *, int, int);
169123949Sbdevoid	iso_protopr1(u_long, int);
170171465Sjhbvoid	tp_protopr(u_long, const char *, int, int);
171123949Sbdevoid	tp_inproto(u_long);
172123949Sbdevoid	tp_stats(caddr_t, caddr_t);
1731590Srgrimes
174263335Sglebiusvoid	mroutepr(void);
175263335Sglebiusvoid	mrt_stats(void);
176149862Scsjpvoid	bpf_stats(char *);
177