1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
|
/*-
* Copyright (c) 2002 Dag-Erling Coïdan Smørgrav
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer
* in this position and unchanged.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/sysctl.h>
#include <sys/file.h>
#include <sys/user.h>
#include <sys/un.h>
#include <sys/unpcb.h>
#include <net/route.h>
#include <netinet/in.h>
#include <netinet/in_pcb.h>
#include <netinet/tcp.h>
#include <netinet/tcp_seq.h>
#include <netinet/tcp_var.h>
#include <arpa/inet.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <netdb.h>
#include <pwd.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
static int opt_4; /* Show IPv4 sockets */
static int opt_6; /* Show IPv6 sockets */
static int opt_c; /* Show connected sockets */
static int opt_L; /* Don't show IPv4 or IPv6 loopback sockets */
static int opt_l; /* Show listening sockets */
static int opt_u; /* Show Unix domain sockets */
static int opt_v; /* Verbose mode */
/*
* Default protocols to use if no -P was defined.
*/
static const char *default_protos[] = {"tcp", "udp", "divert" };
static size_t default_numprotos =
sizeof(default_protos) / sizeof(default_protos[0]);
static int *protos; /* protocols to use */
static size_t numprotos; /* allocated size of protos[] */
static int *ports;
#define INT_BIT (sizeof(int)*CHAR_BIT)
#define SET_PORT(p) do { ports[p / INT_BIT] |= 1 << (p % INT_BIT); } while (0)
#define CHK_PORT(p) (ports[p / INT_BIT] & (1 << (p % INT_BIT)))
struct sock {
void *socket;
void *pcb;
int vflag;
int family;
int proto;
const char *protoname;
struct sockaddr_storage laddr;
struct sockaddr_storage faddr;
struct sock *next;
};
#define HASHSIZE 1009
static struct sock *sockhash[HASHSIZE];
static struct xfile *xfiles;
static int nxfiles;
static int
xprintf(const char *fmt, ...)
{
va_list ap;
int len;
va_start(ap, fmt);
len = vprintf(fmt, ap);
va_end(ap);
if (len < 0)
err(1, "printf()");
return (len);
}
static int
get_proto_type(const char *proto)
{
struct protoent *pent;
if (strlen(proto) == 0)
return (0);
pent = getprotobyname(proto);
if (pent == NULL) {
warn("getprotobyname");
return (-1);
}
return (pent->p_proto);
}
static void init_protos(int num)
{
int proto_count = 0;
if (num > 0) {
proto_count = num;
} else {
/* Find the maximum number of possible protocols. */
while (getprotoent() != NULL)
proto_count++;
endprotoent();
}
if ((protos = malloc(sizeof(int) * proto_count)) == NULL)
err(1, "malloc");
numprotos = proto_count;
}
static int
parse_protos(char *protospec)
{
char *prot;
char *tmp = protospec;
int proto_type, proto_index;
if (protospec == NULL)
return (-1);
init_protos(0);
proto_index = 0;
while ((prot = strsep(&tmp, ",")) != NULL) {
if (strlen(prot) == 0)
continue;
proto_type = get_proto_type(prot);
if (proto_type != -1)
protos[proto_index++] = proto_type;
}
numprotos = proto_index;
return (proto_index);
}
static void
parse_ports(const char *portspec)
{
const char *p, *q;
int port, end;
if (ports == NULL)
if ((ports = calloc(65536 / INT_BIT, sizeof(int))) == NULL)
err(1, "calloc()");
p = portspec;
while (*p != '\0') {
if (!isdigit(*p))
errx(1, "syntax error in port range");
for (q = p; *q != '\0' && isdigit(*q); ++q)
/* nothing */ ;
for (port = 0; p < q; ++p)
port = port * 10 + digittoint(*p);
if (port < 0 || port > 65535)
errx(1, "invalid port number");
SET_PORT(port);
switch (*p) {
case '-':
++p;
break;
case ',':
++p;
/* fall through */
case '\0':
default:
continue;
}
for (q = p; *q != '\0' && isdigit(*q); ++q)
/* nothing */ ;
for (end = 0; p < q; ++p)
end = end * 10 + digittoint(*p);
if (end < port || end > 65535)
errx(1, "invalid port number");
while (port++ < end)
SET_PORT(port);
if (*p == ',')
++p;
}
}
static void
sockaddr(struct sockaddr_storage *sa, int af, void *addr, int port)
{
struct sockaddr_in *sin4;
struct sockaddr_in6 *sin6;
bzero(sa, sizeof *sa);
switch (af) {
case AF_INET:
sin4 = (struct sockaddr_in *)sa;
sin4->sin_len = sizeof *sin4;
sin4->sin_family = af;
sin4->sin_port = port;
sin4->sin_addr = *(struct in_addr *)addr;
break;
case AF_INET6:
sin6 = (struct sockaddr_in6 *)sa;
sin6->sin6_len = sizeof *sin6;
sin6->sin6_family = af;
sin6->sin6_port = port;
sin6->sin6_addr = *(struct in6_addr *)addr;
break;
default:
abort();
}
}
static void
gather_inet(int proto)
{
struct xinpgen *xig, *exig;
struct xinpcb *xip;
struct xtcpcb *xtp;
struct inpcb *inp;
struct xsocket *so;
struct sock *sock;
const char *varname, *protoname;
size_t len, bufsize;
void *buf;
int hash, retry, vflag;
vflag = 0;
if (opt_4)
vflag |= INP_IPV4;
if (opt_6)
vflag |= INP_IPV6;
switch (proto) {
case IPPROTO_TCP:
varname = "net.inet.tcp.pcblist";
protoname = "tcp";
break;
case IPPROTO_UDP:
varname = "net.inet.udp.pcblist";
protoname = "udp";
break;
case IPPROTO_DIVERT:
varname = "net.inet.divert.pcblist";
protoname = "div";
break;
default:
errx(1, "protocol %d not supported", proto);
}
buf = NULL;
bufsize = 8192;
retry = 5;
do {
for (;;) {
if ((buf = realloc(buf, bufsize)) == NULL)
err(1, "realloc()");
len = bufsize;
if (sysctlbyname(varname, buf, &len, NULL, 0) == 0)
break;
if (errno == ENOENT)
goto out;
if (errno != ENOMEM)
err(1, "sysctlbyname()");
bufsize *= 2;
}
xig = (struct xinpgen *)buf;
exig = (struct xinpgen *)(void *)
((char *)buf + len - sizeof *exig);
if (xig->xig_len != sizeof *xig ||
exig->xig_len != sizeof *exig)
errx(1, "struct xinpgen size mismatch");
} while (xig->xig_gen != exig->xig_gen && retry--);
if (xig->xig_gen != exig->xig_gen && opt_v)
warnx("warning: data may be inconsistent");
for (;;) {
xig = (struct xinpgen *)(void *)((char *)xig + xig->xig_len);
if (xig >= exig)
break;
switch (proto) {
case IPPROTO_TCP:
xtp = (struct xtcpcb *)xig;
if (xtp->xt_len != sizeof *xtp) {
warnx("struct xtcpcb size mismatch");
goto out;
}
inp = &xtp->xt_inp;
so = &xtp->xt_socket;
break;
case IPPROTO_UDP:
case IPPROTO_DIVERT:
xip = (struct xinpcb *)xig;
if (xip->xi_len != sizeof *xip) {
warnx("struct xinpcb size mismatch");
goto out;
}
inp = &xip->xi_inp;
so = &xip->xi_socket;
break;
default:
errx(1, "protocol %d not supported", 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;
#define __IN_IS_ADDR_LOOPBACK(pina) \
((ntohl((pina)->s_addr) >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET)
if (opt_L &&
(__IN_IS_ADDR_LOOPBACK(&inp->inp_faddr) ||
__IN_IS_ADDR_LOOPBACK(&inp->inp_laddr)))
continue;
#undef __IN_IS_ADDR_LOOPBACK
} else if (inp->inp_vflag & INP_IPV6) {
if ((inp->in6p_fport == 0 && !opt_l) ||
(inp->in6p_fport != 0 && !opt_c))
continue;
if (opt_L &&
(IN6_IS_ADDR_LOOPBACK(&inp->in6p_faddr) ||
IN6_IS_ADDR_LOOPBACK(&inp->in6p_laddr)))
continue;
} else {
if (opt_v)
warnx("invalid vflag 0x%x", inp->inp_vflag);
continue;
}
if ((sock = calloc(1, sizeof *sock)) == NULL)
err(1, "malloc()");
sock->socket = so->xso_so;
sock->proto = proto;
if (inp->inp_vflag & INP_IPV4) {
sock->family = AF_INET;
sockaddr(&sock->laddr, sock->family,
&inp->inp_laddr, inp->inp_lport);
sockaddr(&sock->faddr, sock->family,
&inp->inp_faddr, inp->inp_fport);
} else if (inp->inp_vflag & INP_IPV6) {
sock->family = AF_INET6;
sockaddr(&sock->laddr, sock->family,
&inp->in6p_laddr, inp->in6p_lport);
sockaddr(&sock->faddr, sock->family,
&inp->in6p_faddr, inp->in6p_fport);
}
sock->vflag = inp->inp_vflag;
sock->protoname = protoname;
hash = (int)((uintptr_t)sock->socket % HASHSIZE);
sock->next = sockhash[hash];
sockhash[hash] = sock;
}
out:
free(buf);
}
static void
gather_unix(int proto)
{
struct xunpgen *xug, *exug;
struct xunpcb *xup;
struct sock *sock;
const char *varname, *protoname;
size_t len, bufsize;
void *buf;
int hash, retry;
switch (proto) {
case SOCK_STREAM:
varname = "net.local.stream.pcblist";
protoname = "stream";
break;
case SOCK_DGRAM:
varname = "net.local.dgram.pcblist";
protoname = "dgram";
break;
default:
abort();
}
buf = NULL;
bufsize = 8192;
retry = 5;
do {
for (;;) {
if ((buf = realloc(buf, bufsize)) == NULL)
err(1, "realloc()");
len = bufsize;
if (sysctlbyname(varname, buf, &len, NULL, 0) == 0)
break;
if (errno != ENOMEM)
err(1, "sysctlbyname()");
bufsize *= 2;
}
xug = (struct xunpgen *)buf;
exug = (struct xunpgen *)(void *)
((char *)buf + len - sizeof *exug);
if (xug->xug_len != sizeof *xug ||
exug->xug_len != sizeof *exug) {
warnx("struct xinpgen size mismatch");
goto out;
}
} while (xug->xug_gen != exug->xug_gen && retry--);
if (xug->xug_gen != exug->xug_gen && opt_v)
warnx("warning: data may be inconsistent");
for (;;) {
xug = (struct xunpgen *)(void *)((char *)xug + xug->xug_len);
if (xug >= exug)
break;
xup = (struct xunpcb *)xug;
if (xup->xu_len != sizeof *xup) {
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;
sock->pcb = xup->xu_unpp;
sock->proto = proto;
sock->family = AF_UNIX;
sock->protoname = protoname;
if (xup->xu_unp.unp_addr != NULL)
sock->laddr =
*(struct sockaddr_storage *)(void *)&xup->xu_addr;
else if (xup->xu_unp.unp_conn != NULL)
*(void **)&sock->faddr = xup->xu_unp.unp_conn;
hash = (int)((uintptr_t)sock->socket % HASHSIZE);
sock->next = sockhash[hash];
sockhash[hash] = sock;
}
out:
free(buf);
}
static void
getfiles(void)
{
size_t len;
if ((xfiles = malloc(len = sizeof *xfiles)) == NULL)
err(1, "malloc()");
while (sysctlbyname("kern.file", xfiles, &len, 0, 0) == -1) {
if (errno != ENOMEM)
err(1, "sysctlbyname()");
len *= 2;
if ((xfiles = realloc(xfiles, len)) == NULL)
err(1, "realloc()");
}
if (len > 0 && xfiles->xf_size != sizeof *xfiles)
errx(1, "struct xfile size mismatch");
nxfiles = len / sizeof *xfiles;
}
static int
printaddr(int af, struct sockaddr_storage *ss)
{
char addrstr[INET6_ADDRSTRLEN] = { '\0', '\0' };
struct sockaddr_un *sun;
void *addr;
int off, port;
switch (af) {
case AF_INET:
addr = &((struct sockaddr_in *)ss)->sin_addr;
if (inet_lnaof(*(struct in_addr *)addr) == INADDR_ANY)
addrstr[0] = '*';
port = ntohs(((struct sockaddr_in *)ss)->sin_port);
break;
case AF_INET6:
addr = &((struct sockaddr_in6 *)ss)->sin6_addr;
if (IN6_IS_ADDR_UNSPECIFIED((struct in6_addr *)addr))
addrstr[0] = '*';
port = ntohs(((struct sockaddr_in6 *)ss)->sin6_port);
break;
case AF_UNIX:
sun = (struct sockaddr_un *)ss;
off = (int)((char *)&sun->sun_path - (char *)sun);
return (xprintf("%.*s", sun->sun_len - off, sun->sun_path));
}
if (addrstr[0] == '\0')
inet_ntop(af, addr, addrstr, sizeof addrstr);
if (port == 0)
return xprintf("%s:*", addrstr);
else
return xprintf("%s:%d", addrstr, port);
}
static const char *
getprocname(pid_t pid)
{
static struct kinfo_proc proc;
size_t len;
int mib[4];
mib[0] = CTL_KERN;
mib[1] = KERN_PROC;
mib[2] = KERN_PROC_PID;
mib[3] = (int)pid;
len = sizeof proc;
if (sysctl(mib, 4, &proc, &len, NULL, 0) == -1) {
/* Do not warn if the process exits before we get its name. */
if (errno != ESRCH)
warn("sysctl()");
return ("??");
}
return (proc.ki_comm);
}
static int
check_ports(struct sock *s)
{
int port;
if (ports == NULL)
return (1);
if ((s->family != AF_INET) && (s->family != AF_INET6))
return (1);
if (s->family == AF_INET)
port = ntohs(((struct sockaddr_in *)(&s->laddr))->sin_port);
else
port = ntohs(((struct sockaddr_in6 *)(&s->laddr))->sin6_port);
if (CHK_PORT(port))
return (1);
if (s->family == AF_INET)
port = ntohs(((struct sockaddr_in *)(&s->faddr))->sin_port);
else
port = ntohs(((struct sockaddr_in6 *)(&s->faddr))->sin6_port);
if (CHK_PORT(port))
return (1);
return (0);
}
static void
display(void)
{
struct passwd *pwd;
struct xfile *xf;
struct sock *s;
void *p;
int hash, n, pos;
printf("%-8s %-10s %-5s %-2s %-6s %-21s %-21s\n",
"USER", "COMMAND", "PID", "FD", "PROTO",
"LOCAL ADDRESS", "FOREIGN ADDRESS");
setpassent(1);
for (xf = xfiles, n = 0; n < nxfiles; ++n, ++xf) {
if (xf->xf_data == NULL)
continue;
hash = (int)((uintptr_t)xf->xf_data % HASHSIZE);
for (s = sockhash[hash]; s != NULL; s = s->next)
if ((void *)s->socket == xf->xf_data)
break;
if (s == NULL)
continue;
if (!check_ports(s))
continue;
pos = 0;
if ((pwd = getpwuid(xf->xf_uid)) == NULL)
pos += xprintf("%lu", (u_long)xf->xf_uid);
else
pos += xprintf("%s", pwd->pw_name);
while (pos < 9)
pos += xprintf(" ");
pos += xprintf("%.10s", getprocname(xf->xf_pid));
while (pos < 20)
pos += xprintf(" ");
pos += xprintf("%lu", (u_long)xf->xf_pid);
while (pos < 26)
pos += xprintf(" ");
pos += xprintf("%d", xf->xf_fd);
while (pos < 29)
pos += xprintf(" ");
pos += xprintf("%s", s->protoname);
if (s->vflag & INP_IPV4)
pos += xprintf("4");
if (s->vflag & INP_IPV6)
pos += xprintf("6");
while (pos < 36)
pos += xprintf(" ");
switch (s->family) {
case AF_INET:
case AF_INET6:
pos += printaddr(s->family, &s->laddr);
while (pos < 58)
pos += xprintf(" ");
pos += printaddr(s->family, &s->faddr);
break;
case AF_UNIX:
/* server */
if (s->laddr.ss_len > 0) {
pos += printaddr(s->family, &s->laddr);
break;
}
/* client */
p = *(void **)&s->faddr;
if (p == NULL) {
pos += xprintf("(not connected)");
break;
}
pos += xprintf("-> ");
for (hash = 0; hash < HASHSIZE; ++hash) {
for (s = sockhash[hash]; s != NULL; s = s->next)
if (s->pcb == p)
break;
if (s != NULL)
break;
}
if (s == NULL || s->laddr.ss_len == 0)
pos += xprintf("??");
else
pos += printaddr(s->family, &s->laddr);
break;
default:
abort();
}
xprintf("\n");
}
}
static int set_default_protos(void)
{
struct protoent *prot;
const char *pname;
size_t pindex;
init_protos(default_numprotos);
for (pindex = 0; pindex < default_numprotos; pindex++) {
pname = default_protos[pindex];
prot = getprotobyname(pname);
if (prot == NULL)
err(1, "getprotobyname: %s", pname);
protos[pindex] = prot->p_proto;
}
numprotos = pindex;
return (pindex);
}
static void
usage(void)
{
fprintf(stderr,
"Usage: sockstat [-46cLlu] [-p ports] [-P protocols]\n");
exit(1);
}
int
main(int argc, char *argv[])
{
int protos_defined = -1;
int o, i;
while ((o = getopt(argc, argv, "46cLlp:P:uv")) != -1)
switch (o) {
case '4':
opt_4 = 1;
break;
case '6':
opt_6 = 1;
break;
case 'c':
opt_c = 1;
break;
case 'L':
opt_L = 1;
break;
case 'l':
opt_l = 1;
break;
case 'p':
parse_ports(optarg);
break;
case 'P':
protos_defined = parse_protos(optarg);
break;
case 'u':
opt_u = 1;
break;
case 'v':
++opt_v;
break;
default:
usage();
}
argc -= optind;
argv += optind;
if (argc > 0)
usage();
if ((!opt_4 && !opt_6) && protos_defined != -1)
opt_4 = opt_6 = 1;
if (!opt_4 && !opt_6 && !opt_u)
opt_4 = opt_6 = opt_u = 1;
if ((opt_4 || opt_6) && protos_defined == -1)
protos_defined = set_default_protos();
if (!opt_c && !opt_l)
opt_c = opt_l = 1;
if (opt_4 || opt_6) {
for (i = 0; i < protos_defined; i++)
gather_inet(protos[i]);
}
if (opt_u || (protos_defined == -1 && !opt_4 && !opt_6)) {
gather_unix(SOCK_STREAM);
gather_unix(SOCK_DGRAM);
}
getfiles();
display();
exit(0);
}
|