|
|
1.1 root 1: /*-
2: * Copyright (c) 1991 The Regents of the University of California.
3: * All rights reserved.
4: *
5: * Redistribution and use in source and binary forms, with or without
6: * modification, are permitted provided that the following conditions
7: * are met:
8: * 1. Redistributions of source code must retain the above copyright
9: * notice, this list of conditions and the following disclaimer.
10: * 2. Redistributions in binary form must reproduce the above copyright
11: * notice, this list of conditions and the following disclaimer in the
12: * documentation and/or other materials provided with the distribution.
13: * 3. All advertising materials mentioning features or use of this software
14: * must display the following acknowledgement:
15: * This product includes software developed by the University of
16: * California, Berkeley and its contributors.
17: * 4. Neither the name of the University nor the names of its contributors
18: * may be used to endorse or promote products derived from this software
19: * without specific prior written permission.
20: *
21: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31: * SUCH DAMAGE.
32: *
33: * @(#)clnp_debug.c 7.8 (Berkeley) 5/27/91
34: */
35:
36: /***********************************************************
37: Copyright IBM Corporation 1987
38:
39: All Rights Reserved
40:
41: Permission to use, copy, modify, and distribute this software and its
42: documentation for any purpose and without fee is hereby granted,
43: provided that the above copyright notice appear in all copies and that
44: both that copyright notice and this permission notice appear in
45: supporting documentation, and that the name of IBM not be
46: used in advertising or publicity pertaining to distribution of the
47: software without specific, written prior permission.
48:
49: IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
50: ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
51: IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
52: ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
53: WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
54: ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
55: SOFTWARE.
56:
57: ******************************************************************/
58:
59: /*
60: * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
61: */
62: /* $Header: clnp_debug.c,v 4.2 88/06/29 14:58:34 hagens Exp $ */
63: /* $Source: /usr/argo/sys/netargo/RCS/clnp_debug.c,v $ */
64:
65: #include "types.h"
66: #include "param.h"
67: #include "mbuf.h"
68: #include "domain.h"
69: #include "protosw.h"
70: #include "socket.h"
71: #include "socketvar.h"
72: #include "errno.h"
73:
74: #include "../net/if.h"
75: #include "../net/route.h"
76:
77: #include "iso.h"
78: #include "clnp.h"
79: #include "clnp_stat.h"
80: #include "argo_debug.h"
81:
82: #ifdef ARGO_DEBUG
83:
84: #ifdef TESTDEBUG
85: #ifdef notdef
86: struct addr_37 u_37 = {
87: {0x00, 0x02, 0x00, 0x10, 0x20, 0x30, 0x35},
88: {0x01, 0x02, 0x03, 0x04, 0x50, 0x60, 0x70, 0x80, 0x90}
89: };
90: struct addr_osinet u_osinet = {
91: {0x00, 0x04},
92: {0x00, 0x02, 0x00, 0x01, 0x23, 0x42, 0x78, 0x20, 0x01, 0x05, 0x00}
93: };
94: #endif notdef
95: struct addr_rfc986 u_rfc986 = {
96: {0x00, 0x06},
97: {0x01, 0xc0, 0x0c, 0x0c, 0xab, 0x11}
98: };
99: struct addr_rfc986 u_bad = {
100: {0x00, 0x01},
101: {0x01, 0xc0, 0x0c, 0x0c, 0xab, 0x11}
102: };
103: #include <stdio.h>
104: main()
105: {
106: struct iso_addr a;
107:
108: a.isoa_afi = AFI_37;
109: a.isoa_u.addr_37 = u_37;
110: a.isoa_len = 17;
111: printf("type 37: %s\n", clnp_iso_addrp(&a));
112:
113: a.isoa_afi = AFI_OSINET;
114: a.isoa_u.addr_osinet = u_osinet;
115: a.isoa_len = 14;
116: printf("type osinet: %s\n", clnp_iso_addrp(&a));
117:
118: a.isoa_afi = AFI_RFC986;
119: a.isoa_u.addr_rfc986 = u_rfc986;
120: a.isoa_len = 9;
121: printf("type rfc986: %s\n", clnp_iso_addrp(&a));
122:
123: a.isoa_afi = 12;
124: a.isoa_u.addr_rfc986 = u_rfc986;
125: a.isoa_len = 9;
126: printf("type bad afi: %s\n", clnp_iso_addrp(&a));
127:
128: a.isoa_afi = AFI_RFC986;
129: a.isoa_u.addr_rfc986 = u_bad;
130: a.isoa_len = 9;
131: printf("type bad idi: %s\n", clnp_iso_addrp(&a));
132: }
133: #endif TESTDEBUG
134:
135: unsigned int clnp_debug;
136: static char letters[] = "0123456789abcdef";
137:
138: /*
139: * Print buffer in hex, return addr of where we left off.
140: * Do not null terminate.
141: */
142: char *
143: clnp_hexp(src, len, where)
144: char *src; /* src of data to print */
145: int len; /* lengthof src */
146: char *where; /* where to put data */
147: {
148: int i;
149:
150: for (i=0; i<len; i++) {
151: *where++ = letters[src[i] >> 4];
152: *where++ = letters[src[i] & 0x0f];
153: }
154: return where;
155: }
156:
157: /*
158: * Return a ptr to a human readable form of an iso addr
159: */
160: static char iso_addr_b[50];
161: #define DELIM '.';
162:
163: char *
164: clnp_iso_addrp(isoa)
165: struct iso_addr *isoa;
166: {
167: char *cp;
168:
169: /* print length */
170: sprintf(iso_addr_b, "[%d] ", isoa->isoa_len);
171:
172: /* set cp to end of what we have */
173: cp = iso_addr_b;
174: while (*cp)
175: cp++;
176:
177: /* print afi */
178: cp = clnp_hexp(isoa->isoa_genaddr, (int)isoa->isoa_len, cp);
179: #ifdef notdef
180: *cp++ = DELIM;
181:
182: /* print type specific part */
183: switch(isoa->isoa_afi) {
184: case AFI_37:
185: cp = clnp_hexp(isoa->t37_idi, ADDR37_IDI_LEN, cp);
186: *cp++ = DELIM;
187: cp = clnp_hexp(isoa->t37_dsp, ADDR37_DSP_LEN, cp);
188: break;
189:
190: /* case AFI_OSINET:*/
191: case AFI_RFC986: {
192: u_short idi;
193:
194: /* osinet and rfc986 have idi in the same place */
195: /* print idi */
196: cp = clnp_hexp(isoa->rfc986_idi, ADDROSINET_IDI_LEN, cp);
197: *cp++ = DELIM;
198: CTOH(isoa->rfc986_idi[0], isoa->rfc986_idi[1], idi);
199:
200: if (idi == IDI_OSINET) {
201: struct ovl_osinet *oosi = (struct ovl_osinet *)isoa;
202: cp = clnp_hexp(oosi->oosi_orgid, OVLOSINET_ORGID_LEN, cp);
203: *cp++ = DELIM;
204: cp = clnp_hexp(oosi->oosi_snetid, OVLOSINET_SNETID_LEN, cp);
205: *cp++ = DELIM;
206: cp = clnp_hexp(oosi->oosi_snpa, OVLOSINET_SNPA_LEN, cp);
207: *cp++ = DELIM;
208: cp = clnp_hexp(oosi->oosi_nsap, OVLOSINET_NSAP_LEN, cp);
209: } else if (idi == IDI_RFC986) {
210: struct ovl_rfc986 *o986 = (struct ovl_rfc986 *)isoa;
211: cp = clnp_hexp(&o986->o986_vers, 1, cp);
212: *cp++ = DELIM;
213: #ifdef vax
214: sprintf(cp, "%d.%d.%d.%d.%d",
215: o986->o986_inetaddr[0] & 0xff,
216: o986->o986_inetaddr[1] & 0xff,
217: o986->o986_inetaddr[2] & 0xff,
218: o986->o986_inetaddr[3] & 0xff,
219: o986->o986_upid & 0xff);
220: return(iso_addr_b);
221: #else
222: cp = clnp_hexp(&o986->o986_inetaddr[0], 1, cp);
223: *cp++ = DELIM;
224: cp = clnp_hexp(&o986->o986_inetaddr[1], 1, cp);
225: *cp++ = DELIM;
226: cp = clnp_hexp(&o986->o986_inetaddr[2], 1, cp);
227: *cp++ = DELIM;
228: cp = clnp_hexp(&o986->o986_inetaddr[3], 1, cp);
229: *cp++ = DELIM;
230: cp = clnp_hexp(&o986->o986_upid, 1, cp);
231: #endif vax
232: }
233:
234: } break;
235:
236: default:
237: *cp++ = '?';
238: break;
239: }
240: #endif notdef
241: *cp = (char)0;
242:
243: return(iso_addr_b);
244: }
245:
246: char *
247: clnp_saddr_isop(s)
248: register struct sockaddr_iso *s;
249: {
250: register char *cp = clnp_iso_addrp(&s->siso_addr);
251:
252: while (*cp) cp++;
253: *cp++ = '(';
254: cp = clnp_hexp(TSEL(s), (int)s->siso_tlen, cp);
255: *cp++ = ')';
256: *cp++ = 0;
257: return (iso_addr_b);
258: }
259:
260: #endif ARGO_DEBUG
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.