Annotation of kernel/bsd/netiso/clnp_debug.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.