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