xref: /csrg-svn/sys/netns/spp_debug.c (revision 43090)
123214Smckusick /*
232597Ssklower  * Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California.
333371Ssklower  * All rights reserved.
423214Smckusick  *
533371Ssklower  * Redistribution and use in source and binary forms are permitted
634856Sbostic  * provided that the above copyright notice and this paragraph are
734856Sbostic  * duplicated in all such forms and that any documentation,
834856Sbostic  * advertising materials, and other materials related to such
934856Sbostic  * distribution and use acknowledge that the software was developed
1034856Sbostic  * by the University of California, Berkeley.  The name of the
1134856Sbostic  * University may not be used to endorse or promote products derived
1234856Sbostic  * from this software without specific prior written permission.
1334856Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
1434856Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
1534856Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1633371Ssklower  *
17*43090Ssklower  *	@(#)spp_debug.c	7.6 (Berkeley) 06/13/90
1823214Smckusick  */
1921494Ssklower 
2021494Ssklower #include "param.h"
2121494Ssklower #include "systm.h"
2221494Ssklower #include "mbuf.h"
2321494Ssklower #include "socket.h"
2421494Ssklower #include "socketvar.h"
2521494Ssklower #include "protosw.h"
2621494Ssklower #include "errno.h"
2721494Ssklower 
2821494Ssklower #include "../net/route.h"
2921494Ssklower #include "../net/if.h"
3021494Ssklower #include "../netinet/tcp_fsm.h"
3121494Ssklower 
3221494Ssklower #include "ns.h"
3321494Ssklower #include "ns_pcb.h"
3421494Ssklower #include "idp.h"
3521494Ssklower #include "idp_var.h"
3621494Ssklower #include "sp.h"
3721494Ssklower #include "spidp.h"
3833719Skarels #define SPPTIMERS
3933719Skarels #include "spp_timer.h"
4021494Ssklower #include "spp_var.h"
4121494Ssklower #define	SANAMES
4221494Ssklower #include "spp_debug.h"
4321494Ssklower 
4421494Ssklower int	sppconsdebug = 0;
4521494Ssklower /*
4621494Ssklower  * spp debug routines
4721494Ssklower  */
4821494Ssklower spp_trace(act, ostate, sp, si, req)
4921494Ssklower 	short act;
5021494Ssklower 	u_char ostate;
5121494Ssklower 	struct sppcb *sp;
5221494Ssklower 	struct spidp *si;
5321494Ssklower 	int req;
5421494Ssklower {
5525034Skarels #ifdef INET
56*43090Ssklower #ifdef TCPDEBUG
5721494Ssklower 	u_short seq, ack, len, alo;
5821494Ssklower 	unsigned long iptime();
5921494Ssklower 	int flags;
6021494Ssklower 	struct spp_debug *sd = &spp_debug[spp_debx++];
6124413Swalsh 	extern char *prurequests[];
6226472Ssklower 	extern char *sanames[];
6324413Swalsh 	extern char *tcpstates[];
6433719Skarels 	extern char *spptimers[];
6521494Ssklower 
6621494Ssklower 	if (spp_debx == SPP_NDEBUG)
6721494Ssklower 		spp_debx = 0;
6821494Ssklower 	sd->sd_time = iptime();
6921494Ssklower 	sd->sd_act = act;
7021494Ssklower 	sd->sd_ostate = ostate;
7121494Ssklower 	sd->sd_cb = (caddr_t)sp;
7221494Ssklower 	if (sp)
7321494Ssklower 		sd->sd_sp = *sp;
7421494Ssklower 	else
7521494Ssklower 		bzero((caddr_t)&sd->sd_sp, sizeof (*sp));
7621494Ssklower 	if (si)
7721494Ssklower 		sd->sd_si = *si;
7821494Ssklower 	else
7921494Ssklower 		bzero((caddr_t)&sd->sd_si, sizeof (*si));
8021494Ssklower 	sd->sd_req = req;
8121494Ssklower 	if (sppconsdebug == 0)
8221494Ssklower 		return;
8321494Ssklower 	if (ostate >= TCP_NSTATES) ostate = 0;
8421494Ssklower 	if (act >= SA_DROP) act = SA_DROP;
8521494Ssklower 	if (sp)
8621494Ssklower 		printf("%x %s:", sp, tcpstates[ostate]);
8721494Ssklower 	else
8821494Ssklower 		printf("???????? ");
8926472Ssklower 	printf("%s ", sanames[act]);
9021494Ssklower 	switch (act) {
9121494Ssklower 
9221494Ssklower 	case SA_RESPOND:
9321494Ssklower 	case SA_INPUT:
9421494Ssklower 	case SA_OUTPUT:
9521494Ssklower 	case SA_DROP:
9621494Ssklower 		if (si == 0)
9721494Ssklower 			break;
9821494Ssklower 		seq = si->si_seq;
9921494Ssklower 		ack = si->si_ack;
10021494Ssklower 		alo = si->si_alo;
10121494Ssklower 		len = si->si_len;
10221494Ssklower 		if (act == SA_OUTPUT) {
10321494Ssklower 			seq = ntohs(seq);
10421494Ssklower 			ack = ntohs(ack);
10521494Ssklower 			alo = ntohs(alo);
10621494Ssklower 			len = ntohs(len);
10721494Ssklower 		}
10821494Ssklower #ifndef lint
10921494Ssklower #define p1(f)  { printf("%s = %x, ", "f", f); }
11021494Ssklower 		p1(seq); p1(ack); p1(alo); p1(len);
11121494Ssklower #endif
11221494Ssklower 		flags = si->si_cc;
11321494Ssklower 		if (flags) {
11421494Ssklower 			char *cp = "<";
11521494Ssklower #ifndef lint
11621494Ssklower #define pf(f) { if (flags&SP_/**/f) { printf("%s%s", cp, "f"); cp = ","; } }
11721494Ssklower 			pf(SP); pf(SA); pf(OB); pf(EM);
11824225Ssklower #else
11924225Ssklower 			cp = cp;
12021494Ssklower #endif
12121494Ssklower 			printf(">");
12221494Ssklower 		}
12321494Ssklower #ifndef lint
12421494Ssklower #define p2(f)  { printf("%s = %x, ", "f", si->si_/**/f); }
12521494Ssklower 		p2(sid);p2(did);p2(dt);p2(pt);
12621494Ssklower #endif
12721494Ssklower 		ns_printhost(&si->si_sna);
12821494Ssklower 		ns_printhost(&si->si_dna);
12921494Ssklower 
13021494Ssklower 		if (act==SA_RESPOND) {
13121494Ssklower 			printf("idp_len = %x, ",
13221494Ssklower 				((struct idp *)si)->idp_len);
13321494Ssklower 		}
13421494Ssklower 		break;
13521494Ssklower 
13621494Ssklower 	case SA_USER:
13721494Ssklower 		printf("%s", prurequests[req&0xff]);
13821494Ssklower 		if ((req & 0xff) == PRU_SLOWTIMO)
13933719Skarels 			printf("<%s>", spptimers[req>>8]);
14021494Ssklower 		break;
14121494Ssklower 	}
14221494Ssklower 	if (sp)
14321494Ssklower 		printf(" -> %s", tcpstates[sp->s_state]);
14421494Ssklower 	/* print out internal state of sp !?! */
14521494Ssklower 	printf("\n");
14621494Ssklower 	if (sp == 0)
14721494Ssklower 		return;
14821494Ssklower #ifndef lint
14921494Ssklower #define p3(f)  { printf("%s = %x, ", "f", sp->s_/**/f); }
15032597Ssklower 	printf("\t"); p3(rack);p3(ralo);p3(smax);p3(flags); printf("\n");
15121494Ssklower #endif
15224413Swalsh #endif
153*43090Ssklower #endif
15421494Ssklower }
155