xref: /f-stack/tools/netstat/netstat.h (revision c36e692a)
1 /*-
2  * Copyright (c) 1992, 1993
3  *	Regents of the University of California.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 4. Neither the name of the University nor the names of its contributors
14  *    may be used to endorse or promote products derived from this software
15  *    without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  *	@(#)netstat.h	8.2 (Berkeley) 1/4/94
30  * $FreeBSD$
31  */
32 
33 #include <sys/cdefs.h>
34 
35 #ifdef FSTACK
36 #ifndef __unused
37 #define __unused __attribute__((__unused__))
38 #endif
39 #endif
40 
41 #define	satosin(sa)	((struct sockaddr_in *)(sa))
42 #define	satosin6(sa)	((struct sockaddr_in6 *)(sa))
43 #define	sin6tosa(sin6)	((struct sockaddr *)(sin6))
44 
45 extern int	Aflag;	/* show addresses of protocol control block */
46 extern int	aflag;	/* show all sockets (including servers) */
47 extern int	bflag;	/* show i/f total bytes in/out */
48 extern int	dflag;	/* show i/f dropped packets */
49 extern int	gflag;	/* show group (multicast) routing or stats */
50 extern int	hflag;	/* show counters in human readable format */
51 extern int	iflag;	/* show interfaces */
52 extern int	Lflag;	/* show size of listen queues */
53 extern int	mflag;	/* show memory stats */
54 extern int	noutputs;	/* how much outputs before we exit */
55 extern int	numeric_addr;	/* show addresses numerically */
56 extern int	numeric_port;	/* show ports numerically */
57 extern int	rflag;	/* show routing tables (or routing stats) */
58 extern int	Rflag;	/* show flowid / RSS information */
59 extern int	sflag;	/* show protocol statistics */
60 extern int	Tflag;  /* show TCP control block info */
61 extern int	Wflag;	/* wide display */
62 extern int	xflag;	/* extended display, includes all socket buffer info */
63 extern int	zflag;	/* zero stats */
64 
65 extern int	interval; /* repeat interval for i/f stats */
66 
67 extern char	*interface; /* desired i/f for stats, or NULL for all i/fs */
68 extern int	unit;	/* unit number for above */
69 
70 extern int	live;	/* true if we are examining a live system */
71 
72 typedef	int kreadfn_t(u_long, void *, size_t);
73 int	fetch_stats(const char *, u_long, void *, size_t, kreadfn_t);
74 int	fetch_stats_ro(const char *, u_long, void *, size_t, kreadfn_t);
75 
76 int	kread(u_long addr, void *buf, size_t size);
77 uint64_t kread_counter(u_long addr);
78 int	kread_counters(u_long addr, void *buf, size_t size);
79 void	kset_dpcpu(u_int);
80 const char *plural(uintmax_t);
81 const char *plurales(uintmax_t);
82 const char *pluralies(uintmax_t);
83 
84 struct sockaddr;
85 struct socket;
86 struct xsocket;
87 int	sotoxsocket(struct socket *, struct xsocket *);
88 void	protopr(u_long, const char *, int, int);
89 void	tcp_stats(u_long, const char *, int, int);
90 void	udp_stats(u_long, const char *, int, int);
91 #ifdef SCTP
92 void	sctp_protopr(u_long, const char *, int, int);
93 void	sctp_stats(u_long, const char *, int, int);
94 #endif
95 void	arp_stats(u_long, const char *, int, int);
96 void	ip_stats(u_long, const char *, int, int);
97 void	icmp_stats(u_long, const char *, int, int);
98 void	igmp_stats(u_long, const char *, int, int);
99 void	pim_stats(u_long, const char *, int, int);
100 void	carp_stats(u_long, const char *, int, int);
101 void	pfsync_stats(u_long, const char *, int, int);
102 #ifdef IPSEC
103 void	ipsec_stats(u_long, const char *, int, int);
104 void	esp_stats(u_long, const char *, int, int);
105 void	ah_stats(u_long, const char *, int, int);
106 void	ipcomp_stats(u_long, const char *, int, int);
107 #endif
108 
109 #ifdef INET6
110 void	ip6_stats(u_long, const char *, int, int);
111 void	ip6_ifstats(char *);
112 void	icmp6_stats(u_long, const char *, int, int);
113 void	icmp6_ifstats(char *);
114 void	pim6_stats(u_long, const char *, int, int);
115 void	rip6_stats(u_long, const char *, int, int);
116 void	mroute6pr(void);
117 void	mrt6_stats(void);
118 
119 struct sockaddr_in6;
120 struct in6_addr;
121 void in6_fillscopeid(struct sockaddr_in6 *);
122 void	inet6print(const char *, struct in6_addr *, int, const char *, int);
123 #endif /*INET6*/
124 
125 #ifdef IPSEC
126 void	pfkey_stats(u_long, const char *, int, int);
127 #endif
128 
129 void	mbpr(void *, u_long);
130 
131 void	netisr_stats(void);
132 
133 void	hostpr(u_long, u_long);
134 void	impstats(u_long, u_long);
135 
136 void	intpr(void (*)(char *), int);
137 
138 void	pr_family(int);
139 void	rt_stats(void);
140 void	flowtable_stats(void);
141 
142 char	*routename(struct sockaddr *, int);
143 const char *netname(struct sockaddr *, struct sockaddr *);
144 void	routepr(int, int);
145 
146 #ifdef NETGRAPH
147 void	netgraphprotopr(u_long, const char *, int, int);
148 #endif
149 
150 void	unixpr(u_long, u_long, u_long, u_long, u_long, bool *);
151 
152 void	mroutepr(void);
153 void	mrt_stats(void);
154 void	bpf_stats(char *);
155