xref: /original-bsd/sys/netccitt/pk_debug.c (revision b7cc7b86)
1 /*
2  * Copyright (c) University of British Columbia, 1984
3  * Copyright (c) 1990 The Regents of the University of California.
4  * All rights reserved.
5  *
6  * This code is derived from software contributed to Berkeley by
7  * the Laboratory for Computation Vision and the Computer Science Department
8  * of the University of British Columbia.
9  *
10  * %sccs.include.redist.c%
11  *
12  *	@(#)pk_debug.c	7.5 (Berkeley) 01/09/91
13  */
14 
15 #include "param.h"
16 #include "systm.h"
17 #include "mbuf.h"
18 #include "socket.h"
19 #include "protosw.h"
20 #include "socketvar.h"
21 #include "errno.h"
22 
23 #include "../net/if.h"
24 
25 #include "x25.h"
26 #include "pk.h"
27 #include "pk_var.h"
28 
29 char	*pk_state[] = {
30 	"Listen",	"Ready",	"Received-Call",
31 	"Sent-Call",	"Data-Transfer","Received-Clear",
32 	"Sent-Clear",
33 };
34 
35 char   *pk_name[] = {
36 	"Call",		"Call-Conf",	"Clear",
37 	"Clear-Conf",	"Data",		"Intr",		"Intr-Conf",
38 	"Rr",		"Rnr",		"Reset",	"Reset-Conf",
39 	"Restart",	"Restart-Conf",	"Invalid"
40 };
41 
42 pk_trace (xcp, m, dir)
43 struct x25config *xcp;
44 register struct mbuf *m;
45 char *dir;
46 {
47 	register char *s;
48 	struct x25_packet *xp = mtod(m, struct x25_packet *);
49 	register int i, len = 0, cnt = 0;
50 
51 	if (xcp -> xc_ptrace == 0)
52 		return;
53 
54 	i = pk_decode (xp) / MAXSTATES;
55 	for (; m; m = m -> m_next) {
56 		len = len + m -> m_len;
57 		++cnt;
58 	}
59 	printf ("LCN=%d %s:	%s	#=%d, len=%d ",
60 		LCN(xp), dir, pk_name[i], cnt, len);
61 	for (s = (char *) xp, i = 0; i < 5; ++i, ++s)
62 		printf ("%x ", (int) * s & 0xff);
63 	printf ("\n");
64 }
65