]>
Commit | Line | Data |
---|---|---|
2aa62f2b | 1 | /* $NetBSD: in.h,v 1.77 2006/11/13 05:13:41 dyoung Exp $ */\r |
2 | \r | |
3 | /*\r | |
4 | * Copyright (c) 1982, 1986, 1990, 1993\r | |
5 | * The Regents of the University of California. All rights reserved.\r | |
6 | *\r | |
7 | * Redistribution and use in source and binary forms, with or without\r | |
8 | * modification, are permitted provided that the following conditions\r | |
9 | * are met:\r | |
10 | * 1. Redistributions of source code must retain the above copyright\r | |
11 | * notice, this list of conditions and the following disclaimer.\r | |
12 | * 2. Redistributions in binary form must reproduce the above copyright\r | |
13 | * notice, this list of conditions and the following disclaimer in the\r | |
14 | * documentation and/or other materials provided with the distribution.\r | |
15 | * 3. Neither the name of the University nor the names of its contributors\r | |
16 | * may be used to endorse or promote products derived from this software\r | |
17 | * without specific prior written permission.\r | |
18 | *\r | |
19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\r | |
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r | |
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r | |
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\r | |
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r | |
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r | |
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r | |
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r | |
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r | |
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r | |
29 | * SUCH DAMAGE.\r | |
30 | *\r | |
31 | * @(#)in.h 8.3 (Berkeley) 1/3/94\r | |
32 | */\r | |
33 | \r | |
34 | /*\r | |
35 | * Constants and structures defined by the internet system,\r | |
36 | * Per RFC 790, September 1981, and numerous additions.\r | |
37 | */\r | |
38 | \r | |
39 | #ifndef _NETINET_IN_H_\r | |
40 | #define _NETINET_IN_H_\r | |
41 | \r | |
42 | #include <machine/int_types.h>\r | |
43 | \r | |
44 | #ifndef uint8_t\r | |
45 | typedef __uint8_t uint8_t;\r | |
46 | #define uint8_t __uint8_t\r | |
47 | #endif\r | |
48 | \r | |
49 | #ifndef uint32_t\r | |
50 | typedef __uint32_t uint32_t;\r | |
51 | #define uint32_t __uint32_t\r | |
52 | #endif\r | |
53 | \r | |
54 | #include <sys/ansi.h>\r | |
55 | \r | |
56 | #ifndef in_addr_t\r | |
57 | typedef __in_addr_t in_addr_t;\r | |
58 | #define in_addr_t __in_addr_t\r | |
59 | #endif\r | |
60 | \r | |
61 | #ifndef in_port_t\r | |
62 | typedef __in_port_t in_port_t;\r | |
63 | #define in_port_t __in_port_t\r | |
64 | #endif\r | |
65 | \r | |
66 | #ifndef sa_family_t\r | |
67 | typedef __sa_family_t sa_family_t;\r | |
68 | #define sa_family_t __sa_family_t\r | |
69 | #endif\r | |
70 | \r | |
71 | /*\r | |
72 | * Protocols\r | |
73 | */\r | |
74 | #define IPPROTO_IP 0 /* dummy for IP */\r | |
75 | #define IPPROTO_HOPOPTS 0 /* IP6 hop-by-hop options */\r | |
76 | #define IPPROTO_ICMP 1 /* control message protocol */\r | |
77 | #define IPPROTO_IGMP 2 /* group mgmt protocol */\r | |
78 | #define IPPROTO_GGP 3 /* gateway^2 (deprecated) */\r | |
79 | #define IPPROTO_IPV4 4 /* IP header */\r | |
80 | #define IPPROTO_IPIP 4 /* IP inside IP */\r | |
81 | #define IPPROTO_TCP 6 /* tcp */\r | |
82 | #define IPPROTO_EGP 8 /* exterior gateway protocol */\r | |
83 | #define IPPROTO_PUP 12 /* pup */\r | |
84 | #define IPPROTO_UDP 17 /* user datagram protocol */\r | |
85 | #define IPPROTO_IDP 22 /* xns idp */\r | |
86 | #define IPPROTO_TP 29 /* tp-4 w/ class negotiation */\r | |
87 | #define IPPROTO_IPV6 41 /* IP6 header */\r | |
88 | #define IPPROTO_ROUTING 43 /* IP6 routing header */\r | |
89 | #define IPPROTO_FRAGMENT 44 /* IP6 fragmentation header */\r | |
90 | #define IPPROTO_RSVP 46 /* resource reservation */\r | |
91 | #define IPPROTO_GRE 47 /* GRE encaps RFC 1701 */\r | |
92 | #define IPPROTO_ESP 50 /* encap. security payload */\r | |
93 | #define IPPROTO_AH 51 /* authentication header */\r | |
94 | #define IPPROTO_MOBILE 55 /* IP Mobility RFC 2004 */\r | |
95 | #define IPPROTO_IPV6_ICMP 58 /* IPv6 ICMP */\r | |
96 | #define IPPROTO_ICMPV6 58 /* ICMP6 */\r | |
97 | #define IPPROTO_NONE 59 /* IP6 no next header */\r | |
98 | #define IPPROTO_DSTOPTS 60 /* IP6 destination option */\r | |
99 | #define IPPROTO_EON 80 /* ISO cnlp */\r | |
100 | #define IPPROTO_ETHERIP 97 /* Ethernet-in-IP */\r | |
101 | #define IPPROTO_ENCAP 98 /* encapsulation header */\r | |
102 | #define IPPROTO_PIM 103 /* Protocol indep. multicast */\r | |
103 | #define IPPROTO_IPCOMP 108 /* IP Payload Comp. Protocol */\r | |
104 | #define IPPROTO_VRRP 112 /* VRRP RFC 2338 */\r | |
105 | #define IPPROTO_CARP 112 /* Common Address Resolution Protocol */\r | |
106 | #define IPPROTO_RAW 255 /* raw IP packet */\r | |
107 | #define IPPROTO_MAX 256\r | |
108 | \r | |
109 | /* last return value of *_input(), meaning "all job for this pkt is done". */\r | |
110 | #define IPPROTO_DONE 257\r | |
111 | \r | |
112 | /* sysctl placeholder for (FAST_)IPSEC */\r | |
113 | #define CTL_IPPROTO_IPSEC 258\r | |
114 | \r | |
115 | \r | |
116 | /*\r | |
117 | * Local port number conventions:\r | |
118 | *\r | |
119 | * Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root),\r | |
120 | * unless a kernel is compiled with IPNOPRIVPORTS defined.\r | |
121 | *\r | |
122 | * When a user does a bind(2) or connect(2) with a port number of zero,\r | |
123 | * a non-conflicting local port address is chosen.\r | |
124 | *\r | |
125 | * The default range is IPPORT_ANONMIN to IPPORT_ANONMAX, although\r | |
126 | * that is settable by sysctl(3); net.inet.ip.anonportmin and\r | |
127 | * net.inet.ip.anonportmax respectively.\r | |
128 | *\r | |
129 | * A user may set the IPPROTO_IP option IP_PORTRANGE to change this\r | |
130 | * default assignment range.\r | |
131 | *\r | |
132 | * The value IP_PORTRANGE_DEFAULT causes the default behavior.\r | |
133 | *\r | |
134 | * The value IP_PORTRANGE_HIGH is the same as IP_PORTRANGE_DEFAULT,\r | |
135 | * and exists only for FreeBSD compatibility purposes.\r | |
136 | *\r | |
137 | * The value IP_PORTRANGE_LOW changes the range to the "low" are\r | |
138 | * that is (by convention) restricted to privileged processes.\r | |
139 | * This convention is based on "vouchsafe" principles only.\r | |
140 | * It is only secure if you trust the remote host to restrict these ports.\r | |
141 | * The range is IPPORT_RESERVEDMIN to IPPORT_RESERVEDMAX.\r | |
142 | */\r | |
143 | \r | |
144 | #define IPPORT_RESERVED 1024\r | |
145 | #define IPPORT_ANONMIN 49152\r | |
146 | #define IPPORT_ANONMAX 65535\r | |
147 | #define IPPORT_RESERVEDMIN 600\r | |
148 | #define IPPORT_RESERVEDMAX (IPPORT_RESERVED-1)\r | |
149 | \r | |
150 | /*\r | |
151 | * Internet address (a structure for historical reasons)\r | |
152 | */\r | |
153 | struct in_addr {\r | |
154 | in_addr_t s_addr;\r | |
155 | } __attribute__((__packed__));\r | |
156 | \r | |
157 | /*\r | |
158 | * Definitions of bits in internet address integers.\r | |
159 | * On subnets, the decomposition of addresses to host and net parts\r | |
160 | * is done according to subnet mask, not the masks here.\r | |
161 | *\r | |
162 | * By byte-swapping the constants, we avoid ever having to byte-swap IP\r | |
163 | * addresses inside the kernel. Unfortunately, user-level programs rely\r | |
164 | * on these macros not doing byte-swapping.\r | |
165 | */\r | |
166 | #ifdef _KERNEL\r | |
167 | #define __IPADDR(x) ((uint32_t) htonl((uint32_t)(x)))\r | |
168 | #else\r | |
169 | #define __IPADDR(x) ((uint32_t)(x))\r | |
170 | #endif\r | |
171 | \r | |
172 | #define IN_CLASSA(i) (((uint32_t)(i) & __IPADDR(0x80000000)) == \\r | |
173 | __IPADDR(0x00000000))\r | |
174 | #define IN_CLASSA_NET __IPADDR(0xff000000)\r | |
175 | #define IN_CLASSA_NSHIFT 24\r | |
176 | #define IN_CLASSA_HOST __IPADDR(0x00ffffff)\r | |
177 | #define IN_CLASSA_MAX 128\r | |
178 | \r | |
179 | #define IN_CLASSB(i) (((uint32_t)(i) & __IPADDR(0xc0000000)) == \\r | |
180 | __IPADDR(0x80000000))\r | |
181 | #define IN_CLASSB_NET __IPADDR(0xffff0000)\r | |
182 | #define IN_CLASSB_NSHIFT 16\r | |
183 | #define IN_CLASSB_HOST __IPADDR(0x0000ffff)\r | |
184 | #define IN_CLASSB_MAX 65536\r | |
185 | \r | |
186 | #define IN_CLASSC(i) (((uint32_t)(i) & __IPADDR(0xe0000000)) == \\r | |
187 | __IPADDR(0xc0000000))\r | |
188 | #define IN_CLASSC_NET __IPADDR(0xffffff00)\r | |
189 | #define IN_CLASSC_NSHIFT 8\r | |
190 | #define IN_CLASSC_HOST __IPADDR(0x000000ff)\r | |
191 | \r | |
192 | #define IN_CLASSD(i) (((uint32_t)(i) & __IPADDR(0xf0000000)) == \\r | |
193 | __IPADDR(0xe0000000))\r | |
194 | /* These ones aren't really net and host fields, but routing needn't know. */\r | |
195 | #define IN_CLASSD_NET __IPADDR(0xf0000000)\r | |
196 | #define IN_CLASSD_NSHIFT 28\r | |
197 | #define IN_CLASSD_HOST __IPADDR(0x0fffffff)\r | |
198 | #define IN_MULTICAST(i) IN_CLASSD(i)\r | |
199 | \r | |
200 | #define IN_EXPERIMENTAL(i) (((uint32_t)(i) & __IPADDR(0xf0000000)) == \\r | |
201 | __IPADDR(0xf0000000))\r | |
202 | #define IN_BADCLASS(i) (((uint32_t)(i) & __IPADDR(0xf0000000)) == \\r | |
203 | __IPADDR(0xf0000000))\r | |
204 | \r | |
205 | #define IN_LINKLOCAL(i) (((uint32_t)(i) & __IPADDR(0xffff0000)) == \\r | |
206 | __IPADDR(0xa9fe0000))\r | |
207 | \r | |
208 | #define IN_PRIVATE(i) ((((uint32_t)(i) & __IPADDR(0xff000000)) == \\r | |
209 | __IPADDR(0x0a000000)) || \\r | |
210 | (((uint32_t)(i) & __IPADDR(0xfff00000)) == \\r | |
211 | __IPADDR(0xac100000)) || \\r | |
212 | (((uint32_t)(i) & __IPADDR(0xffff0000)) == \\r | |
213 | __IPADDR(0xc0a80000)))\r | |
214 | \r | |
215 | #define IN_LOCAL_GROUP(i) (((uint32_t)(i) & __IPADDR(0xffffff00)) == \\r | |
216 | __IPADDR(0xe0000000))\r | |
217 | \r | |
218 | #define IN_ANY_LOCAL(i) (IN_LINKLOCAL(i) || IN_LOCAL_GROUP(i))\r | |
219 | \r | |
220 | #define INADDR_ANY __IPADDR(0x00000000)\r | |
221 | #define INADDR_LOOPBACK __IPADDR(0x7f000001)\r | |
222 | #define INADDR_BROADCAST __IPADDR(0xffffffff) /* must be masked */\r | |
223 | #define INADDR_NONE __IPADDR(0xffffffff) /* -1 return */\r | |
224 | \r | |
225 | #define INADDR_UNSPEC_GROUP __IPADDR(0xe0000000) /* 224.0.0.0 */\r | |
226 | #define INADDR_ALLHOSTS_GROUP __IPADDR(0xe0000001) /* 224.0.0.1 */\r | |
227 | #define INADDR_ALLRTRS_GROUP __IPADDR(0xe0000002) /* 224.0.0.2 */\r | |
228 | #define INADDR_CARP_GROUP __IPADDR(0xe0000012) /* 224.0.0.18 */\r | |
229 | #define INADDR_MAX_LOCAL_GROUP __IPADDR(0xe00000ff) /* 224.0.0.255 */\r | |
230 | \r | |
231 | #define IN_LOOPBACKNET 127 /* official! */\r | |
232 | \r | |
233 | /*\r | |
234 | * Socket address, internet style.\r | |
235 | */\r | |
236 | struct sockaddr_in {\r | |
237 | uint8_t sin_len;\r | |
238 | sa_family_t sin_family;\r | |
239 | in_port_t sin_port;\r | |
240 | struct in_addr sin_addr;\r | |
241 | __int8_t sin_zero[8];\r | |
242 | };\r | |
243 | \r | |
244 | #define INET_ADDRSTRLEN 16\r | |
245 | \r | |
246 | /*\r | |
247 | * Structure used to describe IP options.\r | |
248 | * Used to store options internally, to pass them to a process,\r | |
249 | * or to restore options retrieved earlier.\r | |
250 | * The ip_dst is used for the first-hop gateway when using a source route\r | |
251 | * (this gets put into the header proper).\r | |
252 | */\r | |
253 | struct ip_opts {\r | |
254 | struct in_addr ip_dst; /* first hop, 0 w/o src rt */\r | |
255 | #if defined(__cplusplus)\r | |
256 | __int8_t Ip_opts[40]; /* actually variable in size */\r | |
257 | #else\r | |
258 | __int8_t ip_opts[40]; /* actually variable in size */\r | |
259 | #endif\r | |
260 | };\r | |
261 | \r | |
262 | /*\r | |
263 | * Options for use with [gs]etsockopt at the IP level.\r | |
264 | * First word of comment is data type; bool is stored in int.\r | |
265 | */\r | |
266 | #define IP_OPTIONS 1 /* buf/ip_opts; set/get IP options */\r | |
267 | #define IP_HDRINCL 2 /* int; header is included with data */\r | |
268 | #define IP_TOS 3 /* int; IP type of service and preced. */\r | |
269 | #define IP_TTL 4 /* int; IP time to live */\r | |
270 | #define IP_RECVOPTS 5 /* bool; receive all IP opts w/dgram */\r | |
271 | #define IP_RECVRETOPTS 6 /* bool; receive IP opts for response */\r | |
272 | #define IP_RECVDSTADDR 7 /* bool; receive IP dst addr w/dgram */\r | |
273 | #define IP_RETOPTS 8 /* ip_opts; set/get IP options */\r | |
274 | #define IP_MULTICAST_IF 9 /* in_addr; set/get IP multicast i/f */\r | |
275 | #define IP_MULTICAST_TTL 10 /* u_char; set/get IP multicast ttl */\r | |
276 | #define IP_MULTICAST_LOOP 11 /* u_char; set/get IP multicast loopback */\r | |
277 | #define IP_ADD_MEMBERSHIP 12 /* ip_mreq; add an IP group membership */\r | |
278 | #define IP_DROP_MEMBERSHIP 13 /* ip_mreq; drop an IP group membership */\r | |
279 | #define IP_PORTRANGE 19 /* int; range to use for ephemeral port */\r | |
280 | #define IP_RECVIF 20 /* bool; receive reception if w/dgram */\r | |
281 | #define IP_ERRORMTU 21 /* int; get MTU of last xmit = EMSGSIZE */\r | |
282 | #if 1 /*IPSEC*/\r | |
283 | #define IP_IPSEC_POLICY 22 /* struct; get/set security policy */\r | |
284 | #endif\r | |
285 | \r | |
286 | /*\r | |
287 | * Defaults and limits for options\r | |
288 | */\r | |
289 | #define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */\r | |
290 | #define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */\r | |
291 | #define IP_MAX_MEMBERSHIPS 20 /* per socket; must fit in one mbuf */\r | |
292 | \r | |
293 | /*\r | |
294 | * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.\r | |
295 | */\r | |
296 | struct ip_mreq {\r | |
297 | struct in_addr imr_multiaddr; /* IP multicast address of group */\r | |
298 | struct in_addr imr_interface; /* local IP address of interface */\r | |
299 | };\r | |
300 | \r | |
301 | /*\r | |
302 | * Argument for IP_PORTRANGE:\r | |
303 | * - which range to search when port is unspecified at bind() or connect()\r | |
304 | */\r | |
305 | #define IP_PORTRANGE_DEFAULT 0 /* default range */\r | |
306 | #define IP_PORTRANGE_HIGH 1 /* same as DEFAULT (FreeBSD compat) */\r | |
307 | #define IP_PORTRANGE_LOW 2 /* use privileged range */\r | |
308 | \r | |
309 | #if defined(_NETBSD_SOURCE)\r | |
310 | /*\r | |
311 | * Definitions for inet sysctl operations.\r | |
312 | *\r | |
313 | * Third level is protocol number.\r | |
314 | * Fourth level is desired variable within that protocol.\r | |
315 | */\r | |
316 | #define IPPROTO_MAXID (IPPROTO_AH + 1) /* don't list to IPPROTO_MAX */\r | |
317 | \r | |
318 | #define CTL_IPPROTO_NAMES { \\r | |
319 | { "ip", CTLTYPE_NODE }, \\r | |
320 | { "icmp", CTLTYPE_NODE }, \\r | |
321 | { "igmp", CTLTYPE_NODE }, \\r | |
322 | { "ggp", CTLTYPE_NODE }, \\r | |
323 | { 0, 0 }, \\r | |
324 | { 0, 0 }, \\r | |
325 | { "tcp", CTLTYPE_NODE }, \\r | |
326 | { 0, 0 }, \\r | |
327 | { "egp", CTLTYPE_NODE }, \\r | |
328 | { 0, 0 }, \\r | |
329 | { 0, 0 }, \\r | |
330 | { 0, 0 }, \\r | |
331 | { "pup", CTLTYPE_NODE }, \\r | |
332 | { 0, 0 }, \\r | |
333 | { 0, 0 }, \\r | |
334 | { 0, 0 }, \\r | |
335 | { 0, 0 }, \\r | |
336 | { "udp", CTLTYPE_NODE }, \\r | |
337 | { 0, 0 }, \\r | |
338 | { 0, 0 }, \\r | |
339 | { 0, 0 }, \\r | |
340 | { 0, 0 }, \\r | |
341 | { "idp", CTLTYPE_NODE }, \\r | |
342 | { 0, 0 }, \\r | |
343 | { 0, 0 }, \\r | |
344 | { 0, 0 }, \\r | |
345 | { 0, 0 }, \\r | |
346 | { 0, 0 }, \\r | |
347 | { 0, 0 }, \\r | |
348 | { 0, 0 }, \\r | |
349 | { 0, 0 }, \\r | |
350 | { 0, 0 }, \\r | |
351 | { 0, 0 }, \\r | |
352 | { 0, 0 }, \\r | |
353 | { 0, 0 }, \\r | |
354 | { 0, 0 }, \\r | |
355 | { 0, 0 }, \\r | |
356 | { 0, 0 }, \\r | |
357 | { 0, 0 }, \\r | |
358 | { 0, 0 }, \\r | |
359 | { 0, 0 }, \\r | |
360 | { 0, 0 }, \\r | |
361 | { 0, 0 }, \\r | |
362 | { 0, 0 }, \\r | |
363 | { 0, 0 }, \\r | |
364 | { 0, 0 }, \\r | |
365 | { 0, 0 }, \\r | |
366 | { 0, 0 }, \\r | |
367 | { 0, 0 }, \\r | |
368 | { 0, 0 }, \\r | |
369 | { 0, 0 }, \\r | |
370 | { "ipsec", CTLTYPE_NODE }, \\r | |
371 | { 0, 0 }, \\r | |
372 | { 0, 0 }, \\r | |
373 | { 0, 0 }, \\r | |
374 | { 0, 0 }, \\r | |
375 | { 0, 0 }, \\r | |
376 | { 0, 0 }, \\r | |
377 | { 0, 0 }, \\r | |
378 | { 0, 0 }, \\r | |
379 | { 0, 0 }, \\r | |
380 | { 0, 0 }, \\r | |
381 | { 0, 0 }, \\r | |
382 | { 0, 0 }, \\r | |
383 | { 0, 0 }, \\r | |
384 | { 0, 0 }, \\r | |
385 | { 0, 0 }, \\r | |
386 | { 0, 0 }, \\r | |
387 | { 0, 0 }, \\r | |
388 | { 0, 0 }, \\r | |
389 | { 0, 0 }, \\r | |
390 | { 0, 0 }, \\r | |
391 | { 0, 0 }, \\r | |
392 | { 0, 0 }, \\r | |
393 | { 0, 0 }, \\r | |
394 | { 0, 0 }, \\r | |
395 | { 0, 0 }, \\r | |
396 | { 0, 0 }, \\r | |
397 | { 0, 0 }, \\r | |
398 | { 0, 0 }, \\r | |
399 | { 0, 0 }, \\r | |
400 | { 0, 0 }, \\r | |
401 | { 0, 0 }, \\r | |
402 | { 0, 0 }, \\r | |
403 | { 0, 0 }, \\r | |
404 | { 0, 0 }, \\r | |
405 | { 0, 0 }, \\r | |
406 | { 0, 0 }, \\r | |
407 | { 0, 0 }, \\r | |
408 | { 0, 0 }, \\r | |
409 | { 0, 0 }, \\r | |
410 | { 0, 0 }, \\r | |
411 | { 0, 0 }, \\r | |
412 | { 0, 0 }, \\r | |
413 | { 0, 0 }, \\r | |
414 | { 0, 0 }, \\r | |
415 | { 0, 0 }, \\r | |
416 | { 0, 0 }, \\r | |
417 | { 0, 0 }, \\r | |
418 | { 0, 0 }, \\r | |
419 | { 0, 0 }, \\r | |
420 | { 0, 0 }, \\r | |
421 | { 0, 0 }, \\r | |
422 | { "pim", CTLTYPE_NODE }, \\r | |
423 | }\r | |
424 | \r | |
425 | /*\r | |
426 | * Names for IP sysctl objects\r | |
427 | */\r | |
428 | #define IPCTL_FORWARDING 1 /* act as router */\r | |
429 | #define IPCTL_SENDREDIRECTS 2 /* may send redirects when forwarding */\r | |
430 | #define IPCTL_DEFTTL 3 /* default TTL */\r | |
431 | #ifdef notyet\r | |
432 | #define IPCTL_DEFMTU 4 /* default MTU */\r | |
433 | #endif\r | |
434 | #define IPCTL_FORWSRCRT 5 /* forward source-routed packets */\r | |
435 | #define IPCTL_DIRECTEDBCAST 6 /* default broadcast behavior */\r | |
436 | #define IPCTL_ALLOWSRCRT 7 /* allow/drop all source-routed pkts */\r | |
437 | #define IPCTL_SUBNETSARELOCAL 8 /* treat subnets as local addresses */\r | |
438 | #define IPCTL_MTUDISC 9 /* allow path MTU discovery */\r | |
439 | #define IPCTL_ANONPORTMIN 10 /* minimum ephemeral port */\r | |
440 | #define IPCTL_ANONPORTMAX 11 /* maximum ephemeral port */\r | |
441 | #define IPCTL_MTUDISCTIMEOUT 12 /* allow path MTU discovery */\r | |
442 | #define IPCTL_MAXFLOWS 13 /* maximum ip flows allowed */\r | |
443 | #define IPCTL_HOSTZEROBROADCAST 14 /* is host zero a broadcast addr? */\r | |
444 | #define IPCTL_GIF_TTL 15 /* default TTL for gif encap packet */\r | |
445 | #define IPCTL_LOWPORTMIN 16 /* minimum reserved port */\r | |
446 | #define IPCTL_LOWPORTMAX 17 /* maximum reserved port */\r | |
447 | #define IPCTL_MAXFRAGPACKETS 18 /* max packets reassembly queue */\r | |
448 | #define IPCTL_GRE_TTL 19 /* default TTL for gre encap packet */\r | |
449 | #define IPCTL_CHECKINTERFACE 20 /* drop pkts in from 'wrong' iface */\r | |
450 | #define IPCTL_IFQ 21 /* ipintrq node */\r | |
451 | #define IPCTL_RANDOMID 22 /* use random IP ids (if configured) */\r | |
452 | #define IPCTL_LOOPBACKCKSUM 23 /* do IP checksum on loopback */\r | |
453 | #define IPCTL_STATS 24 /* IP statistics */\r | |
454 | #define IPCTL_MAXID 25\r | |
455 | \r | |
456 | #define IPCTL_NAMES { \\r | |
457 | { 0, 0 }, \\r | |
458 | { "forwarding", CTLTYPE_INT }, \\r | |
459 | { "redirect", CTLTYPE_INT }, \\r | |
460 | { "ttl", CTLTYPE_INT }, \\r | |
461 | { "mtu", CTLTYPE_INT }, \\r | |
462 | { "forwsrcrt", CTLTYPE_INT }, \\r | |
463 | { "directed-broadcast", CTLTYPE_INT }, \\r | |
464 | { "allowsrcrt", CTLTYPE_INT }, \\r | |
465 | { "subnetsarelocal", CTLTYPE_INT }, \\r | |
466 | { "mtudisc", CTLTYPE_INT }, \\r | |
467 | { "anonportmin", CTLTYPE_INT }, \\r | |
468 | { "anonportmax", CTLTYPE_INT }, \\r | |
469 | { "mtudisctimeout", CTLTYPE_INT }, \\r | |
470 | { "maxflows", CTLTYPE_INT }, \\r | |
471 | { "hostzerobroadcast", CTLTYPE_INT }, \\r | |
472 | { "gifttl", CTLTYPE_INT }, \\r | |
473 | { "lowportmin", CTLTYPE_INT }, \\r | |
474 | { "lowportmax", CTLTYPE_INT }, \\r | |
475 | { "maxfragpackets", CTLTYPE_INT }, \\r | |
476 | { "grettl", CTLTYPE_INT }, \\r | |
477 | { "checkinterface", CTLTYPE_INT }, \\r | |
478 | { "ifq", CTLTYPE_NODE }, \\r | |
479 | { "random_id", CTLTYPE_INT }, \\r | |
480 | { "do_loopback_cksum", CTLTYPE_INT }, \\r | |
481 | { "stats", CTLTYPE_STRUCT }, \\r | |
482 | }\r | |
483 | #endif /* _NETBSD_SOURCE */\r | |
484 | \r | |
485 | /* INET6 stuff */\r | |
486 | #define __KAME_NETINET_IN_H_INCLUDED_\r | |
487 | #include <netinet6/in6.h>\r | |
488 | #undef __KAME_NETINET_IN_H_INCLUDED_\r | |
489 | \r | |
490 | #ifdef _KERNEL\r | |
491 | /*\r | |
492 | * in_cksum_phdr:\r | |
493 | *\r | |
494 | * Compute significant parts of the IPv4 checksum pseudo-header\r | |
495 | * for use in a delayed TCP/UDP checksum calculation.\r | |
496 | *\r | |
497 | * Args:\r | |
498 | *\r | |
499 | * src Source IP address\r | |
500 | * dst Destination IP address\r | |
501 | * lenproto htons(proto-hdr-len + proto-number)\r | |
502 | */\r | |
503 | static __inline u_int16_t __attribute__((__unused__))\r | |
504 | in_cksum_phdr(u_int32_t src, u_int32_t dst, u_int32_t lenproto)\r | |
505 | {\r | |
506 | u_int32_t sum;\r | |
507 | \r | |
508 | sum = lenproto +\r | |
509 | (u_int16_t)(src >> 16) +\r | |
510 | (u_int16_t)(src /*& 0xffff*/) +\r | |
511 | (u_int16_t)(dst >> 16) +\r | |
512 | (u_int16_t)(dst /*& 0xffff*/);\r | |
513 | \r | |
514 | sum = (u_int16_t)(sum >> 16) + (u_int16_t)(sum /*& 0xffff*/);\r | |
515 | \r | |
516 | if (sum > 0xffff)\r | |
517 | sum -= 0xffff;\r | |
518 | \r | |
519 | return (sum);\r | |
520 | }\r | |
521 | \r | |
522 | /*\r | |
523 | * in_cksum_addword:\r | |
524 | *\r | |
525 | * Add the two 16-bit network-order values, carry, and return.\r | |
526 | */\r | |
527 | static __inline u_int16_t __attribute__((__unused__))\r | |
528 | in_cksum_addword(u_int16_t a, u_int16_t b)\r | |
529 | {\r | |
530 | u_int32_t sum = a + b;\r | |
531 | \r | |
532 | if (sum > 0xffff)\r | |
533 | sum -= 0xffff;\r | |
534 | \r | |
535 | return (sum);\r | |
536 | }\r | |
537 | \r | |
538 | extern struct in_addr zeroin_addr;\r | |
539 | extern u_char ip_protox[];\r | |
540 | \r | |
541 | int in_broadcast(struct in_addr, struct ifnet *);\r | |
542 | int in_canforward(struct in_addr);\r | |
543 | int in_cksum(struct mbuf *, int);\r | |
544 | int in4_cksum(struct mbuf *, u_int8_t, int, int);\r | |
545 | void in_delayed_cksum(struct mbuf *);\r | |
546 | int in_localaddr(struct in_addr);\r | |
547 | void in_socktrim(struct sockaddr_in *);\r | |
548 | \r | |
549 | #define in_hosteq(s,t) ((s).s_addr == (t).s_addr)\r | |
550 | #define in_nullhost(x) ((x).s_addr == INADDR_ANY)\r | |
551 | \r | |
552 | #define satosin(sa) ((struct sockaddr_in *)(sa))\r | |
553 | #define sintosa(sin) ((struct sockaddr *)(sin))\r | |
554 | #define ifatoia(ifa) ((struct in_ifaddr *)(ifa))\r | |
555 | #endif /* _KERNEL */\r | |
556 | \r | |
557 | #endif /* !_NETINET_IN_H_ */\r |