Deleted Added
full compact
45c45
< "$FreeBSD: head/usr.bin/netstat/main.c 52419 1999-10-21 09:06:11Z julian $";
---
> "$FreeBSD: head/usr.bin/netstat/main.c 54263 1999-12-07 17:39:16Z shin $";
127a128,147
> #define N_IP6STAT 28
> { "_ip6stat" },
> #define N_ICMP6STAT 29
> { "_icmp6stat" },
> #ifdef notyet
> #define N_IPSECSTAT 30
> { "_ipsecstat" },
> #define N_IPSEC6STAT 31
> { "_ipsec6stat" },
> #define N_PIM6STAT 32
> { "_pim6stat" },
> #define N_MRT6PROTO 33
> { "_ip6_mrtproto" },
> #define N_MRT6STAT 34
> { "_mrt6stat" },
> #define N_MF6CTABLE 35
> { "_mf6ctable" },
> #define N_MIF6TABLE 36
> { "_mif6table" },
> #endif
136a157
> void (*pr_istats)(); /* per/if statistics printing routine */
141c162
< tcp_stats, "tcp", IPPROTO_TCP },
---
> tcp_stats, NULL, "tcp", IPPROTO_TCP },
143c164
< udp_stats, "udp", IPPROTO_UDP },
---
> udp_stats, NULL, "udp", IPPROTO_UDP },
145c166
< NULL, "divert", IPPROTO_DIVERT },
---
> NULL, NULL, "divert",IPPROTO_DIVERT },
147c168
< ip_stats, "ip", IPPROTO_RAW },
---
> ip_stats, NULL, "ip", IPPROTO_RAW },
149c170
< icmp_stats, "icmp", IPPROTO_ICMP },
---
> icmp_stats, NULL, "icmp", IPPROTO_ICMP },
151c172,176
< igmp_stats, "igmp", IPPROTO_IGMP },
---
> igmp_stats, NULL, "igmp", IPPROTO_IGMP },
> #ifdef IPSEC
> { -1, N_IPSECSTAT, 1, 0,
> ipsec_stats, NULL, "ipsec", 0},
> #endif
153c178
< bdg_stats, "bdg", 1 /* bridging... */ },
---
> bdg_stats, NULL, "bdg", 1 /* bridging... */ },
155c180
< 0, 0 }
---
> 0, NULL, 0 }
157a183,207
> #ifdef INET6
> struct protox ip6protox[] = {
> { -1, -1, 1, protopr,
> tcp_stats, NULL, "tcp", IPPROTO_TCP },
> { -1, -1, 1, protopr,
> udp_stats, NULL, "udp", IPPROTO_UDP },
> { -1, N_IP6STAT, 1, 0,
> ip6_stats, ip6_ifstats, "ip6", 0 },
> { -1, N_ICMP6STAT, 1, 0,
> icmp6_stats, icmp6_ifstats, "icmp6",0 },
> #ifdef IPSEC
> { -1, N_IPSEC6STAT, 1, 0,
> ipsec_stats, NULL, "ipsec6",0 },
> #endif
> #ifdef notyet
> { -1, N_PIM6STAT, 1, 0,
> pim6_stats, NULL, "pim6", 0 },
> #endif
> { -1, -1, 1, protopr,
> bdg_stats, NULL, "bdg", 1 /* bridging... */ },
> { -1, -1, 0, 0,
> 0, NULL, 0, 0 }
> };
> #endif /*INET6*/
>
160c210
< ddp_stats, "ddp" },
---
> ddp_stats, NULL, "ddp" },
162c212
< 0, 0 }
---
> 0, NULL, 0 }
167c217
< NULL, "ctrl" },
---
> NULL, NULL, "ctrl" },
169,171c219,221
< NULL, "data" },
< { -1, -1, 0, 0,
< 0, 0 }
---
> NULL, NULL, "data" },
> { -1, NULL, 0, 0,
> 0, NULL, 0 }
176c226
< ipx_stats, "ipx", 0 },
---
> ipx_stats, NULL, "ipx", 0 },
178c228
< spx_stats, "spx", 0 },
---
> spx_stats, NULL, "spx", 0 },
180c230
< 0, 0, 0 }
---
> 0, NULL, 0, 0 }
186c236
< idp_stats, "idp" },
---
> idp_stats, NULL, "idp" },
188c238
< spp_stats, "spp" },
---
> spp_stats, NULL, "spp" },
190c240
< nserr_stats, "ns_err" },
---
> nserr_stats, NULL, "ns_err" },
192c242
< 0, 0 }
---
> 0, NULL, 0 }
199c249
< tp_stats, "tp" },
---
> tp_stats, NULL, "tp" },
201c251
< cltp_stats, "cltp" },
---
> cltp_stats, NULL, "cltp" },
203c253
< clnp_stats, "clnp"},
---
> clnp_stats, NULL, "clnp"},
205c255
< esis_stats, "esis"},
---
> esis_stats, NULL, "esis"},
207c257
< 0, 0 }
---
> 0, NULL, 0 }
211c261,266
< struct protox *protoprotox[] = { protox, ipxprotox, atalkprotox,
---
> struct protox *protoprotox[] = {
> protox,
> #ifdef INET6
> ip6protox,
> #endif
> ipxprotox, atalkprotox,
233d287
< register struct protoent *p;
239c293
< while ((ch = getopt(argc, argv, "Aabdf:ghI:iM:mN:np:rstuw:")) != -1)
---
> while ((ch = getopt(argc, argv, "Aabdf:ghI:liM:mN:np:rstuw:")) != -1)
262a317,320
> #ifdef INET6
> else if (strcmp(optarg, "inet6") == 0)
> af = AF_INET6;
> #endif /*INET6*/
292a351,353
> case 'l':
> lflag = 1;
> break;
365a427,431
> if (iflag && tp->pr_istats) {
> kread(0, 0, 0);
> intpr(interval, nl[N_IFNET].n_value, tp->pr_istats);
> exit(0);
> }
393a460,462
> if (af != AF_UNSPEC)
> goto protostat;
>
395c464
< intpr(interval, nl[N_IFNET].n_value);
---
> intpr(interval, nl[N_IFNET].n_value, NULL);
408,412c477,497
< if (sflag)
< mrt_stats(nl[N_MRTSTAT].n_value);
< else
< mroutepr(nl[N_MFCTABLE].n_value,
< nl[N_VIFTABLE].n_value);
---
> if (sflag) {
> if (af == AF_INET || af == AF_UNSPEC)
> mrt_stats(nl[N_MRTSTAT].n_value);
> #ifdef INET6
> #ifdef notyet
> if (af == AF_INET6 || af == AF_UNSPEC)
> mrt6_stats(nl[N_MRT6STAT].n_value);
> #endif
> #endif
> } else {
> if (af == AF_INET || af == AF_UNSPEC)
> mroutepr(nl[N_MFCTABLE].n_value,
> nl[N_VIFTABLE].n_value);
> #ifdef INET6
> #ifdef notyet
> if (af == AF_INET6 || af == AF_UNSPEC)
> mroute6pr(nl[N_MF6CTABLE].n_value,
> nl[N_MIF6TABLE].n_value);
> #endif
> #endif
> }
415,428c500,510
< if (af == AF_INET || af == AF_UNSPEC) {
< setprotoent(1);
< setservent(1);
< /* ugh, this is O(MN) ... why do we do this? */
< while ((p = getprotoent())) {
< for (tp = protox; tp->pr_name; tp++)
< if (strcmp(tp->pr_name, p->p_name) == 0)
< break;
< if (tp->pr_name == 0 || tp->pr_wanted == 0)
< continue;
< printproto(tp, p->p_name);
< }
< endprotoent();
< }
---
>
> protostat:
> kread(0, 0, 0);
> if (af == AF_INET || af == AF_UNSPEC)
> for (tp = protox; tp->pr_name; tp++)
> printproto(tp, tp->pr_name);
> #ifdef INET6
> if (af == AF_INET6 || af == AF_UNSPEC)
> for (tp = ip6protox; tp->pr_name; tp++)
> printproto(tp, tp->pr_name);
> #endif /*INET6*/
469,471c551,561
< pr = tp->pr_stats;
< off = tp->pr_usesysctl ? tp->pr_usesysctl
< : nl[tp->pr_sindex].n_value;
---
> if (iflag) {
> if (tp->pr_istats)
> intpr(interval, nl[N_IFNET].n_value,
> tp->pr_istats);
> return;
> }
> else {
> pr = tp->pr_stats;
> off = tp->pr_usesysctl ? tp->pr_usesysctl
> : nl[tp->pr_sindex].n_value;
> }
478c568
< (*pr)(off, name);
---
> (*pr)(off, name, af);
569c659
< if ((tp = knownname(name)))
---
> if ((tp = knownname(name)) != NULL)
573c663
< while ((p = getprotoent())) {
---
> while ((p = getprotoent()) != NULL) {