Annotation of src/usr.bin/netstat/iso.c, Revision 1.12
1.12 ! millert 1: /* $OpenBSD: iso.c,v 1.11 2003/02/01 01:51:31 deraadt Exp $ */
1.1 deraadt 2: /* $NetBSD: iso.c,v 1.12 1995/10/03 21:42:38 thorpej Exp $ */
3:
4: /*
5: * Copyright (c) 1983, 1988, 1993
6: * The Regents of the University of California. All rights reserved.
7: *
8: * Redistribution and use in source and binary forms, with or without
9: * modification, are permitted provided that the following conditions
10: * are met:
11: * 1. Redistributions of source code must retain the above copyright
12: * notice, this list of conditions and the following disclaimer.
13: * 2. Redistributions in binary form must reproduce the above copyright
14: * notice, this list of conditions and the following disclaimer in the
15: * documentation and/or other materials provided with the distribution.
1.12 ! millert 16: * 3. Neither the name of the University nor the names of its contributors
1.1 deraadt 17: * may be used to endorse or promote products derived from this software
18: * without specific prior written permission.
19: *
20: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30: * SUCH DAMAGE.
31: */
32:
33: #ifndef lint
34: #if 0
35: static char sccsid[] = "from: @(#)iso.c 8.1 (Berkeley) 6/6/93";
36: #else
1.12 ! millert 37: static char *rcsid = "$OpenBSD: iso.c,v 1.11 2003/02/01 01:51:31 deraadt Exp $";
1.1 deraadt 38: #endif
39: #endif /* not lint */
40:
41: /*******************************************************************************
42: Copyright IBM Corporation 1987
43:
44: All Rights Reserved
45:
46: Permission to use, copy, modify, and distribute this software and its
47: documentation for any purpose and without fee is hereby granted,
48: provided that the above copyright notice appear in all copies and that
49: both that copyright notice and this permission notice appear in
50: supporting documentation, and that the name of IBM not be
51: used in advertising or publicity pertaining to distribution of the
52: software without specific, written prior permission.
53:
54: IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
55: ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
56: IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
57: ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
58: WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
59: ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
60: SOFTWARE.
61:
62: *******************************************************************************/
63:
64: /*
65: * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
66: */
67:
68: #include <sys/param.h>
69: #include <sys/queue.h>
70: #include <sys/mbuf.h>
71: #include <sys/time.h>
72: #include <sys/domain.h>
73: #include <sys/protosw.h>
74: #include <sys/socket.h>
75: #include <sys/socketvar.h>
76: #include <errno.h>
77: #include <net/if.h>
78: #include <net/route.h>
79: #include <netinet/in.h>
80: #include <netinet/in_systm.h>
81: #include <netinet/ip.h>
82: #include <netinet/in_pcb.h>
83: #include <netinet/ip_var.h>
84: #include <netiso/iso.h>
85: #include <netiso/iso_errno.h>
86: #include <netiso/clnp.h>
87: #include <netiso/esis.h>
88: #include <netiso/clnp_stat.h>
89: #include <netiso/argo_debug.h>
90: #undef satosiso
91: #include <netiso/tp_param.h>
92: #include <netiso/tp_states.h>
93: #include <netiso/tp_pcb.h>
94: #include <netiso/tp_stat.h>
95: #include <netiso/iso_pcb.h>
96: #include <netiso/cltp_var.h>
97: #include <netiso/cons.h>
98: #ifdef IncStat
99: #undef IncStat
100: #endif
101: #include <netiso/cons_pcb.h>
102: #include <arpa/inet.h>
1.6 millert 103: #include <limits.h>
1.1 deraadt 104: #include <netdb.h>
105: #include <string.h>
106: #include <stdio.h>
107: #include <stdlib.h>
108: #include "netstat.h"
109:
1.9 millert 110: static void tprintstat(struct tp_stat *, int);
111: static void isonetprint(struct sockaddr_iso *, int);
112: static void hexprint(int, char *, char *);
113: extern void inetprint(struct in_addr *, int, char *);
1.1 deraadt 114:
115: /*
116: * Dump esis stats
117: */
118: void
1.11 deraadt 119: esis_stats(u_long off, char *name)
1.1 deraadt 120: {
121: struct esis_stat esis_stat;
122:
123: if (off == 0 ||
124: kread(off, (char *)&esis_stat, sizeof (struct esis_stat)))
125: return;
126: printf("%s:\n", name);
127: printf("\t%d esh sent, %d esh received\n", esis_stat.es_eshsent,
1.10 deraadt 128: esis_stat.es_eshrcvd);
1.1 deraadt 129: printf("\t%d ish sent, %d ish received\n", esis_stat.es_ishsent,
1.10 deraadt 130: esis_stat.es_ishrcvd);
1.1 deraadt 131: printf("\t%d rd sent, %d rd received\n", esis_stat.es_rdsent,
1.10 deraadt 132: esis_stat.es_rdrcvd);
1.1 deraadt 133: printf("\t%d pdus not sent due to insufficient memory\n",
1.10 deraadt 134: esis_stat.es_nomem);
1.1 deraadt 135: printf("\t%d pdus received with bad checksum\n", esis_stat.es_badcsum);
136: printf("\t%d pdus received with bad version number\n",
1.10 deraadt 137: esis_stat.es_badvers);
1.1 deraadt 138: printf("\t%d pdus received with bad type field\n", esis_stat.es_badtype);
139: printf("\t%d short pdus received\n", esis_stat.es_toosmall);
140: }
141:
142: /*
143: * Dump clnp statistics structure.
144: */
145: void
1.11 deraadt 146: clnp_stats(u_long off, char *name)
1.1 deraadt 147: {
148: struct clnp_stat clnp_stat;
149:
150: if (off == 0 ||
151: kread(off, (char *)&clnp_stat, sizeof (clnp_stat)))
152: return;
153:
154: printf("%s:\n\t%d total packets sent\n", name, clnp_stat.cns_sent);
155: printf("\t%d total fragments sent\n", clnp_stat.cns_fragments);
156: printf("\t%d total packets received\n", clnp_stat.cns_total);
157: printf("\t%d with fixed part of header too small\n",
1.10 deraadt 158: clnp_stat.cns_toosmall);
1.1 deraadt 159: printf("\t%d with header length not reasonable\n", clnp_stat.cns_badhlen);
160: printf("\t%d incorrect checksum%s\n",
1.10 deraadt 161: clnp_stat.cns_badcsum, plural(clnp_stat.cns_badcsum));
1.1 deraadt 162: printf("\t%d with unreasonable address lengths\n", clnp_stat.cns_badaddr);
163: printf("\t%d with forgotten segmentation information\n",
1.10 deraadt 164: clnp_stat.cns_noseg);
1.1 deraadt 165: printf("\t%d with an incorrect protocol identifier\n", clnp_stat.cns_noproto);
166: printf("\t%d with an incorrect version\n", clnp_stat.cns_badvers);
167: printf("\t%d dropped because the ttl has expired\n",
1.10 deraadt 168: clnp_stat.cns_ttlexpired);
1.1 deraadt 169: printf("\t%d clnp cache misses\n", clnp_stat.cns_cachemiss);
170: printf("\t%d clnp congestion experience bits set\n",
1.10 deraadt 171: clnp_stat.cns_congest_set);
1.1 deraadt 172: printf("\t%d clnp congestion experience bits received\n",
1.10 deraadt 173: clnp_stat.cns_congest_rcvd);
1.1 deraadt 174: }
175: /*
176: * Dump CLTP statistics structure.
177: */
178: void
1.11 deraadt 179: cltp_stats(u_long off, char *name)
1.1 deraadt 180: {
181: struct cltpstat cltpstat;
182:
183: if (off == 0 ||
184: kread(off, (char *)&cltpstat, sizeof (cltpstat)))
185: return;
186: printf("%s:\n\t%u incomplete header%s\n", name,
1.10 deraadt 187: cltpstat.cltps_hdrops, plural(cltpstat.cltps_hdrops));
1.1 deraadt 188: printf("\t%u bad data length field%s\n",
1.10 deraadt 189: cltpstat.cltps_badlen, plural(cltpstat.cltps_badlen));
1.1 deraadt 190: printf("\t%u bad checksum%s\n",
1.10 deraadt 191: cltpstat.cltps_badsum, plural(cltpstat.cltps_badsum));
1.1 deraadt 192: }
193:
194: struct tp_pcb tpcb;
195: struct isopcb isopcb;
196: struct socket sockb;
197: union {
198: struct sockaddr_iso siso;
199: char data[128];
200: } laddr, faddr;
201: #define kget(o, p) \
202: (kread((u_long)(o), (char *)&p, sizeof (p)))
203:
204: static int first = 1;
205:
206: /*
207: * Print a summary of connections related to an Internet
208: * protocol. For TP, also give state of connection.
209: * Listening processes (aflag) are suppressed unless the
210: * -a (all) flag is specified.
211: */
212: void
1.11 deraadt 213: iso_protopr(u_long off, char *name)
1.1 deraadt 214: {
215: struct isopcb cb;
1.8 mpech 216: struct isopcb *prev, *next;
1.1 deraadt 217:
218: if (off == 0) {
219: printf("%s control block: symbol not in namelist\n", name);
220: return;
221: }
222: if (strcmp(name, "tp") == 0) {
223: tp_protopr(off, name);
224: return;
225: }
226: if (kread(off, (char *)&cb, sizeof(cb)))
227: return;
228: isopcb = cb;
229: prev = (struct isopcb *)off;
230: if (isopcb.isop_next == (struct isopcb *)off)
231: return;
232: while (isopcb.isop_next != (struct isopcb *)off) {
233: next = isopcb.isop_next;
234: kget(next, isopcb);
235: if (isopcb.isop_prev != prev) {
1.5 millert 236: printf("prev %p next %p isop_prev %p isop_next %p???\n",
1.10 deraadt 237: prev, next, isopcb.isop_prev, isopcb.isop_next);
1.1 deraadt 238: break;
239: }
240: kget(isopcb.isop_socket, sockb);
241: iso_protopr1((u_long)next, 0);
242: putchar('\n');
243: prev = next;
244: }
245: }
246:
247: void
1.11 deraadt 248: iso_protopr1(u_long kern_addr, int istp)
1.1 deraadt 249: {
250: if (first) {
251: printf("Active ISO net connections");
252: if (aflag)
253: printf(" (including servers)");
254: putchar('\n');
255: if (Aflag)
1.6 millert 256: printf("%-*.*s %-5.5s %-6.6s %-6.6s %-*.*s %-*.*s %s\n",
257: PLEN, PLEN, "PCB", "Proto", "Recv-Q",
258: "Send-Q", PLEN, PLEN, "Local Address",
259: PLEN, PLEN, "Foreign Address", "(state)");
260: else
261: printf("%-5.5s %-6.6s %-6.6s %-22.22s %-22.22s %s\n",
262: "Proto", "Recv-Q", "Send-Q",
263: "Local Address", "Foreign Address",
264: "(state)");
1.1 deraadt 265: first = 0;
266: }
267: if (Aflag)
1.6 millert 268: printf("%*p ", PLEN,
269: (sockb.so_pcb ? (void *)sockb.so_pcb : (void *)kern_addr));
1.4 millert 270: printf("%-5.5s %6ld %6ld ", "tp", sockb.so_rcv.sb_cc,
271: sockb.so_snd.sb_cc);
1.1 deraadt 272: if (istp && tpcb.tp_lsuffixlen) {
1.11 deraadt 273: hexprint(tpcb.tp_lsuffixlen, tpcb.tp_lsuffix, "()");
274: printf("\t");
1.1 deraadt 275: } else if (isopcb.isop_laddr == 0)
1.11 deraadt 276: printf("*.*\t");
1.1 deraadt 277: else {
1.10 deraadt 278: if ((char *)isopcb.isop_laddr == ((char *)kern_addr) +
279: _offsetof(struct isopcb, isop_sladdr))
280: laddr.siso = isopcb.isop_sladdr;
281: else
282: kget(isopcb.isop_laddr, laddr);
283: isonetprint((struct sockaddr_iso *)&laddr, 1);
1.1 deraadt 284: }
285: if (istp && tpcb.tp_fsuffixlen) {
1.10 deraadt 286: hexprint(tpcb.tp_fsuffixlen, tpcb.tp_fsuffix, "()");
287: printf("\t");
1.1 deraadt 288: } else if (isopcb.isop_faddr == 0)
289: printf("*.*\t");
290: else {
291: if ((char *)isopcb.isop_faddr == ((char *)kern_addr) +
1.10 deraadt 292: _offsetof(struct isopcb, isop_sfaddr))
1.1 deraadt 293: faddr.siso = isopcb.isop_sfaddr;
294: else
295: kget(isopcb.isop_faddr, faddr);
296: isonetprint((struct sockaddr_iso *)&faddr, 0);
297: }
298: }
299:
300: void
1.11 deraadt 301: tp_protopr(u_long off, char *name)
1.1 deraadt 302: {
303: extern char *tp_sstring[];
304: struct tp_ref *tpr, *tpr_base;
305: struct tp_refinfo tpkerninfo;
306: int size;
307:
308: kget(off, tpkerninfo);
309: size = tpkerninfo.tpr_size * sizeof (*tpr);
310: tpr_base = (struct tp_ref *)malloc(size);
311: if (tpr_base == 0)
312: return;
313: kread((u_long)(tpkerninfo.tpr_base), (char *)tpr_base, size);
314: for (tpr = tpr_base; tpr < tpr_base + tpkerninfo.tpr_size; tpr++) {
315: if (tpr->tpr_pcb == 0)
316: continue;
317: kget(tpr->tpr_pcb, tpcb);
318: if (tpcb.tp_state == ST_ERROR)
1.5 millert 319: printf("undefined tpcb state: %p\n", tpr->tpr_pcb);
1.1 deraadt 320: if (!aflag &&
1.10 deraadt 321: (tpcb.tp_state == TP_LISTENING ||
322: tpcb.tp_state == TP_CLOSED ||
323: tpcb.tp_state == TP_REFWAIT))
1.1 deraadt 324: continue;
325: kget(tpcb.tp_sock, sockb);
1.10 deraadt 326: if (tpcb.tp_npcb)
327: switch (tpcb.tp_netservice) {
1.1 deraadt 328: case IN_CLNS:
329: tp_inproto((u_long)tpkerninfo.tpr_base);
330: break;
331: default:
332: kget(tpcb.tp_npcb, isopcb);
333: iso_protopr1((u_long)tpcb.tp_npcb, 1);
334: break;
335: }
336: if (tpcb.tp_state >= tp_NSTATES)
337: printf(" %d", tpcb.tp_state);
338: else
339: printf(" %-12.12s", tp_sstring[tpcb.tp_state]);
340: putchar('\n');
341: }
342: }
343:
344: void
1.11 deraadt 345: tp_inproto(u_long pcb)
1.1 deraadt 346: {
347: struct inpcb inpcb;
1.10 deraadt 348:
1.1 deraadt 349: kget(tpcb.tp_npcb, inpcb);
350: if (!aflag && inet_lnaof(inpcb.inp_laddr) == INADDR_ANY)
351: return;
352: if (Aflag)
1.4 millert 353: printf("%8lx ", pcb);
354: printf("%-5.5s %6ld %6ld ", "tpip",
1.1 deraadt 355: sockb.so_rcv.sb_cc, sockb.so_snd.sb_cc);
356: inetprint(&inpcb.inp_laddr, inpcb.inp_lport, "tp");
357: inetprint(&inpcb.inp_faddr, inpcb.inp_fport, "tp");
358: }
359:
360: /*
361: * Pretty print an iso address (net address + port).
362: * If the nflag was specified, use numbers instead of names.
363: */
364:
365: #ifdef notdef
366: char *
1.11 deraadt 367: isonetname(struct iso_addr *iso)
1.1 deraadt 368: {
369: struct sockaddr_iso sa;
370: struct iso_hostent *ihe = 0;
371: struct iso_hostent *iso_gethostentrybyaddr();
372: struct iso_hostent *iso_getserventrybytsel();
373: struct iso_hostent Ihe;
374: static char line[80];
375:
376: bzero(line, sizeof(line));
1.10 deraadt 377: if (iso->isoa_afi) {
1.1 deraadt 378: sa.siso_family = AF_ISO;
379: sa.siso_addr = *iso;
380: sa.siso_tsuffix = 0;
381:
1.10 deraadt 382: if (!nflag)
1.1 deraadt 383: ihe = iso_gethostentrybyaddr( &sa, 0, 0 );
1.10 deraadt 384: if (ihe) {
1.1 deraadt 385: Ihe = *ihe;
386: ihe = &Ihe;
1.7 deraadt 387: snprintf(line, sizeof line, "%s", ihe->isoh_hname);
1.1 deraadt 388: } else {
1.7 deraadt 389: snprintf(line, sizeof line, "%s", iso_ntoa(iso));
1.1 deraadt 390: }
391: } else {
1.7 deraadt 392: snprintf(line, sizeof line, "*");
1.1 deraadt 393: }
394: return line;
395: }
396:
397: static void
1.11 deraadt 398: isonetprint(struct iso_addr *iso, char *sufx, u_short sufxlen, int islocal)
1.1 deraadt 399: {
400: struct iso_hostent *iso_getserventrybytsel(), *ihe;
401: struct iso_hostent Ihe;
402: char *line, *cp;
403: int Alen = Aflag?18:22;
404:
1.10 deraadt 405: line = isonetname(iso);
1.3 millert 406: cp = strchr(line, '\0');
1.1 deraadt 407: ihe = (struct iso_hostent *)0;
408:
1.10 deraadt 409: if (islocal)
1.1 deraadt 410: islocal = 20;
411: else
412: islocal = 22 + Alen;
413:
1.10 deraadt 414: if (Aflag)
1.1 deraadt 415: islocal += 10 ;
416:
1.10 deraadt 417: if (!nflag) {
418: if ((cp -line)>10) {
1.1 deraadt 419: cp = line+10;
420: bzero(cp, sizeof(line)-10);
421: }
422: }
423:
424: *cp++ = '.';
1.10 deraadt 425: if (sufxlen) {
426: if (!Aflag && !nflag && (ihe=iso_getserventrybytsel(sufx, sufxlen))) {
1.1 deraadt 427: Ihe = *ihe;
428: ihe = &Ihe;
429: }
1.10 deraadt 430: if (ihe && (strlen(ihe->isoh_aname)>0) ) {
1.7 deraadt 431: snprintf(cp, line + sizeof line - cp, "%s",
432: ihe->isoh_aname);
1.10 deraadt 433: } else {
1.1 deraadt 434: iso_sprinttsel(cp, sufx, sufxlen);
435: }
436: } else
1.7 deraadt 437: snprintf(cp, line + sizeof line - cp, "*");
1.1 deraadt 438:
1.10 deraadt 439: if (strlen(line) > Alen ) {
1.1 deraadt 440: fprintf(stdout, " %s", line);
441: fprintf(stdout, "\n %*.s", islocal+Alen," ");
442: } else {
443: fprintf(stdout, " %-*.*s", Alen, Alen,line);
444: }
445: }
446: #endif
447:
448: #ifdef notdef
449: static void
1.11 deraadt 450: x25_protopr(u_long off, char *name)
1.1 deraadt 451: {
452: static char *xpcb_states[] = {
453: "CLOSED",
454: "LISTENING",
455: "CLOSING",
456: "CONNECTING",
457: "ACKWAIT",
458: "OPEN",
459: };
1.8 mpech 460: struct isopcb *prev, *next;
1.1 deraadt 461: struct x25_pcb xpcb;
462:
463: if (off == 0) {
464: printf("%s control block: symbol not in namelist\n", name);
465: return;
466: }
467: kread(off, &xpcb, sizeof (struct x25_pcb));
468: prev = (struct isopcb *)off;
469: if (xpcb.x_next == (struct isopcb *)off)
470: return;
471: while (xpcb.x_next != (struct isopcb *)off) {
472: next = isopcb.isop_next;
473: kread((u_long)next, &xpcb, sizeof (struct x25_pcb));
474: if (xpcb.x_prev != prev) {
475: printf("???\n");
476: break;
477: }
478: kread((u_long)xpcb.x_socket, &sockb, sizeof (sockb));
479:
480: if (!aflag &&
481: xpcb.x_state == LISTENING ||
482: xpcb.x_state == TP_CLOSED ) {
483: prev = next;
484: continue;
485: }
486: if (first) {
487: printf("Active X25 net connections");
488: if (aflag)
489: printf(" (including servers)");
490: putchar('\n');
491: if (Aflag)
1.6 millert 492: printf("%-*.*s %-5.5s %-6.6s %-6.6s %-*.*s %-*.*s %s\n",
493: PLEN, PLEN, "PCB", "Proto", "Recv-Q",
494: "Send-Q", PLEN, PLEN, "Local Address",
495: PLEN, PLEN, "Foreign Address", "(state)");
496: else
497: printf("%-5.5s %-6.6s %-6.6s %-22.22s %-22.22s %s\n",
498: "Proto", "Recv-Q", "Send-Q",
499: "Local Address", "Foreign Address",
500: "(state)");
1.1 deraadt 501: first = 0;
502: }
503: printf("%-5.5s %6d %6d ", name, sockb.so_rcv.sb_cc,
1.10 deraadt 504: sockb.so_snd.sb_cc);
1.1 deraadt 505: isonetprint(&xpcb.x_laddr.siso_addr, &xpcb.x_lport,
1.10 deraadt 506: sizeof(xpcb.x_lport), 1);
1.1 deraadt 507: isonetprint(&xpcb.x_faddr.siso_addr, &xpcb.x_fport,
1.10 deraadt 508: sizeof(xpcb.x_lport), 0);
1.1 deraadt 509: if (xpcb.x_state < 0 || xpcb.x_state >= x25_NSTATES)
510: printf(" 0x0x0x0x0x0x0x0x0x%x", xpcb.x_state);
511: else
512: printf(" %-12.12s", xpcb_states[xpcb.x_state]);
513: putchar('\n');
514: prev = next;
515: }
516: }
517: #endif
518:
519: struct tp_stat tp_stat;
520:
521: void
1.11 deraadt 522: tp_stats(caddr_t off, char *name)
1.1 deraadt 523: {
524: if (off == 0) {
525: printf("TP not configured\n\n");
526: return;
527: }
528: printf("%s:\n", name);
529: kget(off, tp_stat);
530: tprintstat(&tp_stat, 8);
531: }
532:
533: #define OUT stdout
534:
535: static void
1.11 deraadt 536: tprintstat(struct tp_stat *s, int indent)
1.1 deraadt 537: {
538: fprintf(OUT,
1.10 deraadt 539: "%*sReceiving:\n",indent," ");
540: fprintf(OUT,
541: "\t%*s%ld variable parameter%s ignored\n", indent," ",
542: s->ts_param_ignored ,plural(s->ts_param_ignored));
1.1 deraadt 543: fprintf(OUT,
1.10 deraadt 544: "\t%*s%ld invalid parameter code%s\n", indent, " ",
545: s->ts_inv_pcode ,plural(s->ts_inv_pcode));
1.1 deraadt 546: fprintf(OUT,
1.10 deraadt 547: "\t%*s%ld invalid parameter value%s\n", indent, " ",
548: s->ts_inv_pval ,plural(s->ts_inv_pval));
1.1 deraadt 549: fprintf(OUT,
1.10 deraadt 550: "\t%*s%ld invalid dutype%s\n", indent, " ",
551: s->ts_inv_dutype ,plural(s->ts_inv_dutype));
1.1 deraadt 552: fprintf(OUT,
1.10 deraadt 553: "\t%*s%ld negotiation failure%s\n", indent, " ",
554: s->ts_negotfailed ,plural(s->ts_negotfailed));
1.1 deraadt 555: fprintf(OUT,
1.10 deraadt 556: "\t%*s%ld invalid destination reference%s\n", indent, " ",
557: s->ts_inv_dref ,plural(s->ts_inv_dref));
1.1 deraadt 558: fprintf(OUT,
1.10 deraadt 559: "\t%*s%ld invalid suffix parameter%s\n", indent, " ",
560: s->ts_inv_sufx ,plural(s->ts_inv_sufx));
1.1 deraadt 561: fprintf(OUT,
1.10 deraadt 562: "\t%*s%ld invalid length\n",indent, " ", s->ts_inv_length);
1.1 deraadt 563: fprintf(OUT,
1.10 deraadt 564: "\t%*s%ld invalid checksum%s\n", indent, " ",
565: s->ts_bad_csum ,plural(s->ts_bad_csum));
1.1 deraadt 566: fprintf(OUT,
1.10 deraadt 567: "\t%*s%ld DT%s out of order\n", indent, " ",
568: s->ts_dt_ooo ,plural(s->ts_dt_ooo));
1.1 deraadt 569: fprintf(OUT,
1.10 deraadt 570: "\t%*s%ld DT%s not in window\n", indent, " ",
571: s->ts_dt_niw ,plural(s->ts_dt_niw));
1.1 deraadt 572: fprintf(OUT,
1.10 deraadt 573: "\t%*s%ld duplicate DT%s\n", indent, " ",
574: s->ts_dt_dup ,plural(s->ts_dt_dup));
1.1 deraadt 575: fprintf(OUT,
1.10 deraadt 576: "\t%*s%ld XPD%s not in window\n", indent, " ",
577: s->ts_xpd_niw ,plural(s->ts_xpd_niw));
1.1 deraadt 578: fprintf(OUT,
1.10 deraadt 579: "\t%*s%ld XPD%s w/o credit to stash\n", indent, " ",
580: s->ts_xpd_dup ,plural(s->ts_xpd_dup));
1.1 deraadt 581: fprintf(OUT,
1.10 deraadt 582: "\t%*s%ld time%s local credit reneged\n", indent, " ",
583: s->ts_lcdt_reduced ,plural(s->ts_lcdt_reduced));
1.1 deraadt 584: fprintf(OUT,
1.10 deraadt 585: "\t%*s%ld concatenated TPDU%s\n", indent, " ",
586: s->ts_concat_rcvd ,plural(s->ts_concat_rcvd));
1.1 deraadt 587: fprintf(OUT,
1.10 deraadt 588: "%*sSending:\n", indent, " ");
1.1 deraadt 589: fprintf(OUT,
1.10 deraadt 590: "\t%*s%ld XPD mark%s discarded\n", indent, " ",
591: s->ts_xpdmark_del ,plural(s->ts_xpdmark_del));
1.1 deraadt 592: fprintf(OUT,
1.10 deraadt 593: "\t%*sXPD stopped data flow %ld time%s\n", indent, " ",
594: s->ts_xpd_intheway ,plural(s->ts_xpd_intheway));
1.1 deraadt 595: fprintf(OUT,
1.10 deraadt 596: "\t%*s%ld time%s foreign window closed\n", indent, " ",
597: s->ts_zfcdt ,plural(s->ts_zfcdt));
1.1 deraadt 598: fprintf(OUT,
1.10 deraadt 599: "%*sMiscellaneous:\n", indent, " ");
1.1 deraadt 600: fprintf(OUT,
1.10 deraadt 601: "\t%*s%ld small mbuf%s\n", indent, " ",
602: s->ts_mb_small ,plural(s->ts_mb_small));
1.1 deraadt 603: fprintf(OUT,
1.10 deraadt 604: "\t%*s%ld cluster%s\n", indent, " ",
605: s->ts_mb_cluster, plural(s->ts_mb_cluster));
1.1 deraadt 606: fprintf(OUT,
1.10 deraadt 607: "\t%*s%ld source quench \n",indent, " ",
608: s->ts_quench);
1.1 deraadt 609: fprintf(OUT,
1.10 deraadt 610: "\t%*s%ld dec bit%s\n", indent, " ",
611: s->ts_rcvdecbit, plural(s->ts_rcvdecbit));
1.1 deraadt 612: fprintf(OUT,
1.10 deraadt 613: "\t%*sM:L ( M mbuf chains of length L)\n", indent, " ");
1.1 deraadt 614: {
1.8 mpech 615: int j;
1.1 deraadt 616:
1.4 millert 617: fprintf(OUT, "\t%*s%ld: over 16\n", indent, " ",
1.1 deraadt 618: s->ts_mb_len_distr[0]);
1.10 deraadt 619: for (j=1; j<=8; j++) {
1.1 deraadt 620: fprintf(OUT,
1.10 deraadt 621: "\t%*s%ld: %d\t\t%ld: %d\n", indent, " ",
622: s->ts_mb_len_distr[j],j,
623: s->ts_mb_len_distr[j<<1],j<<1);
1.1 deraadt 624: }
625: }
626: fprintf(OUT,
1.10 deraadt 627: "\t%*s%ld EOT rcvd\n", indent, " ", s->ts_eot_input);
1.1 deraadt 628: fprintf(OUT,
1.10 deraadt 629: "\t%*s%ld EOT sent\n", indent, " ", s->ts_EOT_sent);
1.1 deraadt 630: fprintf(OUT,
1.10 deraadt 631: "\t%*s%ld EOT indication%s\n", indent, " ",
632: s->ts_eot_user ,plural(s->ts_eot_user));
1.1 deraadt 633:
634: fprintf(OUT,
1.10 deraadt 635: "%*sConnections:\n", indent, " ");
1.1 deraadt 636: fprintf(OUT,
1.10 deraadt 637: "\t%*s%ld connection%s used extended format\n", indent, " ",
638: s->ts_xtd_fmt ,plural(s->ts_xtd_fmt));
1.1 deraadt 639: fprintf(OUT,
1.10 deraadt 640: "\t%*s%ld connection%s allowed transport expedited data\n", indent, " ",
641: s->ts_use_txpd ,plural(s->ts_use_txpd));
1.1 deraadt 642: fprintf(OUT,
1.10 deraadt 643: "\t%*s%ld connection%s turned off checksumming\n", indent, " ",
644: s->ts_csum_off ,plural(s->ts_csum_off));
1.1 deraadt 645: fprintf(OUT,
1.10 deraadt 646: "\t%*s%ld connection%s dropped due to retrans limit\n", indent, " ",
647: s->ts_conn_gaveup ,plural(s->ts_conn_gaveup));
1.1 deraadt 648: fprintf(OUT,
1.10 deraadt 649: "\t%*s%ld tp 4 connection%s\n", indent, " ",
650: s->ts_tp4_conn ,plural(s->ts_tp4_conn));
1.1 deraadt 651: fprintf(OUT,
1.10 deraadt 652: "\t%*s%ld tp 0 connection%s\n", indent, " ",
653: s->ts_tp0_conn ,plural(s->ts_tp0_conn));
654: {
1.8 mpech 655: int j;
1.1 deraadt 656: static char *name[]= {
657: "~LOCAL, PDN",
658: "~LOCAL,~PDN",
659: " LOCAL,~PDN",
660: " LOCAL, PDN"
661: };
662:
663: fprintf(OUT,
1.10 deraadt 664: "\n%*sRound trip times, listed in ticks:\n", indent, " ");
1.1 deraadt 665: fprintf(OUT,
1.10 deraadt 666: "\t%*s%11.11s %12.12s | %12.12s | %s\n", indent, " ",
667: "Category", "Smoothed avg", "Deviation", "Deviation/Avg");
1.1 deraadt 668: for (j = 0; j <= 3; j++) {
669: fprintf(OUT,
1.10 deraadt 670: "\t%*s%11.11s: %-11d | %-11d | %-11d | %-11d\n", indent, " ",
671: name[j], s->ts_rtt[j], s->ts_rtt[j],
672: s->ts_rtv[j], s->ts_rtv[j]);
1.1 deraadt 673: }
674: }
675: fprintf(OUT,
1.10 deraadt 676: "\n%*sTpdus RECVD [%ld valid, %3.6f %% of total (%ld); %ld dropped]\n",indent," ",
677: s->ts_tpdu_rcvd ,
678: ((s->ts_pkt_rcvd > 0) ?
679: ((100 * (float)s->ts_tpdu_rcvd)/(float)s->ts_pkt_rcvd) : 0),
680: s->ts_pkt_rcvd,
681: s->ts_recv_drop );
1.1 deraadt 682:
683: fprintf(OUT,
1.10 deraadt 684: "\t%*sDT %6ld AK %6ld DR %4ld CR %4ld \n", indent,
685: " ", s->ts_DT_rcvd, s->ts_AK_rcvd, s->ts_DR_rcvd, s->ts_CR_rcvd);
1.1 deraadt 686: fprintf(OUT,
1.10 deraadt 687: "\t%*sXPD %6ld XAK %6ld DC %4ld CC %4ld ER %4ld\n",
688: indent, " ", s->ts_XPD_rcvd, s->ts_XAK_rcvd, s->ts_DC_rcvd,
689: s->ts_CC_rcvd, s->ts_ER_rcvd);
1.1 deraadt 690: fprintf(OUT,
1.10 deraadt 691: "\n%*sTpdus SENT [%ld total, %ld dropped]\n", indent, " ",
692: s->ts_tpdu_sent, s->ts_send_drop);
1.1 deraadt 693:
694: fprintf(OUT,
1.10 deraadt 695: "\t%*sDT %6ld AK %6ld DR %4ld CR %4ld \n", indent,
696: " ", s->ts_DT_sent, s->ts_AK_sent, s->ts_DR_sent, s->ts_CR_sent);
1.1 deraadt 697: fprintf(OUT,
1.10 deraadt 698: "\t%*sXPD %6ld XAK %6ld DC %4ld CC %4ld ER %4ld\n",
699: indent, " ", s->ts_XPD_sent, s->ts_XAK_sent, s->ts_DC_sent,
700: s->ts_CC_sent, s->ts_ER_sent);
1.1 deraadt 701:
702: fprintf(OUT,
1.10 deraadt 703: "\n%*sRetransmissions:\n", indent, " ");
1.1 deraadt 704: #define PERCENT(X,Y) (((Y)>0)?((100 *(float)(X)) / (float) (Y)):0)
705:
706: fprintf(OUT,
1.10 deraadt 707: "\t%*sCR %6ld CC %6ld DR %6ld \n", indent, " ",
708: s->ts_retrans_cr, s->ts_retrans_cc, s->ts_retrans_dr);
1.1 deraadt 709: fprintf(OUT,
1.10 deraadt 710: "\t%*sDT %6ld (%5.2f%%)\n", indent, " ",
711: s->ts_retrans_dt,
712: PERCENT(s->ts_retrans_dt, s->ts_DT_sent));
1.1 deraadt 713: fprintf(OUT,
1.10 deraadt 714: "\t%*sXPD %6ld (%5.2f%%)\n", indent, " ",
715: s->ts_retrans_xpd,
716: PERCENT(s->ts_retrans_xpd, s->ts_XPD_sent));
1.1 deraadt 717:
718: fprintf(OUT,
1.10 deraadt 719: "\n%*sE Timers: [%6ld ticks]\n", indent, " ", s->ts_Eticks);
1.1 deraadt 720: fprintf(OUT,
1.10 deraadt 721: "%*s%6ld timer%s set \t%6ld timer%s expired \t%6ld timer%s cancelled\n",indent, " ",
722: s->ts_Eset ,plural(s->ts_Eset),
723: s->ts_Eexpired ,plural(s->ts_Eexpired),
724: s->ts_Ecan_act ,plural(s->ts_Ecan_act));
1.1 deraadt 725:
726: fprintf(OUT,
1.10 deraadt 727: "\n%*sC Timers: [%6ld ticks]\n", indent, " ",s->ts_Cticks);
1.1 deraadt 728: fprintf(OUT,
1.10 deraadt 729: "%*s%6ld timer%s set \t%6ld timer%s expired \t%6ld timer%s cancelled\n",
730: indent, " ",
731: s->ts_Cset ,plural(s->ts_Cset),
732: s->ts_Cexpired ,plural(s->ts_Cexpired),
733: s->ts_Ccan_act ,plural(s->ts_Ccan_act));
1.1 deraadt 734: fprintf(OUT,
1.10 deraadt 735: "%*s%6ld inactive timer%s cancelled\n", indent, " ",
736: s->ts_Ccan_inact ,plural(s->ts_Ccan_inact));
1.1 deraadt 737:
738: fprintf(OUT,
1.10 deraadt 739: "\n%*sPathological debugging activity:\n", indent, " ");
1.1 deraadt 740: fprintf(OUT,
1.10 deraadt 741: "\t%*s%6ld CC%s sent to zero dref\n", indent, " ",
742: s->ts_zdebug ,plural(s->ts_zdebug));
1.1 deraadt 743: /* SAME LINE AS ABOVE */
744: fprintf(OUT,
1.10 deraadt 745: "\t%*s%6ld random DT%s dropped\n", indent, " ",
746: s->ts_ydebug ,plural(s->ts_ydebug));
1.1 deraadt 747: fprintf(OUT,
1.10 deraadt 748: "\t%*s%6ld illegally large XPD TPDU%s\n", indent, " ",
749: s->ts_vdebug ,plural(s->ts_vdebug));
1.1 deraadt 750: fprintf(OUT,
1.10 deraadt 751: "\t%*s%6ld faked reneging of cdt\n", indent, " ",
752: s->ts_ldebug );
1.1 deraadt 753:
754: fprintf(OUT,
1.10 deraadt 755: "\n%*sACK reasons:\n", indent, " ");
1.4 millert 756: fprintf(OUT, "\t%*s%6ld not acked immediately\n", indent, " ",
1.10 deraadt 757: s->ts_ackreason[_ACK_DONT_] );
1.4 millert 758: fprintf(OUT, "\t%*s%6ld strategy==each\n", indent, " ",
1.10 deraadt 759: s->ts_ackreason[_ACK_STRAT_EACH_] );
1.4 millert 760: fprintf(OUT, "\t%*s%6ld strategy==fullwindow\n", indent, " ",
1.10 deraadt 761: s->ts_ackreason[_ACK_STRAT_FULLWIN_] );
1.4 millert 762: fprintf(OUT, "\t%*s%6ld duplicate DT\n", indent, " ",
1.10 deraadt 763: s->ts_ackreason[_ACK_DUP_] );
1.4 millert 764: fprintf(OUT, "\t%*s%6ld EOTSDU\n", indent, " ",
1.10 deraadt 765: s->ts_ackreason[_ACK_EOT_] );
1.4 millert 766: fprintf(OUT, "\t%*s%6ld reordered DT\n", indent, " ",
1.10 deraadt 767: s->ts_ackreason[_ACK_REORDER_] );
1.4 millert 768: fprintf(OUT, "\t%*s%6ld user rcvd\n", indent, " ",
1.10 deraadt 769: s->ts_ackreason[_ACK_USRRCV_] );
1.4 millert 770: fprintf(OUT, "\t%*s%6ld fcc reqd\n", indent, " ",
1.10 deraadt 771: s->ts_ackreason[_ACK_FCC_] );
1.1 deraadt 772: }
773: #ifndef SSEL
774: #define SSEL(s) ((s)->siso_tlen + TSEL(s))
775: #define PSEL(s) ((s)->siso_slen + SSEL(s))
776: #endif
777:
778: static void
1.11 deraadt 779: isonetprint(struct sockaddr_iso *siso, int islocal)
1.1 deraadt 780: {
781: hexprint(siso->siso_nlen, siso->siso_addr.isoa_genaddr, "{}");
782: if (siso->siso_tlen || siso->siso_slen || siso->siso_plen)
783: hexprint(siso->siso_tlen, TSEL(siso), "()");
784: if (siso->siso_slen || siso->siso_plen)
785: hexprint(siso->siso_slen, SSEL(siso), "[]");
786: if (siso->siso_plen)
787: hexprint(siso->siso_plen, PSEL(siso), "<>");
788: putchar(' ');
789: }
790:
791: static char hexlist[] = "0123456789abcdef", obuf[128];
792:
793: static void
1.11 deraadt 794: hexprint(int n, char *buf, char *delim)
1.1 deraadt 795: {
1.8 mpech 796: u_char *in = (u_char *)buf, *top = in + n;
797: char *out = obuf;
798: int i;
1.1 deraadt 799:
800: if (n == 0)
801: return;
802: while (in < top) {
803: i = *in++;
804: *out++ = '.';
805: if (i > 0xf) {
806: out[1] = hexlist[i & 0xf];
807: i >>= 4;
808: out[0] = hexlist[i];
809: out += 2;
810: } else
811: *out++ = hexlist[i];
812: }
813: *obuf = *delim; *out++ = delim[1]; *out = 0;
814: printf("%s", obuf);
815: }