sprintf(line, "%.*s.", (Aflag && !numeric) ? 12 : 16, inetname(in));
cp = index(line, '\0');
if (!numeric && port)
if ((Sflag || !numeric) && port)
sp = getservbyport((int)port, proto);
if (sp || port == 0)
sprintf(cp, "%.15s", sp ? sp->s_name : "*");
sprintf(line, "%.*s.", lflag ? 39 :
(Aflag && !numeric) ? 12 : 16, inet6name(in6));
GETSERVBYPORT6(port, proto, sp);
sprintf(cp, "%.8s", sp ? sp->s_name : "*");
*cp++ = '.';
if(sufxlen) {
if( !Aflag && !nflag && (ihe=iso_getserventrybytsel(sufx, sufxlen))) {
if( !Aflag && (Sflag || !nflag) && (ihe=iso_getserventrybytsel(sufx, sufxlen))) {
Ihe = *ihe;
ihe = &Ihe;
}
af = AF_UNSPEC;
while ((ch = getopt(argc, argv, "Aabdf:ghI:lLiM:mN:np:rstuw:")) != -1)
while ((ch = getopt(argc, argv, "Aabdf:ghI:lLiM:mN:np:rSstuw:")) != -1)
switch(ch) {
case 'A':
Aflag = 1;
case 'r':
rflag = 1;
break;
case 'S':
Sflag = 1;
case 's':
++sflag;
usage()
{
(void)fprintf(stderr, "%s\n%s\n%s\n%s\n",
"usage: netstat [-AaLln] [-f address_family] [-M core] [-N system]",
"usage: netstat [-AaLlnS] [-f address_family] [-M core] [-N system]",
" netstat [-abdghilmnrs] [-f address_family] [-M core] [-N system]",
" netstat [-abdghilmnrSs] [-f address_family] [-M core] [-N system]",
" netstat [-bdn] [-I interface] [-M core] [-N system] [-w wait]",
" netstat [-M core] [-N system] [-p protocol]");
exit(1);
The program will complain if
.Ar protocol
is unknown or if there is no statistics routine for it.
.It Fl S
Show service names even if numeric output has been requested by the
.Fl n
option.
.It Fl s
Show per-protocol statistics.
If this option is repeated, counters with a value of zero are suppressed.
int nflag; /* show addresses numerically */
int pflag; /* show given protocol */
int rflag; /* show routing tables (or routing stats) */
int Sflag; /* show service names even if -n specified */
int sflag; /* show protocol statistics */
int tflag; /* show i/f watchdog timers */
$user, $cmd, $pid, $fd, $proto,$laddr, $faddr
.
open NETSTAT, "netstat -Aan |" or die "'netstat' failed: $!";
open NETSTAT, "netstat -AanS |" or die "'netstat' failed: $!";
<NETSTAT>; <NETSTAT>;
while (<NETSTAT>) {