Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/netstat/main.c
Show First 20 Lines • Show All 208 Lines • ▼ Show 20 Lines | |||||
int gflag; /* show group (multicast) routing or stats */ | int gflag; /* show group (multicast) routing or stats */ | ||||
int hflag; /* show counters in human readable format */ | int hflag; /* show counters in human readable format */ | ||||
int iflag; /* show interfaces */ | int iflag; /* show interfaces */ | ||||
int Lflag; /* show size of listen queues */ | int Lflag; /* show size of listen queues */ | ||||
int mflag; /* show memory stats */ | int mflag; /* show memory stats */ | ||||
int noutputs = 0; /* how much outputs before we exit */ | int noutputs = 0; /* how much outputs before we exit */ | ||||
int numeric_addr; /* show addresses numerically */ | int numeric_addr; /* show addresses numerically */ | ||||
int numeric_port; /* show ports numerically */ | int numeric_port; /* show ports numerically */ | ||||
int oflag; /* show nexthop objects*/ | |||||
int Pflag; /* show TCP log ID */ | int Pflag; /* show TCP log ID */ | ||||
static int pflag; /* show given protocol */ | static int pflag; /* show given protocol */ | ||||
static int Qflag; /* show netisr information */ | static int Qflag; /* show netisr information */ | ||||
int rflag; /* show routing tables (or routing stats) */ | int rflag; /* show routing tables (or routing stats) */ | ||||
int Rflag; /* show flow / RSS statistics */ | int Rflag; /* show flow / RSS statistics */ | ||||
int sflag; /* show protocol statistics */ | int sflag; /* show protocol statistics */ | ||||
int Wflag; /* wide display */ | int Wflag; /* wide display */ | ||||
int Tflag; /* TCP Information */ | int Tflag; /* TCP Information */ | ||||
Show All 18 Lines | main(int argc, char *argv[]) | ||||
bool first = true; | bool first = true; | ||||
af = AF_UNSPEC; | af = AF_UNSPEC; | ||||
argc = xo_parse_args(argc, argv); | argc = xo_parse_args(argc, argv); | ||||
if (argc < 0) | if (argc < 0) | ||||
exit(EXIT_FAILURE); | exit(EXIT_FAILURE); | ||||
while ((ch = getopt(argc, argv, "46AaBbdF:f:ghI:iLlM:mN:nPp:Qq:RrSTsuWw:xz")) | while ((ch = getopt(argc, argv, "46AaBbdF:f:ghI:iLlM:mN:noPp:Qq:RrSTsuWw:xz")) | ||||
!= -1) | != -1) | ||||
switch(ch) { | switch(ch) { | ||||
case '4': | case '4': | ||||
#ifdef INET | #ifdef INET | ||||
af = AF_INET; | af = AF_INET; | ||||
#else | #else | ||||
errx(1, "IPv4 support is not compiled in"); | errx(1, "IPv4 support is not compiled in"); | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | case 'm': | ||||
mflag = 1; | mflag = 1; | ||||
break; | break; | ||||
case 'N': | case 'N': | ||||
nlistf = optarg; | nlistf = optarg; | ||||
break; | break; | ||||
case 'n': | case 'n': | ||||
numeric_addr = numeric_port = 1; | numeric_addr = numeric_port = 1; | ||||
break; | break; | ||||
case 'o': | |||||
oflag = 1; | |||||
break; | |||||
case 'P': | case 'P': | ||||
Pflag = 1; | Pflag = 1; | ||||
break; | break; | ||||
case 'p': | case 'p': | ||||
if ((tp = name2protox(optarg)) == NULL) { | if ((tp = name2protox(optarg)) == NULL) { | ||||
xo_errx(1, "%s: unknown or uninstrumented " | xo_errx(1, "%s: unknown or uninstrumented " | ||||
"protocol", optarg); | "protocol", optarg); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | if (sflag) { | ||||
} | } | ||||
rt_stats(); | rt_stats(); | ||||
} else | } else | ||||
routepr(fib, af); | routepr(fib, af); | ||||
xo_close_container("statistics"); | xo_close_container("statistics"); | ||||
xo_finish(); | xo_finish(); | ||||
exit(0); | exit(0); | ||||
} | } | ||||
if (oflag) { | |||||
xo_open_container("statistics"); | |||||
nhops_print(fib, af); | |||||
//nhgrp_print(fib, af); | |||||
xo_close_container("statistics"); | |||||
xo_finish(); | |||||
exit(0); | |||||
} | |||||
if (gflag) { | if (gflag) { | ||||
xo_open_container("statistics"); | xo_open_container("statistics"); | ||||
if (sflag) { | if (sflag) { | ||||
if (af == AF_INET || af == AF_UNSPEC) | if (af == AF_INET || af == AF_UNSPEC) | ||||
mrt_stats(); | mrt_stats(); | ||||
#ifdef INET6 | #ifdef INET6 | ||||
if (af == AF_INET6 || af == AF_UNSPEC) | if (af == AF_INET6 || af == AF_UNSPEC) | ||||
▲ Show 20 Lines • Show All 377 Lines • Show Last 20 Lines |