On Sat, Jul 18, 2020 at 08:11:15PM +0000, marfabastewart wrote: > > > > netstat -p only works for the protocols hard-coded in the protox > > > > struct in > > > > /usr/src/usr.bin/netstat/main.c > > > > > > > > > > > > > For the protocol problem, I see the call to getprotoent but > > > > no call to getprotobyname in the name2protox function in > > > > /usr/src/usr.b/in/netstat/main.c > > > > > > > > > > > so, philip guenther did all the hard work: it seems the text additions > > were made 21 years ago with ip6 support, but the code was never added. > > so the current SYNOPSIS was (and still is) correct: -f is not used with > > -I. the text in -I describing -f was wrong, and i've just removed it. > > > > thanks for your mail, > > jmc > > Hi, thank you very much for your quick reply. > It also appears that netstat isn't checking /etc/protcols > when the -p option is called: > > $netstat -an -p rdp > netstat: rdp: unknown protocol > > although rdp is in /etc/protocols. >
well, netstat(1) does not claim to read /etc/protocols, only that some well known protocols may be listed there: Some protocol names and aliases are listed in the file /etc/protocols. > In contrast, other protocols in struct protx > do get a different response: > > $netstat -an -p icmp > netstat: no protocol handler for protocol icmp > > Although I admit I don't know enough to know > whether it would make sense to generate statistics > for icmp. > i'm not sure whether the combination makes sense. looking at SYNOPSIS, it does suggest it should work. but if you run "-an" without -p it will show you what protocols are supported for that usage (not icmp). you want -s for stats: $ netstat -s -p icmp > Of course other protocols like tcp do work without > problems. > so we could easily add a list of the supported protocol names to -p. i guess most people will know what makes sense, and if you try "netstat -p bob" and it errors out, you'll know it isn;t supported. so i'm unsure whether it's worth adding such a list. personally i think it probably should... jmc