This source file includes following definitions.
- in_cksum_phdr
- in_cksum_addword
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 #ifndef _NETINET_IN_H_
41 #define _NETINET_IN_H_
42
43
44
45
46 #define IPPROTO_IP 0
47 #define IPPROTO_HOPOPTS IPPROTO_IP
48 #define IPPROTO_ICMP 1
49 #define IPPROTO_IGMP 2
50 #define IPPROTO_GGP 3
51 #define IPPROTO_IPIP 4
52 #define IPPROTO_IPV4 IPPROTO_IPIP
53 #define IPPROTO_TCP 6
54 #define IPPROTO_EGP 8
55 #define IPPROTO_PUP 12
56 #define IPPROTO_UDP 17
57 #define IPPROTO_IDP 22
58 #define IPPROTO_TP 29
59 #define IPPROTO_IPV6 41
60 #define IPPROTO_ROUTING 43
61 #define IPPROTO_FRAGMENT 44
62 #define IPPROTO_RSVP 46
63 #define IPPROTO_GRE 47
64 #define IPPROTO_ESP 50
65 #define IPPROTO_AH 51
66 #define IPPROTO_MOBILE 55
67 #define IPPROTO_ICMPV6 58
68 #define IPPROTO_NONE 59
69 #define IPPROTO_DSTOPTS 60
70 #define IPPROTO_EON 80
71 #define IPPROTO_ETHERIP 97
72 #define IPPROTO_ENCAP 98
73 #define IPPROTO_PIM 103
74 #define IPPROTO_IPCOMP 108
75 #define IPPROTO_CARP 112
76 #define IPPROTO_PFSYNC 240
77 #define IPPROTO_RAW 255
78
79 #define IPPROTO_MAX 256
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123 #define IPPORT_RESERVED 1024
124 #define IPPORT_USERRESERVED 49151
125
126
127
128
129 #define IPPORT_HIFIRSTAUTO 49152
130 #define IPPORT_HILASTAUTO 65535
131
132
133
134
135 struct in_addr {
136 in_addr_t s_addr;
137 };
138
139
140 #define IPPROTO_DONE 257
141
142
143
144
145
146
147
148
149
150
151 #ifdef _KERNEL
152 #define __IPADDR(x) ((u_int32_t) htonl((u_int32_t)(x)))
153 #else
154 #define __IPADDR(x) ((u_int32_t)(x))
155 #endif
156
157 #define IN_CLASSA(i) (((u_int32_t)(i) & __IPADDR(0x80000000)) == \
158 __IPADDR(0x00000000))
159 #define IN_CLASSA_NET __IPADDR(0xff000000)
160 #define IN_CLASSA_NSHIFT 24
161 #define IN_CLASSA_HOST __IPADDR(0x00ffffff)
162 #define IN_CLASSA_MAX 128
163
164 #define IN_CLASSB(i) (((u_int32_t)(i) & __IPADDR(0xc0000000)) == \
165 __IPADDR(0x80000000))
166 #define IN_CLASSB_NET __IPADDR(0xffff0000)
167 #define IN_CLASSB_NSHIFT 16
168 #define IN_CLASSB_HOST __IPADDR(0x0000ffff)
169 #define IN_CLASSB_MAX 65536
170
171 #define IN_CLASSC(i) (((u_int32_t)(i) & __IPADDR(0xe0000000)) == \
172 __IPADDR(0xc0000000))
173 #define IN_CLASSC_NET __IPADDR(0xffffff00)
174 #define IN_CLASSC_NSHIFT 8
175 #define IN_CLASSC_HOST __IPADDR(0x000000ff)
176
177 #define IN_CLASSD(i) (((u_int32_t)(i) & __IPADDR(0xf0000000)) == \
178 __IPADDR(0xe0000000))
179
180 #define IN_CLASSD_NET __IPADDR(0xf0000000)
181 #define IN_CLASSD_NSHIFT 28
182 #define IN_CLASSD_HOST __IPADDR(0x0fffffff)
183 #define IN_MULTICAST(i) IN_CLASSD(i)
184
185 #define IN_EXPERIMENTAL(i) (((u_int32_t)(i) & __IPADDR(0xf0000000)) == \
186 __IPADDR(0xf0000000))
187 #define IN_BADCLASS(i) (((u_int32_t)(i) & __IPADDR(0xf0000000)) == \
188 __IPADDR(0xf0000000))
189
190 #define IN_LOCAL_GROUP(i) (((u_int32_t)(i) & __IPADDR(0xffffff00)) == \
191 __IPADDR(0xe0000000))
192
193 #define INADDR_ANY __IPADDR(0x00000000)
194 #define INADDR_LOOPBACK __IPADDR(0x7f000001)
195 #define INADDR_BROADCAST __IPADDR(0xffffffff)
196 #ifndef _KERNEL
197 #define INADDR_NONE __IPADDR(0xffffffff)
198 #endif
199
200 #define INADDR_UNSPEC_GROUP __IPADDR(0xe0000000)
201 #define INADDR_ALLHOSTS_GROUP __IPADDR(0xe0000001)
202 #define INADDR_ALLROUTERS_GROUP __IPADDR(0xe0000002)
203 #define INADDR_CARP_GROUP __IPADDR(0xe0000012)
204 #define INADDR_PFSYNC_GROUP __IPADDR(0xe00000f0)
205 #define INADDR_MAX_LOCAL_GROUP __IPADDR(0xe00000ff)
206
207 #define IN_LOOPBACKNET 127
208
209
210
211
212 struct sockaddr_in {
213 u_int8_t sin_len;
214 sa_family_t sin_family;
215 in_port_t sin_port;
216 struct in_addr sin_addr;
217 int8_t sin_zero[8];
218 };
219
220
221
222
223
224
225
226
227 struct ip_opts {
228 struct in_addr ip_dst;
229 #if defined(__cplusplus)
230 int8_t Ip_opts[40];
231 #else
232 int8_t ip_opts[40];
233 #endif
234 };
235
236
237
238
239
240 #define IP_OPTIONS 1
241 #define IP_HDRINCL 2
242 #define IP_TOS 3
243 #define IP_TTL 4
244 #define IP_RECVOPTS 5
245 #define IP_RECVRETOPTS 6
246 #define IP_RECVDSTADDR 7
247 #define IP_RETOPTS 8
248 #define IP_MULTICAST_IF 9
249 #define IP_MULTICAST_TTL 10
250 #define IP_MULTICAST_LOOP 11
251 #define IP_ADD_MEMBERSHIP 12
252 #define IP_DROP_MEMBERSHIP 13
253
254
255
256 #define IP_PORTRANGE 19
257 #define IP_AUTH_LEVEL 20
258 #define IP_ESP_TRANS_LEVEL 21
259 #define IP_ESP_NETWORK_LEVEL 22
260 #define IP_IPSEC_LOCAL_ID 23
261 #define IP_IPSEC_REMOTE_ID 24
262 #define IP_IPSEC_LOCAL_CRED 25
263 #define IP_IPSEC_REMOTE_CRED 26
264 #define IP_IPSEC_LOCAL_AUTH 27
265 #define IP_IPSEC_REMOTE_AUTH 28
266 #define IP_IPCOMP_LEVEL 29
267 #define IP_RECVIF 30
268 #define IP_RECVTTL 31
269 #define IP_MINTTL 32
270
271
272
273
274
275 #define IPSEC_LEVEL_BYPASS 0x00
276 #define IPSEC_LEVEL_NONE 0x00
277 #define IPSEC_LEVEL_AVAIL 0x01
278 #define IPSEC_LEVEL_USE 0x02
279 #define IPSEC_LEVEL_REQUIRE 0x03
280 #define IPSEC_LEVEL_UNIQUE 0x04
281 #define IPSEC_LEVEL_DEFAULT IPSEC_LEVEL_AVAIL
282
283 #define IPSEC_AUTH_LEVEL_DEFAULT IPSEC_LEVEL_DEFAULT
284 #define IPSEC_ESP_TRANS_LEVEL_DEFAULT IPSEC_LEVEL_DEFAULT
285 #define IPSEC_ESP_NETWORK_LEVEL_DEFAULT IPSEC_LEVEL_DEFAULT
286 #define IPSEC_IPCOMP_LEVEL_DEFAULT IPSEC_LEVEL_DEFAULT
287
288
289
290
291 #define IP_DEFAULT_MULTICAST_TTL 1
292 #define IP_DEFAULT_MULTICAST_LOOP 1
293 #define IP_MAX_MEMBERSHIPS 20
294
295
296
297
298 struct ip_mreq {
299 struct in_addr imr_multiaddr;
300 struct in_addr imr_interface;
301 };
302
303
304
305
306
307 #define IP_PORTRANGE_DEFAULT 0
308 #define IP_PORTRANGE_HIGH 1
309 #define IP_PORTRANGE_LOW 2
310
311
312
313
314 #define INET_ADDRSTRLEN 16
315
316
317
318
319
320
321
322 #define IPPROTO_MAXID (IPPROTO_CARP + 1)
323
324 #define CTL_IPPROTO_NAMES { \
325 { "ip", CTLTYPE_NODE }, \
326 { "icmp", CTLTYPE_NODE }, \
327 { "igmp", CTLTYPE_NODE }, \
328 { "ggp", CTLTYPE_NODE }, \
329 { "ipip", CTLTYPE_NODE }, \
330 { 0, 0 }, \
331 { "tcp", CTLTYPE_NODE }, \
332 { 0, 0 }, \
333 { "egp", CTLTYPE_NODE }, \
334 { 0, 0 }, \
335 { 0, 0 }, \
336 { 0, 0 }, \
337 { "pup", CTLTYPE_NODE }, \
338 { 0, 0 }, \
339 { 0, 0 }, \
340 { 0, 0 }, \
341 { 0, 0 }, \
342 { "udp", CTLTYPE_NODE }, \
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 { 0, 0 }, \
369 { 0, 0 }, \
370 { 0, 0 }, \
371 { 0, 0 }, \
372 { "gre", CTLTYPE_NODE }, \
373 { 0, 0 }, \
374 { 0, 0 }, \
375 { "esp", CTLTYPE_NODE }, \
376 { "ah", CTLTYPE_NODE }, \
377 { 0, 0 }, \
378 { 0, 0 }, \
379 { 0, 0 }, \
380 { "mobileip", CTLTYPE_NODE }, \
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 { 0, 0 }, \
419 { 0, 0 }, \
420 { 0, 0 }, \
421 { 0, 0 }, \
422 { "etherip", CTLTYPE_NODE }, \
423 { 0, 0 }, \
424 { 0, 0 }, \
425 { 0, 0 }, \
426 { 0, 0 }, \
427 { 0, 0 }, \
428 { "pim", CTLTYPE_NODE }, \
429 { 0, 0 }, \
430 { 0, 0 }, \
431 { 0, 0 }, \
432 { 0, 0 }, \
433 { "ipcomp", CTLTYPE_NODE }, \
434 { 0, 0 }, \
435 { 0, 0 }, \
436 { 0, 0 }, \
437 { "carp", CTLTYPE_NODE }, \
438 }
439
440
441
442
443 #define IPCTL_FORWARDING 1
444 #define IPCTL_SENDREDIRECTS 2
445 #define IPCTL_DEFTTL 3
446 #ifdef notyet
447 #define IPCTL_DEFMTU 4
448 #endif
449 #define IPCTL_SOURCEROUTE 5
450 #define IPCTL_DIRECTEDBCAST 6
451 #define IPCTL_IPPORT_FIRSTAUTO 7
452 #define IPCTL_IPPORT_LASTAUTO 8
453 #define IPCTL_IPPORT_HIFIRSTAUTO 9
454 #define IPCTL_IPPORT_HILASTAUTO 10
455 #define IPCTL_IPPORT_MAXQUEUE 11
456 #define IPCTL_ENCDEBUG 12
457 #ifdef notdef
458 #define IPCTL_GIF_TTL 13
459 #endif
460 #define IPCTL_IPSEC_EXPIRE_ACQUIRE 14
461 #define IPCTL_IPSEC_EMBRYONIC_SA_TIMEOUT 15
462 #define IPCTL_IPSEC_REQUIRE_PFS 16
463 #define IPCTL_IPSEC_SOFT_ALLOCATIONS 17
464 #define IPCTL_IPSEC_ALLOCATIONS 18
465 #define IPCTL_IPSEC_SOFT_BYTES 19
466 #define IPCTL_IPSEC_BYTES 20
467 #define IPCTL_IPSEC_TIMEOUT 21
468 #define IPCTL_IPSEC_SOFT_TIMEOUT 22
469 #define IPCTL_IPSEC_SOFT_FIRSTUSE 23
470 #define IPCTL_IPSEC_FIRSTUSE 24
471 #define IPCTL_IPSEC_ENC_ALGORITHM 25
472 #define IPCTL_IPSEC_AUTH_ALGORITHM 26
473 #define IPCTL_MTUDISC 27
474 #define IPCTL_MTUDISCTIMEOUT 28
475 #define IPCTL_IPSEC_IPCOMP_ALGORITHM 29
476 #define IPCTL_IFQUEUE 30
477 #define IPCTL_MFORWARDING 31
478 #define IPCTL_MULTIPATH 32
479 #define IPCTL_MAXID 33
480
481 #define IPCTL_NAMES { \
482 { 0, 0 }, \
483 { "forwarding", CTLTYPE_INT }, \
484 { "redirect", CTLTYPE_INT }, \
485 { "ttl", CTLTYPE_INT }, \
486 { 0, 0 }, \
487 { "sourceroute", CTLTYPE_INT }, \
488 { "directed-broadcast", CTLTYPE_INT }, \
489 { "portfirst", CTLTYPE_INT }, \
490 { "portlast", CTLTYPE_INT }, \
491 { "porthifirst", CTLTYPE_INT }, \
492 { "porthilast", CTLTYPE_INT }, \
493 { "maxqueue", CTLTYPE_INT }, \
494 { "encdebug", CTLTYPE_INT }, \
495 { 0, 0 }, \
496 { "ipsec-expire-acquire", CTLTYPE_INT }, \
497 { "ipsec-invalid-life", CTLTYPE_INT }, \
498 { "ipsec-pfs", CTLTYPE_INT }, \
499 { "ipsec-soft-allocs", CTLTYPE_INT }, \
500 { "ipsec-allocs", CTLTYPE_INT }, \
501 { "ipsec-soft-bytes", CTLTYPE_INT }, \
502 { "ipsec-bytes", CTLTYPE_INT }, \
503 { "ipsec-timeout", CTLTYPE_INT }, \
504 { "ipsec-soft-timeout", CTLTYPE_INT }, \
505 { "ipsec-soft-firstuse", CTLTYPE_INT }, \
506 { "ipsec-firstuse", CTLTYPE_INT }, \
507 { "ipsec-enc-alg", CTLTYPE_STRING }, \
508 { "ipsec-auth-alg", CTLTYPE_STRING }, \
509 { "mtudisc", CTLTYPE_INT }, \
510 { "mtudisctimeout", CTLTYPE_INT }, \
511 { "ipsec-comp-alg", CTLTYPE_STRING }, \
512 { "ifq", CTLTYPE_NODE }, \
513 { "mforwarding", CTLTYPE_INT }, \
514 { "multipath", CTLTYPE_INT } \
515 }
516 #define IPCTL_VARS { \
517 NULL, \
518 &ipforwarding, \
519 &ipsendredirects, \
520 &ip_defttl, \
521 NULL, \
522 NULL, \
523 &ip_directedbcast, \
524 &ipport_firstauto, \
525 &ipport_lastauto, \
526 &ipport_hifirstauto, \
527 &ipport_hilastauto, \
528 &ip_maxqueue, \
529 &encdebug, \
530 NULL, \
531 &ipsec_expire_acquire, \
532 &ipsec_keep_invalid, \
533 &ipsec_require_pfs, \
534 &ipsec_soft_allocations, \
535 &ipsec_exp_allocations, \
536 &ipsec_soft_bytes, \
537 &ipsec_exp_bytes, \
538 &ipsec_exp_timeout, \
539 &ipsec_soft_timeout, \
540 &ipsec_soft_first_use, \
541 &ipsec_exp_first_use, \
542 NULL, \
543 NULL, \
544 NULL, \
545 NULL, \
546 NULL, \
547 NULL, \
548 &ipmforwarding, \
549 &ipmultipath \
550 }
551
552
553 #define __KAME_NETINET_IN_H_INCLUDED_
554 #include <netinet6/in6.h>
555 #undef __KAME_NETINET_IN_H_INCLUDED_
556
557 #ifndef _KERNEL
558
559 #include <sys/cdefs.h>
560
561 __BEGIN_DECLS
562 int bindresvport(int, struct sockaddr_in *);
563 struct sockaddr;
564 int bindresvport_sa(int, struct sockaddr *);
565 __END_DECLS
566
567 #else
568
569
570
571
572
573
574
575
576
577
578
579
580 static __inline u_int16_t __attribute__((__unused__))
581 in_cksum_phdr(u_int32_t src, u_int32_t dst, u_int32_t lenproto)
582 {
583 u_int32_t sum;
584
585 sum = lenproto +
586 (u_int16_t)(src >> 16) +
587 (u_int16_t)(src ) +
588 (u_int16_t)(dst >> 16) +
589 (u_int16_t)(dst );
590
591 sum = (u_int16_t)(sum >> 16) + (u_int16_t)(sum );
592
593 if (sum > 0xffff)
594 sum -= 0xffff;
595
596 return (sum);
597 }
598
599
600
601
602
603
604 static __inline u_int16_t __attribute__((__unused__))
605 in_cksum_addword(u_int16_t a, u_int16_t b)
606 {
607 u_int32_t sum = a + b;
608
609 if (sum > 0xffff)
610 sum -= 0xffff;
611
612 return (sum);
613 }
614
615 extern struct in_addr zeroin_addr;
616
617 int in_broadcast(struct in_addr, struct ifnet *);
618 int in_canforward(struct in_addr);
619 int in_cksum(struct mbuf *, int);
620 int in4_cksum(struct mbuf *, u_int8_t, int, int);
621 void in_delayed_cksum(struct mbuf *);
622 int in_localaddr(struct in_addr);
623 void in_socktrim(struct sockaddr_in *);
624 char *inet_ntoa(struct in_addr);
625
626 #define in_hosteq(s,t) ((s).s_addr == (t).s_addr)
627 #define in_nullhost(x) ((x).s_addr == INADDR_ANY)
628
629 #define satosin(sa) ((struct sockaddr_in *)(sa))
630 #define sintosa(sin) ((struct sockaddr *)(sin))
631 #define ifatoia(ifa) ((struct in_ifaddr *)(ifa))
632 #endif
633 #endif