xref: /openbsd-src/sys/netinet/in.h (revision b2ea75c1b17e1a9a339660e7ed45cd24946b230e)
1 /*	$OpenBSD: in.h,v 1.54 2001/07/05 08:40:12 angelos Exp $	*/
2 /*	$NetBSD: in.h,v 1.20 1996/02/13 23:41:47 christos Exp $	*/
3 
4 /*
5  * Copyright (c) 1982, 1986, 1990, 1993
6  *	The Regents of the University of California.  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  *	@(#)in.h	8.3 (Berkeley) 1/3/94
37  */
38 
39 /*
40  * Constants and structures defined by the internet system,
41  * Per RFC 790, September 1981, and numerous additions.
42  */
43 
44 #ifndef _NETINET_IN_H_
45 #define	_NETINET_IN_H_
46 
47 /*
48  * Protocols
49  */
50 #define	IPPROTO_IP		0		/* dummy for IP */
51 #define IPPROTO_HOPOPTS		IPPROTO_IP	/* Hop-by-hop option header */
52 #define	IPPROTO_ICMP		1		/* control message protocol */
53 #define	IPPROTO_IGMP		2		/* group mgmt protocol */
54 #define	IPPROTO_GGP		3		/* gateway^2 (deprecated) */
55 #define	IPPROTO_IPIP		4		/* IP inside IP */
56 #define	IPPROTO_IPV4		IPPROTO_IPIP	/* IP inside IP */
57 #define	IPPROTO_TCP		6		/* tcp */
58 #define	IPPROTO_EGP		8		/* exterior gateway protocol */
59 #define	IPPROTO_PUP		12		/* pup */
60 #define	IPPROTO_UDP		17		/* user datagram protocol */
61 #define	IPPROTO_IDP		22		/* xns idp */
62 #define	IPPROTO_TP		29 		/* tp-4 w/ class negotiation */
63 #define IPPROTO_IPV6		41		/* IPv6 in IPv6 */
64 #define IPPROTO_ROUTING		43		/* Routing header */
65 #define IPPROTO_FRAGMENT	44		/* Fragmentation/reassembly header */
66 #define IPPROTO_RSVP		46		/* resource reservation */
67 #define	IPPROTO_GRE		47		/* GRE encap, RFCs 1701/1702 */
68 #define	IPPROTO_ESP		50		/* Encap. Security Payload */
69 #define	IPPROTO_AH		51		/* Authentication header */
70 #define	IPPROTO_MOBILE		55		/* IP Mobility, RFC 2004 */
71 #define IPPROTO_ICMPV6		58		/* ICMP for IPv6 */
72 #define IPPROTO_NONE		59		/* No next header */
73 #define IPPROTO_DSTOPTS		60		/* Destination options header */
74 #define	IPPROTO_EON		80		/* ISO cnlp */
75 #define IPPROTO_ETHERIP		97		/* Ethernet in IPv4 */
76 #define	IPPROTO_ENCAP		98		/* encapsulation header */
77 #define IPPROTO_PIM		103		/* Protocol indep. multicast */
78 #define IPPROTO_IPCOMP		108		/* IP Payload Comp. Protocol */
79 #define	IPPROTO_RAW		255		/* raw IP packet */
80 
81 #define	IPPROTO_MAX		256
82 
83 /*
84  * From FreeBSD:
85  *
86  * Local port number conventions:
87  *
88  * When a user does a bind(2) or connect(2) with a port number of zero,
89  * a non-conflicting local port address is chosen.
90  * The default range is IPPORT_RESERVED through
91  * IPPORT_USERRESERVED, although that is settable by sysctl.
92  *
93  * A user may set the IPPROTO_IP option IP_PORTRANGE to change this
94  * default assignment range.
95  *
96  * The value IP_PORTRANGE_DEFAULT causes the default behavior.
97  *
98  * The value IP_PORTRANGE_HIGH changes the range of candidate port numbers
99  * into the "high" range.  These are reserved for client outbound connections
100  * which do not want to be filtered by any firewalls.
101  *
102  * The value IP_PORTRANGE_LOW changes the range to the "low" are
103  * that is (by convention) restricted to privileged processes.  This
104  * convention is based on "vouchsafe" principles only.  It is only secure
105  * if you trust the remote host to restrict these ports.
106  *
107  * The default range of ports and the high range can be changed by
108  * sysctl(3).  (net.inet.ip.port{hi}{first,last})
109  *
110  * Changing those values has bad security implications if you are
111  * using a a stateless firewall that is allowing packets outside of that
112  * range in order to allow transparent outgoing connections.
113  *
114  * Such a firewall configuration will generally depend on the use of these
115  * default values.  If you change them, you may find your Security
116  * Administrator looking for you with a heavy object.
117  */
118 
119 /*
120  * Ports < IPPORT_RESERVED are reserved for
121  * privileged processes (e.g. root).
122  * Ports > IPPORT_USERRESERVED are reserved
123  * for servers, not necessarily privileged.
124  */
125 #define	IPPORT_RESERVED		1024
126 #define	IPPORT_USERRESERVED	49151
127 
128 /*
129  * Default local port range to use by setting IP_PORTRANGE_HIGH
130  */
131 #define IPPORT_HIFIRSTAUTO	49152
132 #define IPPORT_HILASTAUTO	65535
133 
134 /*
135  * IP Version 4 Internet address (a structure for historical reasons)
136  */
137 struct in_addr {
138 	in_addr_t s_addr;
139 };
140 
141 /* last return value of *_input(), meaning "all job for this pkt is done".  */
142 #define	IPPROTO_DONE		257
143 
144 /*
145  * Definitions of bits in internet address integers.
146  * On subnets, the decomposition of addresses to host and net parts
147  * is done according to subnet mask, not the masks here.
148  *
149  * By byte-swapping the constants, we avoid ever having to byte-swap IP
150  * addresses inside the kernel.  Unfortunately, user-level programs rely
151  * on these macros not doing byte-swapping.
152  */
153 #ifdef _KERNEL
154 #define	__IPADDR(x)	((u_int32_t) htonl((u_int32_t)(x)))
155 #else
156 #define	__IPADDR(x)	((u_int32_t)(x))
157 #endif
158 
159 #define	IN_CLASSA(i)		(((u_int32_t)(i) & __IPADDR(0x80000000)) == \
160 				 __IPADDR(0x00000000))
161 #define	IN_CLASSA_NET		__IPADDR(0xff000000)
162 #define	IN_CLASSA_NSHIFT	24
163 #define	IN_CLASSA_HOST		__IPADDR(0x00ffffff)
164 #define	IN_CLASSA_MAX		128
165 
166 #define	IN_CLASSB(i)		(((u_int32_t)(i) & __IPADDR(0xc0000000)) == \
167 				 __IPADDR(0x80000000))
168 #define	IN_CLASSB_NET		__IPADDR(0xffff0000)
169 #define	IN_CLASSB_NSHIFT	16
170 #define	IN_CLASSB_HOST		__IPADDR(0x0000ffff)
171 #define	IN_CLASSB_MAX		65536
172 
173 #define	IN_CLASSC(i)		(((u_int32_t)(i) & __IPADDR(0xe0000000)) == \
174 				 __IPADDR(0xc0000000))
175 #define	IN_CLASSC_NET		__IPADDR(0xffffff00)
176 #define	IN_CLASSC_NSHIFT	8
177 #define	IN_CLASSC_HOST		__IPADDR(0x000000ff)
178 
179 #define	IN_CLASSD(i)		(((u_int32_t)(i) & __IPADDR(0xf0000000)) == \
180 				 __IPADDR(0xe0000000))
181 /* These ones aren't really net and host fields, but routing needn't know. */
182 #define	IN_CLASSD_NET		__IPADDR(0xf0000000)
183 #define	IN_CLASSD_NSHIFT	28
184 #define	IN_CLASSD_HOST		__IPADDR(0x0fffffff)
185 #define	IN_MULTICAST(i)		IN_CLASSD(i)
186 
187 #define	IN_EXPERIMENTAL(i)	(((u_int32_t)(i) & __IPADDR(0xf0000000)) == \
188 				 __IPADDR(0xf0000000))
189 #define	IN_BADCLASS(i)		(((u_int32_t)(i) & __IPADDR(0xf0000000)) == \
190 				 __IPADDR(0xf0000000))
191 
192 #define	IN_LOCAL_GROUP(i)	(((u_int32_t)(i) & __IPADDR(0xffffff00)) == \
193 				 __IPADDR(0xe0000000))
194 
195 #define	INADDR_ANY		__IPADDR(0x00000000)
196 #define	INADDR_LOOPBACK		__IPADDR(0x7f000001)
197 #define	INADDR_BROADCAST	__IPADDR(0xffffffff)	/* must be masked */
198 #ifndef _KERNEL
199 #define	INADDR_NONE		__IPADDR(0xffffffff)	/* -1 return */
200 #endif
201 
202 #define	INADDR_UNSPEC_GROUP	__IPADDR(0xe0000000)	/* 224.0.0.0 */
203 #define	INADDR_ALLHOSTS_GROUP	__IPADDR(0xe0000001)	/* 224.0.0.1 */
204 #define INADDR_MAX_LOCAL_GROUP	__IPADDR(0xe00000ff)	/* 224.0.0.255 */
205 
206 #define	IN_LOOPBACKNET		127			/* official! */
207 
208 /*
209  * IP Version 4 socket address.
210  */
211 struct sockaddr_in {
212 	u_int8_t    sin_len;
213 	sa_family_t sin_family;
214 	in_port_t   sin_port;
215 	struct	    in_addr sin_addr;
216 	int8_t	    sin_zero[8];
217 };
218 
219 /*
220  * Structure used to describe IP options.
221  * Used to store options internally, to pass them to a process,
222  * or to restore options retrieved earlier.
223  * The ip_dst is used for the first-hop gateway when using a source route
224  * (this gets put into the header proper).
225  */
226 struct ip_opts {
227 	struct in_addr	ip_dst;		/* first hop, 0 w/o src rt */
228 #if defined(__cplusplus)
229 	int8_t		Ip_opts[40];	/* cannot have same name as class */
230 #else
231 	int8_t		ip_opts[40];	/* actually variable in size */
232 #endif
233 };
234 
235 /*
236  * Options for use with [gs]etsockopt at the IP level.
237  * First word of comment is data type; bool is stored in int.
238  */
239 #define	IP_OPTIONS		1    /* buf/ip_opts; set/get IP options */
240 #define	IP_HDRINCL		2    /* int; header is included with data */
241 #define	IP_TOS			3    /* int; IP type of service and preced. */
242 #define	IP_TTL			4    /* int; IP time to live */
243 #define	IP_RECVOPTS		5    /* bool; receive all IP opts w/dgram */
244 #define	IP_RECVRETOPTS		6    /* bool; receive IP opts for response */
245 #define	IP_RECVDSTADDR		7    /* bool; receive IP dst addr w/dgram */
246 #define	IP_RETOPTS		8    /* ip_opts; set/get IP options */
247 #define	IP_MULTICAST_IF		9    /* in_addr; set/get IP multicast i/f  */
248 #define	IP_MULTICAST_TTL	10   /* u_char; set/get IP multicast ttl */
249 #define	IP_MULTICAST_LOOP	11   /* u_char; set/get IP multicast loopback */
250 #define	IP_ADD_MEMBERSHIP	12   /* ip_mreq; add an IP group membership */
251 #define	IP_DROP_MEMBERSHIP	13   /* ip_mreq; drop an IP group membership */
252 
253 /* 14-17 left empty for future compatibility with FreeBSD */
254 
255 #define IP_PORTRANGE		19   /* int; range to choose for unspec port */
256 #define IP_AUTH_LEVEL		20   /* int; authentication used */
257 #define IP_ESP_TRANS_LEVEL	21   /* int; transport encryption */
258 #define IP_ESP_NETWORK_LEVEL	22   /* int; full-packet encryption */
259 #define IP_IPSEC_LOCAL_ID	23   /* buf; IPsec local ID */
260 #define IP_IPSEC_REMOTE_ID	24   /* buf; IPsec remote ID */
261 #define IP_IPSEC_LOCAL_CRED	25   /* buf; IPsec local credentials */
262 #define IP_IPSEC_REMOTE_CRED	26   /* buf; IPsec remote credentials */
263 #define IP_IPSEC_LOCAL_AUTH	27   /* buf; IPsec local auth material */
264 #define IP_IPSEC_REMOTE_AUTH	28   /* buf; IPsec remote auth material */
265 #define IP_IPCOMP_LEVEL		29   /* int; compression used */
266 
267 /*
268  * Security levels - IPsec, not IPSO
269  */
270 
271 #define IPSEC_LEVEL_BYPASS      0x00    /* Bypass policy altogether */
272 #define IPSEC_LEVEL_NONE        0x00    /* Send clear, accept any */
273 #define IPSEC_LEVEL_AVAIL       0x01    /* Send secure if SA available */
274 #define IPSEC_LEVEL_USE         0x02    /* Send secure, accept any */
275 #define IPSEC_LEVEL_REQUIRE     0x03    /* Require secure inbound, also use */
276 #define IPSEC_LEVEL_UNIQUE      0x04    /* Use outbound SA that is unique */
277 #define IPSEC_LEVEL_DEFAULT     IPSEC_LEVEL_AVAIL
278 
279 #define IPSEC_AUTH_LEVEL_DEFAULT IPSEC_LEVEL_DEFAULT
280 #define IPSEC_ESP_TRANS_LEVEL_DEFAULT IPSEC_LEVEL_DEFAULT
281 #define IPSEC_ESP_NETWORK_LEVEL_DEFAULT IPSEC_LEVEL_DEFAULT
282 #define IPSEC_IPCOMP_LEVEL_DEFAULT IPSEC_LEVEL_DEFAULT
283 
284 /*
285  * Defaults and limits for options
286  */
287 #define	IP_DEFAULT_MULTICAST_TTL  1	/* normally limit m'casts to 1 hop  */
288 #define	IP_DEFAULT_MULTICAST_LOOP 1	/* normally hear sends if a member  */
289 #define	IP_MAX_MEMBERSHIPS	20	/* per socket; must fit in one mbuf */
290 
291 /*
292  * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
293  */
294 struct ip_mreq {
295 	struct	in_addr imr_multiaddr;	/* IP multicast address of group */
296 	struct	in_addr imr_interface;	/* local IP address of interface */
297 };
298 
299 /*
300  * Argument for IP_PORTRANGE:
301  * - which range to search when port is unspecified at bind() or connect()
302  */
303 #define IP_PORTRANGE_DEFAULT	0	/* default range */
304 #define IP_PORTRANGE_HIGH	1	/* "high" - request firewall bypass */
305 #define IP_PORTRANGE_LOW	2	/* "low" - vouchsafe security */
306 
307 /*
308  * Buffer lengths for strings containing printable IP addresses
309  */
310 #define INET_ADDRSTRLEN		16
311 
312 /*
313  * Definitions for inet sysctl operations.
314  *
315  * Third level is protocol number.
316  * Fourth level is desired variable within that protocol.
317  */
318 #define	IPPROTO_MAXID	(IPPROTO_IPCOMP + 1)	/* don't list to IPPROTO_MAX */
319 
320 #define	CTL_IPPROTO_NAMES { \
321 	{ "ip", CTLTYPE_NODE }, \
322 	{ "icmp", CTLTYPE_NODE }, \
323 	{ "igmp", CTLTYPE_NODE }, \
324 	{ "ggp", CTLTYPE_NODE }, \
325 	{ "ipip", CTLTYPE_NODE }, \
326 	{ 0, 0 }, \
327 	{ "tcp", CTLTYPE_NODE }, \
328 	{ 0, 0 }, \
329 	{ "egp", CTLTYPE_NODE }, \
330 	{ 0, 0 }, \
331 	{ 0, 0 }, \
332 	{ 0, 0 }, \
333 	{ "pup", CTLTYPE_NODE }, \
334 	{ 0, 0 }, \
335 	{ 0, 0 }, \
336 	{ 0, 0 }, \
337 	{ 0, 0 }, \
338 	{ "udp", CTLTYPE_NODE }, \
339 	{ 0, 0 }, \
340 	{ 0, 0 }, \
341 	{ 0, 0 }, \
342 	{ 0, 0 }, \
343 	{ 0, 0 }, \
344 	{ 0, 0 }, \
345 	{ 0, 0 }, \
346 	{ 0, 0 }, \
347 	{ 0, 0 }, \
348 	{ 0, 0 }, \
349 	{ 0, 0 }, \
350 	{ 0, 0 }, \
351 	{ 0, 0 }, \
352 	{ 0, 0 }, \
353 	{ 0, 0 }, \
354 	{ 0, 0 }, \
355 	{ 0, 0 }, \
356 	{ 0, 0 }, \
357 	{ 0, 0 }, \
358 	{ 0, 0 }, \
359 	{ 0, 0 }, \
360 	{ 0, 0 }, \
361 	{ 0, 0 }, \
362 	{ 0, 0 }, \
363 	{ 0, 0 }, \
364 	{ 0, 0 }, \
365 	{ 0, 0 }, \
366 	{ 0, 0 }, \
367 	{ 0, 0 }, \
368 	{ "gre", CTLTYPE_NODE }, \
369 	{ 0, 0 }, \
370 	{ 0, 0 }, \
371 	{ "esp", CTLTYPE_NODE }, \
372 	{ "ah", CTLTYPE_NODE }, \
373 	{ 0, 0 }, \
374 	{ 0, 0 }, \
375 	{ 0, 0 }, \
376 	{ "mobileip", CTLTYPE_NODE }, \
377 	{ 0, 0 }, \
378 	{ 0, 0 }, \
379 	{ 0, 0 }, \
380 	{ 0, 0 }, \
381 	{ 0, 0 }, \
382 	{ 0, 0 }, \
383 	{ 0, 0 }, \
384 	{ 0, 0 }, \
385 	{ 0, 0 }, \
386 	{ 0, 0 }, \
387 	{ 0, 0 }, \
388 	{ 0, 0 }, \
389 	{ 0, 0 }, \
390 	{ 0, 0 }, \
391 	{ 0, 0 }, \
392 	{ 0, 0 }, \
393 	{ 0, 0 }, \
394 	{ 0, 0 }, \
395 	{ 0, 0 }, \
396 	{ 0, 0 }, \
397 	{ 0, 0 }, \
398 	{ 0, 0 }, \
399 	{ 0, 0 }, \
400 	{ 0, 0 }, \
401 	{ 0, 0 }, \
402 	{ 0, 0 }, \
403 	{ 0, 0 }, \
404 	{ 0, 0 }, \
405 	{ 0, 0 }, \
406 	{ 0, 0 }, \
407 	{ 0, 0 }, \
408 	{ 0, 0 }, \
409 	{ 0, 0 }, \
410 	{ 0, 0 }, \
411 	{ 0, 0 }, \
412 	{ 0, 0 }, \
413 	{ 0, 0 }, \
414 	{ 0, 0 }, \
415 	{ 0, 0 }, \
416 	{ 0, 0 }, \
417 	{ 0, 0 }, \
418 	{ "etherip", CTLTYPE_NODE }, \
419 	{ 0, 0 }, \
420 	{ 0, 0 }, \
421 	{ 0, 0 }, \
422 	{ 0, 0 }, \
423 	{ 0, 0 }, \
424 	{ 0, 0 }, \
425 	{ 0, 0 }, \
426 	{ 0, 0 }, \
427 	{ 0, 0 }, \
428 	{ 0, 0 }, \
429 	{ "ipcomp", CTLTYPE_NODE }, \
430 }
431 
432 /*
433  * Names for IP sysctl objects
434  */
435 #define	IPCTL_FORWARDING	1	/* act as router */
436 #define	IPCTL_SENDREDIRECTS	2	/* may send redirects when forwarding */
437 #define	IPCTL_DEFTTL		3	/* default TTL */
438 #ifdef notyet
439 #define	IPCTL_DEFMTU		4	/* default MTU */
440 #endif
441 #define	IPCTL_SOURCEROUTE	5	/* may perform source routes */
442 #define	IPCTL_DIRECTEDBCAST	6	/* default broadcast behavior */
443 #define IPCTL_IPPORT_FIRSTAUTO	7
444 #define IPCTL_IPPORT_LASTAUTO	8
445 #define IPCTL_IPPORT_HIFIRSTAUTO 9
446 #define IPCTL_IPPORT_HILASTAUTO	10
447 #define	IPCTL_IPPORT_MAXQUEUE	11
448 #define	IPCTL_ENCDEBUG		12
449 #ifdef notdef	/*obsolete*/
450 #define IPCTL_GIF_TTL		13	/* default TTL for gif encap packet */
451 #endif
452 #define IPCTL_IPSEC_EXPIRE_ACQUIRE 14   /* How long to wait for key mgmt. */
453 #define IPCTL_IPSEC_EMBRYONIC_SA_TIMEOUT	15 /* new SA lifetime */
454 #define IPCTL_IPSEC_REQUIRE_PFS 16
455 #define IPCTL_IPSEC_SOFT_ALLOCATIONS            17
456 #define IPCTL_IPSEC_ALLOCATIONS 18
457 #define IPCTL_IPSEC_SOFT_BYTES  19
458 #define IPCTL_IPSEC_BYTES       20
459 #define IPCTL_IPSEC_TIMEOUT     21
460 #define IPCTL_IPSEC_SOFT_TIMEOUT 22
461 #define IPCTL_IPSEC_SOFT_FIRSTUSE 23
462 #define IPCTL_IPSEC_FIRSTUSE    24
463 #define IPCTL_IPSEC_ENC_ALGORITHM 25
464 #define IPCTL_IPSEC_AUTH_ALGORITHM 26
465 #define	IPCTL_MTUDISC		27	/* allow path MTU discovery */
466 #define	IPCTL_MTUDISCTIMEOUT	28	/* allow path MTU discovery */
467 #define	IPCTL_IPSEC_IPCOMP_ALGORITHM	29
468 #define	IPCTL_MAXID		30
469 
470 #define	IPCTL_NAMES { \
471 	{ 0, 0 }, \
472 	{ "forwarding", CTLTYPE_INT }, \
473 	{ "redirect", CTLTYPE_INT }, \
474 	{ "ttl", CTLTYPE_INT }, \
475 	/* { "mtu", CTLTYPE_INT }, */ { 0, 0 }, \
476 	{ "sourceroute", CTLTYPE_INT }, \
477 	{ "directed-broadcast", CTLTYPE_INT }, \
478 	{ "portfirst", CTLTYPE_INT }, \
479 	{ "portlast", CTLTYPE_INT }, \
480 	{ "porthifirst", CTLTYPE_INT }, \
481 	{ "porthilast", CTLTYPE_INT }, \
482 	{ "maxqueue", CTLTYPE_INT }, \
483 	{ "encdebug", CTLTYPE_INT }, \
484 	{ 0, 0 }, \
485 	{ "ipsec-expire-acquire", CTLTYPE_INT }, \
486 	{ "ipsec-invalid-life", CTLTYPE_INT }, \
487 	{ "ipsec-pfs", CTLTYPE_INT }, \
488 	{ "ipsec-soft-allocs", CTLTYPE_INT }, \
489 	{ "ipsec-allocs", CTLTYPE_INT }, \
490 	{ "ipsec-soft-bytes", CTLTYPE_INT }, \
491 	{ "ipsec-bytes", CTLTYPE_INT }, \
492 	{ "ipsec-timeout", CTLTYPE_INT }, \
493 	{ "ipsec-soft-timeout", CTLTYPE_INT }, \
494 	{ "ipsec-soft-firstuse", CTLTYPE_INT }, \
495 	{ "ipsec-firstuse", CTLTYPE_INT }, \
496 	{ "ipsec-enc-alg", CTLTYPE_STRING }, \
497 	{ "ipsec-auth-alg", CTLTYPE_STRING }, \
498 	{ "mtudisc", CTLTYPE_INT }, \
499 	{ "mtudisctimeout", CTLTYPE_INT }, \
500 	{ "ipsec-comp-alg", CTLTYPE_STRING }, \
501 }
502 
503 /* INET6 stuff */
504 #define __KAME_NETINET_IN_H_INCLUDED_
505 #include <netinet6/in6.h>
506 #undef __KAME_NETINET_IN_H_INCLUDED_
507 
508 #ifndef _KERNEL
509 
510 #include <sys/cdefs.h>
511 
512 __BEGIN_DECLS
513 int	   bindresvport __P((int, struct sockaddr_in *));
514 struct sockaddr;
515 int	   bindresvport_sa __P((int, struct sockaddr *));
516 __END_DECLS
517 
518 #else
519 /*
520  * in_cksum_phdr:
521  *
522  *	Compute significant parts of the IPv4 checksum pseudo-header
523  *	for use in a delayed TCP/UDP checksum calculation.
524  *
525  *	Args:
526  *
527  *		src		Source IP address
528  *		dst		Destination IP address
529  *		lenproto	htons(proto-hdr-len + proto-number)
530  */
531 static __inline u_int16_t __attribute__((__unused__))
532 in_cksum_phdr(u_int32_t src, u_int32_t dst, u_int32_t lenproto)
533 {
534 	u_int32_t sum;
535 
536 	sum = lenproto +
537 	      (u_int16_t)(src >> 16) +
538 	      (u_int16_t)(src /*& 0xffff*/) +
539 	      (u_int16_t)(dst >> 16) +
540 	      (u_int16_t)(dst /*& 0xffff*/);
541 
542 	sum = (u_int16_t)(sum >> 16) + (u_int16_t)(sum /*& 0xffff*/);
543 
544 	if (sum > 0xffff)
545 		sum -= 0xffff;
546 
547 	return (sum);
548 }
549 
550 /*
551  * in_cksum_addword:
552  *
553  *	Add the two 16-bit network-order values, carry, and return.
554  */
555 static __inline u_int16_t __attribute__((__unused__))
556 in_cksum_addword(u_int16_t a, u_int16_t b)
557 {
558 	u_int32_t sum = a + b;
559 
560 	if (sum > 0xffff)
561 		sum -= 0xffff;
562 
563 	return (sum);
564 }
565 
566 int	   in_broadcast __P((struct in_addr, struct ifnet *));
567 int	   in_canforward __P((struct in_addr));
568 int	   in_cksum __P((struct mbuf *, int));
569 int	   in4_cksum __P((struct mbuf *, u_int8_t, int, int));
570 void	   in_delayed_cksum __P((struct mbuf *));
571 int	   in_localaddr __P((struct in_addr));
572 void	   in_socktrim __P((struct sockaddr_in *));
573 char	  *inet_ntoa __P((struct in_addr));
574 
575 #define	in_hosteq(s,t)	((s).s_addr == (t).s_addr)
576 #define	in_nullhost(x)	((x).s_addr == INADDR_ANY)
577 
578 #define	satosin(sa)	((struct sockaddr_in *)(sa))
579 #define	sintosa(sin)	((struct sockaddr *)(sin))
580 #define	ifatoia(ifa)	((struct in_ifaddr *)(ifa))
581 #endif /* _KERNEL */
582 #endif /* _NETINET_IN_H_ */
583