Commit | Line | Data |
---|---|---|
7bcd1bb8 KB |
1 | /*- |
2 | * Copyright (c) 1991 The Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
5 | * %sccs.include.redist.c% | |
6 | * | |
52ac7ba2 | 7 | * @(#)clnp_debug.c 7.9 (Berkeley) %G% |
7bcd1bb8 KB |
8 | */ |
9 | ||
011444fe KS |
10 | /*********************************************************** |
11 | Copyright IBM Corporation 1987 | |
12 | ||
13 | All Rights Reserved | |
14 | ||
15 | Permission to use, copy, modify, and distribute this software and its | |
16 | documentation for any purpose and without fee is hereby granted, | |
17 | provided that the above copyright notice appear in all copies and that | |
18 | both that copyright notice and this permission notice appear in | |
19 | supporting documentation, and that the name of IBM not be | |
20 | used in advertising or publicity pertaining to distribution of the | |
21 | software without specific, written prior permission. | |
22 | ||
23 | IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING | |
24 | ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL | |
25 | IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR | |
26 | ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, | |
27 | WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, | |
28 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS | |
29 | SOFTWARE. | |
30 | ||
31 | ******************************************************************/ | |
32 | ||
33 | /* | |
34 | * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison | |
35 | */ | |
36 | /* $Header: clnp_debug.c,v 4.2 88/06/29 14:58:34 hagens Exp $ */ | |
37 | /* $Source: /usr/argo/sys/netargo/RCS/clnp_debug.c,v $ */ | |
011444fe | 38 | |
e663c139 KM |
39 | #include "types.h" |
40 | #include "param.h" | |
41 | #include "mbuf.h" | |
42 | #include "domain.h" | |
43 | #include "protosw.h" | |
44 | #include "socket.h" | |
45 | #include "socketvar.h" | |
46 | #include "errno.h" | |
011444fe KS |
47 | |
48 | #include "../net/if.h" | |
49 | #include "../net/route.h" | |
50 | ||
a50e2bc0 KS |
51 | #include "iso.h" |
52 | #include "clnp.h" | |
53 | #include "clnp_stat.h" | |
54 | #include "argo_debug.h" | |
011444fe KS |
55 | |
56 | #ifdef ARGO_DEBUG | |
57 | ||
58 | #ifdef TESTDEBUG | |
59 | #ifdef notdef | |
60 | struct addr_37 u_37 = { | |
61 | {0x00, 0x02, 0x00, 0x10, 0x20, 0x30, 0x35}, | |
62 | {0x01, 0x02, 0x03, 0x04, 0x50, 0x60, 0x70, 0x80, 0x90} | |
63 | }; | |
64 | struct addr_osinet u_osinet = { | |
65 | {0x00, 0x04}, | |
66 | {0x00, 0x02, 0x00, 0x01, 0x23, 0x42, 0x78, 0x20, 0x01, 0x05, 0x00} | |
67 | }; | |
68 | #endif notdef | |
69 | struct addr_rfc986 u_rfc986 = { | |
70 | {0x00, 0x06}, | |
71 | {0x01, 0xc0, 0x0c, 0x0c, 0xab, 0x11} | |
72 | }; | |
73 | struct addr_rfc986 u_bad = { | |
74 | {0x00, 0x01}, | |
75 | {0x01, 0xc0, 0x0c, 0x0c, 0xab, 0x11} | |
76 | }; | |
77 | #include <stdio.h> | |
78 | main() | |
79 | { | |
80 | struct iso_addr a; | |
81 | ||
82 | a.isoa_afi = AFI_37; | |
83 | a.isoa_u.addr_37 = u_37; | |
84 | a.isoa_len = 17; | |
85 | printf("type 37: %s\n", clnp_iso_addrp(&a)); | |
86 | ||
87 | a.isoa_afi = AFI_OSINET; | |
88 | a.isoa_u.addr_osinet = u_osinet; | |
89 | a.isoa_len = 14; | |
90 | printf("type osinet: %s\n", clnp_iso_addrp(&a)); | |
91 | ||
92 | a.isoa_afi = AFI_RFC986; | |
93 | a.isoa_u.addr_rfc986 = u_rfc986; | |
94 | a.isoa_len = 9; | |
95 | printf("type rfc986: %s\n", clnp_iso_addrp(&a)); | |
96 | ||
97 | a.isoa_afi = 12; | |
98 | a.isoa_u.addr_rfc986 = u_rfc986; | |
99 | a.isoa_len = 9; | |
100 | printf("type bad afi: %s\n", clnp_iso_addrp(&a)); | |
101 | ||
102 | a.isoa_afi = AFI_RFC986; | |
103 | a.isoa_u.addr_rfc986 = u_bad; | |
104 | a.isoa_len = 9; | |
105 | printf("type bad idi: %s\n", clnp_iso_addrp(&a)); | |
106 | } | |
107 | #endif TESTDEBUG | |
108 | ||
109 | unsigned int clnp_debug; | |
110 | static char letters[] = "0123456789abcdef"; | |
111 | ||
112 | /* | |
113 | * Print buffer in hex, return addr of where we left off. | |
114 | * Do not null terminate. | |
115 | */ | |
116 | char * | |
117 | clnp_hexp(src, len, where) | |
118 | char *src; /* src of data to print */ | |
52ac7ba2 | 119 | int len; /* lengthof src */ |
011444fe KS |
120 | char *where; /* where to put data */ |
121 | { | |
122 | int i; | |
123 | ||
124 | for (i=0; i<len; i++) { | |
52ac7ba2 KS |
125 | register int j = ((u_char *)src)[i]; |
126 | *where++ = letters[j >> 4]; | |
127 | *where++ = letters[j & 0x0f]; | |
011444fe KS |
128 | } |
129 | return where; | |
130 | } | |
131 | ||
132 | /* | |
133 | * Return a ptr to a human readable form of an iso addr | |
134 | */ | |
135 | static char iso_addr_b[50]; | |
136 | #define DELIM '.'; | |
137 | ||
138 | char * | |
139 | clnp_iso_addrp(isoa) | |
140 | struct iso_addr *isoa; | |
141 | { | |
142 | char *cp; | |
143 | ||
144 | /* print length */ | |
66c6c4df | 145 | sprintf(iso_addr_b, "[%d] ", isoa->isoa_len); |
011444fe KS |
146 | |
147 | /* set cp to end of what we have */ | |
148 | cp = iso_addr_b; | |
149 | while (*cp) | |
150 | cp++; | |
151 | ||
152 | /* print afi */ | |
a50e2bc0 KS |
153 | cp = clnp_hexp(isoa->isoa_genaddr, (int)isoa->isoa_len, cp); |
154 | #ifdef notdef | |
011444fe KS |
155 | *cp++ = DELIM; |
156 | ||
157 | /* print type specific part */ | |
158 | switch(isoa->isoa_afi) { | |
159 | case AFI_37: | |
160 | cp = clnp_hexp(isoa->t37_idi, ADDR37_IDI_LEN, cp); | |
161 | *cp++ = DELIM; | |
162 | cp = clnp_hexp(isoa->t37_dsp, ADDR37_DSP_LEN, cp); | |
163 | break; | |
164 | ||
165 | /* case AFI_OSINET:*/ | |
166 | case AFI_RFC986: { | |
167 | u_short idi; | |
168 | ||
169 | /* osinet and rfc986 have idi in the same place */ | |
170 | /* print idi */ | |
171 | cp = clnp_hexp(isoa->rfc986_idi, ADDROSINET_IDI_LEN, cp); | |
172 | *cp++ = DELIM; | |
173 | CTOH(isoa->rfc986_idi[0], isoa->rfc986_idi[1], idi); | |
174 | ||
175 | if (idi == IDI_OSINET) { | |
176 | struct ovl_osinet *oosi = (struct ovl_osinet *)isoa; | |
177 | cp = clnp_hexp(oosi->oosi_orgid, OVLOSINET_ORGID_LEN, cp); | |
178 | *cp++ = DELIM; | |
179 | cp = clnp_hexp(oosi->oosi_snetid, OVLOSINET_SNETID_LEN, cp); | |
180 | *cp++ = DELIM; | |
181 | cp = clnp_hexp(oosi->oosi_snpa, OVLOSINET_SNPA_LEN, cp); | |
182 | *cp++ = DELIM; | |
183 | cp = clnp_hexp(oosi->oosi_nsap, OVLOSINET_NSAP_LEN, cp); | |
184 | } else if (idi == IDI_RFC986) { | |
185 | struct ovl_rfc986 *o986 = (struct ovl_rfc986 *)isoa; | |
186 | cp = clnp_hexp(&o986->o986_vers, 1, cp); | |
187 | *cp++ = DELIM; | |
188 | #ifdef vax | |
66c6c4df | 189 | sprintf(cp, "%d.%d.%d.%d.%d", |
011444fe KS |
190 | o986->o986_inetaddr[0] & 0xff, |
191 | o986->o986_inetaddr[1] & 0xff, | |
192 | o986->o986_inetaddr[2] & 0xff, | |
193 | o986->o986_inetaddr[3] & 0xff, | |
194 | o986->o986_upid & 0xff); | |
195 | return(iso_addr_b); | |
196 | #else | |
197 | cp = clnp_hexp(&o986->o986_inetaddr[0], 1, cp); | |
198 | *cp++ = DELIM; | |
199 | cp = clnp_hexp(&o986->o986_inetaddr[1], 1, cp); | |
200 | *cp++ = DELIM; | |
201 | cp = clnp_hexp(&o986->o986_inetaddr[2], 1, cp); | |
202 | *cp++ = DELIM; | |
203 | cp = clnp_hexp(&o986->o986_inetaddr[3], 1, cp); | |
204 | *cp++ = DELIM; | |
205 | cp = clnp_hexp(&o986->o986_upid, 1, cp); | |
206 | #endif vax | |
207 | } | |
208 | ||
209 | } break; | |
210 | ||
211 | default: | |
212 | *cp++ = '?'; | |
213 | break; | |
214 | } | |
a50e2bc0 | 215 | #endif notdef |
011444fe KS |
216 | *cp = (char)0; |
217 | ||
218 | return(iso_addr_b); | |
219 | } | |
220 | ||
a50e2bc0 KS |
221 | char * |
222 | clnp_saddr_isop(s) | |
223 | register struct sockaddr_iso *s; | |
011444fe | 224 | { |
a50e2bc0 KS |
225 | register char *cp = clnp_iso_addrp(&s->siso_addr); |
226 | ||
227 | while (*cp) cp++; | |
228 | *cp++ = '('; | |
44f52ea5 | 229 | cp = clnp_hexp(TSEL(s), (int)s->siso_tlen, cp); |
a50e2bc0 KS |
230 | *cp++ = ')'; |
231 | *cp++ = 0; | |
232 | return (iso_addr_b); | |
011444fe KS |
233 | } |
234 | ||
011444fe | 235 | #endif ARGO_DEBUG |