* Copyright (c) 1989, 1990 The Regents of the University of California.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
static char sccsid
[] = "@(#)iso.c 5.6 (Berkeley) 4/27/91";
* $Header: iso.c,v 3.3 88/12/08 14:44:49 hagens Exp $
* $Source: /usr/argo/src/ucb/netstat/RCS/iso.c,v $
/*******************************************************************************
Copyright IBM Corporation 1987
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of IBM not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
*******************************************************************************/
* ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
#include <sys/socketvar.h>
#include <netiso/iso_errno.h>
#include <netiso/clnp_stat.h>
#include <netiso/argo_debug.h>
#include <netiso/tp_param.h>
#include <netiso/tp_states.h>
#include <netiso/tp_astring.c>
#include <netiso/tp_pcb.h>
#include <netiso/tp_stat.h>
#include <netiso/iso_pcb.h>
#include <netiso/cltp_var.h>
#include <netiso/cons_pcb.h>
struct esis_stat esis_stat
;
kvm_read(off
, (char *)&esis_stat
, sizeof (struct esis_stat
));
printf("\t%d esh sent, %d esh received\n", esis_stat
.es_eshsent
,
printf("\t%d ish sent, %d ish received\n", esis_stat
.es_ishsent
,
printf("\t%d rd sent, %d rd received\n", esis_stat
.es_rdsent
,
printf("\t%d pdus not sent due to insufficient memory\n",
printf("\t%d pdus received with bad checksum\n", esis_stat
.es_badcsum
);
printf("\t%d pdus received with bad version number\n",
printf("\t%d pdus received with bad type field\n", esis_stat
.es_badtype
);
printf("\t%d short pdus received\n", esis_stat
.es_toosmall
);
* Dump clnp statistics structure.
struct clnp_stat clnp_stat
;
kvm_read(off
, (char *)&clnp_stat
, sizeof (clnp_stat
));
printf("%s:\n\t%d total packets sent\n", name
, clnp_stat
.cns_sent
);
printf("\t%d total fragments sent\n", clnp_stat
.cns_fragments
);
printf("\t%d total packets received\n", clnp_stat
.cns_total
);
printf("\t%d with fixed part of header too small\n",
printf("\t%d with header length not reasonable\n", clnp_stat
.cns_badhlen
);
printf("\t%d incorrect checksum%s\n",
clnp_stat
.cns_badcsum
, plural(clnp_stat
.cns_badcsum
));
printf("\t%d with unreasonable address lengths\n", clnp_stat
.cns_badaddr
);
printf("\t%d with forgotten segmentation information\n",
printf("\t%d with an incorrect protocol identifier\n", clnp_stat
.cns_noproto
);
printf("\t%d with an incorrect version\n", clnp_stat
.cns_badvers
);
printf("\t%d dropped because the ttl has expired\n",
clnp_stat
.cns_ttlexpired
);
printf("\t%d clnp cache misses\n", clnp_stat
.cns_cachemiss
);
printf("\t%d clnp congestion experience bits set\n",
clnp_stat
.cns_congest_set
);
printf("\t%d clnp congestion experience bits received\n",
clnp_stat
.cns_congest_rcvd
);
* Dump CLTP statistics structure.
struct cltpstat cltpstat
;
kvm_read(off
, (char *)&cltpstat
, sizeof (cltpstat
));
printf("%s:\n\t%u incomplete header%s\n", name
,
cltpstat
.cltps_hdrops
, plural(cltpstat
.cltps_hdrops
));
printf("\t%u bad data length field%s\n",
cltpstat
.cltps_badlen
, plural(cltpstat
.cltps_badlen
));
printf("\t%u bad checksum%s\n",
cltpstat
.cltps_badsum
, plural(cltpstat
.cltps_badsum
));
struct sockaddr_iso siso
;
(kvm_read((off_t)(o), (char *)&p, sizeof (p)))
* Print a summary of connections related to an Internet
* protocol. For TP, also give state of connection.
* Listening processes (aflag) are suppressed unless the
* -a (all) flag is specified.
register struct isopcb
*prev
, *next
;
int istp
= (strcmp(name
, "tp") == 0);
printf("%s control block: symbol not in namelist\n", name
);
prev
= (struct isopcb
*)off
;
if (isopcb
.isop_next
== (struct isopcb
*)off
)
while (isopcb
.isop_next
!= (struct isopcb
*)off
) {
if (isopcb
.isop_prev
!= prev
) {
printf("prev 0x%x next 0x%x isop_prev 0x%x isop_next 0x%x???\n",
prev
, next
, isopcb
.isop_prev
, isopcb
.isop_next
);
kget(isopcb
.isop_socket
, sockb
);
kget(sockb
.so_tpcb
, tpcb
);
if (tpcb
.tp_state
== ST_ERROR
)
fprintf(stderr
,"addr: 0x%x, prev 0x%x\n", next
, prev
);
tpcb
.tp_state
== TP_LISTENING
||
tpcb
.tp_state
== TP_CLOSED
||
tpcb
.tp_state
== TP_REFWAIT
) {
printf("Active ISO net connections");
printf(" (including servers)");
printf("%-8.8s ", "PCB");
"%-5.5s %-6.6s %-6.6s %-18.18s %-18.18s %s\n" :
"%-5.5s %-6.6s %-6.6s %-22.22s %-22.22s %s\n",
"Proto", "Recv-Q", "Send-Q",
"Local Address", "Foreign Address", "(state)");
(istp
? (off_t
)sockb
.so_tpcb
: (off_t
)next
));
printf("%-5.5s %6d %6d ", name
, sockb
.so_rcv
.sb_cc
,
if (isopcb
.isop_laddr
== 0)
if ((char *)isopcb
.isop_laddr
== ((char *)next
) +
_offsetof(struct isopcb
, isop_sladdr
))
laddr
.siso
= isopcb
.isop_sladdr
;
kget(isopcb
.isop_laddr
, laddr
);
if (isopcb
.isop_faddr
== 0)
if ((char *)isopcb
.isop_faddr
== ((char *)next
) +
_offsetof(struct isopcb
, isop_sfaddr
))
faddr
.siso
= isopcb
.isop_sfaddr
;
kget(isopcb
.isop_faddr
, faddr
);
if (tpcb
.tp_state
>= tp_NSTATES
)
printf(" %d", tpcb
.tp_state
);
printf(" %-12.12s", tp_sstring
[tpcb
.tp_state
]);
* Pretty print an iso address (net address + port).
* If the nflag was specified, use numbers instead of names.
register struct iso_addr
*iso
;
struct iso_hostent
*ihe
= 0;
struct iso_hostent
*iso_gethostentrybyaddr();
struct iso_hostent
*iso_getserventrybytsel();
bzero(line
, sizeof(line
));
ihe
= iso_gethostentrybyaddr( &sa
, 0, 0 );
sprintf(line
, "%s", ihe
->isoh_hname
);
sprintf(line
, "%s", iso_ntoa(iso
));
isonetprint(iso
, sufx
, sufxlen
, islocal
)
register struct iso_addr
*iso
;
struct iso_hostent
*iso_getserventrybytsel(), *ihe
;
char *line
, *cp
, *index();
ihe
= (struct iso_hostent
*)0;
bzero(cp
, sizeof(line
)-10);
if( !Aflag
&& !nflag
&& (ihe
=iso_getserventrybytsel(sufx
, sufxlen
))) {
if( ihe
&& (strlen(ihe
->isoh_aname
)>0) ) {
sprintf(cp
, "%s", ihe
->isoh_aname
);
iso_sprinttsel(cp
, sufx
, sufxlen
);
fprintf(stdout, Aflag?" %-18.18s":" %-22.22s", line);
if( strlen(line
) > Alen
) {
fprintf(stdout
, " %s", line
);
fprintf(stdout
, "\n %*.s", islocal
+Alen
," ");
fprintf(stdout
, " %-*.*s", Alen
, Alen
,line
);
static char *xpcb_states
[] = {
register struct isopcb
*prev
, *next
;
printf("%s control block: symbol not in namelist\n", name
);
kvm_read(off
, &xpcb
, sizeof (struct x25_pcb
));
prev
= (struct isopcb
*)off
;
if (xpcb
.x_next
== (struct isopcb
*)off
)
while (xpcb
.x_next
!= (struct isopcb
*)off
) {
kvm_read((off_t
)next
, &xpcb
, sizeof (struct x25_pcb
));
if (xpcb
.x_prev
!= prev
) {
kvm_read((off_t
)xpcb
.x_socket
, &sockb
, sizeof (sockb
));
xpcb
.x_state
== LISTENING
||
xpcb
.x_state
== TP_CLOSED
) {
printf("Active X25 net connections");
printf(" (including servers)");
printf("%-8.8s ", "PCB");
"%-5.5s %-6.6s %-6.6s %-18.18s %-18.18s %s\n" :
"%-5.5s %-6.6s %-6.6s %-22.22s %-22.22s %s\n",
"Proto", "Recv-Q", "Send-Q",
"Local Address", "Foreign Address", "(state)");
printf("%-5.5s %6d %6d ", name
, sockb
.so_rcv
.sb_cc
,
isonetprint(&xpcb
.x_laddr
.siso_addr
, &xpcb
.x_lport
,
sizeof(xpcb
.x_lport
), 1);
isonetprint(&xpcb
.x_faddr
.siso_addr
, &xpcb
.x_fport
,
sizeof(xpcb
.x_lport
), 0);
if (xpcb
.x_state
< 0 || xpcb
.x_state
>= x25_NSTATES
)
printf(" 0x0x0x0x0x0x0x0x0x%x", xpcb
.x_state
);
printf(" %-12.12s", xpcb_states
[xpcb
.x_state
]);
printf("TP not configured\n\n");
#define plural(x) (x>1?"s":"")
register struct tp_stat
*s
;
"%*sReceiving:\n",indent
," ");
"\t%*s%d variable parameter%s ignored\n", indent
," ",
s
->ts_param_ignored
,plural(s
->ts_param_ignored
));
"\t%*s%d invalid parameter code%s\n", indent
, " ",
s
->ts_inv_pcode
,plural(s
->ts_inv_pcode
));
"\t%*s%d invalid parameter value%s\n", indent
, " ",
s
->ts_inv_pval
,plural(s
->ts_inv_pval
));
"\t%*s%d invalid dutype%s\n", indent
, " ",
s
->ts_inv_dutype
,plural(s
->ts_inv_dutype
));
"\t%*s%d negotiation failure%s\n", indent
, " ",
s
->ts_negotfailed
,plural(s
->ts_negotfailed
));
"\t%*s%d invalid destination reference%s\n", indent
, " ",
s
->ts_inv_dref
,plural(s
->ts_inv_dref
));
"\t%*s%d invalid suffix parameter%s\n", indent
, " ",
s
->ts_inv_sufx
,plural(s
->ts_inv_sufx
));
"\t%*s%d invalid length\n",indent
, " ", s
->ts_inv_length
);
"\t%*s%d invalid checksum%s\n", indent
, " ",
s
->ts_bad_csum
,plural(s
->ts_bad_csum
));
"\t%*s%d DT%s out of order\n", indent
, " ",
s
->ts_dt_ooo
,plural(s
->ts_dt_ooo
));
"\t%*s%d DT%s not in window\n", indent
, " ",
s
->ts_dt_niw
,plural(s
->ts_dt_niw
));
"\t%*s%d duplicate DT%s\n", indent
, " ",
s
->ts_dt_dup
,plural(s
->ts_dt_dup
));
"\t%*s%d XPD%s not in window\n", indent
, " ",
s
->ts_xpd_niw
,plural(s
->ts_xpd_niw
));
"\t%*s%d XPD%s w/o credit to stash\n", indent
, " ",
s
->ts_xpd_dup
,plural(s
->ts_xpd_dup
));
"\t%*s%d time%s local credit reneged\n", indent
, " ",
s
->ts_lcdt_reduced
,plural(s
->ts_lcdt_reduced
));
"\t%*s%d concatenated TPDU%s\n", indent
, " ",
s
->ts_concat_rcvd
,plural(s
->ts_concat_rcvd
));
"%*sSending:\n", indent
, " ");
"\t%*s%d XPD mark%s discarded\n", indent
, " ",
s
->ts_xpdmark_del
,plural(s
->ts_xpdmark_del
));
"\t%*sXPD stopped data flow %d time%s\n", indent
, " ",
s
->ts_xpd_intheway
,plural(s
->ts_xpd_intheway
));
"\t%*s%d time%s foreign window closed\n", indent
, " ",
s
->ts_zfcdt
,plural(s
->ts_zfcdt
));
"%*sMiscellaneous:\n", indent
, " ");
"\t%*s%d small mbuf%s\n", indent
, " ",
s
->ts_mb_small
,plural(s
->ts_mb_small
));
"\t%*s%d cluster%s\n", indent
, " ",
s
->ts_mb_cluster
, plural(s
->ts_mb_cluster
));
"\t%*s%d source quench \n",indent
, " ",
"\t%*s%d dec bit%s\n", indent
, " ",
s
->ts_rcvdecbit
, plural(s
->ts_rcvdecbit
));
"\t%*sM:L ( M mbuf chains of length L)\n", indent
, " ");
fprintf(OUT
, "\t%*s%d: over 16\n", indent
, " ",
"\t%*s%d: %d\t\t%d: %d\n", indent
, " ",
s
->ts_mb_len_distr
[j
<<1],j
<<1
"\t%*s%d EOT rcvd\n", indent
, " ", s
->ts_eot_input
);
"\t%*s%d EOT sent\n", indent
, " ", s
->ts_EOT_sent
);
"\t%*s%d EOT indication%s\n", indent
, " ",
s
->ts_eot_user
,plural(s
->ts_eot_user
));
"%*sConnections:\n", indent
, " ");
"\t%*s%d connection%s used extended format\n", indent
, " ",
s
->ts_xtd_fmt
,plural(s
->ts_xtd_fmt
));
"\t%*s%d connection%s allowed transport expedited data\n", indent
, " ",
s
->ts_use_txpd
,plural(s
->ts_use_txpd
));
"\t%*s%d connection%s turned off checksumming\n", indent
, " ",
s
->ts_csum_off
,plural(s
->ts_csum_off
));
"\t%*s%d connection%s dropped due to retrans limit\n", indent
, " ",
s
->ts_conn_gaveup
,plural(s
->ts_conn_gaveup
));
"\t%*s%d tp 4 connection%s\n", indent
, " ",
s
->ts_tp4_conn
,plural(s
->ts_tp4_conn
));
"\t%*s%d tp 0 connection%s\n", indent
, " ",
s
->ts_tp0_conn
,plural(s
->ts_tp0_conn
));
div = (s->ts_rtt[(i)].tv_sec * 1000000) + \
s->ts_rtt[(i)].tv_usec ;\
f = ((s->ts_rtv[(i)].tv_sec * 1000000) + \
s->ts_rtv[(i)].tv_usec)/div; \
"\n%*sRound trip times, listed in (sec: usec):\n", indent
, " ");
"\t%*s%11.11s %12.12s | %12.12s | %s\n", indent
, " ",
"Smoothed avg", "Deviation", "Deviation/Avg");
"\t%*s%11.11s: %5d:%-6d | %5d:%-6d | %-6d\n", indent
, " ",
"\n%*sTpdus RECVD [%d valid, %3.6f %% of total (%d); %d dropped]\n",indent
," ",
((100 * (float)s
->ts_tpdu_rcvd
)/(float)s
->ts_pkt_rcvd
)
"\t%*sDT %6d AK %6d DR %4d CR %4d \n", indent
, " ",
s
->ts_DT_rcvd
, s
->ts_AK_rcvd
, s
->ts_DR_rcvd
, s
->ts_CR_rcvd
);
"\t%*sXPD %6d XAK %6d DC %4d CC %4d ER %4d\n", indent
, " ",
s
->ts_XPD_rcvd
, s
->ts_XAK_rcvd
, s
->ts_DC_rcvd
, s
->ts_CC_rcvd
,
"\n%*sTpdus SENT [%d total, %d dropped]\n", indent
, " ",
s
->ts_tpdu_sent
, s
->ts_send_drop
);
"\t%*sDT %6d AK %6d DR %4d CR %4d \n", indent
, " ",
s
->ts_DT_sent
, s
->ts_AK_sent
, s
->ts_DR_sent
, s
->ts_CR_sent
);
"\t%*sXPD %6d XAK %6d DC %4d CC %4d ER %4d\n", indent
, " ",
s
->ts_XPD_sent
, s
->ts_XAK_sent
, s
->ts_DC_sent
, s
->ts_CC_sent
,
"\n%*sRetransmissions:\n", indent
, " ");
#define PERCENT(X,Y) (((Y)>0)?((100 *(float)(X)) / (float) (Y)):0)
"\t%*sCR %6d CC %6d DR %6d \n", indent
, " ",
s
->ts_retrans_cr
, s
->ts_retrans_cc
, s
->ts_retrans_dr
);
"\t%*sDT %6d (%5.2f%%)\n", indent
, " ",
PERCENT(s
->ts_retrans_dt
, s
->ts_DT_sent
));
"\t%*sXPD %6d (%5.2f%%)\n", indent
, " ",
PERCENT(s
->ts_retrans_xpd
, s
->ts_XPD_sent
));
"\n%*sE Timers: [%6d ticks]\n", indent
, " ", s
->ts_Eticks
);
"%*s%6d timer%s set \t%6d timer%s expired \t%6d timer%s cancelled\n",indent
, " ",
s
->ts_Eset
,plural(s
->ts_Eset
),
s
->ts_Eexpired
,plural(s
->ts_Eexpired
),
s
->ts_Ecan_act
,plural(s
->ts_Ecan_act
));
"\n%*sC Timers: [%6d ticks]\n", indent
, " ",s
->ts_Cticks
);
"%*s%6d timer%s set \t%6d timer%s expired \t%6d timer%s cancelled\n",
s
->ts_Cset
,plural(s
->ts_Cset
),
s
->ts_Cexpired
,plural(s
->ts_Cexpired
),
s
->ts_Ccan_act
,plural(s
->ts_Ccan_act
));
"%*s%6d inactive timer%s cancelled\n", indent
, " ",
s
->ts_Ccan_inact
,plural(s
->ts_Ccan_inact
));
"\n%*sPathological debugging activity:\n", indent
, " ");
"\t%*s%6d CC%s sent to zero dref\n", indent
, " ",
s
->ts_zdebug
,plural(s
->ts_zdebug
));
"\t%*s%6d random DT%s dropped\n", indent
, " ",
s
->ts_ydebug
,plural(s
->ts_ydebug
));
"\t%*s%6d illegally large XPD TPDU%s\n", indent
, " ",
s
->ts_vdebug
,plural(s
->ts_vdebug
));
"\t%*s%6d faked reneging of cdt\n", indent
, " ",
"\n%*sACK reasons:\n", indent
, " ");
fprintf(OUT
, "\t%*s%6d not acked immediately\n", indent
, " ",
s
->ts_ackreason
[_ACK_DONT_
] );
fprintf(OUT
, "\t%*s%6d strategy==each\n", indent
, " ",
s
->ts_ackreason
[_ACK_STRAT_EACH_
] );
fprintf(OUT
, "\t%*s%6d strategy==fullwindow\n", indent
, " ",
s
->ts_ackreason
[_ACK_STRAT_FULLWIN_
] );
fprintf(OUT
, "\t%*s%6d duplicate DT\n", indent
, " ",
s
->ts_ackreason
[_ACK_DUP_
] );
fprintf(OUT
, "\t%*s%6d EOTSDU\n", indent
, " ",
s
->ts_ackreason
[_ACK_EOT_
] );
fprintf(OUT
, "\t%*s%6d reordered DT\n", indent
, " ",
s
->ts_ackreason
[_ACK_REORDER_
] );
fprintf(OUT
, "\t%*s%6d user rcvd\n", indent
, " ",
s
->ts_ackreason
[_ACK_USRRCV_
] );
fprintf(OUT
, "\t%*s%6d fcc reqd\n", indent
, " ",
s
->ts_ackreason
[_ACK_FCC_
] );
#define SSEL(s) ((s)->siso_tlen + TSEL(s))
#define PSEL(s) ((s)->siso_slen + SSEL(s))
isonetprint(siso
, islocal
)
register struct sockaddr_iso
*siso
;
hexprint(siso
->siso_nlen
, siso
->siso_addr
.isoa_genaddr
, "{}");
if (siso
->siso_tlen
|| siso
->siso_slen
|| siso
->siso_plen
)
hexprint(siso
->siso_tlen
, TSEL(siso
), "()");
if (siso
->siso_slen
|| siso
->siso_plen
)
hexprint(siso
->siso_slen
, SSEL(siso
), "[]");
hexprint(siso
->siso_plen
, PSEL(siso
), "<>");
static char hexlist
[] = "0123456789abcdef", obuf
[128];
register u_char
*in
= (u_char
*)buf
, *top
= in
+ n
;
register char *out
= obuf
;
out
[1] = hexlist
[i
& 0xf];
*obuf
= *delim
; *out
++ = delim
[1]; *out
= 0;