summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat
diff options
context:
space:
mode:
authordwmalone <dwmalone@FreeBSD.org>2002-09-05 17:06:51 +0000
committerdwmalone <dwmalone@FreeBSD.org>2002-09-05 17:06:51 +0000
commitcb4604919fc3c4fef1de7daff27468d6c5fbd56d (patch)
tree959e14da31f6b728ead4e7600874639513bcf91a /usr.bin/netstat
parentbd265f5118e4fb79ee5176679e737794dc630d3d (diff)
downloadFreeBSD-src-cb4604919fc3c4fef1de7daff27468d6c5fbd56d.zip
FreeBSD-src-cb4604919fc3c4fef1de7daff27468d6c5fbd56d.tar.gz
Warns cleanups for netstat:
1) Include arpa/inet.h for ntohs. 2) Constness fixes. 3) Fix shadowing except for "sin" which shouldn't be in scope. 4) Remove register keyword. 5) Add missing initialsers to user defined structs. 5) Make prototype of netname6 globally visable. 6) Use right macros for printing syncache stats (even though entrie isn't a word).
Diffstat (limited to 'usr.bin/netstat')
-rw-r--r--usr.bin/netstat/atalk.c11
-rw-r--r--usr.bin/netstat/if.c15
-rw-r--r--usr.bin/netstat/inet.c73
-rw-r--r--usr.bin/netstat/inet6.c17
-rw-r--r--usr.bin/netstat/ipsec.c4
-rw-r--r--usr.bin/netstat/ipx.c14
-rw-r--r--usr.bin/netstat/iso.c26
-rw-r--r--usr.bin/netstat/main.c32
-rw-r--r--usr.bin/netstat/mbuf.c8
-rw-r--r--usr.bin/netstat/mroute.c10
-rw-r--r--usr.bin/netstat/mroute6.c10
-rw-r--r--usr.bin/netstat/netgraph.c2
-rw-r--r--usr.bin/netstat/netstat.h67
-rw-r--r--usr.bin/netstat/ns.c14
-rw-r--r--usr.bin/netstat/route.c86
15 files changed, 194 insertions, 195 deletions
diff --git a/usr.bin/netstat/atalk.c b/usr.bin/netstat/atalk.c
index 0d9cc17..d0a09c2 100644
--- a/usr.bin/netstat/atalk.c
+++ b/usr.bin/netstat/atalk.c
@@ -45,6 +45,7 @@ static const char rcsid[] =
#include <sys/socketvar.h>
#include <sys/protosw.h>
+#include <arpa/inet.h>
#include <net/route.h>
#include <netatalk/at.h>
@@ -69,7 +70,7 @@ static int first = 1;
* -a (all) flag is specified.
*/
-static char *
+static const char *
at_pr_net(struct sockaddr_at *sat, int numeric)
{
static char mybuf[50];
@@ -86,7 +87,7 @@ static char mybuf[50];
return mybuf;
}
-static char *
+static const char *
at_pr_host(struct sockaddr_at *sat, int numeric)
{
static char mybuf[50];
@@ -103,7 +104,7 @@ static char mybuf[50];
return mybuf;
}
-static char *
+static const char *
at_pr_port(struct sockaddr_at *sat)
{
static char mybuf[50];
@@ -214,7 +215,7 @@ atalk_print2(struct sockaddr *sa, struct sockaddr *mask, int what)
}
void
-atalkprotopr(u_long off __unused, char *name, int af __unused)
+atalkprotopr(u_long off __unused, const char *name, int af1 __unused)
{
struct ddpcb *this, *next;
@@ -263,7 +264,7 @@ atalkprotopr(u_long off __unused, char *name, int af __unused)
* Dump DDP statistics structure.
*/
void
-ddp_stats(u_long off __unused, char *name, int af __unused)
+ddp_stats(u_long off __unused, const char *name, int af1 __unused)
{
struct ddpstat ddpstat;
diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c
index e58fbd2..1b012ce 100644
--- a/usr.bin/netstat/if.c
+++ b/usr.bin/netstat/if.c
@@ -80,14 +80,13 @@ static void sidewaysintpr (u_int, u_long);
static void catchalarm (int);
#ifdef INET6
-char *netname6 (struct sockaddr_in6 *, struct in6_addr *);
static char ntop_buf[INET6_ADDRSTRLEN]; /* for inet_ntop() */
static int bdg_done;
#endif
/* print bridge statistics */
void
-bdg_stats(u_long dummy __unused, char *name, int _af __unused)
+bdg_stats(u_long dummy __unused, const char *name, int af1 __unused)
{
int i;
size_t slen ;
@@ -223,7 +222,7 @@ intpr(int _interval, u_long ifnetaddr, void (*pfunc)(char *))
#ifdef INET6
struct sockaddr_in6 *sin6;
#endif
- register char *cp;
+ char *cp;
int n, m;
network_layer = 0;
@@ -318,7 +317,7 @@ intpr(int _interval, u_long ifnetaddr, void (*pfunc)(char *))
netname6(&ifaddr.in6.ia_addr,
&ifaddr.in6.ia_prefixmask.sin6_addr));
printf("%-17.17s ",
- (char *)inet_ntop(AF_INET6,
+ inet_ntop(AF_INET6,
&sin6->sin6_addr,
ntop_buf, sizeof(ntop_buf)));
@@ -516,13 +515,13 @@ u_char signalled; /* set if alarm goes off "early" */
* XXX - should be rewritten to use ifmib(4).
*/
static void
-sidewaysintpr(unsigned interval, u_long off)
+sidewaysintpr(unsigned interval1, u_long off)
{
struct ifnet ifnet;
u_long firstifnet;
struct ifnethead ifnethead;
struct iftot *iftot, *ip, *ipn, *total, *sum, *interesting;
- register int line;
+ int line;
int oldmask, first;
u_long interesting_off;
@@ -575,7 +574,7 @@ sidewaysintpr(unsigned interval, u_long off)
(void)signal(SIGALRM, catchalarm);
signalled = NO;
- (void)alarm(interval);
+ (void)alarm(interval1);
first = 1;
banner:
printf("%17s %14s %16s", "input",
@@ -664,7 +663,7 @@ loop:
}
sigsetmask(oldmask);
signalled = NO;
- (void)alarm(interval);
+ (void)alarm(interval1);
line++;
first = 0;
if (line == 21)
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c
index 39b77c1..e3fedca 100644
--- a/usr.bin/netstat/inet.c
+++ b/usr.bin/netstat/inet.c
@@ -81,9 +81,8 @@ static const char rcsid[] =
#include "netstat.h"
char *inetname (struct in_addr *);
-void inetprint (struct in_addr *, int, char *, int);
+void inetprint (struct in_addr *, int, const char *, int);
#ifdef INET6
-extern void inet6print (struct in6_addr *, int, char *, int);
static int udp_done, tcp_done;
#endif /* INET6 */
@@ -95,7 +94,7 @@ static int udp_done, tcp_done;
*/
void
protopr(u_long proto, /* for sysctl version we pass proto # */
- char *name, int af)
+ const char *name, int af1)
{
int istcp;
static int first = 1;
@@ -172,11 +171,11 @@ protopr(u_long proto, /* for sysctl version we pass proto # */
if (inp->inp_gencnt > oxig->xig_gen)
continue;
- if ((af == AF_INET && (inp->inp_vflag & INP_IPV4) == 0)
+ if ((af1 == AF_INET && (inp->inp_vflag & INP_IPV4) == 0)
#ifdef INET6
- || (af == AF_INET6 && (inp->inp_vflag & INP_IPV6) == 0)
+ || (af1 == AF_INET6 && (inp->inp_vflag & INP_IPV6) == 0)
#endif /* INET6 */
- || (af == AF_UNSPEC && ((inp->inp_vflag & INP_IPV4) == 0
+ || (af1 == AF_UNSPEC && ((inp->inp_vflag & INP_IPV4) == 0
#ifdef INET6
&& (inp->inp_vflag &
INP_IPV6) == 0
@@ -186,13 +185,13 @@ protopr(u_long proto, /* for sysctl version we pass proto # */
continue;
if (!aflag &&
(
- (af == AF_INET &&
+ (af1 == AF_INET &&
inet_lnaof(inp->inp_laddr) == INADDR_ANY)
#ifdef INET6
- || (af == AF_INET6 &&
+ || (af1 == AF_INET6 &&
IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr))
#endif /* INET6 */
- || (af == AF_UNSPEC &&
+ || (af1 == AF_UNSPEC &&
(((inp->inp_vflag & INP_IPV4) != 0 &&
inet_lnaof(inp->inp_laddr) == INADDR_ANY)
#ifdef INET6
@@ -244,11 +243,11 @@ protopr(u_long proto, /* for sysctl version we pass proto # */
? "4 " : " ";
printf("%-3.3s%-2.2s ", name, vchar);
if (Lflag) {
- char buf[15];
+ char buf1[15];
- snprintf(buf, 15, "%d/%d/%d", so->so_qlen,
+ snprintf(buf1, 15, "%d/%d/%d", so->so_qlen,
so->so_incqlen, so->so_qlimit);
- printf("%-14.14s ", buf);
+ printf("%-14.14s ", buf1);
} else {
printf("%6u %6u ",
so->so_rcv.sb_cc,
@@ -343,7 +342,7 @@ protopr(u_long proto, /* for sysctl version we pass proto # */
* Dump TCP statistics structure.
*/
void
-tcp_stats(u_long off __unused, char *name, int af __unused)
+tcp_stats(u_long off __unused, const char *name, int af1 __unused)
{
struct tcpstat tcpstat, zerostat;
size_t len = sizeof tcpstat;
@@ -436,21 +435,21 @@ tcp_stats(u_long off __unused, char *name, int af __unused)
p(tcps_predack, "\t%lu correct ACK header prediction%s\n");
p(tcps_preddat, "\t%lu correct data packet header prediction%s\n");
- p(tcps_sc_added, "\t%lu syncache entries added\n");
- p(tcps_sc_retransmitted, "\t\t%lu retransmitted\n");
- p(tcps_sc_dupsyn, "\t\t%lu dupsyn\n");
- p(tcps_sc_dropped, "\t\t%lu dropped\n");
- p(tcps_sc_completed, "\t\t%lu completed\n");
- p(tcps_sc_bucketoverflow, "\t\t%lu bucket overflow\n");
- p(tcps_sc_cacheoverflow, "\t\t%lu cache overflow\n");
- p(tcps_sc_reset, "\t\t%lu reset\n");
- p(tcps_sc_stale, "\t\t%lu stale\n");
- p(tcps_sc_aborted, "\t\t%lu aborted\n");
- p(tcps_sc_badack, "\t\t%lu badack\n");
- p(tcps_sc_unreach, "\t\t%lu unreach\n");
- p(tcps_sc_zonefail, "\t\t%lu zone failures\n");
- p(tcps_sc_sendcookie, "\t%lu cookies sent\n");
- p(tcps_sc_recvcookie, "\t%lu cookies received\n");
+ p(tcps_sc_added, "\t%lu syncache entrie%s added\n");
+ p1a(tcps_sc_retransmitted, "\t\t%lu retransmitted\n");
+ p1a(tcps_sc_dupsyn, "\t\t%lu dupsyn\n");
+ p1a(tcps_sc_dropped, "\t\t%lu dropped\n");
+ p1a(tcps_sc_completed, "\t\t%lu completed\n");
+ p1a(tcps_sc_bucketoverflow, "\t\t%lu bucket overflow\n");
+ p1a(tcps_sc_cacheoverflow, "\t\t%lu cache overflow\n");
+ p1a(tcps_sc_reset, "\t\t%lu reset\n");
+ p1a(tcps_sc_stale, "\t\t%lu stale\n");
+ p1a(tcps_sc_aborted, "\t\t%lu aborted\n");
+ p1a(tcps_sc_badack, "\t\t%lu badack\n");
+ p1a(tcps_sc_unreach, "\t\t%lu unreach\n");
+ p(tcps_sc_zonefail, "\t\t%lu zone failure%s\n");
+ p(tcps_sc_sendcookie, "\t%lu cookie%s sent\n");
+ p(tcps_sc_recvcookie, "\t%lu cookie%s received\n");
#undef p
#undef p1a
#undef p2
@@ -462,7 +461,7 @@ tcp_stats(u_long off __unused, char *name, int af __unused)
* Dump UDP statistics structure.
*/
void
-udp_stats(u_long off __unused, char *name, int af __unused)
+udp_stats(u_long off __unused, const char *name, int af1 __unused)
{
struct udpstat udpstat, zerostat;
size_t len = sizeof udpstat;
@@ -516,7 +515,7 @@ udp_stats(u_long off __unused, char *name, int af __unused)
* Dump IP statistics structure.
*/
void
-ip_stats(u_long off __unused, char *name, int af __unused)
+ip_stats(u_long off __unused, const char *name, int af1 __unused)
{
struct ipstat ipstat, zerostat;
size_t len = sizeof ipstat;
@@ -573,7 +572,7 @@ ip_stats(u_long off __unused, char *name, int af __unused)
#undef p1a
}
-static char *icmpnames[] = {
+static const char *icmpnames[] = {
"echo reply",
"#1",
"#2",
@@ -599,7 +598,7 @@ static char *icmpnames[] = {
* Dump ICMP statistics.
*/
void
-icmp_stats(u_long off __unused, char *name, int af __unused)
+icmp_stats(u_long off __unused, const char *name, int af1 __unused)
{
struct icmpstat icmpstat, zerostat;
int i, first;
@@ -674,7 +673,7 @@ icmp_stats(u_long off __unused, char *name, int af __unused)
* Dump IGMP statistics structure.
*/
void
-igmp_stats(u_long off __unused, char *name, int af __unused)
+igmp_stats(u_long off __unused, const char *name, int af1 __unused)
{
struct igmpstat igmpstat, zerostat;
size_t len = sizeof igmpstat;
@@ -710,7 +709,7 @@ igmp_stats(u_long off __unused, char *name, int af __unused)
* Pretty print an Internet address (net address + port).
*/
void
-inetprint(struct in_addr *in, int port, char *proto, int numeric_port)
+inetprint(struct in_addr *in, int port, const char *proto, int num_port)
{
struct servent *sp = 0;
char line[80], *cp;
@@ -719,9 +718,9 @@ inetprint(struct in_addr *in, int port, char *proto, int numeric_port)
if (Wflag)
sprintf(line, "%s.", inetname(in));
else
- sprintf(line, "%.*s.", (Aflag && !numeric_port) ? 12 : 16, inetname(in));
+ sprintf(line, "%.*s.", (Aflag && !num_port) ? 12 : 16, inetname(in));
cp = index(line, '\0');
- if (!numeric_port && port)
+ if (!num_port && port)
sp = getservbyport((int)port, proto);
if (sp || port == 0)
sprintf(cp, "%.15s ", sp ? sp->s_name : "*");
@@ -742,7 +741,7 @@ inetprint(struct in_addr *in, int port, char *proto, int numeric_port)
char *
inetname(struct in_addr *inp)
{
- register char *cp;
+ char *cp;
static char line[MAXHOSTNAMELEN];
struct hostent *hp;
struct netent *np;
diff --git a/usr.bin/netstat/inet6.c b/usr.bin/netstat/inet6.c
index e6351e9..afff8d6 100644
--- a/usr.bin/netstat/inet6.c
+++ b/usr.bin/netstat/inet6.c
@@ -73,11 +73,10 @@ static char sccsid[] = "@(#)inet6.c 8.4 (Berkeley) 4/20/94";
struct socket sockb;
char *inet6name (struct in6_addr *);
-void inet6print (struct in6_addr *, int, char *, int);
static char ntop_buf[INET6_ADDRSTRLEN];
-static char *ip6nh[] = {
+static const char *ip6nh[] = {
"hop by hop",
"ICMP",
"IGMP",
@@ -340,7 +339,7 @@ static char *ip6nh[] = {
* Dump IP6 statistics structure.
*/
void
-ip6_stats(u_long off __unused, char *name, int af __unused)
+ip6_stats(u_long off __unused, const char *name, int af1 __unused)
{
struct ip6stat ip6stat;
int first, i;
@@ -550,7 +549,7 @@ ip6_ifstats(char *ifname)
#undef p_5
}
-static char *icmp6names[] = {
+static const char *icmp6names[] = {
"#0",
"unreach",
"packet too big",
@@ -813,7 +812,7 @@ static char *icmp6names[] = {
* Dump ICMP6 statistics.
*/
void
-icmp6_stats(u_long off __unused, char *name, int af __unused)
+icmp6_stats(u_long off __unused, const char *name, int af1 __unused)
{
struct icmp6stat icmp6stat;
int i, first;
@@ -963,7 +962,7 @@ icmp6_ifstats(char *ifname)
* Dump PIM statistics structure.
*/
void
-pim6_stats(u_long off __unused, char *name, int af __unused)
+pim6_stats(u_long off __unused, const char *name, int af1 __unused)
{
struct pim6stat pim6stat;
@@ -988,7 +987,7 @@ pim6_stats(u_long off __unused, char *name, int af __unused)
* Dump raw ip6 statistics structure.
*/
void
-rip6_stats(u_long off __unused, char *name, int af __unused)
+rip6_stats(u_long off __unused, const char *name, int af1 __unused)
{
struct rip6stat rip6stat;
u_quad_t delivered;
@@ -1043,7 +1042,7 @@ rip6_stats(u_long off __unused, char *name, int af __unused)
};
void
-inet6print(struct in6_addr *in6, int port, char *proto, int numeric)
+inet6print(struct in6_addr *in6, int port, const char *proto, int numeric)
{
struct servent *sp = 0;
char line[80], *cp;
@@ -1071,7 +1070,7 @@ inet6print(struct in6_addr *in6, int port, char *proto, int numeric)
char *
inet6name(struct in6_addr *in6p)
{
- register char *cp;
+ char *cp;
static char line[50];
struct hostent *hp;
static char domain[MAXHOSTNAMELEN];
diff --git a/usr.bin/netstat/ipsec.c b/usr.bin/netstat/ipsec.c
index 0826da6..e0316aa 100644
--- a/usr.bin/netstat/ipsec.c
+++ b/usr.bin/netstat/ipsec.c
@@ -235,7 +235,7 @@ print_ipsecstats(void)
}
void
-ipsec_stats(u_long off __unused, char *name, int af __unused)
+ipsec_stats(u_long off __unused, const char *name, int af1 __unused)
{
if (off == 0)
return;
@@ -259,7 +259,7 @@ pfkey_msgtype_names(int x)
}
void
-pfkey_stats(u_long off __unused, char *name, int af __unused)
+pfkey_stats(u_long off __unused, const char *name, int af1 __unused)
{
struct pfkeystat pfkeystat;
unsigned first, type;
diff --git a/usr.bin/netstat/ipx.c b/usr.bin/netstat/ipx.c
index f334257..2ab359a 100644
--- a/usr.bin/netstat/ipx.c
+++ b/usr.bin/netstat/ipx.c
@@ -83,10 +83,10 @@ static int first = 1;
*/
void
-ipxprotopr(u_long off, char *name, int af __unused)
+ipxprotopr(u_long off, const char *name, int af1 __unused)
{
struct ipxpcb cb;
- register struct ipxpcb *prev, *next;
+ struct ipxpcb *prev, *next;
int isspx;
if (off == 0)
@@ -159,7 +159,7 @@ ipxprotopr(u_long off, char *name, int af __unused)
* Dump SPX statistics structure.
*/
void
-spx_stats(u_long off, char *name, int af __unused)
+spx_stats(u_long off, const char *name, int af1 __unused)
{
struct spx_istat spx_istat;
#define spxstat spx_istat.newstats
@@ -235,7 +235,7 @@ spx_stats(u_long off, char *name, int af __unused)
* Dump IPX statistics structure.
*/
void
-ipx_stats(u_long off, char *name, int af __unused)
+ipx_stats(u_long off, const char *name, int af1 __unused)
{
struct ipxstat ipxstat;
@@ -278,11 +278,11 @@ static struct {
*/
/*ARGSUSED*/
void
-ipxerr_stats(u_long off, char *name, int af __unused)
+ipxerr_stats(u_long off, const char *name, int af __unused)
{
struct ipx_errstat ipx_errstat;
- register int j;
- register int histoprint = 1;
+ int j;
+ int histoprint = 1;
int z;
if (off == 0)
diff --git a/usr.bin/netstat/iso.c b/usr.bin/netstat/iso.c
index 682aadc..c0de1d1 100644
--- a/usr.bin/netstat/iso.c
+++ b/usr.bin/netstat/iso.c
@@ -115,7 +115,7 @@ extern void inetprint (struct in_addr *, int, char *);
* Dump esis stats
*/
void
-esis_stats(u_long off, char *name, int af __unused)
+esis_stats(u_long off, const char *name, int af __unused)
{
struct esis_stat esis_stat;
@@ -142,7 +142,7 @@ esis_stats(u_long off, char *name, int af __unused)
* Dump clnp statistics structure.
*/
void
-clnp_stats(u_long off, char *name, int af __unused)
+clnp_stats(u_long off, const char *name, int af __unused)
{
struct clnp_stat clnp_stat;
@@ -175,7 +175,7 @@ clnp_stats(u_long off, char *name, int af __unused)
* Dump CLTP statistics structure.
*/
void
-cltp_stats(u_long off, char *name, int af __unused)
+cltp_stats(u_long off, const char *name, int af __unused)
{
struct cltpstat cltpstat;
@@ -209,10 +209,10 @@ static int first = 1;
* -a (all) flag is specified.
*/
void
-iso_protopr(u_long off, char *name, int af __unused)
+iso_protopr(u_long off, const char *name, int af __unused)
{
struct isopcb cb;
- register struct isopcb *prev, *next;
+ struct isopcb *prev, *next;
if (off == 0) {
printf("%s control block: symbol not in namelist\n", name);
@@ -293,7 +293,7 @@ iso_protopr1(u_long kern_addr, int istp)
}
void
-tp_protopr(u_long off, char *name, int af __unused)
+tp_protopr(u_long off, const char *name, int af __unused)
{
extern char *tp_sstring[];
struct tp_ref *tpr, *tpr_base;
@@ -444,7 +444,7 @@ isonetprint(struct iso_addr *iso, char *sufx, u_short sufxlen, int islocal)
#ifdef notdef
static void
-x25_protopr(u_long off, char *name, int af __unused)
+x25_protopr(u_long off, const char *name, int af __unused)
{
static char *xpcb_states[] = {
"CLOSED",
@@ -454,7 +454,7 @@ x25_protopr(u_long off, char *name, int af __unused)
"ACKWAIT",
"OPEN",
};
- register struct isopcb *prev, *next;
+ struct isopcb *prev, *next;
struct x25_pcb xpcb;
if (off == 0) {
@@ -606,7 +606,7 @@ tprintstat(struct tp_stat *s, int indent)
fprintf(OUT,
"\t%*sM:L ( M mbuf chains of length L)\n", indent, " ");
{
- register int j;
+ int j;
fprintf(OUT, "\t%*s%d: over 16\n", indent, " ",
s->ts_mb_len_distr[0]);
@@ -647,7 +647,7 @@ tprintstat(struct tp_stat *s, int indent)
"\t%*s%d tp 0 connection%s\n", indent, " ",
s->ts_tp0_conn ,plural(s->ts_tp0_conn));
{
- register int j;
+ int j;
static char *name[]= {
"~LOCAL, PDN",
"~LOCAL,~PDN",
@@ -794,9 +794,9 @@ static char hexlist[] = "0123456789abcdef", obuf[128];
static void
hexprint(int n, char *buf, char *delim)
{
- register u_char *in = (u_char *)buf, *top = in + n;
- register char *out = obuf;
- register int i;
+ u_char *in = (u_char *)buf, *top = in + n;
+ char *out = obuf;
+ int i;
if (n == 0)
return;
diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c
index a4dce63..6af1ac7 100644
--- a/usr.bin/netstat/main.c
+++ b/usr.bin/netstat/main.c
@@ -172,13 +172,13 @@ struct protox {
u_char pr_index; /* index into nlist of cb head */
u_char pr_sindex; /* index into nlist of stat block */
u_char pr_wanted; /* 1 if wanted, 0 otherwise */
- void (*pr_cblocks)(u_long, char *, int);
+ void (*pr_cblocks)(u_long, const char *, int);
/* control blocks printing routine */
- void (*pr_stats)(u_long, char *, int);
+ void (*pr_stats)(u_long, const char *, int);
/* statistics printing routine */
void (*pr_istats)(char *); /* per/if statistics printing routine */
const char *pr_name; /* well-known name */
- int pr_usesysctl; /* true if we use sysctl, not kvm */
+ u_long pr_usesysctl; /* true if we use sysctl, not kvm */
} protox[] = {
{ -1, -1, 1, protopr,
tcp_stats, NULL, "tcp", IPPROTO_TCP },
@@ -199,7 +199,7 @@ struct protox {
{ -1, -1, 1, 0,
bdg_stats, NULL, "bdg", 1 /* bridging... */ },
{ -1, -1, 0, 0,
- 0, NULL, 0 }
+ 0, NULL, 0, 0 }
};
#ifdef INET6
@@ -240,18 +240,18 @@ struct protox pfkeyprotox[] = {
struct protox atalkprotox[] = {
{ N_DDPCB, N_DDPSTAT, 1, atalkprotopr,
- ddp_stats, NULL, "ddp" },
+ ddp_stats, NULL, "ddp", 0 },
{ -1, -1, 0, 0,
- 0, NULL, 0 }
+ 0, NULL, 0, 0 }
};
struct protox netgraphprotox[] = {
{ N_NGSOCKS, -1, 1, netgraphprotopr,
- NULL, NULL, "ctrl" },
+ NULL, NULL, "ctrl", 0 },
{ N_NGSOCKS, -1, 1, netgraphprotopr,
- NULL, NULL, "data" },
+ NULL, NULL, "data", 0 },
{ -1, NULL, 0, 0,
- 0, NULL, 0 }
+ 0, NULL, 0, 0 }
};
struct protox ipxprotox[] = {
@@ -341,11 +341,9 @@ int unit; /* unit number for above */
int af; /* address family */
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
- register struct protox *tp = NULL; /* for printing cblocks & stats */
+ struct protox *tp = NULL; /* for printing cblocks & stats */
int ch;
af = AF_UNSPEC;
@@ -611,10 +609,10 @@ main(argc, argv)
*/
static void
printproto(tp, name)
- register struct protox *tp;
+ struct protox *tp;
const char *name;
{
- void (*pr)(u_long, char *, int);
+ void (*pr)(u_long, const char *, int);
u_long off;
if (sflag) {
@@ -693,13 +691,13 @@ kread(u_long addr, char *buf, int size)
return (0);
}
-char *
+const char *
plural(int n)
{
return (n != 1 ? "s" : "");
}
-char *
+const char *
plurales(int n)
{
return (n != 1 ? "es" : "");
diff --git a/usr.bin/netstat/mbuf.c b/usr.bin/netstat/mbuf.c
index 0c1fdd4..5193071 100644
--- a/usr.bin/netstat/mbuf.c
+++ b/usr.bin/netstat/mbuf.c
@@ -56,7 +56,7 @@ typedef int bool;
static struct mbtypenames {
short mt_type;
- char *mt_name;
+ const char *mt_name;
} mbtypenames[] = {
{ MT_DATA, "data" },
{ MT_OOBDATA, "oob data" },
@@ -95,9 +95,9 @@ static struct mbtypenames {
* Print mbuf statistics.
*/
void
-mbpr(u_long mbaddr, u_long mbtaddr, u_long nmbcaddr, u_long nmbufaddr,
- u_long mblimaddr, u_long cllimaddr, u_long cpusaddr, u_long pgsaddr,
- u_long mbpaddr)
+mbpr(u_long mbaddr, u_long mbtaddr __unused, u_long nmbcaddr, u_long nmbufaddr,
+ u_long mblimaddr, u_long cllimaddr, u_long cpusaddr __unused,
+ u_long pgsaddr, u_long mbpaddr)
{
int i, j, nmbufs, nmbclusters, page_size, num_objs;
u_int mbuf_limit, clust_limit;
diff --git a/usr.bin/netstat/mroute.c b/usr.bin/netstat/mroute.c
index 78e64f2..3c42f45 100644
--- a/usr.bin/netstat/mroute.c
+++ b/usr.bin/netstat/mroute.c
@@ -74,11 +74,11 @@ mroutepr(u_long mfcaddr, u_long vifaddr)
struct mfc *mfctable[MFCTBLSIZ];
struct vif viftable[MAXVIFS];
struct mfc mfc, *m;
- register struct vif *v;
- register vifi_t vifi;
- register int i;
- register int banner_printed;
- register int saved_numeric_addr;
+ struct vif *v;
+ vifi_t vifi;
+ int i;
+ int banner_printed;
+ int saved_numeric_addr;
vifi_t maxvif = 0;
if (mfcaddr == 0 || vifaddr == 0) {
diff --git a/usr.bin/netstat/mroute6.c b/usr.bin/netstat/mroute6.c
index 342a689..4dbaca5 100644
--- a/usr.bin/netstat/mroute6.c
+++ b/usr.bin/netstat/mroute6.c
@@ -98,11 +98,11 @@ mroute6pr(u_long mfcaddr, u_long mifaddr)
struct mif6 mif6table[MAXMIFS];
struct mf6c mfc;
struct rtdetq rte, *rtep;
- register struct mif6 *mifp;
- register mifi_t mifi;
- register int i;
- register int banner_printed;
- register int saved_numeric_addr;
+ struct mif6 *mifp;
+ mifi_t mifi;
+ int i;
+ int banner_printed;
+ int saved_numeric_addr;
mifi_t maxmif = 0;
long int waitings;
diff --git a/usr.bin/netstat/netgraph.c b/usr.bin/netstat/netgraph.c
index e536063..845a7cc 100644
--- a/usr.bin/netstat/netgraph.c
+++ b/usr.bin/netstat/netgraph.c
@@ -65,7 +65,7 @@ static int first = 1;
static int csock = -1;
void
-netgraphprotopr(u_long off, char *name, int af __unused)
+netgraphprotopr(u_long off, const char *name, int af1 __unused)
{
struct ngpcb *this, *next;
struct ngpcb ngpcb;
diff --git a/usr.bin/netstat/netstat.h b/usr.bin/netstat/netstat.h
index eca68c0..ecadd0e 100644
--- a/usr.bin/netstat/netstat.h
+++ b/usr.bin/netstat/netstat.h
@@ -60,40 +60,41 @@ extern int unit; /* unit number for above */
extern int af; /* address family */
int kread (u_long addr, char *buf, int size);
-char *plural (int);
-char *plurales (int);
-
-void protopr (u_long, char *, int);
-void tcp_stats (u_long, char *, int);
-void udp_stats (u_long, char *, int);
-void ip_stats (u_long, char *, int);
-void icmp_stats (u_long, char *, int);
-void igmp_stats (u_long, char *, int);
+const char *plural (int);
+const char *plurales (int);
+
+void protopr (u_long, const char *, int);
+void tcp_stats (u_long, const char *, int);
+void udp_stats (u_long, const char *, int);
+void ip_stats (u_long, const char *, int);
+void icmp_stats (u_long, const char *, int);
+void igmp_stats (u_long, const char *, int);
#ifdef IPSEC
-void ipsec_stats (u_long, char *, int);
+void ipsec_stats (u_long, const char *, int);
#endif
#ifdef INET6
-void ip6_stats (u_long, char *, int);
+void ip6_stats (u_long, const char *, int);
void ip6_ifstats (char *);
-void icmp6_stats (u_long, char *, int);
+void icmp6_stats (u_long, const char *, int);
void icmp6_ifstats (char *);
-void pim6_stats (u_long, char *, int);
-void rip6_stats (u_long, char *, int);
+void pim6_stats (u_long, const char *, int);
+void rip6_stats (u_long, const char *, int);
void mroute6pr (u_long, u_long);
void mrt6_stats (u_long);
struct sockaddr_in6;
struct in6_addr;
char *routename6 (struct sockaddr_in6 *);
-char *netname6 (struct sockaddr_in6 *, struct in6_addr *);
+const char *netname6 (struct sockaddr_in6 *, struct in6_addr *);
+void inet6print (struct in6_addr *, int, const char *, int);
#endif /*INET6*/
#ifdef IPSEC
-void pfkey_stats (u_long, char *, int);
+void pfkey_stats (u_long, const char *, int);
#endif
-void bdg_stats (u_long, char *, int);
+void bdg_stats (u_long, const char *, int);
void mbpr (u_long, u_long, u_long, u_long, u_long, u_long,
u_long, u_long, u_long);
@@ -119,29 +120,29 @@ char *ipx_print (struct sockaddr *);
char *ns_print (struct sockaddr *);
void routepr (u_long);
-void ipxprotopr (u_long, char *, int);
-void spx_stats (u_long, char *, int);
-void ipx_stats (u_long, char *, int);
-void ipxerr_stats (u_long, char *, int);
+void ipxprotopr (u_long, const char *, int);
+void spx_stats (u_long, const char *, int);
+void ipx_stats (u_long, const char *, int);
+void ipxerr_stats (u_long, const char *, int);
-void nsprotopr (u_long, char *, int);
-void spp_stats (u_long, char *, int);
-void idp_stats (u_long, char *, int);
-void nserr_stats (u_long, char *, int);
+void nsprotopr (u_long, const char *, int);
+void spp_stats (u_long, const char *, int);
+void idp_stats (u_long, const char *, int);
+void nserr_stats (u_long, const char *, int);
-void atalkprotopr (u_long, char *, int);
-void ddp_stats (u_long, char *, int);
+void atalkprotopr (u_long, const char *, int);
+void ddp_stats (u_long, const char *, int);
-void netgraphprotopr (u_long, char *, int);
+void netgraphprotopr (u_long, const char *, int);
void unixpr (void);
-void esis_stats (u_long, char *, int);
-void clnp_stats (u_long, char *, int);
-void cltp_stats (u_long, char *, int);
-void iso_protopr (u_long, char *, int);
+void esis_stats (u_long, const char *, int);
+void clnp_stats (u_long, const char *, int);
+void cltp_stats (u_long, const char *, int);
+void iso_protopr (u_long, const char *, int);
void iso_protopr1 (u_long, int);
-void tp_protopr (u_long, char *, int);
+void tp_protopr (u_long, const char *, int);
void tp_inproto (u_long);
void tp_stats (caddr_t, caddr_t);
diff --git a/usr.bin/netstat/ns.c b/usr.bin/netstat/ns.c
index 4a9944a..ff235a2 100644
--- a/usr.bin/netstat/ns.c
+++ b/usr.bin/netstat/ns.c
@@ -85,10 +85,10 @@ static int first = 1;
*/
void
-nsprotopr(u_long off, char *name, int af __unused)
+nsprotopr(u_long off, const char *name, int af __unused)
{
struct nspcb cb;
- register struct nspcb *prev, *next;
+ struct nspcb *prev, *next;
int isspp;
if (off == 0)
@@ -158,7 +158,7 @@ nsprotopr(u_long off, char *name, int af __unused)
* Dump SPP statistics structure.
*/
void
-spp_stats(u_long off, char *name, int af __unused)
+spp_stats(u_long off, const char *name, int af __unused)
{
struct spp_istat spp_istat;
#define sppstat spp_istat.newstats
@@ -234,7 +234,7 @@ spp_stats(u_long off, char *name, int af __unused)
* Dump IDP statistics structure.
*/
void
-idp_stats(u_long off, char *name, int af __unused)
+idp_stats(u_long off, const char *name, int af __unused)
{
struct idpstat idpstat;
@@ -268,11 +268,11 @@ static struct {
*/
/*ARGSUSED*/
void
-nserr_stats(u_long off, char *name, int af __unused)
+nserr_stats(u_long off, const char *name, int af __unused)
{
struct ns_errstat ns_errstat;
- register int j;
- register int histoprint = 1;
+ int j;
+ int histoprint = 1;
int z;
if (off == 0)
diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c
index 9beb7fb..fecdabe 100644
--- a/usr.bin/netstat/route.c
+++ b/usr.bin/netstat/route.c
@@ -106,7 +106,7 @@ struct bits {
{ RTF_PROTO3, '3' },
{ RTF_BLACKHOLE,'B' },
{ RTF_BROADCAST,'b' },
- { 0 }
+ { 0 , 0 }
};
typedef union {
@@ -136,7 +136,7 @@ static void np_rtentry (struct rt_msghdr *);
static void p_sockaddr (struct sockaddr *, struct sockaddr *, int, int);
static const char *fmt_sockaddr (struct sockaddr *sa, struct sockaddr *mask,
int flags);
-static void p_flags (int, char *);
+static void p_flags (int, const char *);
static const char *fmt_flags(int f);
static void p_rtentry (struct rtentry *);
static u_long forgemask (u_long);
@@ -186,11 +186,11 @@ routepr(u_long rtree)
* Print address family header before a section of the routing table.
*/
void
-pr_family(int af)
+pr_family(int af1)
{
- char *afname;
+ const char *afname;
- switch (af) {
+ switch (af1) {
case AF_INET:
afname = "Internet";
break;
@@ -226,7 +226,7 @@ pr_family(int af)
if (afname)
printf("\n%s:\n", afname);
else
- printf("\nProtocol Family %d:\n", af);
+ printf("\nProtocol Family %d:\n", af1);
}
/* column widths; each followed by one space */
@@ -363,12 +363,12 @@ size_cols_rtentry(struct rtentry *rt)
* Print header for routing table columns.
*/
void
-pr_rthdr(int af)
+pr_rthdr(int af1)
{
if (Aflag)
printf("%-8.8s ","Address");
- if (af == AF_INET || Wflag) {
+ if (af1 == AF_INET || Wflag) {
if (Wflag) {
printf("%-*.*s %-*.*s %-*.*s %*.*s %*.*s %*.*s %*.*s %*s\n",
wid_dst, wid_dst, "Destination",
@@ -490,7 +490,7 @@ ntreestuff(void)
size_t needed;
int mib[6];
char *buf, *next, *lim;
- register struct rt_msghdr *rtm;
+ struct rt_msghdr *rtm;
mib[0] = CTL_NET;
mib[1] = PF_ROUTE;
@@ -518,12 +518,12 @@ ntreestuff(void)
static void
np_rtentry(struct rt_msghdr *rtm)
{
- register struct sockaddr *sa = (struct sockaddr *)(rtm + 1);
+ struct sockaddr *sa = (struct sockaddr *)(rtm + 1);
#ifdef notdef
static int masks_done, banner_printed;
#endif
static int old_af;
- int af = 0, interesting = RTF_UP | RTF_GATEWAY | RTF_HOST;
+ int af1 = 0, interesting = RTF_UP | RTF_GATEWAY | RTF_HOST;
#ifdef notdef
/* for the moment, netmasks are skipped over */
@@ -534,14 +534,14 @@ np_rtentry(struct rt_msghdr *rtm)
if (masks_done == 0) {
if (rtm->rtm_addrs != RTA_DST ) {
masks_done = 1;
- af = sa->sa_family;
+ af1 = sa->sa_family;
}
} else
#endif
- af = sa->sa_family;
- if (af != old_af) {
- pr_family(af);
- old_af = af;
+ af1 = sa->sa_family;
+ if (af1 != old_af) {
+ pr_family(af1);
+ old_af = af1;
}
if (rtm->rtm_addrs == RTA_DST)
p_sockaddr(sa, NULL, 0, 36);
@@ -575,13 +575,12 @@ static const char *
fmt_sockaddr(struct sockaddr *sa, struct sockaddr *mask, int flags)
{
static char workbuf[128];
- char *cplim;
- char *cp = workbuf;
+ const char *cp;
switch(sa->sa_family) {
case AF_INET:
{
- register struct sockaddr_in *sin = (struct sockaddr_in *)sa;
+ struct sockaddr_in *sin = (struct sockaddr_in *)sa;
if ((sin->sin_addr.s_addr == INADDR_ANY) &&
mask &&
@@ -658,12 +657,13 @@ fmt_sockaddr(struct sockaddr *sa, struct sockaddr *mask, int flags)
case AF_LINK:
{
- register struct sockaddr_dl *sdl = (struct sockaddr_dl *)sa;
+ struct sockaddr_dl *sdl = (struct sockaddr_dl *)sa;
if (sdl->sdl_nlen == 0 && sdl->sdl_alen == 0 &&
- sdl->sdl_slen == 0)
+ sdl->sdl_slen == 0) {
(void) sprintf(workbuf, "link#%d", sdl->sdl_index);
- else
+ cp = workbuf;
+ } else
switch (sdl->sdl_type) {
case IFT_ETHER:
@@ -682,15 +682,17 @@ fmt_sockaddr(struct sockaddr *sa, struct sockaddr *mask, int flags)
default:
{
- register u_char *s = (u_char *)sa->sa_data, *slim;
+ u_char *s = (u_char *)sa->sa_data, *slim;
+ char *cq, *cqlim;
+ cq = workbuf;
slim = sa->sa_len + (u_char *) sa;
- cplim = cp + sizeof(workbuf) - 6;
- cp += sprintf(cp, "(%d)", sa->sa_family);
- while (s < slim && cp < cplim) {
- cp += sprintf(cp, " %02x", *s++);
+ cqlim = cq + sizeof(workbuf) - 6;
+ cq += sprintf(cq, "(%d)", sa->sa_family);
+ while (s < slim && cq < cqlim) {
+ cq += sprintf(cq, " %02x", *s++);
if (s < slim)
- cp += sprintf(cp, "%02x", *s++);
+ cq += sprintf(cq, "%02x", *s++);
}
cp = workbuf;
}
@@ -700,7 +702,7 @@ fmt_sockaddr(struct sockaddr *sa, struct sockaddr *mask, int flags)
}
static void
-p_flags(int f, char *format)
+p_flags(int f, const char *format)
{
printf(format, fmt_flags(f));
}
@@ -783,7 +785,7 @@ p_rtentry(struct rtentry *rt)
char *
routename(u_long in)
{
- register char *cp;
+ char *cp;
static char line[MAXHOSTNAMELEN];
struct hostent *hp;
@@ -825,7 +827,7 @@ forgemask(u_long a)
static void
domask(char *dst, u_long addr, u_long mask)
{
- register int b, i;
+ int b, i;
if (!mask || (forgemask(addr) == mask)) {
*dst = '\0';
@@ -834,7 +836,7 @@ domask(char *dst, u_long addr, u_long mask)
i = 0;
for (b = 0; b < 32; b++)
if (mask & (1 << b)) {
- register int bb;
+ int bb;
i = b;
for (bb = b+1; bb < 32; bb++)
@@ -861,7 +863,7 @@ netname(u_long in, u_long mask)
static char line[MAXHOSTNAMELEN];
struct netent *np = 0;
u_long dmask;
- register u_long i;
+ u_long i;
#define NSHIFT(m) ( \
(m) == IN_CLASSA_NET ? IN_CLASSA_NSHIFT : \
@@ -917,7 +919,7 @@ netname(u_long in, u_long mask)
}
#ifdef INET6
-char *
+const char *
netname6(struct sockaddr_in6 *sa6, struct in6_addr *mask)
{
static char line[MAXHOSTNAMELEN];
@@ -1041,9 +1043,9 @@ ipx_print(struct sockaddr *sa)
{
u_short port;
struct servent *sp = 0;
- char *net = "", *host = "";
- register char *p;
- register u_char *q;
+ const char *net = "", *host = "";
+ char *p;
+ u_char *q;
struct ipx_addr work = ((struct sockaddr_ipx *)sa)->sipx_addr;
static char mybuf[50];
char cport[10], chost[15], cnet[15];
@@ -1108,7 +1110,7 @@ ipx_print(struct sockaddr *sa)
char *
ipx_phost(struct sockaddr *sa)
{
- register struct sockaddr_ipx *sipx = (struct sockaddr_ipx *)sa;
+ struct sockaddr_ipx *sipx = (struct sockaddr_ipx *)sa;
struct sockaddr_ipx work;
static union ipx_net ipx_zeronet;
char *p;
@@ -1132,13 +1134,13 @@ short ns_bh[] = {-1,-1,-1};
char *
ns_print(struct sockaddr *sa)
{
- register struct sockaddr_ns *sns = (struct sockaddr_ns*)sa;
+ struct sockaddr_ns *sns = (struct sockaddr_ns*)sa;
struct ns_addr work;
union { union ns_net net_e; u_long long_e; } net;
u_short port;
static char mybuf[50], cport[10], chost[25];
char *host = "";
- register char *p; register u_char *q;
+ char *p; u_char *q;
work = sns->sns_addr;
port = ntohs(work.x_port);
@@ -1178,7 +1180,7 @@ ns_print(struct sockaddr *sa)
char *
ns_phost(struct sockaddr *sa)
{
- register struct sockaddr_ns *sns = (struct sockaddr_ns *)sa;
+ struct sockaddr_ns *sns = (struct sockaddr_ns *)sa;
struct sockaddr_ns work;
static union ns_net ns_zeronet;
char *p;
@@ -1197,7 +1199,7 @@ ns_phost(struct sockaddr *sa)
void
upHex(char *p0)
{
- register char *p = p0;
+ char *p = p0;
for (; *p; p++)
switch (*p) {
OpenPOWER on IntegriCloud