Deleted Added
full compact
inet.c (52415) inet.c (54263)
1/*
2 * Copyright (c) 1983, 1988, 1993, 1995
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 22 unchanged lines hidden (view full) ---

31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
35/*
36static char sccsid[] = "@(#)inet.c 8.5 (Berkeley) 5/24/95";
37*/
38static const char rcsid[] =
1/*
2 * Copyright (c) 1983, 1988, 1993, 1995
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 22 unchanged lines hidden (view full) ---

31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
35/*
36static char sccsid[] = "@(#)inet.c 8.5 (Berkeley) 5/24/95";
37*/
38static const char rcsid[] =
39 "$FreeBSD: head/usr.bin/netstat/inet.c 52415 1999-10-21 07:08:56Z julian $";
39 "$FreeBSD: head/usr.bin/netstat/inet.c 54263 1999-12-07 17:39:16Z shin $";
40#endif /* not lint */
41
42#include <sys/param.h>
43#include <sys/queue.h>
44#include <sys/socket.h>
45#include <sys/socketvar.h>
46#include <sys/sysctl.h>
47#include <sys/protosw.h>
48
49#include <net/route.h>
50#include <netinet/in.h>
51#include <netinet/in_systm.h>
52#include <netinet/ip.h>
40#endif /* not lint */
41
42#include <sys/param.h>
43#include <sys/queue.h>
44#include <sys/socket.h>
45#include <sys/socketvar.h>
46#include <sys/sysctl.h>
47#include <sys/protosw.h>
48
49#include <net/route.h>
50#include <netinet/in.h>
51#include <netinet/in_systm.h>
52#include <netinet/ip.h>
53#ifdef INET6
54#include <netinet/ip6.h>
55#endif /* INET6 */
53#include <netinet/in_pcb.h>
54#include <netinet/ip_icmp.h>
55#include <netinet/icmp_var.h>
56#include <netinet/igmp_var.h>
57#include <netinet/ip_var.h>
58#include <netinet/tcp.h>
59#include <netinet/tcpip.h>
60#include <netinet/tcp_seq.h>
61#define TCPSTATES
62#include <netinet/tcp_fsm.h>
63#include <netinet/tcp_timer.h>
64#include <netinet/tcp_var.h>
65#include <netinet/tcp_debug.h>
66#include <netinet/udp.h>
67#include <netinet/udp_var.h>
56#include <netinet/in_pcb.h>
57#include <netinet/ip_icmp.h>
58#include <netinet/icmp_var.h>
59#include <netinet/igmp_var.h>
60#include <netinet/ip_var.h>
61#include <netinet/tcp.h>
62#include <netinet/tcpip.h>
63#include <netinet/tcp_seq.h>
64#define TCPSTATES
65#include <netinet/tcp_fsm.h>
66#include <netinet/tcp_timer.h>
67#include <netinet/tcp_var.h>
68#include <netinet/tcp_debug.h>
69#include <netinet/udp.h>
70#include <netinet/udp_var.h>
71#ifdef IPSEC
72#include <netinet6/ipsec.h>
73#endif
68
69#include <arpa/inet.h>
70#include <err.h>
71#include <errno.h>
72#include <netdb.h>
73#include <stdio.h>
74#include <stdlib.h>
75#include <string.h>
76#include <unistd.h>
77#include "netstat.h"
78
79char *inetname __P((struct in_addr *));
80void inetprint __P((struct in_addr *, int, char *, int));
74
75#include <arpa/inet.h>
76#include <err.h>
77#include <errno.h>
78#include <netdb.h>
79#include <stdio.h>
80#include <stdlib.h>
81#include <string.h>
82#include <unistd.h>
83#include "netstat.h"
84
85char *inetname __P((struct in_addr *));
86void inetprint __P((struct in_addr *, int, char *, int));
87#ifdef INET6
88extern void inet6print __P((struct in6_addr *, int, char *, int));
89static int udp_done, tcp_done;
90#endif /* INET6 */
81
82/*
83 * Print a summary of connections related to an Internet
84 * protocol. For TCP, also give state of connection.
85 * Listening processes (aflag) are suppressed unless the
86 * -a (all) flag is specified.
87 */
88void
91
92/*
93 * Print a summary of connections related to an Internet
94 * protocol. For TCP, also give state of connection.
95 * Listening processes (aflag) are suppressed unless the
96 * -a (all) flag is specified.
97 */
98void
89protopr(proto, name)
99protopr(proto, name, af)
90 u_long proto; /* for sysctl version we pass proto # */
91 char *name;
100 u_long proto; /* for sysctl version we pass proto # */
101 char *name;
102 int af;
92{
93 int istcp;
94 static int first = 1;
95 char *buf;
96 const char *mibvar;
97 struct tcpcb *tp = NULL;
98 struct inpcb *inp;
99 struct xinpgen *xig, *oxig;
100 struct xsocket *so;
101 size_t len;
102
103 istcp = 0;
104 switch (proto) {
105 case IPPROTO_TCP:
103{
104 int istcp;
105 static int first = 1;
106 char *buf;
107 const char *mibvar;
108 struct tcpcb *tp = NULL;
109 struct inpcb *inp;
110 struct xinpgen *xig, *oxig;
111 struct xsocket *so;
112 size_t len;
113
114 istcp = 0;
115 switch (proto) {
116 case IPPROTO_TCP:
117#ifdef INET6
118 if (tcp_done != 0)
119 return;
120 else
121 tcp_done = 1;
122#endif
106 istcp = 1;
107 mibvar = "net.inet.tcp.pcblist";
108 break;
109 case IPPROTO_UDP:
123 istcp = 1;
124 mibvar = "net.inet.tcp.pcblist";
125 break;
126 case IPPROTO_UDP:
127#ifdef INET6
128 if (udp_done != 0)
129 return;
130 else
131 udp_done = 1;
132#endif
110 mibvar = "net.inet.udp.pcblist";
111 break;
112 case IPPROTO_DIVERT:
113 mibvar = "net.inet.divert.pcblist";
114 break;
115 default:
116 mibvar = "net.inet.raw.pcblist";
117 break;

--- 30 unchanged lines hidden (view full) ---

148 /* Ignore sockets for protocols other than the desired one. */
149 if (so->xso_protocol != proto)
150 continue;
151
152 /* Ignore PCBs which were freed during copyout. */
153 if (inp->inp_gencnt > oxig->xig_gen)
154 continue;
155
133 mibvar = "net.inet.udp.pcblist";
134 break;
135 case IPPROTO_DIVERT:
136 mibvar = "net.inet.divert.pcblist";
137 break;
138 default:
139 mibvar = "net.inet.raw.pcblist";
140 break;

--- 30 unchanged lines hidden (view full) ---

171 /* Ignore sockets for protocols other than the desired one. */
172 if (so->xso_protocol != proto)
173 continue;
174
175 /* Ignore PCBs which were freed during copyout. */
176 if (inp->inp_gencnt > oxig->xig_gen)
177 continue;
178
156 if (!aflag && inet_lnaof(inp->inp_laddr) == INADDR_ANY)
179 if ((af == AF_INET && (inp->inp_vflag & INP_IPV4) == 0)
180#ifdef INET6
181 || (af == AF_INET6 && (inp->inp_vflag & INP_IPV6) == 0)
182#endif /* INET6 */
183 || (af == AF_UNSPEC && ((inp->inp_vflag & INP_IPV4) == 0
184#ifdef INET6
185 && (inp->inp_vflag &
186 INP_IPV6) == 0
187#endif /* INET6 */
188 ))
189 )
157 continue;
190 continue;
191 if (!aflag &&
192 (
193 (af == AF_INET &&
194 inet_lnaof(inp->inp_laddr) == INADDR_ANY)
195#ifdef INET6
196 || (af == AF_INET6 &&
197 IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr))
198#endif /* INET6 */
199 || (af == AF_UNSPEC &&
200 (((inp->inp_vflag & INP_IPV4) != 0 &&
201 inet_lnaof(inp->inp_laddr) == INADDR_ANY)
202#ifdef INET6
203 || ((inp->inp_vflag & INP_IPV6) != 0 &&
204 IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr))
205#endif
206 ))
207 ))
208 continue;
158
159 if (first) {
160 printf("Active Internet connections");
161 if (aflag)
162 printf(" (including servers)");
163 putchar('\n');
164 if (Aflag)
165 printf("%-8.8s ", "Socket");
209
210 if (first) {
211 printf("Active Internet connections");
212 if (aflag)
213 printf(" (including servers)");
214 putchar('\n');
215 if (Aflag)
216 printf("%-8.8s ", "Socket");
166 printf("%-5.5s %-6.6s %-6.6s %-21.21s %-21.21s %s\n",
217 printf(Aflag ?
218 "%-5.5s %-6.6s %-6.6s %-18.18s %-18.18s %s\n" :
219 "%-5.5s %-6.6s %-6.6s %-22.22s %-22.22s %s\n",
167 "Proto", "Recv-Q", "Send-Q",
168 "Local Address", "Foreign Address", "(state)");
169 first = 0;
170 }
171 if (Aflag) {
172 if (istcp)
173 printf("%8lx ", (u_long)inp->inp_ppcb);
174 else
175 printf("%8lx ", (u_long)so->so_pcb);
176 }
220 "Proto", "Recv-Q", "Send-Q",
221 "Local Address", "Foreign Address", "(state)");
222 first = 0;
223 }
224 if (Aflag) {
225 if (istcp)
226 printf("%8lx ", (u_long)inp->inp_ppcb);
227 else
228 printf("%8lx ", (u_long)so->so_pcb);
229 }
177 printf("%-5.5s %6ld %6ld ", name, so->so_rcv.sb_cc,
178 so->so_snd.sb_cc);
230 printf("%-3.3s%s%s %6ld %6ld ", name,
231 (inp->inp_vflag & INP_IPV4) ? "4" : "",
232#ifdef INET6
233 (inp->inp_vflag & INP_IPV6) ? "6" :
234#endif
235 "",
236 so->so_rcv.sb_cc,
237 so->so_snd.sb_cc);
179 if (nflag) {
238 if (nflag) {
180 inetprint(&inp->inp_laddr, (int)inp->inp_lport,
181 name, 1);
182 inetprint(&inp->inp_faddr, (int)inp->inp_fport,
183 name, 1);
239 if (inp->inp_vflag & INP_IPV4) {
240 inetprint(&inp->inp_laddr, (int)inp->inp_lport,
241 name, 1);
242 inetprint(&inp->inp_faddr, (int)inp->inp_fport,
243 name, 1);
244 }
245#ifdef INET6
246 else if (inp->inp_vflag & INP_IPV6) {
247 inet6print(&inp->in6p_laddr,
248 (int)inp->inp_lport, name, 1);
249 inet6print(&inp->in6p_faddr,
250 (int)inp->inp_fport, name, 1);
251 } /* else nothing printed now */
252#endif /* INET6 */
184 } else if (inp->inp_flags & INP_ANONPORT) {
253 } else if (inp->inp_flags & INP_ANONPORT) {
185 inetprint(&inp->inp_laddr, (int)inp->inp_lport,
186 name, 1);
187 inetprint(&inp->inp_faddr, (int)inp->inp_fport,
188 name, 0);
254 if (inp->inp_vflag & INP_IPV4) {
255 inetprint(&inp->inp_laddr, (int)inp->inp_lport,
256 name, 1);
257 inetprint(&inp->inp_faddr, (int)inp->inp_fport,
258 name, 0);
259 }
260#ifdef INET6
261 else if (inp->inp_vflag & INP_IPV6) {
262 inet6print(&inp->in6p_laddr,
263 (int)inp->inp_lport, name, 1);
264 inet6print(&inp->in6p_faddr,
265 (int)inp->inp_fport, name, 0);
266 } /* else nothing printed now */
267#endif /* INET6 */
189 } else {
268 } else {
190 inetprint(&inp->inp_laddr, (int)inp->inp_lport,
191 name, 0);
192 inetprint(&inp->inp_faddr, (int)inp->inp_fport,
193 name, inp->inp_lport != inp->inp_fport);
269 if (inp->inp_vflag & INP_IPV4) {
270 inetprint(&inp->inp_laddr, (int)inp->inp_lport,
271 name, 0);
272 inetprint(&inp->inp_faddr, (int)inp->inp_fport,
273 name,
274 inp->inp_lport != inp->inp_fport);
275 }
276#ifdef INET6
277 else if (inp->inp_vflag & INP_IPV6) {
278 inet6print(&inp->in6p_laddr,
279 (int)inp->inp_lport, name, 0);
280 inet6print(&inp->in6p_faddr,
281 (int)inp->inp_fport, name,
282 inp->inp_lport != inp->inp_fport);
283 } /* else nothing printed now */
284#endif /* INET6 */
194 }
195 if (istcp) {
196 if (tp->t_state < 0 || tp->t_state >= TCP_NSTATES)
197 printf("%d", tp->t_state);
198 else {
199 printf("%s", tcpstates[tp->t_state]);
200#if defined(TF_NEEDSYN) && defined(TF_NEEDFIN)
201 /* Show T/TCP `hidden state' */

--- 30 unchanged lines hidden (view full) ---

232 struct tcpstat tcpstat;
233 size_t len = sizeof tcpstat;
234
235 if (sysctlbyname("net.inet.tcp.stats", &tcpstat, &len, 0, 0) < 0) {
236 warn("sysctl: net.inet.tcp.stats");
237 return;
238 }
239
285 }
286 if (istcp) {
287 if (tp->t_state < 0 || tp->t_state >= TCP_NSTATES)
288 printf("%d", tp->t_state);
289 else {
290 printf("%s", tcpstates[tp->t_state]);
291#if defined(TF_NEEDSYN) && defined(TF_NEEDFIN)
292 /* Show T/TCP `hidden state' */

--- 30 unchanged lines hidden (view full) ---

323 struct tcpstat tcpstat;
324 size_t len = sizeof tcpstat;
325
326 if (sysctlbyname("net.inet.tcp.stats", &tcpstat, &len, 0, 0) < 0) {
327 warn("sysctl: net.inet.tcp.stats");
328 return;
329 }
330
331#ifdef INET6
332 if (tcp_done != 0)
333 return;
334 else
335 tcp_done = 1;
336#endif
337
240 printf ("%s:\n", name);
241
242#define p(f, m) if (tcpstat.f || sflag <= 1) \
243 printf(m, tcpstat.f, plural(tcpstat.f))
244#define p1a(f, m) if (tcpstat.f || sflag <= 1) \
245 printf(m, tcpstat.f)
246#define p2(f1, f2, m) if (tcpstat.f1 || tcpstat.f2 || sflag <= 1) \
247 printf(m, tcpstat.f1, plural(tcpstat.f1), tcpstat.f2, plural(tcpstat.f2))

--- 78 unchanged lines hidden (view full) ---

326 size_t len = sizeof udpstat;
327 u_long delivered;
328
329 if (sysctlbyname("net.inet.udp.stats", &udpstat, &len, 0, 0) < 0) {
330 warn("sysctl: net.inet.udp.stats");
331 return;
332 }
333
338 printf ("%s:\n", name);
339
340#define p(f, m) if (tcpstat.f || sflag <= 1) \
341 printf(m, tcpstat.f, plural(tcpstat.f))
342#define p1a(f, m) if (tcpstat.f || sflag <= 1) \
343 printf(m, tcpstat.f)
344#define p2(f1, f2, m) if (tcpstat.f1 || tcpstat.f2 || sflag <= 1) \
345 printf(m, tcpstat.f1, plural(tcpstat.f1), tcpstat.f2, plural(tcpstat.f2))

--- 78 unchanged lines hidden (view full) ---

424 size_t len = sizeof udpstat;
425 u_long delivered;
426
427 if (sysctlbyname("net.inet.udp.stats", &udpstat, &len, 0, 0) < 0) {
428 warn("sysctl: net.inet.udp.stats");
429 return;
430 }
431
432#ifdef INET6
433 if (udp_done != 0)
434 return;
435 else
436 udp_done = 1;
437#endif
438
334 printf("%s:\n", name);
335#define p(f, m) if (udpstat.f || sflag <= 1) \
336 printf(m, udpstat.f, plural(udpstat.f))
337#define p1a(f, m) if (udpstat.f || sflag <= 1) \
338 printf(m, udpstat.f)
339 p(udps_ipackets, "\t%lu datagram%s received\n");
340 p1a(udps_hdrops, "\t%lu with incomplete header\n");
341 p1a(udps_badlen, "\t%lu with bad data length field\n");

--- 39 unchanged lines hidden (view full) ---

381 printf(m, ipstat.f, plural(ipstat.f))
382#define p1a(f, m) if (ipstat.f || sflag <= 1) \
383 printf(m, ipstat.f)
384
385 p(ips_total, "\t%lu total packet%s received\n");
386 p(ips_badsum, "\t%lu bad header checksum%s\n");
387 p1a(ips_toosmall, "\t%lu with size smaller than minimum\n");
388 p1a(ips_tooshort, "\t%lu with data size < data length\n");
439 printf("%s:\n", name);
440#define p(f, m) if (udpstat.f || sflag <= 1) \
441 printf(m, udpstat.f, plural(udpstat.f))
442#define p1a(f, m) if (udpstat.f || sflag <= 1) \
443 printf(m, udpstat.f)
444 p(udps_ipackets, "\t%lu datagram%s received\n");
445 p1a(udps_hdrops, "\t%lu with incomplete header\n");
446 p1a(udps_badlen, "\t%lu with bad data length field\n");

--- 39 unchanged lines hidden (view full) ---

486 printf(m, ipstat.f, plural(ipstat.f))
487#define p1a(f, m) if (ipstat.f || sflag <= 1) \
488 printf(m, ipstat.f)
489
490 p(ips_total, "\t%lu total packet%s received\n");
491 p(ips_badsum, "\t%lu bad header checksum%s\n");
492 p1a(ips_toosmall, "\t%lu with size smaller than minimum\n");
493 p1a(ips_tooshort, "\t%lu with data size < data length\n");
494 p1a(ips_toolong, "\t%lu with ip length > max ip packet size\n");
389 p1a(ips_badhlen, "\t%lu with header length < data size\n");
390 p1a(ips_badlen, "\t%lu with data length < header length\n");
391 p1a(ips_badoptions, "\t%lu with bad options\n");
392 p1a(ips_badvers, "\t%lu with incorrect version number\n");
393 p(ips_fragments, "\t%lu fragment%s received\n");
394 p(ips_fragdropped, "\t%lu fragment%s dropped (dup or out of space)\n");
395 p(ips_fragtimeout, "\t%lu fragment%s dropped after timeout\n");
396 p(ips_reassembled, "\t%lu packet%s reassembled ok\n");

--- 10 unchanged lines hidden (view full) ---

407 p(ips_localout, "\t%lu packet%s sent from this host\n");
408 p(ips_rawout, "\t%lu packet%s sent with fabricated ip header\n");
409 p(ips_odropped,
410 "\t%lu output packet%s dropped due to no bufs, etc.\n");
411 p(ips_noroute, "\t%lu output packet%s discarded due to no route\n");
412 p(ips_fragmented, "\t%lu output datagram%s fragmented\n");
413 p(ips_ofragments, "\t%lu fragment%s created\n");
414 p(ips_cantfrag, "\t%lu datagram%s that can't be fragmented\n");
495 p1a(ips_badhlen, "\t%lu with header length < data size\n");
496 p1a(ips_badlen, "\t%lu with data length < header length\n");
497 p1a(ips_badoptions, "\t%lu with bad options\n");
498 p1a(ips_badvers, "\t%lu with incorrect version number\n");
499 p(ips_fragments, "\t%lu fragment%s received\n");
500 p(ips_fragdropped, "\t%lu fragment%s dropped (dup or out of space)\n");
501 p(ips_fragtimeout, "\t%lu fragment%s dropped after timeout\n");
502 p(ips_reassembled, "\t%lu packet%s reassembled ok\n");

--- 10 unchanged lines hidden (view full) ---

513 p(ips_localout, "\t%lu packet%s sent from this host\n");
514 p(ips_rawout, "\t%lu packet%s sent with fabricated ip header\n");
515 p(ips_odropped,
516 "\t%lu output packet%s dropped due to no bufs, etc.\n");
517 p(ips_noroute, "\t%lu output packet%s discarded due to no route\n");
518 p(ips_fragmented, "\t%lu output datagram%s fragmented\n");
519 p(ips_ofragments, "\t%lu fragment%s created\n");
520 p(ips_cantfrag, "\t%lu datagram%s that can't be fragmented\n");
521 p(ips_nogif, "\t%lu tunneling packet%s that can't find gif\n");
415#undef p
416#undef p1a
417}
418
419static char *icmpnames[] = {
420 "echo reply",
421 "#1",
422 "#2",

--- 113 unchanged lines hidden (view full) ---

536 p(igps_rcv_reports, "\t%u membership report%s received\n");
537 p(igps_rcv_badreports, "\t%u membership report%s received with invalid field(s)\n");
538 p(igps_rcv_ourreports, "\t%u membership report%s received for groups to which we belong\n");
539 p(igps_snd_reports, "\t%u membership report%s sent\n");
540#undef p
541#undef py
542}
543
522#undef p
523#undef p1a
524}
525
526static char *icmpnames[] = {
527 "echo reply",
528 "#1",
529 "#2",

--- 113 unchanged lines hidden (view full) ---

643 p(igps_rcv_reports, "\t%u membership report%s received\n");
644 p(igps_rcv_badreports, "\t%u membership report%s received with invalid field(s)\n");
645 p(igps_rcv_ourreports, "\t%u membership report%s received for groups to which we belong\n");
646 p(igps_snd_reports, "\t%u membership report%s sent\n");
647#undef p
648#undef py
649}
650
651#ifdef IPSEC
652static char *ipsec_ahnames[] = {
653 "none",
654 "hmac MD5",
655 "hmac SHA1",
656 "keyed MD5",
657 "keyed SHA1",
658 "null",
659};
660
661static char *ipsec_espnames[] = {
662 "none",
663 "DES CBC",
664 "3DES CBC",
665 "simple",
666 "blowfish CBC",
667 "CAST128 CBC",
668 "RC5 CBC",
669};
670
544/*
671/*
672 * Dump IPSEC statistics structure.
673 */
674void
675ipsec_stats(off, name)
676 u_long off;
677 char *name;
678{
679 struct ipsecstat ipsecstat;
680 int first, proto;
681
682 if (off == 0)
683 return;
684 printf ("%s:\n", name);
685 kread(off, (char *)&ipsecstat, sizeof (ipsecstat));
686
687#define p(f, m) if (ipsecstat.f || sflag <= 1) \
688 printf(m, ipsecstat.f, plural(ipsecstat.f))
689
690 p(in_success, "\t%lu inbound packet%s processed successfully\n");
691 p(in_polvio, "\t%lu inbound packet%s violated process security "
692 "policy\n");
693 p(in_nosa, "\t%lu inbound packet%s with no SA available\n");
694 p(in_inval, "\t%lu inbound packet%s failed processing due to EINVAL\n");
695 p(in_badspi, "\t%lu inbound packet%s failed getting SPI\n");
696 p(in_ahreplay, "\t%lu inbound packet%s failed on AH replay check\n");
697 p(in_espreplay, "\t%lu inbound packet%s failed on ESP replay check\n");
698 p(in_ahauthsucc, "\t%lu inbound AH packet%s considered authentic\n");
699 p(in_ahauthfail, "\t%lu inbound AH packet%s failed on authentication\n");
700 p(in_espauthsucc, "\t%lu inbound ESP packet%s considered authentic\n");
701 p(in_espauthfail, "\t%lu inbound ESP packet%s failed on authentication\n");
702 for (first = 1, proto = 0; proto < SADB_AALG_MAX; proto++) {
703 if (ipsecstat.in_ahhist[proto] <= 0)
704 continue;
705 if (first) {
706 printf("\tAH input histogram:\n");
707 first = 0;
708 }
709 printf("\t\t%s: %lu\n", ipsec_ahnames[proto],
710 ipsecstat.in_ahhist[proto]);
711 }
712 for (first = 1, proto = 0; proto < SADB_EALG_MAX; proto++) {
713 if (ipsecstat.in_esphist[proto] <= 0)
714 continue;
715 if (first) {
716 printf("\tESP input histogram:\n");
717 first = 0;
718 }
719 printf("\t\t%s: %lu\n", ipsec_espnames[proto],
720 ipsecstat.in_esphist[proto]);
721 }
722
723 p(out_success, "\t%lu outbound packet%s processed successfully\n");
724 p(out_polvio, "\t%lu outbound packet%s violated process security "
725 "policy\n");
726 p(out_nosa, "\t%lu outbound packet%s with no SA available\n");
727 p(out_inval, "\t%lu outbound packet%s failed processing due to "
728 "EINVAL\n");
729 p(out_noroute, "\t%lu outbound packet%s with no route\n");
730 for (first = 1, proto = 0; proto < SADB_AALG_MAX; proto++) {
731 if (ipsecstat.out_ahhist[proto] <= 0)
732 continue;
733 if (first) {
734 printf("\tAH output histogram:\n");
735 first = 0;
736 }
737 printf("\t\t%s: %lu\n", ipsec_ahnames[proto],
738 ipsecstat.out_ahhist[proto]);
739 }
740 for (first = 1, proto = 0; proto < SADB_EALG_MAX; proto++) {
741 if (ipsecstat.out_esphist[proto] <= 0)
742 continue;
743 if (first) {
744 printf("\tESP output histogram:\n");
745 first = 0;
746 }
747 printf("\t\t%s: %lu\n", ipsec_espnames[proto],
748 ipsecstat.out_esphist[proto]);
749 }
750#undef p
751}
752#endif /*IPSEC*/
753
754/*
545 * Pretty print an Internet address (net address + port).
546 */
547void
548inetprint(in, port, proto,numeric)
549 register struct in_addr *in;
550 int port;
551 char *proto;
552 int numeric;
553{
554 struct servent *sp = 0;
555 char line[80], *cp;
755 * Pretty print an Internet address (net address + port).
756 */
757void
758inetprint(in, port, proto,numeric)
759 register struct in_addr *in;
760 int port;
761 char *proto;
762 int numeric;
763{
764 struct servent *sp = 0;
765 char line[80], *cp;
766 int width;
556
557 sprintf(line, "%.*s.", (Aflag && !numeric) ? 12 : 16, inetname(in));
558 cp = index(line, '\0');
559 if (!numeric && port)
560 sp = getservbyport((int)port, proto);
561 if (sp || port == 0)
562 sprintf(cp, "%.15s", sp ? sp->s_name : "*");
563 else
564 sprintf(cp, "%d", ntohs((u_short)port));
767
768 sprintf(line, "%.*s.", (Aflag && !numeric) ? 12 : 16, inetname(in));
769 cp = index(line, '\0');
770 if (!numeric && port)
771 sp = getservbyport((int)port, proto);
772 if (sp || port == 0)
773 sprintf(cp, "%.15s", sp ? sp->s_name : "*");
774 else
775 sprintf(cp, "%d", ntohs((u_short)port));
565 printf("%-21.21s ", line);
776 width = Aflag ? 18 : 22;
777 printf(" %-*.*s", width, width, line);
566}
567
568/*
569 * Construct an Internet address representation.
570 * If the nflag has been supplied, give
571 * numeric value, otherwise try for symbolic name.
572 */
573char *

--- 39 unchanged lines hidden ---
778}
779
780/*
781 * Construct an Internet address representation.
782 * If the nflag has been supplied, give
783 * numeric value, otherwise try for symbolic name.
784 */
785char *

--- 39 unchanged lines hidden ---