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/iso.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: iso.h,v 1.22 2007/11/21 16:49:08 is 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  *      @(#)iso.h       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 #ifndef _NETISO_ISO_H_
   62 #define _NETISO_ISO_H_
   63 
   64 #include <sys/ansi.h>
   65 
   66 #ifndef sa_family_t
   67 typedef __sa_family_t   sa_family_t;
   68 #define sa_family_t     __sa_family_t
   69 #endif
   70 
   71 /*
   72  *      Return true if this is a multicast address
   73  *      This assumes that the bit transmission is lsb first. This
   74  *      assumption is valid for 802.3 but not 802.5. There is a
   75  *      kludge to get around this for 802.5 -- see if_lan.c
   76  *      where subnetwork header is setup.
   77  */
   78 #define IS_MULTICAST(snpa)\
   79         ((snpa)[0] & 0x01)
   80 
   81 /*
   82  * Protocols
   83  */
   84 #define ISOPROTO_TCP    6       /* IETF experiment */
   85 #define ISOPROTO_UDP    17      /* IETF experiment */
   86 #define ISOPROTO_TP0    25      /* connection oriented transport protocol */
   87 #define ISOPROTO_TP1    26      /* not implemented */
   88 #define ISOPROTO_TP2    27      /* not implemented */
   89 #define ISOPROTO_TP3    28      /* not implemented */
   90 #define ISOPROTO_TP4    29      /* connection oriented transport protocol */
   91 #define ISOPROTO_TP             ISOPROTO_TP4    /* tp-4 with negotiation */
   92 #define ISOPROTO_CLTP   30      /* connectionless transport (not yet impl.) */
   93 #define ISOPROTO_CLNP   31      /* connectionless internetworking protocol */
   94 #define ISOPROTO_X25    32      /* cons */
   95 #define ISOPROTO_INACT_NL       33      /* inactive network layer! */
   96 #define ISOPROTO_ESIS   34      /* ES-IS protocol */
   97 #define ISOPROTO_INTRAISIS      35      /* IS-IS protocol */
   98 #define ISOPROTO_IDRP   36      /* Interdomain Routing Protocol */
   99 
  100 #define ISOPROTO_RAW    255     /* raw clnp */
  101 #define ISOPROTO_MAX    256
  102 
  103 #define ISO_PORT_RESERVED               1024
  104 #define ISO_PORT_USERRESERVED   5000
  105 /*
  106  * Port/socket numbers: standard network functions
  107  * NOT PRESENTLY USED
  108  */
  109 #define ISO_PORT_MAINT          501
  110 #define ISO_PORT_ECHO           507
  111 #define ISO_PORT_DISCARD        509
  112 #define ISO_PORT_SYSTAT         511
  113 #define ISO_PORT_NETSTAT        515
  114 /*
  115  * Port/socket numbers: non-standard application functions
  116  */
  117 #define ISO_PORT_LOGIN          513
  118 /*
  119  * Port/socket numbers: public use
  120  */
  121 #define ISO_PORT_PUBLIC         1024    /* high bit set --> public */
  122 
  123 /*
  124  *      Network layer protocol identifiers
  125  */
  126 #define ISO8473_CLNP    0x81
  127 #define ISO9542_ESIS    0x82
  128 #define ISO9542X25_ESIS 0x8a
  129 #define ISO10589_ISIS           0x83
  130 #define ISO8878A_CONS           0x84
  131 #define ISO10747_IDRP           0x85
  132 
  133 
  134 #ifndef IN_CLASSA_NET
  135 #include <netinet/in.h>
  136 #endif                          /* IN_CLASSA_NET */
  137 
  138 
  139 
  140 /*
  141  * The following looks like a sockaddr to facilitate using tree lookup
  142  * routines
  143  */
  144 struct iso_addr {
  145         uint8_t         isoa_len;       /* length (in bytes) */
  146         char            isoa_genaddr[20];       /* general opaque address */
  147 };
  148 
  149 struct sockaddr_iso {
  150         uint8_t         siso_len;       /* length */
  151         sa_family_t     siso_family;    /* family */
  152         uint8_t         siso_plen;      /* presentation selector length */
  153         uint8_t         siso_slen;      /* session selector length */
  154         uint8_t         siso_tlen;      /* transport selector length */
  155         struct iso_addr siso_addr;      /* network address */
  156         uint8_t         siso_pad[6];    /* space for gosip v2 sels */
  157         /* makes struct 32 bytes long */
  158 };
  159 #define siso_nlen siso_addr.isoa_len
  160 #define siso_data siso_addr.isoa_genaddr
  161 
  162 static inline void *
  163 WRITABLE_TSEL(struct sockaddr_iso *siso)
  164 {
  165         return &siso->siso_data[siso->siso_nlen];
  166 }
  167 
  168 static inline const char *
  169 TSEL(const struct sockaddr_iso *siso)
  170 {
  171         return &siso->siso_data[siso->siso_nlen];
  172 }
  173 
  174 #define SAME_ISOADDR(a, b) \
  175         (bcmp((a)->siso_data, (b)->siso_data, (unsigned)(a)->siso_nlen)==0)
  176 #define SAME_ISOIFADDR(a, b) (bcmp((a)->siso_data, (b)->siso_data, \
  177         (unsigned)((b)->siso_nlen - (b)->siso_tlen)) == 0)
  178 /*
  179  * The following are specific values for siso->siso_data[0],
  180  * otherwise known as the AFI:
  181  */
  182 #define AFI_37          0x37    /* bcd of "37" */
  183 #define AFI_OSINET      0x47    /* bcd of "47" */
  184 #define AFI_RFC986      0x47    /* bcd of "47" */
  185 #define AFI_SNA         0x00    /* SubNetwork Address; invalid really... */
  186 
  187 #ifdef _KERNEL
  188 
  189 #include <sys/protosw.h>
  190 
  191 extern struct domain isodomain;
  192 extern const struct protosw isosw[];
  193 
  194 #define satosiso(sa)    ((struct sockaddr_iso *)(sa))
  195 #define satocsiso(sa)   ((const struct sockaddr_iso *)(sa))
  196 #define sisotosa(siso)  ((struct sockaddr *)(siso))
  197 
  198 int sockaddr_iso_cmp(const struct sockaddr *, const struct sockaddr *);
  199 
  200 static inline int
  201 sockaddr_iso_init1(struct sockaddr_iso *siso, const struct iso_addr *addr)
  202 {
  203         memset(&siso->siso_plen, 0,
  204             sizeof(*siso) - offsetof(struct sockaddr_iso, siso_plen));
  205 
  206         if (offsetof(struct iso_addr, isoa_genaddr[addr->isoa_len]) >
  207             sizeof(struct iso_addr))
  208                 return EINVAL;
  209         memcpy(&siso->siso_addr, addr,
  210             offsetof(struct iso_addr, isoa_genaddr[addr->isoa_len]));
  211         return 0;
  212 }
  213 
  214 static inline int
  215 sockaddr_iso_init(struct sockaddr_iso *siso, const struct iso_addr *addr)
  216 {
  217         siso->siso_family = AF_ISO;
  218         siso->siso_len = sizeof(*siso);
  219         return sockaddr_iso_init1(siso, addr);
  220 }
  221 
  222 static inline struct sockaddr *
  223 sockaddr_iso_alloc(const struct iso_addr *addr, int flags)
  224 {
  225         struct sockaddr *sa;
  226 
  227         sa = sockaddr_alloc(AF_ISO, sizeof(struct sockaddr_iso), flags);
  228 
  229         if (sa == NULL)
  230                 return NULL;
  231 
  232         if (sockaddr_iso_init1(satosiso(sa), addr) != 0) {
  233                 sockaddr_free(sa);
  234                 return NULL;
  235         }
  236         return sa;
  237 }
  238 
  239 #else
  240 /* user utilities definitions from the iso library */
  241 
  242 #include <sys/cdefs.h>
  243 
  244 __BEGIN_DECLS
  245 struct iso_addr *iso_addr(const char *);
  246 char           *iso_ntoa(const struct iso_addr *);
  247 
  248 /* THESE DON'T EXIST YET */
  249 struct hostent *iso_gethostbyname(const char *);
  250 struct hostent *iso_gethostbyaddr(const char *, int, int);
  251 __END_DECLS
  252 
  253 #endif /* _KERNEL */
  254 
  255 #endif /* !_NETISO_ISO_H_ */

Cache object: 35aa2b5e725c8e59e3398949607973aa


[ 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.