aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/netstat
diff options
context:
space:
mode:
authorRobert Watson <rwatson@FreeBSD.org>2009-10-05 15:06:14 +0000
committerRobert Watson <rwatson@FreeBSD.org>2009-10-05 15:06:14 +0000
commit963b7ccd3b045db7404a023760379bece1756504 (patch)
tree682615d848b9a13d6e23364173a88b17dc81eeed /usr.bin/netstat
parent3ac5a8e8b122c276080e9ac3d37549d056b043a6 (diff)
Notes
Diffstat (limited to 'usr.bin/netstat')
-rw-r--r--usr.bin/netstat/main.c5
-rw-r--r--usr.bin/netstat/netstat.h2
-rw-r--r--usr.bin/netstat/unix.c26
3 files changed, 26 insertions, 7 deletions
diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c
index ebbe1d24fbf6..b1c494086eef 100644
--- a/usr.bin/netstat/main.c
+++ b/usr.bin/netstat/main.c
@@ -186,6 +186,8 @@ static struct nlist nl[] = {
{ .n_name = "_mfctablesize" },
#define N_ARPSTAT 55
{ .n_name = "_arpstat" },
+#define N_UNP_SPHEAD 56
+ { .n_name = "unp_sphead" },
{ .n_name = NULL },
};
@@ -601,7 +603,8 @@ main(int argc, char *argv[])
#endif /* NETGRAPH */
if ((af == AF_UNIX || af == AF_UNSPEC) && !sflag)
unixpr(nl[N_UNP_COUNT].n_value, nl[N_UNP_GENCNT].n_value,
- nl[N_UNP_DHEAD].n_value, nl[N_UNP_SHEAD].n_value);
+ nl[N_UNP_DHEAD].n_value, nl[N_UNP_SHEAD].n_value,
+ nl[N_UNP_SPHEAD].n_value);
exit(0);
}
diff --git a/usr.bin/netstat/netstat.h b/usr.bin/netstat/netstat.h
index f834495e32b4..259ca823e285 100644
--- a/usr.bin/netstat/netstat.h
+++ b/usr.bin/netstat/netstat.h
@@ -150,7 +150,7 @@ void ddp_stats(u_long, const char *, int, int);
void netgraphprotopr(u_long, const char *, int, int);
#endif
-void unixpr(u_long, u_long, u_long, u_long);
+void unixpr(u_long, u_long, u_long, u_long, u_long);
void esis_stats(u_long, const char *, int, int);
void clnp_stats(u_long, const char *, int, int);
diff --git a/usr.bin/netstat/unix.c b/usr.bin/netstat/unix.c
index 209fc8d497be..0ad8f34a52a2 100644
--- a/usr.bin/netstat/unix.c
+++ b/usr.bin/netstat/unix.c
@@ -193,21 +193,37 @@ fail:
}
void
-unixpr(u_long count_off, u_long gencnt_off, u_long dhead_off, u_long shead_off)
+unixpr(u_long count_off, u_long gencnt_off, u_long dhead_off, u_long shead_off,
+ u_long sphead_off)
{
char *buf;
int ret, type;
struct xsocket *so;
struct xunpgen *xug, *oxug;
struct xunpcb *xunp;
+ u_long head_off;
for (type = SOCK_STREAM; type <= SOCK_SEQPACKET; type++) {
if (live)
ret = pcblist_sysctl(type, &buf);
- else
- ret = pcblist_kvm(count_off, gencnt_off,
- type == SOCK_STREAM ? shead_off :
- (type == SOCK_DGRAM ? dhead_off : 0), &buf);
+ else {
+ head_off = 0;
+ switch (type) {
+ case SOCK_STREAM:
+ head_off = shead_off;
+ break;
+
+ case SOCK_DGRAM:
+ head_off = dhead_off;
+ break;
+
+ case SOCK_SEQPACKET:
+ head_off = sphead_off;
+ break;
+ }
+ ret = pcblist_kvm(count_off, gencnt_off, head_off,
+ &buf);
+ }
if (ret == -1)
continue;
if (ret < 0)