xref: /csrg-svn/sys/netns/spp_debug.c (revision 24413)
123214Smckusick /*
223214Smckusick  * Copyright (c) 1982 Regents of the University of California.
323214Smckusick  * All rights reserved.  The Berkeley software License Agreement
423214Smckusick  * specifies the terms and conditions for redistribution.
523214Smckusick  *
6*24413Swalsh  *	@(#)spp_debug.c	6.4 (Berkeley) 08/23/85
723214Smckusick  */
821494Ssklower 
921494Ssklower #include "param.h"
1021494Ssklower #include "systm.h"
1121494Ssklower #include "mbuf.h"
1221494Ssklower #include "socket.h"
1321494Ssklower #include "socketvar.h"
1421494Ssklower #include "protosw.h"
1521494Ssklower #include "errno.h"
1621494Ssklower 
1721494Ssklower #include "../net/route.h"
1821494Ssklower #include "../net/if.h"
1921494Ssklower #include "../netinet/tcp_fsm.h"
2021494Ssklower #include "../netinet/tcp_timer.h"
2121494Ssklower 
2221494Ssklower #include "ns.h"
2321494Ssklower #include "ns_pcb.h"
2421494Ssklower #include "idp.h"
2521494Ssklower #include "idp_var.h"
2621494Ssklower #include "sp.h"
2721494Ssklower #include "spidp.h"
2821494Ssklower #include "spp_var.h"
2921494Ssklower #define	SANAMES
3021494Ssklower #include "spp_debug.h"
3121494Ssklower 
3221494Ssklower int	sppconsdebug = 0;
3321494Ssklower /*
3421494Ssklower  * spp debug routines
3521494Ssklower  */
3621494Ssklower spp_trace(act, ostate, sp, si, req)
3721494Ssklower 	short act;
3821494Ssklower 	u_char ostate;
3921494Ssklower 	struct sppcb *sp;
4021494Ssklower 	struct spidp *si;
4121494Ssklower 	int req;
4221494Ssklower {
43*24413Swalsh #ifndef BBNNET
4421494Ssklower 	u_short seq, ack, len, alo;
4521494Ssklower 	unsigned long iptime();
4621494Ssklower 	int flags;
4721494Ssklower 	struct spp_debug *sd = &spp_debug[spp_debx++];
48*24413Swalsh 	extern char *prurequests[];
49*24413Swalsh 	extern char *tanames[];
50*24413Swalsh 	extern char *tcpstates[];
51*24413Swalsh 	extern char *tcptimers[];
5221494Ssklower 
5321494Ssklower 	if (spp_debx == SPP_NDEBUG)
5421494Ssklower 		spp_debx = 0;
5521494Ssklower 	sd->sd_time = iptime();
5621494Ssklower 	sd->sd_act = act;
5721494Ssklower 	sd->sd_ostate = ostate;
5821494Ssklower 	sd->sd_cb = (caddr_t)sp;
5921494Ssklower 	if (sp)
6021494Ssklower 		sd->sd_sp = *sp;
6121494Ssklower 	else
6221494Ssklower 		bzero((caddr_t)&sd->sd_sp, sizeof (*sp));
6321494Ssklower 	if (si)
6421494Ssklower 		sd->sd_si = *si;
6521494Ssklower 	else
6621494Ssklower 		bzero((caddr_t)&sd->sd_si, sizeof (*si));
6721494Ssklower 	sd->sd_req = req;
6821494Ssklower 	if (sppconsdebug == 0)
6921494Ssklower 		return;
7021494Ssklower 	if (ostate >= TCP_NSTATES) ostate = 0;
7121494Ssklower 	if (act >= SA_DROP) act = SA_DROP;
7221494Ssklower 	if (sp)
7321494Ssklower 		printf("%x %s:", sp, tcpstates[ostate]);
7421494Ssklower 	else
7521494Ssklower 		printf("???????? ");
7621494Ssklower 	printf("%s ", tanames[act]);
7721494Ssklower 	switch (act) {
7821494Ssklower 
7921494Ssklower 	case SA_RESPOND:
8021494Ssklower 	case SA_INPUT:
8121494Ssklower 	case SA_OUTPUT:
8221494Ssklower 	case SA_DROP:
8321494Ssklower 		if (si == 0)
8421494Ssklower 			break;
8521494Ssklower 		seq = si->si_seq;
8621494Ssklower 		ack = si->si_ack;
8721494Ssklower 		alo = si->si_alo;
8821494Ssklower 		len = si->si_len;
8921494Ssklower 		if (act == SA_OUTPUT) {
9021494Ssklower 			seq = ntohs(seq);
9121494Ssklower 			ack = ntohs(ack);
9221494Ssklower 			alo = ntohs(alo);
9321494Ssklower 			len = ntohs(len);
9421494Ssklower 		}
9521494Ssklower #ifndef lint
9621494Ssklower #define p1(f)  { printf("%s = %x, ", "f", f); }
9721494Ssklower 		p1(seq); p1(ack); p1(alo); p1(len);
9821494Ssklower #endif
9921494Ssklower 		flags = si->si_cc;
10021494Ssklower 		if (flags) {
10121494Ssklower 			char *cp = "<";
10221494Ssklower #ifndef lint
10321494Ssklower #define pf(f) { if (flags&SP_/**/f) { printf("%s%s", cp, "f"); cp = ","; } }
10421494Ssklower 			pf(SP); pf(SA); pf(OB); pf(EM);
10524225Ssklower #else
10624225Ssklower 			cp = cp;
10721494Ssklower #endif
10821494Ssklower 			printf(">");
10921494Ssklower 		}
11021494Ssklower #ifndef lint
11121494Ssklower #define p2(f)  { printf("%s = %x, ", "f", si->si_/**/f); }
11221494Ssklower 		p2(sid);p2(did);p2(dt);p2(pt);
11321494Ssklower #endif
11421494Ssklower 		ns_printhost(&si->si_sna);
11521494Ssklower 		ns_printhost(&si->si_dna);
11621494Ssklower 
11721494Ssklower 		if (act==SA_RESPOND) {
11821494Ssklower 			printf("idp_len = %x, ",
11921494Ssklower 				((struct idp *)si)->idp_len);
12021494Ssklower 		}
12121494Ssklower 		break;
12221494Ssklower 
12321494Ssklower 	case SA_USER:
12421494Ssklower 		printf("%s", prurequests[req&0xff]);
12521494Ssklower 		if ((req & 0xff) == PRU_SLOWTIMO)
12621494Ssklower 			printf("<%s>", tcptimers[req>>8]);
12721494Ssklower 		break;
12821494Ssklower 	}
12921494Ssklower 	if (sp)
13021494Ssklower 		printf(" -> %s", tcpstates[sp->s_state]);
13121494Ssklower 	/* print out internal state of sp !?! */
13221494Ssklower 	printf("\n");
13321494Ssklower 	if (sp == 0)
13421494Ssklower 		return;
13521494Ssklower #ifndef lint
13621494Ssklower #define p3(f)  { printf("%s = %x, ", "f", sp->s_/**/f); }
13721494Ssklower 	printf("\t"); p3(rack);p3(ralo);p3(snt);p3(flags); printf("\n");
13821494Ssklower #endif
139*24413Swalsh #endif
14021494Ssklower }
141