The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/netiso/clnp_debug.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

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

Cache object: 6d4db9a786286364330d60e72eee3f81


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.