1 | /* Modified for emx by hv and em 1994,1996
|
---|
2 | * Modified for gcc/os2 by bird 2003
|
---|
3 | * Modified for kLIBC by bird 2007, added INET_ADDRSTRLEN.
|
---|
4 | *
|
---|
5 | * Copyright (c) 1982, 1986, 1990 Regents of the University of California.
|
---|
6 | * All rights reserved.
|
---|
7 | *
|
---|
8 | * Redistribution and use in source and binary forms, with or without
|
---|
9 | * modification, are permitted provided that the following conditions
|
---|
10 | * are met:
|
---|
11 | * 1. Redistributions of source code must retain the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer.
|
---|
13 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
14 | * notice, this list of conditions and the following disclaimer in the
|
---|
15 | * documentation and/or other materials provided with the distribution.
|
---|
16 | * 3. All advertising materials mentioning features or use of this software
|
---|
17 | * must display the following acknowledgement:
|
---|
18 | * This product includes software developed by the University of
|
---|
19 | * California, Berkeley and its contributors.
|
---|
20 | * 4. Neither the name of the University nor the names of its contributors
|
---|
21 | * may be used to endorse or promote products derived from this software
|
---|
22 | * without specific prior written permission.
|
---|
23 | *
|
---|
24 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
---|
25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
---|
26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
---|
27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
---|
28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
---|
29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
---|
30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
---|
31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
---|
32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
---|
33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
34 | * SUCH DAMAGE.
|
---|
35 | *
|
---|
36 | * from: @(#)in.h 7.11 (Berkeley) 4/20/91
|
---|
37 | * $Id: in.h,v 1.8 1994/01/28 13:46:02 deraadt Exp $
|
---|
38 | */
|
---|
39 |
|
---|
40 | #ifndef _NETINET_IN_H_
|
---|
41 | #define _NETINET_IN_H_
|
---|
42 |
|
---|
43 | #ifndef _EMX_TCPIP
|
---|
44 | #define _EMX_TCPIP
|
---|
45 | #endif
|
---|
46 |
|
---|
47 | #include <sys/param.h> /* htons() etc. */
|
---|
48 | /* added 2007: */
|
---|
49 | #include <sys/cdefs.h>
|
---|
50 | #include <sys/_types.h>
|
---|
51 | #include <machine/endian.h>
|
---|
52 |
|
---|
53 | __BEGIN_DECLS
|
---|
54 |
|
---|
55 | /* added 2007: */
|
---|
56 | #if __POSIX_VISIBLE >= 200112
|
---|
57 | #define INET_ADDRSTRLEN 16
|
---|
58 | #endif
|
---|
59 |
|
---|
60 | /*
|
---|
61 | * Constants and structures defined by the internet system,
|
---|
62 | * Per RFC 790, September 1981.
|
---|
63 | */
|
---|
64 |
|
---|
65 | /*
|
---|
66 | * Protocols
|
---|
67 | */
|
---|
68 | #define IPPROTO_IP 0 /* dummy for IP */
|
---|
69 | #define IPPROTO_ICMP 1 /* control message protocol */
|
---|
70 | #define IPPROTO_IGMP 2 /* group mgmt protocol */
|
---|
71 | #define IPPROTO_GGP 3 /* gateway^2 (deprecated) */
|
---|
72 | #define IPPROTO_TCP 6 /* tcp */
|
---|
73 | #define IPPROTO_EGP 8 /* exterior gateway protocol */
|
---|
74 | #define IPPROTO_PUP 12 /* pup */
|
---|
75 | #define IPPROTO_UDP 17 /* user datagram protocol */
|
---|
76 | #define IPPROTO_IDP 22 /* xns idp */
|
---|
77 | #ifndef TCPV40HDRS
|
---|
78 | #define IPPROTO_TP 29 /* tp-4 w/ class negotiation */
|
---|
79 | #define IPPROTO_EON 80 /* ISO cnlp */
|
---|
80 | #define IPPROTO_ENCAP 98 /* encapsulation header */
|
---|
81 | #endif
|
---|
82 |
|
---|
83 | #define IPPROTO_RAW 255 /* raw IP packet */
|
---|
84 | #define IPPROTO_MAX 256
|
---|
85 |
|
---|
86 |
|
---|
87 | /*
|
---|
88 | * Local port number conventions:
|
---|
89 | * Ports < IPPORT_RESERVED are reserved for
|
---|
90 | * privileged processes (e.g. root).
|
---|
91 | * Ports > IPPORT_USERRESERVED are reserved
|
---|
92 | * for servers, not necessarily privileged.
|
---|
93 | */
|
---|
94 | #ifdef TCPV40HDRS
|
---|
95 | #define IPPORT_RESERVED 1024
|
---|
96 | #define IPPORT_USERRESERVED 5000
|
---|
97 | #else
|
---|
98 | /* Changing the ephemeral port #s as per Internet Assigned Numbers Authority's
|
---|
99 | * update as found in JUL '97. [Ref: http://www.isi.edu/div7/iana/descript/html] */
|
---|
100 | #define IPPORT_RESERVED 49152 /* Old 1024. Changed as per IANA draft */
|
---|
101 | #define IPPORT_USERRESERVED 65535 /* Old 5000. Changed as per IANA draft */
|
---|
102 | #endif
|
---|
103 |
|
---|
104 | #ifdef TCPV40HDRS
|
---|
105 | /*
|
---|
106 | * Link numbers
|
---|
107 | */
|
---|
108 | #define IMPLINK_IP 155
|
---|
109 | #define IMPLINK_LOWEXPER 156
|
---|
110 | #define IMPLINK_HIGHEXPER 158
|
---|
111 | #endif
|
---|
112 |
|
---|
113 | /*
|
---|
114 | * Internet address (a structure for historical reasons)
|
---|
115 | */
|
---|
116 | #ifndef _STRUCT_IN_ADDR_DECLARED
|
---|
117 | struct in_addr {
|
---|
118 | u_long s_addr;
|
---|
119 | };
|
---|
120 | #define _STRUCT_IN_ADDR_DECLARED
|
---|
121 | #endif
|
---|
122 |
|
---|
123 |
|
---|
124 | /*
|
---|
125 | * Definitions of bits in internet address integers.
|
---|
126 | * On subnets, the decomposition of addresses to host and net parts
|
---|
127 | * is done according to subnet mask, not the masks here.
|
---|
128 | */
|
---|
129 | #define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
|
---|
130 | #define IN_CLASSA_NET 0xff000000
|
---|
131 | #define IN_CLASSA_NSHIFT 24
|
---|
132 | #define IN_CLASSA_HOST 0x00ffffff
|
---|
133 | #define IN_CLASSA_MAX 128
|
---|
134 |
|
---|
135 | #define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
|
---|
136 | #define IN_CLASSB_NET 0xffff0000
|
---|
137 | #define IN_CLASSB_NSHIFT 16
|
---|
138 | #define IN_CLASSB_HOST 0x0000ffff
|
---|
139 | #define IN_CLASSB_MAX 65536
|
---|
140 |
|
---|
141 | #define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
|
---|
142 | #define IN_CLASSC_NET 0xffffff00
|
---|
143 | #define IN_CLASSC_NSHIFT 8
|
---|
144 | #define IN_CLASSC_HOST 0x000000ff
|
---|
145 |
|
---|
146 | #define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000)
|
---|
147 | #ifdef TCPV40HDRS
|
---|
148 | #define IN_CLASSD_NET 0xffffffff
|
---|
149 | #define IN_CLASSD_HOST 0
|
---|
150 | #else
|
---|
151 | #define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */
|
---|
152 | #define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */
|
---|
153 | #endif
|
---|
154 | #define IN_CLASSD_NSHIFT 28 /* net and host fields, but */
|
---|
155 | #define IN_MULTICAST(i) IN_CLASSD(i)
|
---|
156 |
|
---|
157 | #ifdef TCPV40HDRS
|
---|
158 | #define IN_EXPERIMENTAL(i) (((long)(i) & 0xe0000000) == 0xe0000000)
|
---|
159 | #else
|
---|
160 | #define IN_EXPERIMENTAL(i) (((long)(i) & 0xf0000000) == 0xe0000000)
|
---|
161 | #endif
|
---|
162 | #define IN_BADCLASS(i) (((long)(i) & 0xf0000000) == 0xf0000000)
|
---|
163 |
|
---|
164 | #define INADDR_ANY (u_long)0x00000000
|
---|
165 | #ifndef TCPV40HDRS
|
---|
166 | #define INADDR_LOOPBACK (u_long)0x7f000001
|
---|
167 | #endif
|
---|
168 | #define INADDR_BROADCAST (u_long)0xffffffff /* must be masked */
|
---|
169 |
|
---|
170 | #define INADDR_UNSPEC_GROUP (u_long)0xe0000000 /* 224.0.0.0 */
|
---|
171 | #define INADDR_ALLHOSTS_GROUP (u_long)0xe0000001 /* 224.0.0.1 */
|
---|
172 | #define INADDR_MAX_LOCAL_GROUP (u_long)0xe00000ff /* 224.0.0.255 */
|
---|
173 |
|
---|
174 | #ifndef KERNEL
|
---|
175 | #define INADDR_NONE 0xffffffff /* -1 return */
|
---|
176 | #endif
|
---|
177 |
|
---|
178 | #define IN_LOOPBACKNET 127 /* official! */
|
---|
179 |
|
---|
180 |
|
---|
181 | /*
|
---|
182 | * Socket address, internet style. 4.3BSD
|
---|
183 | */
|
---|
184 | #ifdef TCPV40HDRS
|
---|
185 | struct sockaddr_in {
|
---|
186 | short sin_family;
|
---|
187 | u_short sin_port;
|
---|
188 | struct in_addr sin_addr;
|
---|
189 | char sin_zero[8];
|
---|
190 | };
|
---|
191 | #else
|
---|
192 | #pragma pack(1)
|
---|
193 | struct sockaddr_in {
|
---|
194 | u_char sin_len;
|
---|
195 | u_char sin_family;
|
---|
196 | u_short sin_port;
|
---|
197 | struct in_addr sin_addr;
|
---|
198 | char sin_zero[8];
|
---|
199 | };
|
---|
200 | #pragma pack()
|
---|
201 | #endif
|
---|
202 |
|
---|
203 | /*
|
---|
204 | * Structure used to describe IP options.
|
---|
205 | * Used to store options internally, to pass them to a process,
|
---|
206 | * or to restore options retrieved earlier.
|
---|
207 | * The ip_dst is used for the first-hop gateway when using a source route
|
---|
208 | * (this gets put into the header proper).
|
---|
209 | */
|
---|
210 | #ifndef TCPV40HDRS
|
---|
211 | #pragma pack(1)
|
---|
212 | #endif
|
---|
213 | struct ip_opts {
|
---|
214 | struct in_addr ip_dst; /* first hop, 0 w/o src rt */
|
---|
215 | char ip_opts[40]; /* actually variable in size */
|
---|
216 | };
|
---|
217 | #ifndef TCPV40HDRS
|
---|
218 | #pragma pack()
|
---|
219 | #endif
|
---|
220 |
|
---|
221 | /*
|
---|
222 | * Options for use with [gs]etsockopt at the IP level.
|
---|
223 | * First word of comment is data type; bool is stored in int.
|
---|
224 | */
|
---|
225 | #define IP_OPTIONS 1 /* buf/ip_opts; set/get IP options */
|
---|
226 | #define IP_MULTICAST_IF 2 /* u_char; set/get IP mcast i/f */
|
---|
227 | #define IP_MULTICAST_TTL 3 /* u_char; set/get IP mcast ttl */
|
---|
228 | #define IP_MULTICAST_LOOP 4 /* u_char; set/get IP mcast loopback */
|
---|
229 | #define IP_ADD_MEMBERSHIP 5 /* ip_mreq; add IP group membership */
|
---|
230 | #define IP_DROP_MEMBERSHIP 6 /* ip_mreq; drop IP group membership */
|
---|
231 | #ifndef TCPV40HDRS
|
---|
232 | #define IP_HDRINCL 7 /* int; header is included with data */
|
---|
233 | #define IP_TOS 8 /* int; IP type of service and preced. */
|
---|
234 | #define IP_TTL 9 /* int; IP time to live */
|
---|
235 | #define IP_RECVOPTS 10 /* bool; receive all IP opts w/dgram */
|
---|
236 | #define IP_RECVRETOPTS 11 /* bool; receive IP opts for response */
|
---|
237 | #define IP_RECVDSTADDR 12 /* bool; receive IP dst addr w/dgram */
|
---|
238 | #define IP_RETOPTS 13 /* ip_opts; set/get IP options */
|
---|
239 | #define IP_RECVTRRI 14 /* bool; receive token ring routing inf */
|
---|
240 | #endif
|
---|
241 |
|
---|
242 | /*
|
---|
243 | * Defaults and limits for options
|
---|
244 | */
|
---|
245 | #define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */
|
---|
246 | #define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */
|
---|
247 | #define IP_MAX_MEMBERSHIPS 20 /* per socket; must fit in one mbuf */
|
---|
248 | #ifndef TCPV40HDRS
|
---|
249 | #define MAX_IN_MULTI 16*IP_MAX_MEMBERSHIPS /* 320 max per os2 */
|
---|
250 | extern u_short CntInMulti;
|
---|
251 | #endif
|
---|
252 |
|
---|
253 | /*
|
---|
254 | * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
|
---|
255 | */
|
---|
256 | #ifndef TCPV40HDRS
|
---|
257 | #pragma pack(1)
|
---|
258 | #endif
|
---|
259 | struct ip_mreq {
|
---|
260 | struct in_addr imr_multiaddr; /* IP multicast address of group */
|
---|
261 | struct in_addr imr_interface; /* local IP address of interface */
|
---|
262 | };
|
---|
263 | #ifndef TCPV40HDRS
|
---|
264 | #pragma pack()
|
---|
265 | #endif
|
---|
266 |
|
---|
267 | #ifdef TCPV40HDRS
|
---|
268 | /* for functions */
|
---|
269 | #include <arpa/inet.h>
|
---|
270 |
|
---|
271 | #else
|
---|
272 |
|
---|
273 | /*
|
---|
274 | * Definitions for inet sysctl operations.
|
---|
275 | *
|
---|
276 | * Third level is protocol number.
|
---|
277 | * Fourth level is desired variable within that protocol.
|
---|
278 | */
|
---|
279 | #define IPPROTO_MAXID (IPPROTO_IDP + 1) /* don't list to IPPROTO_MAX */
|
---|
280 |
|
---|
281 | #define CTL_IPPROTO_NAMES { \
|
---|
282 | { "ip", CTLTYPE_NODE }, \
|
---|
283 | { "icmp", CTLTYPE_NODE }, \
|
---|
284 | { "igmp", CTLTYPE_NODE }, \
|
---|
285 | { "ggp", CTLTYPE_NODE }, \
|
---|
286 | { 0, 0 }, \
|
---|
287 | { 0, 0 }, \
|
---|
288 | { "tcp", CTLTYPE_NODE }, \
|
---|
289 | { 0, 0 }, \
|
---|
290 | { "egp", CTLTYPE_NODE }, \
|
---|
291 | { 0, 0 }, \
|
---|
292 | { 0, 0 }, \
|
---|
293 | { 0, 0 }, \
|
---|
294 | { "pup", CTLTYPE_NODE }, \
|
---|
295 | { 0, 0 }, \
|
---|
296 | { 0, 0 }, \
|
---|
297 | { 0, 0 }, \
|
---|
298 | { 0, 0 }, \
|
---|
299 | { "udp", CTLTYPE_NODE }, \
|
---|
300 | { 0, 0 }, \
|
---|
301 | { 0, 0 }, \
|
---|
302 | { 0, 0 }, \
|
---|
303 | { 0, 0 }, \
|
---|
304 | { "idp", CTLTYPE_NODE }, \
|
---|
305 | }
|
---|
306 | #endif /*TCPV40HDRS (else) */
|
---|
307 |
|
---|
308 | __END_DECLS
|
---|
309 |
|
---|
310 | #endif /* !_NETINET_IN_H_ */
|
---|