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