Thu Apr 23 00:24:50 2020 UTC ()
Avoid common symbol definitions.


(joerg)
diff -r1.99 -r1.100 src/usr.bin/netstat/main.c
diff -r1.51 -r1.52 src/usr.bin/netstat/netstat.h

cvs diff -r1.99 -r1.100 src/usr.bin/netstat/main.c (expand / switch to unified diff)

--- src/usr.bin/netstat/main.c 2016/07/14 20:13:10 1.99
+++ src/usr.bin/netstat/main.c 2020/04/23 00:24:50 1.100
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: main.c,v 1.99 2016/07/14 20:13:10 christos Exp $ */ 1/* $NetBSD: main.c,v 1.100 2020/04/23 00:24:50 joerg Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1983, 1988, 1993 4 * Copyright (c) 1983, 1988, 1993
5 * Regents of the University of California. All rights reserved. 5 * Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -29,27 +29,27 @@ @@ -29,27 +29,27 @@
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34__COPYRIGHT("@(#) Copyright (c) 1983, 1988, 1993\ 34__COPYRIGHT("@(#) Copyright (c) 1983, 1988, 1993\
35 Regents of the University of California. All rights reserved."); 35 Regents of the University of California. All rights reserved.");
36#endif /* not lint */ 36#endif /* not lint */
37 37
38#ifndef lint 38#ifndef lint
39#if 0 39#if 0
40static char sccsid[] = "from: @(#)main.c 8.4 (Berkeley) 3/1/94"; 40static char sccsid[] = "from: @(#)main.c 8.4 (Berkeley) 3/1/94";
41#else 41#else
42__RCSID("$NetBSD: main.c,v 1.99 2016/07/14 20:13:10 christos Exp $"); 42__RCSID("$NetBSD: main.c,v 1.100 2020/04/23 00:24:50 joerg Exp $");
43#endif 43#endif
44#endif /* not lint */ 44#endif /* not lint */
45 45
46#include <sys/param.h> 46#include <sys/param.h>
47#include <sys/file.h> 47#include <sys/file.h>
48#include <sys/protosw.h> 48#include <sys/protosw.h>
49#include <sys/socket.h> 49#include <sys/socket.h>
50 50
51#include <net/if.h> 51#include <net/if.h>
52#include <netinet/in.h> 52#include <netinet/in.h>
53 53
54#include <ctype.h> 54#include <ctype.h>
55#include <err.h> 55#include <err.h>
@@ -57,26 +57,58 @@ __RCSID("$NetBSD: main.c,v 1.99 2016/07/ @@ -57,26 +57,58 @@ __RCSID("$NetBSD: main.c,v 1.99 2016/07/
57#include <kvm.h> 57#include <kvm.h>
58#include <limits.h> 58#include <limits.h>
59#include <netdb.h> 59#include <netdb.h>
60#include <nlist.h> 60#include <nlist.h>
61#include <paths.h> 61#include <paths.h>
62#include <stdio.h> 62#include <stdio.h>
63#include <stdlib.h> 63#include <stdlib.h>
64#include <string.h> 64#include <string.h>
65#include <unistd.h> 65#include <unistd.h>
66#include "netstat.h" 66#include "netstat.h"
67#include "rtutil.h" 67#include "rtutil.h"
68#include "prog_ops.h" 68#include "prog_ops.h"
69 69
 70int Aflag;
 71int aflag;
 72int Bflag;
 73int bflag;
 74int dflag;
 75#ifndef SMALL
 76int gflag;
 77#endif
 78int hflag;
 79int iflag;
 80int Lflag;
 81int lflag;
 82int mflag;
 83int numeric_addr;
 84int numeric_port;
 85int nflag;
 86int Pflag;
 87int pflag;
 88int qflag;
 89int rflag;
 90int sflag;
 91int tagflag;
 92int tflag;
 93int Vflag;
 94int vflag;
 95
 96char *interface;
 97
 98int af;
 99int use_sysctl;
 100int force_sysctl;
 101
70struct nlist nl[] = { 102struct nlist nl[] = {
71#define N_MBSTAT 0 103#define N_MBSTAT 0
72 { "_mbstat", 0, 0, 0, 0 }, 104 { "_mbstat", 0, 0, 0, 0 },
73#define N_IPSTAT 1 105#define N_IPSTAT 1
74 { "_ipstat", 0, 0, 0, 0 }, /* not available via kvm */ 106 { "_ipstat", 0, 0, 0, 0 }, /* not available via kvm */
75#define N_TCBTABLE 2 107#define N_TCBTABLE 2
76 { "_tcbtable", 0, 0, 0, 0 }, 108 { "_tcbtable", 0, 0, 0, 0 },
77#define N_TCPSTAT 3 109#define N_TCPSTAT 3
78 { "_tcpstat", 0, 0, 0, 0 }, /* not available via kvm */ 110 { "_tcpstat", 0, 0, 0, 0 }, /* not available via kvm */
79#define N_UDBTABLE 4 111#define N_UDBTABLE 4
80 { "_udbtable", 0, 0, 0, 0 }, 112 { "_udbtable", 0, 0, 0, 0 },
81#define N_UDPSTAT 5 113#define N_UDPSTAT 5
82 { "_udpstat", 0, 0, 0, 0 }, /* not available via kvm */ 114 { "_udpstat", 0, 0, 0, 0 }, /* not available via kvm */

cvs diff -r1.51 -r1.52 src/usr.bin/netstat/netstat.h (expand / switch to unified diff)

--- src/usr.bin/netstat/netstat.h 2014/11/06 21:30:09 1.51
+++ src/usr.bin/netstat/netstat.h 2020/04/23 00:24:50 1.52
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: netstat.h,v 1.51 2014/11/06 21:30:09 christos Exp $ */ 1/* $NetBSD: netstat.h,v 1.52 2020/04/23 00:24:50 joerg Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1992, 1993 4 * Copyright (c) 1992, 1993
5 * Regents of the University of California. All rights reserved. 5 * Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -24,57 +24,57 @@ @@ -24,57 +24,57 @@
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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 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 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 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 * 30 *
31 * from: @(#)netstat.h 8.2 (Berkeley) 1/4/94 31 * from: @(#)netstat.h 8.2 (Berkeley) 1/4/94
32 */ 32 */
33 33
34#include <sys/cdefs.h> 34#include <sys/cdefs.h>
35#include <kvm.h> 35#include <kvm.h>
36 36
37int Aflag; /* show addresses of protocol control block */ 37extern int Aflag; /* show addresses of protocol control block */
38int aflag; /* show all sockets (including servers) */ 38extern int aflag; /* show all sockets (including servers) */
39int Bflag; /* show Berkeley Packet Filter information */ 39extern int Bflag; /* show Berkeley Packet Filter information */
40int bflag; /* show i/f byte stats */ 40extern int bflag; /* show i/f byte stats */
41int dflag; /* show i/f dropped packets */ 41extern int dflag; /* show i/f dropped packets */
42#ifndef SMALL 42#ifndef SMALL
43int gflag; /* show group (multicast) routing or stats */ 43extern int gflag; /* show group (multicast) routing or stats */
44#endif 44#endif
45int hflag; /* humanize byte counts */ 45extern int hflag; /* humanize byte counts */
46int iflag; /* show interfaces */ 46extern int iflag; /* show interfaces */
47int Lflag; /* don't show LLINFO entries */ 47extern int Lflag; /* don't show LLINFO entries */
48int lflag; /* show routing table with use and ref */ 48extern int lflag; /* show routing table with use and ref */
49int mflag; /* show memory stats */ 49extern int mflag; /* show memory stats */
50int numeric_addr; /* show addresses numerically */ 50extern int numeric_addr; /* show addresses numerically */
51int numeric_port; /* show ports numerically */ 51extern int numeric_port; /* show ports numerically */
52int nflag; /* same as above, for show.c compat */ 52extern int nflag; /* same as above, for show.c compat */
53int Pflag; /* dump a PCB */ 53extern int Pflag; /* dump a PCB */
54int pflag; /* show given protocol */ 54extern int pflag; /* show given protocol */
55int qflag; /* show softintrq */ 55extern int qflag; /* show softintrq */
56int rflag; /* show routing tables (or routing stats) */ 56extern int rflag; /* show routing tables (or routing stats) */
57int sflag; /* show protocol statistics */ 57extern int sflag; /* show protocol statistics */
58int tagflag; /* show route tags */ 58extern int tagflag; /* show route tags */
59int tflag; /* show i/f watchdog timers */ 59extern int tflag; /* show i/f watchdog timers */
60int Vflag; /* show Vestigial TIME_WAIT (VTW) information */ 60extern int Vflag; /* show Vestigial TIME_WAIT (VTW) information */
61int vflag; /* verbose route information or don't truncate names */ 61extern int vflag; /* verbose route information or don't truncate names */
62 62
63char *interface; /* desired i/f for stats, or NULL for all i/fs */ 63extern char *interface; /* desired i/f for stats, or NULL for all i/fs */
64 64
65int af; /* address family */ 65extern int af; /* address family */
66int use_sysctl; /* use sysctl instead of kmem */ 66extern int use_sysctl; /* use sysctl instead of kmem */
67int force_sysctl; /* force use of sysctl (or exit) - for testing */ 67extern int force_sysctl; /* force use of sysctl (or exit) - for testing */
68 68
69 69
70int kread(u_long addr, char *buf, int size); 70int kread(u_long addr, char *buf, int size);
71const char *plural(int); 71const char *plural(int);
72const char *plurales(int); 72const char *plurales(int);
73int get_hardticks(void); 73int get_hardticks(void);
74 74
75void protopr(u_long, const char *); 75void protopr(u_long, const char *);
76void tcp_stats(u_long, const char *); 76void tcp_stats(u_long, const char *);
77void tcp_dump(u_long, const char *, u_long); 77void tcp_dump(u_long, const char *, u_long);
78void udp_stats(u_long, const char *); 78void udp_stats(u_long, const char *);
79void ip_stats(u_long, const char *); 79void ip_stats(u_long, const char *);
80void icmp_stats(u_long, const char *); 80void icmp_stats(u_long, const char *);