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