From 482ca4274b70d4a6df1a19aaab8435551cf6b9be Mon Sep 17 00:00:00 2001 From: Yoshinobu Inoue Date: Sat, 26 Feb 2000 02:56:16 +0000 Subject: [PATCH] Update sockstat to support INET6 socket printing. Approved by: jkh Submitted by: Ben Smithurst Reviewed by: des --- usr.bin/sockstat/sockstat.1 | 3 ++- usr.bin/sockstat/sockstat.pl | 13 ++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/usr.bin/sockstat/sockstat.1 b/usr.bin/sockstat/sockstat.1 index 09859098f8d7..a55909c60881 100644 --- a/usr.bin/sockstat/sockstat.1 +++ b/usr.bin/sockstat/sockstat.1 @@ -60,7 +60,8 @@ The address the foreign end of the socket is bound to (see .Sh SEE ALSO .Xr fstat 1 , .Xr netstat 1 , -.Xr inet 4 . +.Xr inet 4 , +.Xr inet6 4 . .Sh HISTORY The .Nm diff --git a/usr.bin/sockstat/sockstat.pl b/usr.bin/sockstat/sockstat.pl index 3c251884cb49..c20f5425621e 100644 --- a/usr.bin/sockstat/sockstat.pl +++ b/usr.bin/sockstat/sockstat.pl @@ -29,7 +29,7 @@ # $FreeBSD$ # -my (%myaddr, %hisaddr); +my (%proto, %myaddr, %hisaddr); my ($user, $cmd, $pid, $fd, $inet, $type, $proto, $sock, $laddr, $faddr); print <; ; while () { my ($sock, $proto, $recvq, $sendq, $laddr, $faddr, $state) = split; - ($myaddr{$sock}, $hisaddr{$sock}) = ($laddr, $faddr); + ($proto{$sock}, $myaddr{$sock}, $hisaddr{$sock}) = + ($proto, $laddr, $faddr); } close NETSTAT; @@ -54,8 +56,9 @@ open FSTAT, "fstat |" or die "'fstat' failed: $!\n"; while () { ($user, $cmd, $pid, $fd, $inet, $type, $proto, $sock) = split; chop $fd; - next unless ($inet eq "internet"); - ($laddr, $faddr) = ($myaddr{$sock}, $hisaddr{$sock}); + next unless ($inet =~ m/^internet6?$/); + ($proto, $laddr, $faddr) = + ($proto{$sock}, $myaddr{$sock}, $hisaddr{$sock}); write STDOUT; }