mirror of
https://git.freebsd.org/src.git
synced 2026-01-16 23:02:24 +00:00
netstat: add support for UDP-Lite endpoints
With this patch UDP-Lite endpoints are also shown per default. Reviewed by: Nick Banks MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D53252
This commit is contained in:
parent
f48c6390dd
commit
c2b08c13c2
2 changed files with 30 additions and 11 deletions
|
|
@ -83,7 +83,7 @@ static void inetprint(const char *, struct in_addr *, int, const char *, int,
|
|||
const int);
|
||||
#endif
|
||||
#ifdef INET6
|
||||
static int udp_done, tcp_done, sdp_done;
|
||||
static int udp_done, udplite_done, tcp_done, sdp_done;
|
||||
#endif /* INET6 */
|
||||
|
||||
static int
|
||||
|
|
@ -100,6 +100,9 @@ pcblist_sysctl(int proto, const char *name, char **bufp)
|
|||
case IPPROTO_UDP:
|
||||
mibvar = "net.inet.udp.pcblist";
|
||||
break;
|
||||
case IPPROTO_UDPLITE:
|
||||
mibvar = "net.inet.udplite.pcblist";
|
||||
break;
|
||||
default:
|
||||
mibvar = "net.inet.raw.pcblist";
|
||||
break;
|
||||
|
|
@ -220,13 +223,20 @@ protopr(u_long off, const char *name, int af1, int proto)
|
|||
return;
|
||||
else
|
||||
udp_done = 1;
|
||||
#endif
|
||||
break;
|
||||
case IPPROTO_UDPLITE:
|
||||
#ifdef INET6
|
||||
if (udplite_done != 0)
|
||||
return;
|
||||
else
|
||||
udplite_done = 1;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
if (!pcblist_sysctl(proto, name, &buf))
|
||||
return;
|
||||
|
||||
if (istcp && (cflag || Cflag)) {
|
||||
fnamelen = strlen("Stack");
|
||||
cnamelen = strlen("CC");
|
||||
|
|
@ -318,18 +328,18 @@ protopr(u_long off, const char *name, int af1, int proto)
|
|||
"Proto", "Listen", "Local Address");
|
||||
else if (Tflag)
|
||||
xo_emit((Aflag && !Wflag) ?
|
||||
"{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-18.18s} {T:/%s}" :
|
||||
"{T:/%-9.9s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-18.18s} {T:/%s}" :
|
||||
((!Wflag || af1 == AF_INET) ?
|
||||
"{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-22.22s} {T:/%s}" :
|
||||
"{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-45.45s} {T:/%s}"),
|
||||
"{T:/%-9.9s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-22.22s} {T:/%s}" :
|
||||
"{T:/%-9.9s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-45.45s} {T:/%s}"),
|
||||
"Proto", "Rexmit", "OOORcv", "0-win",
|
||||
"Local Address", "Foreign Address");
|
||||
else {
|
||||
xo_emit((Aflag && !Wflag) ?
|
||||
"{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-18.18s} {T:/%-18.18s}" :
|
||||
"{T:/%-9.9s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-18.18s} {T:/%-18.18s}" :
|
||||
((!Wflag || af1 == AF_INET) ?
|
||||
"{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-22.22s} {T:/%-22.22s}" :
|
||||
"{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-45.45s} {T:/%-45.45s}"),
|
||||
"{T:/%-9.9s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-22.22s} {T:/%-22.22s}" :
|
||||
"{T:/%-9.9s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-45.45s} {T:/%-45.45s}"),
|
||||
"Proto", "Recv-Q", "Send-Q",
|
||||
"Local Address", "Foreign Address");
|
||||
if (!xflag && !Rflag)
|
||||
|
|
@ -382,9 +392,14 @@ protopr(u_long off, const char *name, int af1, int proto)
|
|||
vchar = ((inp->inp_vflag & INP_IPV4) != 0) ?
|
||||
"4" : "";
|
||||
if (istcp && (tp->t_flags & TF_TOE) != 0)
|
||||
xo_emit("{:protocol/%-3.3s%-2.2s/%s%s} ", "toe", vchar);
|
||||
else
|
||||
xo_emit("{:protocol/%-3.3s%-2.2s/%s%s} ", name, vchar);
|
||||
xo_emit("{:protocol/%-3.3s%-6.6s/%s%s} ", "toe", vchar);
|
||||
else {
|
||||
int len;
|
||||
|
||||
len = max (2, 9 - strlen(name));
|
||||
xo_emit("{:protocol/%.7s%-*.*s/%s%s} ", name, len, len,
|
||||
vchar);
|
||||
}
|
||||
if (Lflag) {
|
||||
char buf1[33];
|
||||
|
||||
|
|
|
|||
|
|
@ -83,6 +83,8 @@ static struct protox {
|
|||
tcp_stats, NULL, "tcp", 1, IPPROTO_TCP },
|
||||
{ -1 , N_UDPSTAT, 1, protopr,
|
||||
udp_stats, NULL, "udp", 1, IPPROTO_UDP },
|
||||
{ -1, -1, 1, protopr,
|
||||
NULL, NULL, "udplite", 1, IPPROTO_UDPLITE },
|
||||
#ifdef SCTP
|
||||
{ -1, N_SCTPSTAT, 1, sctp_protopr,
|
||||
sctp_stats, NULL, "sctp", 1, IPPROTO_SCTP },
|
||||
|
|
@ -131,6 +133,8 @@ static struct protox ip6protox[] = {
|
|||
tcp_stats, NULL, "tcp", 1, IPPROTO_TCP },
|
||||
{ -1 , N_UDPSTAT, 1, protopr,
|
||||
udp_stats, NULL, "udp", 1, IPPROTO_UDP },
|
||||
{ -1, -1, 1, protopr,
|
||||
NULL, NULL, "udplite", 1, IPPROTO_UDPLITE },
|
||||
{ -1 , N_IP6STAT, 1, protopr,
|
||||
ip6_stats, ip6_ifstats, "ip6", 1, IPPROTO_RAW },
|
||||
{ -1 , N_ICMP6STAT, 1, protopr,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue