linux32_sys_ptrace() fixes.
[netbsd-mini2440.git] / sys / netiso / iso.h
blob5e4d171ef2854684e6116386a5aaaf7cf18e8d37
1 /* $NetBSD: iso.h,v 1.21 2007/08/30 02:17:38 dyoung Exp $ */
3 /*-
4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved.
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.
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.
31 * @(#)iso.h 8.1 (Berkeley) 6/10/93
34 /***********************************************************
35 Copyright IBM Corporation 1987
37 All Rights Reserved
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.
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.
55 ******************************************************************/
58 * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
61 #ifndef _NETISO_ISO_H_
62 #define _NETISO_ISO_H_
64 #include <sys/ansi.h>
66 #ifndef sa_family_t
67 typedef __sa_family_t sa_family_t;
68 #define sa_family_t __sa_family_t
69 #endif
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.
78 #define IS_MULTICAST(snpa)\
79 ((snpa)[0] & 0x01)
82 * Protocols
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 */
100 #define ISOPROTO_RAW 255 /* raw clnp */
101 #define ISOPROTO_MAX 256
103 #define ISO_PORT_RESERVED 1024
104 #define ISO_PORT_USERRESERVED 5000
106 * Port/socket numbers: standard network functions
107 * NOT PRESENTLY USED
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
115 * Port/socket numbers: non-standard application functions
117 #define ISO_PORT_LOGIN 513
119 * Port/socket numbers: public use
121 #define ISO_PORT_PUBLIC 1024 /* high bit set --> public */
124 * Network layer protocol identifiers
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
134 #ifndef IN_CLASSA_NET
135 #include <netinet/in.h>
136 #endif /* IN_CLASSA_NET */
141 * The following looks like a sockaddr to facilitate using tree lookup
142 * routines
144 struct iso_addr {
145 uint8_t isoa_len; /* length (in bytes) */
146 char isoa_genaddr[20]; /* general opaque address */
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 */
159 #define siso_nlen siso_addr.isoa_len
160 #define siso_data siso_addr.isoa_genaddr
162 static inline void *
163 WRITABLE_TSEL(struct sockaddr_iso *siso)
165 return &siso->siso_data[siso->siso_nlen];
168 static inline const char *
169 TSEL(const struct sockaddr_iso *siso)
171 return &siso->siso_data[siso->siso_nlen];
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)
179 * The following are specific values for siso->siso_data[0],
180 * otherwise known as the AFI:
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... */
187 #ifdef _KERNEL
189 #include <sys/protosw.h>
191 extern struct domain isodomain;
192 extern const struct protosw isosw[];
194 #define satosiso(sa) ((struct sockaddr_iso *)(sa))
195 #define satocsiso(sa) ((const struct sockaddr_iso *)(sa))
196 #define sisotosa(siso) ((struct sockaddr *)(siso))
198 int sockaddr_iso_cmp(const struct sockaddr *, const struct sockaddr *);
200 static inline int
201 sockaddr_iso_init1(struct sockaddr_iso *siso, const struct iso_addr *addr)
203 memset(&siso->siso_plen, 0,
204 sizeof(*siso) - offsetof(struct sockaddr_iso, siso_plen));
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;
214 static inline int
215 sockaddr_iso_init(struct sockaddr_iso *siso, const struct iso_addr *addr)
217 siso->siso_family = AF_ISO;
218 siso->siso_len = sizeof(*siso);
219 return sockaddr_iso_init1(siso, addr);
222 static inline struct sockaddr *
223 sockaddr_iso_alloc(const struct iso_addr *addr, int flags)
225 struct sockaddr *sa;
227 sa = sockaddr_alloc(AF_ISO, sizeof(struct sockaddr_iso), flags);
229 if (sa == NULL)
230 return NULL;
232 if (sockaddr_iso_init1(satosiso(sa), addr) != 0) {
233 sockaddr_free(sa);
234 return NULL;
236 return sa;
239 #else
240 /* user utilities definitions from the iso library */
242 #include <sys/cdefs.h>
244 __BEGIN_DECLS
245 struct iso_addr *iso_addr(const char *);
246 char *iso_ntoa(const struct iso_addr *);
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
253 #endif /* _KERNEL */
255 #endif /* !_NETISO_ISO_H_ */