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