Changeset View
Changeset View
Standalone View
Standalone View
head/usr.bin/netstat/main.c
Show First 20 Lines • Show All 199 Lines • ▼ Show 20 Lines | |||||
static kvm_t *kvmd; | static kvm_t *kvmd; | ||||
static char *nlistf = NULL, *memf = NULL; | static char *nlistf = NULL, *memf = NULL; | ||||
int Aflag; /* show addresses of protocol control block */ | int Aflag; /* show addresses of protocol control block */ | ||||
int aflag; /* show all sockets (including servers) */ | int aflag; /* show all sockets (including servers) */ | ||||
static int Bflag; /* show information about bpf consumers */ | static int Bflag; /* show information about bpf consumers */ | ||||
int bflag; /* show i/f total bytes in/out */ | int bflag; /* show i/f total bytes in/out */ | ||||
int Cflag; /* show congestion control */ | int cflag; /* show TCP congestion control stack */ | ||||
int Cflag; /* show congestion control algo and vars */ | |||||
int dflag; /* show i/f dropped packets */ | int dflag; /* show i/f dropped packets */ | ||||
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 */ | ||||
Show All 29 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:nOoPp:Qq:RrSTsuWw:xz")) | while ((ch = getopt(argc, argv, "46AaBbCcdF: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 All 12 Lines | case 'a': | ||||
aflag = 1; | aflag = 1; | ||||
break; | break; | ||||
case 'B': | case 'B': | ||||
Bflag = 1; | Bflag = 1; | ||||
break; | break; | ||||
case 'b': | case 'b': | ||||
bflag = 1; | bflag = 1; | ||||
break; | break; | ||||
case 'c': | |||||
cflag = 1; | |||||
break; | |||||
case 'C': | case 'C': | ||||
Cflag = 1; | Cflag = 1; | ||||
break; | break; | ||||
case 'd': | case 'd': | ||||
dflag = 1; | dflag = 1; | ||||
break; | break; | ||||
case 'F': | case 'F': | ||||
fib = strtol(optarg, &endptr, 0); | fib = strtol(optarg, &endptr, 0); | ||||
▲ Show 20 Lines • Show All 590 Lines • ▼ Show 20 Lines | name2protox(const char *name) | ||||
endprotoent(); | endprotoent(); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
static void | static void | ||||
usage(void) | usage(void) | ||||
{ | { | ||||
(void)xo_error("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n", | (void)xo_error("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n", | ||||
"usage: netstat [-46AaLnRSTWx] [-f protocol_family | -p protocol]\n" | "usage: netstat [-46AaCcLnRSTWx] [-f protocol_family | -p protocol]\n" | ||||
" [-M core] [-N system]", | " [-M core] [-N system]", | ||||
" netstat -i | -I interface [-46abdhnW] [-f address_family]\n" | " netstat -i | -I interface [-46abdhnW] [-f address_family]\n" | ||||
" [-M core] [-N system]", | " [-M core] [-N system]", | ||||
" netstat -w wait [-I interface] [-46d] [-M core] [-N system]\n" | " netstat -w wait [-I interface] [-46d] [-M core] [-N system]\n" | ||||
" [-q howmany]", | " [-q howmany]", | ||||
" netstat -s [-46sz] [-f protocol_family | -p protocol]\n" | " netstat -s [-46sz] [-f protocol_family | -p protocol]\n" | ||||
" [-M core] [-N system]", | " [-M core] [-N system]", | ||||
" netstat -i | -I interface -s [-46s]\n" | " netstat -i | -I interface -s [-46s]\n" | ||||
Show All 12 Lines |