xref: /csrg-svn/sys/netccitt/pk_debug.c (revision 47267)
141709Ssklower /*
241709Ssklower  * Copyright (c) University of British Columbia, 1984
341709Ssklower  * Copyright (c) 1990 The Regents of the University of California.
441709Ssklower  * All rights reserved.
541709Ssklower  *
641709Ssklower  * This code is derived from software contributed to Berkeley by
741709Ssklower  * the Laboratory for Computation Vision and the Computer Science Department
841709Ssklower  * of the University of British Columbia.
941709Ssklower  *
1041709Ssklower  * %sccs.include.redist.c%
1141709Ssklower  *
12*47267Ssklower  *	@(#)pk_debug.c	7.6 (Berkeley) 03/12/91
1341709Ssklower  */
1441591Ssklower 
1545165Ssklower #include "param.h"
1645165Ssklower #include "systm.h"
1745165Ssklower #include "mbuf.h"
1845165Ssklower #include "socket.h"
1945165Ssklower #include "protosw.h"
2045165Ssklower #include "socketvar.h"
2145165Ssklower #include "errno.h"
2241591Ssklower 
2345165Ssklower #include "../net/if.h"
2441591Ssklower 
2545165Ssklower #include "x25.h"
2645165Ssklower #include "pk.h"
2745165Ssklower #include "pk_var.h"
2845165Ssklower 
2941591Ssklower char	*pk_state[] = {
3041591Ssklower 	"Listen",	"Ready",	"Received-Call",
3141591Ssklower 	"Sent-Call",	"Data-Transfer","Received-Clear",
3241591Ssklower 	"Sent-Clear",
3341591Ssklower };
3441591Ssklower 
3541591Ssklower char   *pk_name[] = {
3641591Ssklower 	"Call",		"Call-Conf",	"Clear",
3741591Ssklower 	"Clear-Conf",	"Data",		"Intr",		"Intr-Conf",
3841591Ssklower 	"Rr",		"Rnr",		"Reset",	"Reset-Conf",
39*47267Ssklower 	"Restart",	"Restart-Conf",	"Reject",	"Diagnostic",
40*47267Ssklower 	"Invalid"
4141591Ssklower };
4241591Ssklower 
4345893Ssklower pk_trace (xcp, m, dir)
4441591Ssklower struct x25config *xcp;
4545893Ssklower register struct mbuf *m;
4641591Ssklower char *dir;
4741591Ssklower {
4841591Ssklower 	register char *s;
4945893Ssklower 	struct x25_packet *xp = mtod(m, struct x25_packet *);
5041591Ssklower 	register int i, len = 0, cnt = 0;
5141591Ssklower 
5241591Ssklower 	if (xcp -> xc_ptrace == 0)
5341591Ssklower 		return;
5441591Ssklower 
5541591Ssklower 	i = pk_decode (xp) / MAXSTATES;
5645893Ssklower 	for (; m; m = m -> m_next) {
5741591Ssklower 		len = len + m -> m_len;
5841591Ssklower 		++cnt;
5941591Ssklower 	}
6041591Ssklower 	printf ("LCN=%d %s:	%s	#=%d, len=%d ",
6145571Ssklower 		LCN(xp), dir, pk_name[i], cnt, len);
6241591Ssklower 	for (s = (char *) xp, i = 0; i < 5; ++i, ++s)
6341591Ssklower 		printf ("%x ", (int) * s & 0xff);
6441591Ssklower 	printf ("\n");
6541591Ssklower }
66