Import Upstream version 1.2.2
[quagga-debian.git] / isisd / include-netbsd / iso.h
1 /*      $NetBSD: iso.h,v 1.13 2000/07/28 12:13:34 kleink 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. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *      This product includes software developed by the University of
18  *      California, Berkeley and its contributors.
19  * 4. Neither the name of the University nor the names of its contributors
20  *    may be used to endorse or promote products derived from this software
21  *    without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  *
35  *      @(#)iso.h       8.1 (Berkeley) 6/10/93
36  */
37
38 /***********************************************************
39                 Copyright IBM Corporation 1987
40
41                       All Rights Reserved
42
43 Permission to use, copy, modify, and distribute this software and its
44 documentation for any purpose and without fee is hereby granted,
45 provided that the above copyright notice appear in all copies and that
46 both that copyright notice and this permission notice appear in
47 supporting documentation, and that the name of IBM not be
48 used in advertising or publicity pertaining to distribution of the
49 software without specific, written prior permission.
50
51 IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
52 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
53 IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
54 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
55 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
56 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
57 SOFTWARE.
58
59 ******************************************************************/
60
61 /*
62  * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
63  */
64
65 #ifndef _NETISO_ISO_H_
66 #define _NETISO_ISO_H_
67
68 #if 0
69 #include <sys/ansi.h>
70 #endif
71
72 #if 0
73 #ifndef sa_family_t
74 typedef __sa_family_t   sa_family_t;
75 #define sa_family_t     __sa_family_t
76 #endif
77 #endif
78 /*
79  *      Return true if this is a multicast address
80  *      This assumes that the bit transmission is lsb first. This
81  *      assumption is valid for 802.3 but not 802.5. There is a
82  *      kludge to get around this for 802.5 -- see if_lan.c
83  *      where subnetwork header is setup.
84  */
85 #define IS_MULTICAST(snpa)\
86         ((snpa)[0] & 0x01)
87
88 /*
89  * Protocols
90  */
91 #define ISOPROTO_TCP    6       /* IETF experiment */
92 #define ISOPROTO_UDP    17      /* IETF experiment */
93 #define ISOPROTO_TP0    25      /* connection oriented transport protocol */
94 #define ISOPROTO_TP1    26      /* not implemented */
95 #define ISOPROTO_TP2    27      /* not implemented */
96 #define ISOPROTO_TP3    28      /* not implemented */
97 #define ISOPROTO_TP4    29      /* connection oriented transport protocol */
98 #define ISOPROTO_TP             ISOPROTO_TP4    /* tp-4 with negotiation */
99 #define ISOPROTO_CLTP   30      /* connectionless transport (not yet impl.) */
100 #define ISOPROTO_CLNP   31      /* connectionless internetworking protocol */
101 #define ISOPROTO_X25    32      /* cons */
102 #define ISOPROTO_INACT_NL       33      /* inactive network layer! */
103 #define ISOPROTO_ESIS   34      /* ES-IS protocol */
104 #define ISOPROTO_INTRAISIS      35      /* IS-IS protocol */
105 #define ISOPROTO_IDRP   36      /* Interdomain Routing Protocol */
106
107 #define ISOPROTO_RAW    255     /* raw clnp */
108 #define ISOPROTO_MAX    256
109
110 #define ISO_PORT_RESERVED               1024
111 #define ISO_PORT_USERRESERVED   5000
112 /*
113  * Port/socket numbers: standard network functions
114  * NOT PRESENTLY USED
115  */
116 #define ISO_PORT_MAINT          501
117 #define ISO_PORT_ECHO           507
118 #define ISO_PORT_DISCARD        509
119 #define ISO_PORT_SYSTAT         511
120 #define ISO_PORT_NETSTAT        515
121 /*
122  * Port/socket numbers: non-standard application functions
123  */
124 #define ISO_PORT_LOGIN          513
125 /*
126  * Port/socket numbers: public use
127  */
128 #define ISO_PORT_PUBLIC         1024    /* high bit set --> public */
129
130 /*
131  *      Network layer protocol identifiers
132  */
133 #define ISO8473_CLNP    0x81
134 #define ISO9542_ESIS    0x82
135 #define ISO9542X25_ESIS 0x8a
136 #define ISO10589_ISIS   0x83
137 #define ISO8878A_CONS   0x84
138 #define ISO10747_IDRP   0x85
139
140
141 #ifndef IN_CLASSA_NET
142 #include <netinet/in.h>
143 #endif                          /* IN_CLASSA_NET */
144
145
146
147 /*
148  * The following looks like a sockaddr to facilitate using tree lookup
149  * routines
150  */
151 struct iso_addr {
152         u_char          isoa_len;       /* length (in bytes) */
153         char            isoa_genaddr[20];       /* general opaque address */
154 };
155
156 struct sockaddr_iso {
157         u_char          siso_len;       /* length */
158         sa_family_t     siso_family;    /* family */
159         u_char          siso_plen;      /* presentation selector length */
160         u_char          siso_slen;      /* session selector length */
161         u_char          siso_tlen;      /* transport selector length */
162         struct iso_addr siso_addr;      /* network address */
163         u_char          siso_pad[6];    /* space for gosip v2 sels */
164         /* makes struct 32 bytes long */
165 };
166 #define siso_nlen siso_addr.isoa_len
167 #define siso_data siso_addr.isoa_genaddr
168
169 #define TSEL(s) ((caddr_t)((s)->siso_data + (s)->siso_nlen))
170
171 #define SAME_ISOADDR(a, b) \
172         (bcmp((a)->siso_data, (b)->siso_data, (unsigned)(a)->siso_nlen)==0)
173 #define SAME_ISOIFADDR(a, b) (bcmp((a)->siso_data, (b)->siso_data, \
174         (unsigned)((b)->siso_nlen - (b)->siso_tlen)) == 0)
175 /*
176  * The following are specific values for siso->siso_data[0],
177  * otherwise known as the AFI:
178  */
179 #define AFI_37          0x37    /* bcd of "37" */
180 #define AFI_OSINET      0x47    /* bcd of "47" */
181 #define AFI_RFC986      0x47    /* bcd of "47" */
182 #define AFI_SNA         0x00    /* SubNetwork Address; invalid really... */
183
184 #ifdef _KERNEL
185
186 extern struct domain isodomain;
187 extern struct protosw isosw[];
188
189 #define satosiso(sa)    ((struct sockaddr_iso *)(sa))
190 #define sisotosa(siso)  ((struct sockaddr *)(siso))
191
192 #else
193 /* user utilities definitions from the iso library */
194
195 #ifndef HAVE_SYS_CDEFS_H
196 #define __P(x)  x
197 #define __BEGIN_DECLS
198 #define __END_DECLS
199 #else
200 #include <sys/cdefs.h>
201 #endif
202
203 __BEGIN_DECLS
204 struct iso_addr *iso_addr __P((const char *));
205 char           *iso_ntoa __P((const struct iso_addr *));
206
207 /* THESE DON'T EXIST YET */
208 struct hostent *iso_gethostbyname __P((const char *));
209 struct hostent *iso_gethostbyaddr __P((const char *, int, int));
210 __END_DECLS
211
212 #endif /* _KERNEL */
213
214 #endif /* _NETISO_ISO_H_ */