1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1991, 1993
5 *	The Regents of the University of California.  All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
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.
18 *
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
29 * SUCH DAMAGE.
30 */
31
32#include <sys/cdefs.h>
33#include <fcntl.h>
34#include <kvm.h>
35
36extern struct	cmdtab *curcmd;
37extern struct	cmdtab cmdtab[];
38extern struct	text *xtext;
39extern WINDOW	*wnd;
40extern char	**dr_name;
41extern char	c, *namp, hostname[];
42extern double	avenrun[3];
43extern float	*dk_mspw;
44extern kvm_t	*kd;
45extern long	ntext, textp;
46extern int	*dk_select;
47extern int	CMDLINE;
48extern int	dk_ndrive;
49extern int	hz, stathz;
50extern double	hertz;		/* sampling frequency for cp_time and dk_time */
51extern int	col;
52extern int	nhosts;
53extern int	nports;
54extern int	protos;
55extern int	verbose;
56extern unsigned int	delay;
57
58extern int	curscale;
59extern char	*matchline;
60extern int	showpps;
61extern int	needsort;
62
63struct in_conninfo;
64
65extern struct device_selection *dev_select;
66extern long			generation;
67extern int			num_devices;
68extern int			num_selected;
69extern int			num_selections;
70extern long			select_generation;
71
72extern struct nlist		namelist[];
73
74int	 checkhost(struct in_conninfo *);
75int	 checkport(struct in_conninfo *);
76void	 closeicmp(WINDOW *);
77void	 closeicmp6(WINDOW *);
78void	 closeifstat(WINDOW *);
79void	 closeiostat(WINDOW *);
80void	 closeip(WINDOW *);
81void	 closeip6(WINDOW *);
82void	 closekre(WINDOW *);
83void	 closenetstat(WINDOW *);
84void	 closepigs(WINDOW *);
85void	 closeswap(WINDOW *);
86void	 closetcp(WINDOW *);
87int	 cmdifstat(const char *, const char *);
88int	 cmdiolat(const char *, const char *);
89int	 cmdiostat(const char *, const char *);
90int	 cmdkre(const char *, const char *);
91int	 cmdnetstat(const char *, const char *);
92struct	 cmdtab *lookup(const char *);
93void	 command(const char *);
94void	 die(int);
95void	 display(void);
96int	 dkinit(void);
97int	 dkcmd(char *, char *);
98void	 error(const char *fmt, ...) __printflike(1, 2);
99void	 fetchicmp(void);
100void	 fetchicmp6(void);
101void	 fetchifstat(void);
102void	 fetchip(void);
103void	 fetchip6(void);
104void	 fetchiostat(void);
105void	 fetchkre(void);
106void	 fetchnetstat(void);
107void	 fetchpigs(void);
108void	 fetchswap(void);
109void	 fetchtcp(void);
110void	 getsysctl(const char *, void *, size_t);
111int	 ifcmd(const char *cmd, const char *args);
112int	 initicmp(void);
113int	 initicmp6(void);
114int	 initifstat(void);
115int	 initip(void);
116int	 initip6(void);
117int	 initiostat(void);
118int	 initkre(void);
119int	 initnetstat(void);
120int	 initpigs(void);
121int	 initswap(void);
122int	 inittcp(void);
123int	 keyboard(void);
124int	 kvm_ckread(void *, void *, int);
125void	 labelicmp(void);
126void	 labelicmp6(void);
127void	 labelifstat(void);
128void	 labelip(void);
129void	 labelip6(void);
130void	 labeliostat(void);
131void	 labelkre(void);
132void	 labelnetstat(void);
133void	 labelpigs(void);
134void	 labels(void);
135void	 labelswap(void);
136void	 labeltcp(void);
137void	 load(void);
138int	 netcmd(const char *, const char *);
139void	 nlisterr(struct nlist []);
140WINDOW	*openicmp(void);
141WINDOW	*openicmp6(void);
142WINDOW	*openifstat(void);
143WINDOW	*openip(void);
144WINDOW	*openip6(void);
145WINDOW	*openiostat(void);
146WINDOW	*openkre(void);
147WINDOW	*opennetstat(void);
148WINDOW	*openpigs(void);
149WINDOW	*openswap(void);
150WINDOW	*opentcp(void);
151int	 prefix(const char *, const char *);
152void	 reseticmp(void);
153void	 reseticmp6(void);
154void	 resetip(void);
155void	 resetip6(void);
156void	 resettcp(void);
157void	 showicmp(void);
158void	 showicmp6(void);
159void	 showifstat(void);
160void	 showip(void);
161void	 showip6(void);
162void	 showiostat(void);
163void	 showkre(void);
164void	 shownetstat(void);
165void	 showpigs(void);
166void	 showswap(void);
167void	 showtcp(void);
168void	 status(void);
169void	 suspend(int);
170char	*sysctl_dynread(const char *, size_t *);
171void	 sysputpage(WINDOW* , int, int, int, uint64_t, int);
172void	 sysputspaces(WINDOW* , int, int, int);
173void	 sysputstrs(WINDOW* , int, int, int);
174void	 sysputXs(WINDOW* , int, int, int);
175void	 sysputuint64(WINDOW* , int, int, int, uint64_t, int);
176void	 sysputwuint64(WINDOW* , int, int, int, uint64_t, int);
177
178#define SYSTAT_CMD(name)	\
179	void	 close ## name(WINDOW *); \
180	void	 fetch ## name(void); \
181	int	 init ## name(void); \
182	void	 label ## name(void); \
183	WINDOW	*open ## name(void); \
184	void	 reset ## name(void); \
185	void	 show ## name(void)
186
187SYSTAT_CMD( zarc );
188SYSTAT_CMD( sctp );
189SYSTAT_CMD( iolat );
190