summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2002-08-01 11:02:30 +0000
committerdes <des@FreeBSD.org>2002-08-01 11:02:30 +0000
commit7884f69d0c458139263f6343b511c4e36912cdbe (patch)
treef44f454af25578886edca3b947584e99f668f0b9 /usr.bin
parent019ef4b4806181326e31bef879d16af2fe534b45 (diff)
downloadFreeBSD-src-7884f69d0c458139263f6343b511c4e36912cdbe.zip
FreeBSD-src-7884f69d0c458139263f6343b511c4e36912cdbe.tar.gz
Implement the -l and -c options, which I'd forgotten.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/sockstat/sockstat.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/usr.bin/sockstat/sockstat.c b/usr.bin/sockstat/sockstat.c
index 3c28bb2..46a7e95 100644
--- a/usr.bin/sockstat/sockstat.c
+++ b/usr.bin/sockstat/sockstat.c
@@ -258,6 +258,20 @@ gather_inet(int proto)
}
if ((inp->inp_vflag & vflag) == 0)
continue;
+ if (inp->inp_vflag & INP_IPV4) {
+ if ((inp->inp_fport == 0 && !opt_l) ||
+ (inp->inp_fport != 0 && !opt_c))
+ continue;
+ } else if (inp->inp_vflag & INP_IPV6) {
+ if ((inp->in6p_fport == 0 && !opt_l) ||
+ (inp->in6p_fport != 0 && !opt_c))
+ continue;
+ } else {
+ if (opt_v)
+ warnx("invalid vflag 0x%x", inp->inp_vflag);
+ free(sock);
+ continue;
+ }
if ((sock = calloc(1, sizeof *sock)) == NULL)
err(1, "malloc()");
sock->socket = so->xso_so;
@@ -274,11 +288,6 @@ gather_inet(int proto)
&inp->in6p_laddr, inp->in6p_lport);
sockaddr(&sock->faddr, sock->family,
&inp->in6p_faddr, inp->in6p_fport);
- } else {
- if (opt_v)
- warnx("invalid vflag 0x%x", inp->inp_vflag);
- free(sock);
- continue;
}
sock->vflag = inp->inp_vflag;
sock->protoname = protoname;
@@ -348,6 +357,9 @@ gather_unix(int proto)
warnx("struct xunpcb size mismatch");
goto out;
}
+ if ((xup->xu_unp.unp_conn == NULL && !opt_l) ||
+ (xup->xu_unp.unp_conn != NULL && !opt_c))
+ continue;
if ((sock = calloc(1, sizeof *sock)) == NULL)
err(1, "malloc()");
sock->socket = xup->xu_socket.xso_so;
@@ -454,7 +466,6 @@ display(void)
setpassent(1);
for (xf = xfiles, n = 0; n < nxfiles; ++n, ++xf) {
hash = (int)((uintptr_t)xf->xf_data % HASHSIZE);
- /*xprintf("%p %d\n", xf->xf_data, hash);*/
for (s = sockhash[hash]; s != NULL; s = s->next)
if (s->socket == xf->xf_data)
break;
OpenPOWER on IntegriCloud