Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/netstat/main.c
| Show First 20 Lines • Show All 209 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 nhgrp objects*/ | |||||
| int oflag; /* show nexthop objects*/ | 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 */ | ||||
| Show All 19 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, "46AaBbCdF:f:ghI:iLlM:mN:noPp:Qq:RrSTsuWw:xz")) | while ((ch = getopt(argc, argv, "46AaBbCdF:f:ghI:iLlM:mN:nOoPp: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 86 Lines • ▼ Show 20 Lines | 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': | case 'o': | ||||
| oflag = 1; | oflag = 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 140 Lines • ▼ Show 20 Lines | #endif | ||||
| } | } | ||||
| if (oflag) { | if (oflag) { | ||||
| xo_open_container("statistics"); | xo_open_container("statistics"); | ||||
| nhops_print(fib, af); | nhops_print(fib, af); | ||||
| xo_close_container("statistics"); | xo_close_container("statistics"); | ||||
| xo_finish(); | xo_finish(); | ||||
| exit(0); | exit(0); | ||||
| } | } | ||||
| if (Oflag) { | |||||
| xo_open_container("statistics"); | |||||
| 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 | ||||
| ▲ Show 20 Lines • Show All 378 Lines • Show Last 20 Lines | |||||