Annotation of src/usr.bin/netstat/iso.c, Revision 1.6
1.6 ! millert 1: /* $OpenBSD: iso.c,v 1.5 1997/06/29 20:52:41 millert 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.6 ! millert 41: static char *rcsid = "$OpenBSD: iso.c,v 1.5 1997/06/29 20:52:41 millert 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:
114: static void tprintstat __P((struct tp_stat *, int));
115: static void isonetprint __P((struct sockaddr_iso *, int));
116: static void hexprint __P((int, char *, char *));
117: extern void inetprint __P((struct in_addr *, int, char *));
118:
119: /*
120: * Dump esis stats
121: */
122: void
123: esis_stats(off, name)
124: u_long off;
125: char *name;
126: {
127: struct esis_stat esis_stat;
128:
129: if (off == 0 ||
130: kread(off, (char *)&esis_stat, sizeof (struct esis_stat)))
131: return;
132: printf("%s:\n", name);
133: printf("\t%d esh sent, %d esh received\n", esis_stat.es_eshsent,
134: esis_stat.es_eshrcvd);
135: printf("\t%d ish sent, %d ish received\n", esis_stat.es_ishsent,
136: esis_stat.es_ishrcvd);
137: printf("\t%d rd sent, %d rd received\n", esis_stat.es_rdsent,
138: esis_stat.es_rdrcvd);
139: printf("\t%d pdus not sent due to insufficient memory\n",
140: esis_stat.es_nomem);
141: printf("\t%d pdus received with bad checksum\n", esis_stat.es_badcsum);
142: printf("\t%d pdus received with bad version number\n",
143: esis_stat.es_badvers);
144: printf("\t%d pdus received with bad type field\n", esis_stat.es_badtype);
145: printf("\t%d short pdus received\n", esis_stat.es_toosmall);
146: }
147:
148: /*
149: * Dump clnp statistics structure.
150: */
151: void
152: clnp_stats(off, name)
153: u_long off;
154: char *name;
155: {
156: struct clnp_stat clnp_stat;
157:
158: if (off == 0 ||
159: kread(off, (char *)&clnp_stat, sizeof (clnp_stat)))
160: return;
161:
162: printf("%s:\n\t%d total packets sent\n", name, clnp_stat.cns_sent);
163: printf("\t%d total fragments sent\n", clnp_stat.cns_fragments);
164: printf("\t%d total packets received\n", clnp_stat.cns_total);
165: printf("\t%d with fixed part of header too small\n",
166: clnp_stat.cns_toosmall);
167: printf("\t%d with header length not reasonable\n", clnp_stat.cns_badhlen);
168: printf("\t%d incorrect checksum%s\n",
169: clnp_stat.cns_badcsum, plural(clnp_stat.cns_badcsum));
170: printf("\t%d with unreasonable address lengths\n", clnp_stat.cns_badaddr);
171: printf("\t%d with forgotten segmentation information\n",
172: clnp_stat.cns_noseg);
173: printf("\t%d with an incorrect protocol identifier\n", clnp_stat.cns_noproto);
174: printf("\t%d with an incorrect version\n", clnp_stat.cns_badvers);
175: printf("\t%d dropped because the ttl has expired\n",
176: clnp_stat.cns_ttlexpired);
177: printf("\t%d clnp cache misses\n", clnp_stat.cns_cachemiss);
178: printf("\t%d clnp congestion experience bits set\n",
179: clnp_stat.cns_congest_set);
180: printf("\t%d clnp congestion experience bits received\n",
181: clnp_stat.cns_congest_rcvd);
182: }
183: /*
184: * Dump CLTP statistics structure.
185: */
186: void
187: cltp_stats(off, name)
188: u_long off;
189: char *name;
190: {
191: struct cltpstat cltpstat;
192:
193: if (off == 0 ||
194: kread(off, (char *)&cltpstat, sizeof (cltpstat)))
195: return;
196: printf("%s:\n\t%u incomplete header%s\n", name,
197: cltpstat.cltps_hdrops, plural(cltpstat.cltps_hdrops));
198: printf("\t%u bad data length field%s\n",
199: cltpstat.cltps_badlen, plural(cltpstat.cltps_badlen));
200: printf("\t%u bad checksum%s\n",
201: cltpstat.cltps_badsum, plural(cltpstat.cltps_badsum));
202: }
203:
204: struct tp_pcb tpcb;
205: struct isopcb isopcb;
206: struct socket sockb;
207: union {
208: struct sockaddr_iso siso;
209: char data[128];
210: } laddr, faddr;
211: #define kget(o, p) \
212: (kread((u_long)(o), (char *)&p, sizeof (p)))
213:
214: static int first = 1;
215:
216: /*
217: * Print a summary of connections related to an Internet
218: * protocol. For TP, also give state of connection.
219: * Listening processes (aflag) are suppressed unless the
220: * -a (all) flag is specified.
221: */
222: void
223: iso_protopr(off, name)
224: u_long off;
225: char *name;
226: {
227: struct isopcb cb;
228: register struct isopcb *prev, *next;
229:
230: if (off == 0) {
231: printf("%s control block: symbol not in namelist\n", name);
232: return;
233: }
234: if (strcmp(name, "tp") == 0) {
235: tp_protopr(off, name);
236: return;
237: }
238: if (kread(off, (char *)&cb, sizeof(cb)))
239: return;
240: isopcb = cb;
241: prev = (struct isopcb *)off;
242: if (isopcb.isop_next == (struct isopcb *)off)
243: return;
244: while (isopcb.isop_next != (struct isopcb *)off) {
245: next = isopcb.isop_next;
246: kget(next, isopcb);
247: if (isopcb.isop_prev != prev) {
1.5 millert 248: printf("prev %p next %p isop_prev %p isop_next %p???\n",
1.1 deraadt 249: prev, next, isopcb.isop_prev, isopcb.isop_next);
250: break;
251: }
252: kget(isopcb.isop_socket, sockb);
253: iso_protopr1((u_long)next, 0);
254: putchar('\n');
255: prev = next;
256: }
257: }
258:
259: void
260: iso_protopr1(kern_addr, istp)
261: u_long kern_addr;
262: int istp;
263: {
264: if (first) {
265: printf("Active ISO net connections");
266: if (aflag)
267: printf(" (including servers)");
268: putchar('\n');
269: if (Aflag)
1.6 ! millert 270: printf("%-*.*s %-5.5s %-6.6s %-6.6s %-*.*s %-*.*s %s\n",
! 271: PLEN, PLEN, "PCB", "Proto", "Recv-Q",
! 272: "Send-Q", PLEN, PLEN, "Local Address",
! 273: PLEN, PLEN, "Foreign Address", "(state)");
! 274: else
! 275: printf("%-5.5s %-6.6s %-6.6s %-22.22s %-22.22s %s\n",
! 276: "Proto", "Recv-Q", "Send-Q",
! 277: "Local Address", "Foreign Address",
! 278: "(state)");
1.1 deraadt 279: first = 0;
280: }
281: if (Aflag)
1.6 ! millert 282: printf("%*p ", PLEN,
! 283: (sockb.so_pcb ? (void *)sockb.so_pcb : (void *)kern_addr));
1.4 millert 284: printf("%-5.5s %6ld %6ld ", "tp", sockb.so_rcv.sb_cc,
285: sockb.so_snd.sb_cc);
1.1 deraadt 286: if (istp && tpcb.tp_lsuffixlen) {
287: hexprint(tpcb.tp_lsuffixlen, tpcb.tp_lsuffix, "()");
288: printf("\t");
289: } else if (isopcb.isop_laddr == 0)
290: printf("*.*\t");
291: else {
292: if ((char *)isopcb.isop_laddr == ((char *)kern_addr) +
293: _offsetof(struct isopcb, isop_sladdr))
294: laddr.siso = isopcb.isop_sladdr;
295: else
296: kget(isopcb.isop_laddr, laddr);
297: isonetprint((struct sockaddr_iso *)&laddr, 1);
298: }
299: if (istp && tpcb.tp_fsuffixlen) {
300: hexprint(tpcb.tp_fsuffixlen, tpcb.tp_fsuffix, "()");
301: printf("\t");
302: } else if (isopcb.isop_faddr == 0)
303: printf("*.*\t");
304: else {
305: if ((char *)isopcb.isop_faddr == ((char *)kern_addr) +
306: _offsetof(struct isopcb, isop_sfaddr))
307: faddr.siso = isopcb.isop_sfaddr;
308: else
309: kget(isopcb.isop_faddr, faddr);
310: isonetprint((struct sockaddr_iso *)&faddr, 0);
311: }
312: }
313:
314: void
315: tp_protopr(off, name)
316: u_long off;
317: char *name;
318: {
319: extern char *tp_sstring[];
320: struct tp_ref *tpr, *tpr_base;
321: struct tp_refinfo tpkerninfo;
322: int size;
323:
324: kget(off, tpkerninfo);
325: size = tpkerninfo.tpr_size * sizeof (*tpr);
326: tpr_base = (struct tp_ref *)malloc(size);
327: if (tpr_base == 0)
328: return;
329: kread((u_long)(tpkerninfo.tpr_base), (char *)tpr_base, size);
330: for (tpr = tpr_base; tpr < tpr_base + tpkerninfo.tpr_size; tpr++) {
331: if (tpr->tpr_pcb == 0)
332: continue;
333: kget(tpr->tpr_pcb, tpcb);
334: if (tpcb.tp_state == ST_ERROR)
1.5 millert 335: printf("undefined tpcb state: %p\n", tpr->tpr_pcb);
1.1 deraadt 336: if (!aflag &&
337: (tpcb.tp_state == TP_LISTENING ||
338: tpcb.tp_state == TP_CLOSED ||
339: tpcb.tp_state == TP_REFWAIT)) {
340: continue;
341: }
342: kget(tpcb.tp_sock, sockb);
343: if (tpcb.tp_npcb) switch(tpcb.tp_netservice) {
344: case IN_CLNS:
345: tp_inproto((u_long)tpkerninfo.tpr_base);
346: break;
347: default:
348: kget(tpcb.tp_npcb, isopcb);
349: iso_protopr1((u_long)tpcb.tp_npcb, 1);
350: break;
351: }
352: if (tpcb.tp_state >= tp_NSTATES)
353: printf(" %d", tpcb.tp_state);
354: else
355: printf(" %-12.12s", tp_sstring[tpcb.tp_state]);
356: putchar('\n');
357: }
358: }
359:
360: void
361: tp_inproto(pcb)
362: u_long pcb;
363: {
364: struct inpcb inpcb;
365: kget(tpcb.tp_npcb, inpcb);
366: if (!aflag && inet_lnaof(inpcb.inp_laddr) == INADDR_ANY)
367: return;
368: if (Aflag)
1.4 millert 369: printf("%8lx ", pcb);
370: printf("%-5.5s %6ld %6ld ", "tpip",
1.1 deraadt 371: sockb.so_rcv.sb_cc, sockb.so_snd.sb_cc);
372: inetprint(&inpcb.inp_laddr, inpcb.inp_lport, "tp");
373: inetprint(&inpcb.inp_faddr, inpcb.inp_fport, "tp");
374: }
375:
376: /*
377: * Pretty print an iso address (net address + port).
378: * If the nflag was specified, use numbers instead of names.
379: */
380:
381: #ifdef notdef
382: char *
383: isonetname(iso)
384: register struct iso_addr *iso;
385: {
386: struct sockaddr_iso sa;
387: struct iso_hostent *ihe = 0;
388: struct iso_hostent *iso_gethostentrybyaddr();
389: struct iso_hostent *iso_getserventrybytsel();
390: struct iso_hostent Ihe;
391: static char line[80];
392:
393: bzero(line, sizeof(line));
394: if( iso->isoa_afi ) {
395: sa.siso_family = AF_ISO;
396: sa.siso_addr = *iso;
397: sa.siso_tsuffix = 0;
398:
399: if (!nflag )
400: ihe = iso_gethostentrybyaddr( &sa, 0, 0 );
401: if( ihe ) {
402: Ihe = *ihe;
403: ihe = &Ihe;
404: sprintf(line, "%s", ihe->isoh_hname);
405: } else {
406: sprintf(line, "%s", iso_ntoa(iso));
407: }
408: } else {
409: sprintf(line, "*");
410: }
411: return line;
412: }
413:
414: static void
415: isonetprint(iso, sufx, sufxlen, islocal)
416: register struct iso_addr *iso;
417: char *sufx;
418: u_short sufxlen;
419: int islocal;
420: {
421: struct iso_hostent *iso_getserventrybytsel(), *ihe;
422: struct iso_hostent Ihe;
423: char *line, *cp;
424: int Alen = Aflag?18:22;
425:
426: line = isonetname(iso);
1.3 millert 427: cp = strchr(line, '\0');
1.1 deraadt 428: ihe = (struct iso_hostent *)0;
429:
430: if( islocal )
431: islocal = 20;
432: else
433: islocal = 22 + Alen;
434:
435: if(Aflag)
436: islocal += 10 ;
437:
438: if(!nflag) {
439: if( (cp -line)>10 ) {
440: cp = line+10;
441: bzero(cp, sizeof(line)-10);
442: }
443: }
444:
445: *cp++ = '.';
446: if(sufxlen) {
447: if( !Aflag && !nflag && (ihe=iso_getserventrybytsel(sufx, sufxlen))) {
448: Ihe = *ihe;
449: ihe = &Ihe;
450: }
451: if( ihe && (strlen(ihe->isoh_aname)>0) ) {
452: sprintf(cp, "%s", ihe->isoh_aname);
453: } else {
454: iso_sprinttsel(cp, sufx, sufxlen);
455: }
456: } else
457: sprintf(cp, "*");
458: /*
459: fprintf(stdout, Aflag?" %-18.18s":" %-22.22s", line);
460: */
461:
462: if( strlen(line) > Alen ) {
463: fprintf(stdout, " %s", line);
464: fprintf(stdout, "\n %*.s", islocal+Alen," ");
465: } else {
466: fprintf(stdout, " %-*.*s", Alen, Alen,line);
467: }
468: }
469: #endif
470:
471: #ifdef notdef
472: static void
473: x25_protopr(off, name)
474: u_long off;
475: char *name;
476: {
477: static char *xpcb_states[] = {
478: "CLOSED",
479: "LISTENING",
480: "CLOSING",
481: "CONNECTING",
482: "ACKWAIT",
483: "OPEN",
484: };
485: register struct isopcb *prev, *next;
486: struct x25_pcb xpcb;
487:
488: if (off == 0) {
489: printf("%s control block: symbol not in namelist\n", name);
490: return;
491: }
492: kread(off, &xpcb, sizeof (struct x25_pcb));
493: prev = (struct isopcb *)off;
494: if (xpcb.x_next == (struct isopcb *)off)
495: return;
496: while (xpcb.x_next != (struct isopcb *)off) {
497: next = isopcb.isop_next;
498: kread((u_long)next, &xpcb, sizeof (struct x25_pcb));
499: if (xpcb.x_prev != prev) {
500: printf("???\n");
501: break;
502: }
503: kread((u_long)xpcb.x_socket, &sockb, sizeof (sockb));
504:
505: if (!aflag &&
506: xpcb.x_state == LISTENING ||
507: xpcb.x_state == TP_CLOSED ) {
508: prev = next;
509: continue;
510: }
511: if (first) {
512: printf("Active X25 net connections");
513: if (aflag)
514: printf(" (including servers)");
515: putchar('\n');
516: if (Aflag)
1.6 ! millert 517: printf("%-*.*s %-5.5s %-6.6s %-6.6s %-*.*s %-*.*s %s\n",
! 518: PLEN, PLEN, "PCB", "Proto", "Recv-Q",
! 519: "Send-Q", PLEN, PLEN, "Local Address",
! 520: PLEN, PLEN, "Foreign Address", "(state)");
! 521: else
! 522: printf("%-5.5s %-6.6s %-6.6s %-22.22s %-22.22s %s\n",
! 523: "Proto", "Recv-Q", "Send-Q",
! 524: "Local Address", "Foreign Address",
! 525: "(state)");
1.1 deraadt 526: first = 0;
527: }
528: printf("%-5.5s %6d %6d ", name, sockb.so_rcv.sb_cc,
529: sockb.so_snd.sb_cc);
530: isonetprint(&xpcb.x_laddr.siso_addr, &xpcb.x_lport,
531: sizeof(xpcb.x_lport), 1);
532: isonetprint(&xpcb.x_faddr.siso_addr, &xpcb.x_fport,
533: sizeof(xpcb.x_lport), 0);
534: if (xpcb.x_state < 0 || xpcb.x_state >= x25_NSTATES)
535: printf(" 0x0x0x0x0x0x0x0x0x%x", xpcb.x_state);
536: else
537: printf(" %-12.12s", xpcb_states[xpcb.x_state]);
538: putchar('\n');
539: prev = next;
540: }
541: }
542: #endif
543:
544: struct tp_stat tp_stat;
545:
546: void
547: tp_stats(off, name)
548: caddr_t off, name;
549: {
550: if (off == 0) {
551: printf("TP not configured\n\n");
552: return;
553: }
554: printf("%s:\n", name);
555: kget(off, tp_stat);
556: tprintstat(&tp_stat, 8);
557: }
558:
559: #define OUT stdout
560:
561: static void
562: tprintstat(s, indent)
563: register struct tp_stat *s;
564: int indent;
565: {
566: fprintf(OUT,
567: "%*sReceiving:\n",indent," ");
568: fprintf(OUT,
1.4 millert 569: "\t%*s%ld variable parameter%s ignored\n", indent," ",
1.1 deraadt 570: s->ts_param_ignored ,plural(s->ts_param_ignored));
571: fprintf(OUT,
1.4 millert 572: "\t%*s%ld invalid parameter code%s\n", indent, " ",
1.1 deraadt 573: s->ts_inv_pcode ,plural(s->ts_inv_pcode));
574: fprintf(OUT,
1.4 millert 575: "\t%*s%ld invalid parameter value%s\n", indent, " ",
1.1 deraadt 576: s->ts_inv_pval ,plural(s->ts_inv_pval));
577: fprintf(OUT,
1.4 millert 578: "\t%*s%ld invalid dutype%s\n", indent, " ",
1.1 deraadt 579: s->ts_inv_dutype ,plural(s->ts_inv_dutype));
580: fprintf(OUT,
1.4 millert 581: "\t%*s%ld negotiation failure%s\n", indent, " ",
1.1 deraadt 582: s->ts_negotfailed ,plural(s->ts_negotfailed));
583: fprintf(OUT,
1.4 millert 584: "\t%*s%ld invalid destination reference%s\n", indent, " ",
1.1 deraadt 585: s->ts_inv_dref ,plural(s->ts_inv_dref));
586: fprintf(OUT,
1.4 millert 587: "\t%*s%ld invalid suffix parameter%s\n", indent, " ",
1.1 deraadt 588: s->ts_inv_sufx ,plural(s->ts_inv_sufx));
589: fprintf(OUT,
1.4 millert 590: "\t%*s%ld invalid length\n",indent, " ", s->ts_inv_length);
1.1 deraadt 591: fprintf(OUT,
1.4 millert 592: "\t%*s%ld invalid checksum%s\n", indent, " ",
1.1 deraadt 593: s->ts_bad_csum ,plural(s->ts_bad_csum));
594: fprintf(OUT,
1.4 millert 595: "\t%*s%ld DT%s out of order\n", indent, " ",
1.1 deraadt 596: s->ts_dt_ooo ,plural(s->ts_dt_ooo));
597: fprintf(OUT,
1.4 millert 598: "\t%*s%ld DT%s not in window\n", indent, " ",
1.1 deraadt 599: s->ts_dt_niw ,plural(s->ts_dt_niw));
600: fprintf(OUT,
1.4 millert 601: "\t%*s%ld duplicate DT%s\n", indent, " ",
1.1 deraadt 602: s->ts_dt_dup ,plural(s->ts_dt_dup));
603: fprintf(OUT,
1.4 millert 604: "\t%*s%ld XPD%s not in window\n", indent, " ",
1.1 deraadt 605: s->ts_xpd_niw ,plural(s->ts_xpd_niw));
606: fprintf(OUT,
1.4 millert 607: "\t%*s%ld XPD%s w/o credit to stash\n", indent, " ",
1.1 deraadt 608: s->ts_xpd_dup ,plural(s->ts_xpd_dup));
609: fprintf(OUT,
1.4 millert 610: "\t%*s%ld time%s local credit reneged\n", indent, " ",
1.1 deraadt 611: s->ts_lcdt_reduced ,plural(s->ts_lcdt_reduced));
612: fprintf(OUT,
1.4 millert 613: "\t%*s%ld concatenated TPDU%s\n", indent, " ",
1.1 deraadt 614: s->ts_concat_rcvd ,plural(s->ts_concat_rcvd));
615: fprintf(OUT,
616: "%*sSending:\n", indent, " ");
617: fprintf(OUT,
1.4 millert 618: "\t%*s%ld XPD mark%s discarded\n", indent, " ",
1.1 deraadt 619: s->ts_xpdmark_del ,plural(s->ts_xpdmark_del));
620: fprintf(OUT,
1.4 millert 621: "\t%*sXPD stopped data flow %ld time%s\n", indent, " ",
1.1 deraadt 622: s->ts_xpd_intheway ,plural(s->ts_xpd_intheway));
623: fprintf(OUT,
1.4 millert 624: "\t%*s%ld time%s foreign window closed\n", indent, " ",
1.1 deraadt 625: s->ts_zfcdt ,plural(s->ts_zfcdt));
626: fprintf(OUT,
627: "%*sMiscellaneous:\n", indent, " ");
628: fprintf(OUT,
1.4 millert 629: "\t%*s%ld small mbuf%s\n", indent, " ",
1.1 deraadt 630: s->ts_mb_small ,plural(s->ts_mb_small));
631: fprintf(OUT,
1.4 millert 632: "\t%*s%ld cluster%s\n", indent, " ",
1.1 deraadt 633: s->ts_mb_cluster, plural(s->ts_mb_cluster));
634: fprintf(OUT,
1.4 millert 635: "\t%*s%ld source quench \n",indent, " ",
1.1 deraadt 636: s->ts_quench);
637: fprintf(OUT,
1.4 millert 638: "\t%*s%ld dec bit%s\n", indent, " ",
1.1 deraadt 639: s->ts_rcvdecbit, plural(s->ts_rcvdecbit));
640: fprintf(OUT,
641: "\t%*sM:L ( M mbuf chains of length L)\n", indent, " ");
642: {
643: register int j;
644:
1.4 millert 645: fprintf(OUT, "\t%*s%ld: over 16\n", indent, " ",
1.1 deraadt 646: s->ts_mb_len_distr[0]);
647: for( j=1; j<=8; j++) {
648: fprintf(OUT,
1.4 millert 649: "\t%*s%ld: %d\t\t%ld: %d\n", indent, " ",
1.1 deraadt 650: s->ts_mb_len_distr[j],j,
651: s->ts_mb_len_distr[j<<1],j<<1
652: );
653: }
654: }
655: fprintf(OUT,
1.4 millert 656: "\t%*s%ld EOT rcvd\n", indent, " ", s->ts_eot_input);
1.1 deraadt 657: fprintf(OUT,
1.4 millert 658: "\t%*s%ld EOT sent\n", indent, " ", s->ts_EOT_sent);
1.1 deraadt 659: fprintf(OUT,
1.4 millert 660: "\t%*s%ld EOT indication%s\n", indent, " ",
1.1 deraadt 661: s->ts_eot_user ,plural(s->ts_eot_user));
662:
663: fprintf(OUT,
664: "%*sConnections:\n", indent, " ");
665: fprintf(OUT,
1.4 millert 666: "\t%*s%ld connection%s used extended format\n", indent, " ",
1.1 deraadt 667: s->ts_xtd_fmt ,plural(s->ts_xtd_fmt));
668: fprintf(OUT,
1.4 millert 669: "\t%*s%ld connection%s allowed transport expedited data\n", indent, " ",
1.1 deraadt 670: s->ts_use_txpd ,plural(s->ts_use_txpd));
671: fprintf(OUT,
1.4 millert 672: "\t%*s%ld connection%s turned off checksumming\n", indent, " ",
1.1 deraadt 673: s->ts_csum_off ,plural(s->ts_csum_off));
674: fprintf(OUT,
1.4 millert 675: "\t%*s%ld connection%s dropped due to retrans limit\n", indent, " ",
1.1 deraadt 676: s->ts_conn_gaveup ,plural(s->ts_conn_gaveup));
677: fprintf(OUT,
1.4 millert 678: "\t%*s%ld tp 4 connection%s\n", indent, " ",
1.1 deraadt 679: s->ts_tp4_conn ,plural(s->ts_tp4_conn));
680: fprintf(OUT,
1.4 millert 681: "\t%*s%ld tp 0 connection%s\n", indent, " ",
1.1 deraadt 682: s->ts_tp0_conn ,plural(s->ts_tp0_conn));
683: {
684: register int j;
685: static char *name[]= {
686: "~LOCAL, PDN",
687: "~LOCAL,~PDN",
688: " LOCAL,~PDN",
689: " LOCAL, PDN"
690: };
691:
692: fprintf(OUT,
693: "\n%*sRound trip times, listed in ticks:\n", indent, " ");
694: fprintf(OUT,
695: "\t%*s%11.11s %12.12s | %12.12s | %s\n", indent, " ",
696: "Category",
697: "Smoothed avg", "Deviation", "Deviation/Avg");
698: for (j = 0; j <= 3; j++) {
699: fprintf(OUT,
700: "\t%*s%11.11s: %-11d | %-11d | %-11d | %-11d\n", indent, " ",
701: name[j],
702: s->ts_rtt[j],
703: s->ts_rtt[j],
704: s->ts_rtv[j],
705: s->ts_rtv[j]);
706: }
707: }
708: fprintf(OUT,
1.4 millert 709: "\n%*sTpdus RECVD [%ld valid, %3.6f %% of total (%ld); %ld dropped]\n",indent," ",
1.1 deraadt 710: s->ts_tpdu_rcvd ,
711: ((s->ts_pkt_rcvd > 0) ?
712: ((100 * (float)s->ts_tpdu_rcvd)/(float)s->ts_pkt_rcvd)
713: : 0),
714: s->ts_pkt_rcvd,
715: s->ts_recv_drop );
716:
717: fprintf(OUT,
1.4 millert 718: "\t%*sDT %6ld AK %6ld DR %4ld CR %4ld \n", indent,
719: " ", s->ts_DT_rcvd, s->ts_AK_rcvd, s->ts_DR_rcvd, s->ts_CR_rcvd);
1.1 deraadt 720: fprintf(OUT,
1.4 millert 721: "\t%*sXPD %6ld XAK %6ld DC %4ld CC %4ld ER %4ld\n",
722: indent, " ", s->ts_XPD_rcvd, s->ts_XAK_rcvd, s->ts_DC_rcvd,
723: s->ts_CC_rcvd, s->ts_ER_rcvd);
1.1 deraadt 724: fprintf(OUT,
1.4 millert 725: "\n%*sTpdus SENT [%ld total, %ld dropped]\n", indent, " ",
1.1 deraadt 726: s->ts_tpdu_sent, s->ts_send_drop);
727:
728: fprintf(OUT,
1.4 millert 729: "\t%*sDT %6ld AK %6ld DR %4ld CR %4ld \n", indent,
730: " ", s->ts_DT_sent, s->ts_AK_sent, s->ts_DR_sent, s->ts_CR_sent);
1.1 deraadt 731: fprintf(OUT,
1.4 millert 732: "\t%*sXPD %6ld XAK %6ld DC %4ld CC %4ld ER %4ld\n",
733: indent, " ", s->ts_XPD_sent, s->ts_XAK_sent, s->ts_DC_sent,
734: s->ts_CC_sent, s->ts_ER_sent);
1.1 deraadt 735:
736: fprintf(OUT,
737: "\n%*sRetransmissions:\n", indent, " ");
738: #define PERCENT(X,Y) (((Y)>0)?((100 *(float)(X)) / (float) (Y)):0)
739:
740: fprintf(OUT,
1.4 millert 741: "\t%*sCR %6ld CC %6ld DR %6ld \n", indent, " ",
1.1 deraadt 742: s->ts_retrans_cr, s->ts_retrans_cc, s->ts_retrans_dr);
743: fprintf(OUT,
1.4 millert 744: "\t%*sDT %6ld (%5.2f%%)\n", indent, " ",
1.1 deraadt 745: s->ts_retrans_dt,
746: PERCENT(s->ts_retrans_dt, s->ts_DT_sent));
747: fprintf(OUT,
1.4 millert 748: "\t%*sXPD %6ld (%5.2f%%)\n", indent, " ",
1.1 deraadt 749: s->ts_retrans_xpd,
750: PERCENT(s->ts_retrans_xpd, s->ts_XPD_sent));
751:
752:
753: fprintf(OUT,
1.4 millert 754: "\n%*sE Timers: [%6ld ticks]\n", indent, " ", s->ts_Eticks);
1.1 deraadt 755: fprintf(OUT,
1.4 millert 756: "%*s%6ld timer%s set \t%6ld timer%s expired \t%6ld timer%s cancelled\n",indent, " ",
1.1 deraadt 757: s->ts_Eset ,plural(s->ts_Eset),
758: s->ts_Eexpired ,plural(s->ts_Eexpired),
759: s->ts_Ecan_act ,plural(s->ts_Ecan_act));
760:
761: fprintf(OUT,
1.4 millert 762: "\n%*sC Timers: [%6ld ticks]\n", indent, " ",s->ts_Cticks);
1.1 deraadt 763: fprintf(OUT,
1.4 millert 764: "%*s%6ld timer%s set \t%6ld timer%s expired \t%6ld timer%s cancelled\n",
1.1 deraadt 765: indent, " ",
766: s->ts_Cset ,plural(s->ts_Cset),
767: s->ts_Cexpired ,plural(s->ts_Cexpired),
768: s->ts_Ccan_act ,plural(s->ts_Ccan_act));
769: fprintf(OUT,
1.4 millert 770: "%*s%6ld inactive timer%s cancelled\n", indent, " ",
1.1 deraadt 771: s->ts_Ccan_inact ,plural(s->ts_Ccan_inact));
772:
773: fprintf(OUT,
774: "\n%*sPathological debugging activity:\n", indent, " ");
775: fprintf(OUT,
1.4 millert 776: "\t%*s%6ld CC%s sent to zero dref\n", indent, " ",
1.1 deraadt 777: s->ts_zdebug ,plural(s->ts_zdebug));
778: /* SAME LINE AS ABOVE */
779: fprintf(OUT,
1.4 millert 780: "\t%*s%6ld random DT%s dropped\n", indent, " ",
1.1 deraadt 781: s->ts_ydebug ,plural(s->ts_ydebug));
782: fprintf(OUT,
1.4 millert 783: "\t%*s%6ld illegally large XPD TPDU%s\n", indent, " ",
1.1 deraadt 784: s->ts_vdebug ,plural(s->ts_vdebug));
785: fprintf(OUT,
1.4 millert 786: "\t%*s%6ld faked reneging of cdt\n", indent, " ",
1.1 deraadt 787: s->ts_ldebug );
788:
789: fprintf(OUT,
790: "\n%*sACK reasons:\n", indent, " ");
1.4 millert 791: fprintf(OUT, "\t%*s%6ld not acked immediately\n", indent, " ",
1.1 deraadt 792: s->ts_ackreason[_ACK_DONT_] );
1.4 millert 793: fprintf(OUT, "\t%*s%6ld strategy==each\n", indent, " ",
1.1 deraadt 794: s->ts_ackreason[_ACK_STRAT_EACH_] );
1.4 millert 795: fprintf(OUT, "\t%*s%6ld strategy==fullwindow\n", indent, " ",
1.1 deraadt 796: s->ts_ackreason[_ACK_STRAT_FULLWIN_] );
1.4 millert 797: fprintf(OUT, "\t%*s%6ld duplicate DT\n", indent, " ",
1.1 deraadt 798: s->ts_ackreason[_ACK_DUP_] );
1.4 millert 799: fprintf(OUT, "\t%*s%6ld EOTSDU\n", indent, " ",
1.1 deraadt 800: s->ts_ackreason[_ACK_EOT_] );
1.4 millert 801: fprintf(OUT, "\t%*s%6ld reordered DT\n", indent, " ",
1.1 deraadt 802: s->ts_ackreason[_ACK_REORDER_] );
1.4 millert 803: fprintf(OUT, "\t%*s%6ld user rcvd\n", indent, " ",
1.1 deraadt 804: s->ts_ackreason[_ACK_USRRCV_] );
1.4 millert 805: fprintf(OUT, "\t%*s%6ld fcc reqd\n", indent, " ",
1.1 deraadt 806: s->ts_ackreason[_ACK_FCC_] );
807: }
808: #ifndef SSEL
809: #define SSEL(s) ((s)->siso_tlen + TSEL(s))
810: #define PSEL(s) ((s)->siso_slen + SSEL(s))
811: #endif
812:
813: static void
814: isonetprint(siso, islocal)
815: register struct sockaddr_iso *siso;
816: int islocal;
817: {
818: hexprint(siso->siso_nlen, siso->siso_addr.isoa_genaddr, "{}");
819: if (siso->siso_tlen || siso->siso_slen || siso->siso_plen)
820: hexprint(siso->siso_tlen, TSEL(siso), "()");
821: if (siso->siso_slen || siso->siso_plen)
822: hexprint(siso->siso_slen, SSEL(siso), "[]");
823: if (siso->siso_plen)
824: hexprint(siso->siso_plen, PSEL(siso), "<>");
825: putchar(' ');
826: }
827:
828: static char hexlist[] = "0123456789abcdef", obuf[128];
829:
830: static void
831: hexprint(n, buf, delim)
832: int n;
833: char *buf, *delim;
834: {
835: register u_char *in = (u_char *)buf, *top = in + n;
836: register char *out = obuf;
837: register int i;
838:
839: if (n == 0)
840: return;
841: while (in < top) {
842: i = *in++;
843: *out++ = '.';
844: if (i > 0xf) {
845: out[1] = hexlist[i & 0xf];
846: i >>= 4;
847: out[0] = hexlist[i];
848: out += 2;
849: } else
850: *out++ = hexlist[i];
851: }
852: *obuf = *delim; *out++ = delim[1]; *out = 0;
853: printf("%s", obuf);
854: }