1/* Copyright (C) 1991-2013 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _NETINET_IN_H
19#define _NETINET_IN_H 1
20
21#include <features.h>
22#include <stdint.h>
23#include <sys/socket.h>
24#include <bits/types.h>
25
26
27__BEGIN_DECLS
28
29/* Standard well-defined IP protocols. */
30enum
31 {
32 IPPROTO_IP = 0, /* Dummy protocol for TCP. */
33#define IPPROTO_IP IPPROTO_IP
34 IPPROTO_HOPOPTS = 0, /* IPv6 Hop-by-Hop options. */
35#define IPPROTO_HOPOPTS IPPROTO_HOPOPTS
36 IPPROTO_ICMP = 1, /* Internet Control Message Protocol. */
37#define IPPROTO_ICMP IPPROTO_ICMP
38 IPPROTO_IGMP = 2, /* Internet Group Management Protocol. */
39#define IPPROTO_IGMP IPPROTO_IGMP
40 IPPROTO_IPIP = 4, /* IPIP tunnels (older KA9Q tunnels use 94). */
41#define IPPROTO_IPIP IPPROTO_IPIP
42 IPPROTO_TCP = 6, /* Transmission Control Protocol. */
43#define IPPROTO_TCP IPPROTO_TCP
44 IPPROTO_EGP = 8, /* Exterior Gateway Protocol. */
45#define IPPROTO_EGP IPPROTO_EGP
46 IPPROTO_PUP = 12, /* PUP protocol. */
47#define IPPROTO_PUP IPPROTO_PUP
48 IPPROTO_UDP = 17, /* User Datagram Protocol. */
49#define IPPROTO_UDP IPPROTO_UDP
50 IPPROTO_IDP = 22, /* XNS IDP protocol. */
51#define IPPROTO_IDP IPPROTO_IDP
52 IPPROTO_TP = 29, /* SO Transport Protocol Class 4. */
53#define IPPROTO_TP IPPROTO_TP
54 IPPROTO_DCCP = 33, /* Datagram Congestion Control Protocol. */
55#define IPPROTO_DCCP IPPROTO_DCCP
56 IPPROTO_IPV6 = 41, /* IPv6 header. */
57#define IPPROTO_IPV6 IPPROTO_IPV6
58 IPPROTO_ROUTING = 43, /* IPv6 routing header. */
59#define IPPROTO_ROUTING IPPROTO_ROUTING
60 IPPROTO_FRAGMENT = 44, /* IPv6 fragmentation header. */
61#define IPPROTO_FRAGMENT IPPROTO_FRAGMENT
62 IPPROTO_RSVP = 46, /* Reservation Protocol. */
63#define IPPROTO_RSVP IPPROTO_RSVP
64 IPPROTO_GRE = 47, /* General Routing Encapsulation. */
65#define IPPROTO_GRE IPPROTO_GRE
66 IPPROTO_ESP = 50, /* encapsulating security payload. */
67#define IPPROTO_ESP IPPROTO_ESP
68 IPPROTO_AH = 51, /* authentication header. */
69#define IPPROTO_AH IPPROTO_AH
70 IPPROTO_ICMPV6 = 58, /* ICMPv6. */
71#define IPPROTO_ICMPV6 IPPROTO_ICMPV6
72 IPPROTO_NONE = 59, /* IPv6 no next header. */
73#define IPPROTO_NONE IPPROTO_NONE
74 IPPROTO_DSTOPTS = 60, /* IPv6 destination options. */
75#define IPPROTO_DSTOPTS IPPROTO_DSTOPTS
76 IPPROTO_MTP = 92, /* Multicast Transport Protocol. */
77#define IPPROTO_MTP IPPROTO_MTP
78 IPPROTO_ENCAP = 98, /* Encapsulation Header. */
79#define IPPROTO_ENCAP IPPROTO_ENCAP
80 IPPROTO_PIM = 103, /* Protocol Independent Multicast. */
81#define IPPROTO_PIM IPPROTO_PIM
82 IPPROTO_COMP = 108, /* Compression Header Protocol. */
83#define IPPROTO_COMP IPPROTO_COMP
84 IPPROTO_SCTP = 132, /* Stream Control Transmission Protocol. */
85#define IPPROTO_SCTP IPPROTO_SCTP
86 IPPROTO_UDPLITE = 136, /* UDP-Lite protocol. */
87#define IPPROTO_UDPLITE IPPROTO_UDPLITE
88 IPPROTO_RAW = 255, /* Raw IP packets. */
89#define IPPROTO_RAW IPPROTO_RAW
90 IPPROTO_MAX
91 };
92
93
94/* Type to represent a port. */
95typedef uint16_t in_port_t;
96
97/* Standard well-known ports. */
98enum
99 {
100 IPPORT_ECHO = 7, /* Echo service. */
101 IPPORT_DISCARD = 9, /* Discard transmissions service. */
102 IPPORT_SYSTAT = 11, /* System status service. */
103 IPPORT_DAYTIME = 13, /* Time of day service. */
104 IPPORT_NETSTAT = 15, /* Network status service. */
105 IPPORT_FTP = 21, /* File Transfer Protocol. */
106 IPPORT_TELNET = 23, /* Telnet protocol. */
107 IPPORT_SMTP = 25, /* Simple Mail Transfer Protocol. */
108 IPPORT_TIMESERVER = 37, /* Timeserver service. */
109 IPPORT_NAMESERVER = 42, /* Domain Name Service. */
110 IPPORT_WHOIS = 43, /* Internet Whois service. */
111 IPPORT_MTP = 57,
112
113 IPPORT_TFTP = 69, /* Trivial File Transfer Protocol. */
114 IPPORT_RJE = 77,
115 IPPORT_FINGER = 79, /* Finger service. */
116 IPPORT_TTYLINK = 87,
117 IPPORT_SUPDUP = 95, /* SUPDUP protocol. */
118
119
120 IPPORT_EXECSERVER = 512, /* execd service. */
121 IPPORT_LOGINSERVER = 513, /* rlogind service. */
122 IPPORT_CMDSERVER = 514,
123 IPPORT_EFSSERVER = 520,
124
125 /* UDP ports. */
126 IPPORT_BIFFUDP = 512,
127 IPPORT_WHOSERVER = 513,
128 IPPORT_ROUTESERVER = 520,
129
130 /* Ports less than this value are reserved for privileged processes. */
131 IPPORT_RESERVED = 1024,
132
133 /* Ports greater this value are reserved for (non-privileged) servers. */
134 IPPORT_USERRESERVED = 5000
135 };
136
137
138/* Internet address. */
139typedef uint32_t in_addr_t;
140struct in_addr
141 {
142 in_addr_t s_addr;
143 };
144
145
146/* Definitions of the bits in an Internet address integer.
147
148 On subnets, host and network parts are found according to
149 the subnet mask, not these masks. */
150
151#define IN_CLASSA(a) ((((in_addr_t)(a)) & 0x80000000) == 0)
152#define IN_CLASSA_NET 0xff000000
153#define IN_CLASSA_NSHIFT 24
154#define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET)
155#define IN_CLASSA_MAX 128
156
157#define IN_CLASSB(a) ((((in_addr_t)(a)) & 0xc0000000) == 0x80000000)
158#define IN_CLASSB_NET 0xffff0000
159#define IN_CLASSB_NSHIFT 16
160#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET)
161#define IN_CLASSB_MAX 65536
162
163#define IN_CLASSC(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xc0000000)
164#define IN_CLASSC_NET 0xffffff00
165#define IN_CLASSC_NSHIFT 8
166#define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET)
167
168#define IN_CLASSD(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xe0000000)
169#define IN_MULTICAST(a) IN_CLASSD(a)
170
171#define IN_EXPERIMENTAL(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xe0000000)
172#define IN_BADCLASS(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000)
173
174/* Address to accept any incoming messages. */
175#define INADDR_ANY ((in_addr_t) 0x00000000)
176/* Address to send to all hosts. */
177#define INADDR_BROADCAST ((in_addr_t) 0xffffffff)
178/* Address indicating an error return. */
179#define INADDR_NONE ((in_addr_t) 0xffffffff)
180
181/* Network number for local host loopback. */
182#define IN_LOOPBACKNET 127
183/* Address to loopback in software to local host. */
184#ifndef INADDR_LOOPBACK
185# define INADDR_LOOPBACK ((in_addr_t) 0x7f000001) /* Inet 127.0.0.1. */
186#endif
187
188/* Defines for Multicast INADDR. */
189#define INADDR_UNSPEC_GROUP ((in_addr_t) 0xe0000000) /* 224.0.0.0 */
190#define INADDR_ALLHOSTS_GROUP ((in_addr_t) 0xe0000001) /* 224.0.0.1 */
191#define INADDR_ALLRTRS_GROUP ((in_addr_t) 0xe0000002) /* 224.0.0.2 */
192#define INADDR_MAX_LOCAL_GROUP ((in_addr_t) 0xe00000ff) /* 224.0.0.255 */
193
194
195/* IPv6 address */
196struct in6_addr
197 {
198 union
199 {
200 uint8_t __u6_addr8[16];
201#if defined __USE_MISC || defined __USE_GNU
202 uint16_t __u6_addr16[8];
203 uint32_t __u6_addr32[4];
204#endif
205 } __in6_u;
206#define s6_addr __in6_u.__u6_addr8
207#if defined __USE_MISC || defined __USE_GNU
208# define s6_addr16 __in6_u.__u6_addr16
209# define s6_addr32 __in6_u.__u6_addr32
210#endif
211 };
212
213extern const struct in6_addr in6addr_any; /* :: */
214extern const struct in6_addr in6addr_loopback; /* ::1 */
215#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
216#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
217
218#define INET_ADDRSTRLEN 16
219#define INET6_ADDRSTRLEN 46
220
221
222/* Structure describing an Internet socket address. */
223struct sockaddr_in
224 {
225 __SOCKADDR_COMMON (sin_);
226 in_port_t sin_port; /* Port number. */
227 struct in_addr sin_addr; /* Internet address. */
228
229 /* Pad to size of `struct sockaddr'. */
230 unsigned char sin_zero[sizeof (struct sockaddr) -
231 __SOCKADDR_COMMON_SIZE -
232 sizeof (in_port_t) -
233 sizeof (struct in_addr)];
234 };
235
236/* Ditto, for IPv6. */
237struct sockaddr_in6
238 {
239 __SOCKADDR_COMMON (sin6_);
240 in_port_t sin6_port; /* Transport layer port # */
241 uint32_t sin6_flowinfo; /* IPv6 flow information */
242 struct in6_addr sin6_addr; /* IPv6 address */
243 uint32_t sin6_scope_id; /* IPv6 scope-id */
244 };
245
246
247#if defined __USE_MISC || defined __USE_GNU
248/* IPv4 multicast request. */
249struct ip_mreq
250 {
251 /* IP multicast address of group. */
252 struct in_addr imr_multiaddr;
253
254 /* Local IP address of interface. */
255 struct in_addr imr_interface;
256 };
257
258struct ip_mreq_source
259 {
260 /* IP multicast address of group. */
261 struct in_addr imr_multiaddr;
262
263 /* IP address of source. */
264 struct in_addr imr_interface;
265
266 /* IP address of interface. */
267 struct in_addr imr_sourceaddr;
268 };
269#endif
270
271
272/* Likewise, for IPv6. */
273struct ipv6_mreq
274 {
275 /* IPv6 multicast address of group */
276 struct in6_addr ipv6mr_multiaddr;
277
278 /* local interface */
279 unsigned int ipv6mr_interface;
280 };
281
282
283#if defined __USE_MISC || defined __USE_GNU
284/* Multicast group request. */
285struct group_req
286 {
287 /* Interface index. */
288 uint32_t gr_interface;
289
290 /* Group address. */
291 struct sockaddr_storage gr_group;
292 };
293
294struct group_source_req
295 {
296 /* Interface index. */
297 uint32_t gsr_interface;
298
299 /* Group address. */
300 struct sockaddr_storage gsr_group;
301
302 /* Source address. */
303 struct sockaddr_storage gsr_source;
304 };
305
306
307/* Full-state filter operations. */
308struct ip_msfilter
309 {
310 /* IP multicast address of group. */
311 struct in_addr imsf_multiaddr;
312
313 /* Local IP address of interface. */
314 struct in_addr imsf_interface;
315
316 /* Filter mode. */
317 uint32_t imsf_fmode;
318
319 /* Number of source addresses. */
320 uint32_t imsf_numsrc;
321 /* Source addresses. */
322 struct in_addr imsf_slist[1];
323 };
324
325#define IP_MSFILTER_SIZE(numsrc) (sizeof (struct ip_msfilter) \
326 - sizeof (struct in_addr) \
327 + (numsrc) * sizeof (struct in_addr))
328
329struct group_filter
330 {
331 /* Interface index. */
332 uint32_t gf_interface;
333
334 /* Group address. */
335 struct sockaddr_storage gf_group;
336
337 /* Filter mode. */
338 uint32_t gf_fmode;
339
340 /* Number of source addresses. */
341 uint32_t gf_numsrc;
342 /* Source addresses. */
343 struct sockaddr_storage gf_slist[1];
344};
345
346#define GROUP_FILTER_SIZE(numsrc) (sizeof (struct group_filter) \
347 - sizeof (struct sockaddr_storage) \
348 + ((numsrc) \
349 * sizeof (struct sockaddr_storage)))
350#endif
351
352
353/* Get system-specific definitions. */
354#include <bits/in.h>
355
356/* Functions to convert between host and network byte order.
357
358 Please note that these functions normally take `unsigned long int' or
359 `unsigned short int' values as arguments and also return them. But
360 this was a short-sighted decision since on different systems the types
361 may have different representations but the values are always the same. */
362
363extern uint32_t ntohl (uint32_t __netlong) __THROW __attribute__ ((__const__));
364extern uint16_t ntohs (uint16_t __netshort)
365 __THROW __attribute__ ((__const__));
366extern uint32_t htonl (uint32_t __hostlong)
367 __THROW __attribute__ ((__const__));
368extern uint16_t htons (uint16_t __hostshort)
369 __THROW __attribute__ ((__const__));
370
371#include <endian.h>
372
373/* Get machine dependent optimized versions of byte swapping functions. */
374#include <bits/byteswap.h>
375
376#ifdef __OPTIMIZE__
377/* We can optimize calls to the conversion functions. Either nothing has
378 to be done or we are using directly the byte-swapping functions which
379 often can be inlined. */
380# if __BYTE_ORDER == __BIG_ENDIAN
381/* The host byte order is the same as network byte order,
382 so these functions are all just identity. */
383# define ntohl(x) (x)
384# define ntohs(x) (x)
385# define htonl(x) (x)
386# define htons(x) (x)
387# else
388# if __BYTE_ORDER == __LITTLE_ENDIAN
389# define ntohl(x) __bswap_32 (x)
390# define ntohs(x) __bswap_16 (x)
391# define htonl(x) __bswap_32 (x)
392# define htons(x) __bswap_16 (x)
393# endif
394# endif
395#endif
396
397#ifdef __GNUC__
398# define IN6_IS_ADDR_UNSPECIFIED(a) \
399 (__extension__ \
400 ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \
401 __a->s6_addr32[0] == 0 \
402 && __a->s6_addr32[1] == 0 \
403 && __a->s6_addr32[2] == 0 \
404 && __a->s6_addr32[3] == 0; }))
405
406# define IN6_IS_ADDR_LOOPBACK(a) \
407 (__extension__ \
408 ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \
409 __a->s6_addr32[0] == 0 \
410 && __a->s6_addr32[1] == 0 \
411 && __a->s6_addr32[2] == 0 \
412 && __a->s6_addr32[3] == htonl (1); }))
413
414# define IN6_IS_ADDR_LINKLOCAL(a) \
415 (__extension__ \
416 ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \
417 (__a->s6_addr32[0] & htonl (0xffc00000)) == htonl (0xfe800000); }))
418
419# define IN6_IS_ADDR_SITELOCAL(a) \
420 (__extension__ \
421 ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \
422 (__a->s6_addr32[0] & htonl (0xffc00000)) == htonl (0xfec00000); }))
423
424# define IN6_IS_ADDR_V4MAPPED(a) \
425 (__extension__ \
426 ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \
427 __a->s6_addr32[0] == 0 \
428 && __a->s6_addr32[1] == 0 \
429 && __a->s6_addr32[2] == htonl (0xffff); }))
430
431# define IN6_IS_ADDR_V4COMPAT(a) \
432 (__extension__ \
433 ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \
434 __a->s6_addr32[0] == 0 \
435 && __a->s6_addr32[1] == 0 \
436 && __a->s6_addr32[2] == 0 \
437 && ntohl (__a->s6_addr32[3]) > 1; }))
438
439# define IN6_ARE_ADDR_EQUAL(a,b) \
440 (__extension__ \
441 ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \
442 const struct in6_addr *__b = (const struct in6_addr *) (b); \
443 __a->s6_addr32[0] == __b->s6_addr32[0] \
444 && __a->s6_addr32[1] == __b->s6_addr32[1] \
445 && __a->s6_addr32[2] == __b->s6_addr32[2] \
446 && __a->s6_addr32[3] == __b->s6_addr32[3]; }))
447#else
448# define IN6_IS_ADDR_UNSPECIFIED(a) \
449 (((const uint32_t *) (a))[0] == 0 \
450 && ((const uint32_t *) (a))[1] == 0 \
451 && ((const uint32_t *) (a))[2] == 0 \
452 && ((const uint32_t *) (a))[3] == 0)
453
454# define IN6_IS_ADDR_LOOPBACK(a) \
455 (((const uint32_t *) (a))[0] == 0 \
456 && ((const uint32_t *) (a))[1] == 0 \
457 && ((const uint32_t *) (a))[2] == 0 \
458 && ((const uint32_t *) (a))[3] == htonl (1))
459
460# define IN6_IS_ADDR_LINKLOCAL(a) \
461 ((((const uint32_t *) (a))[0] & htonl (0xffc00000)) \
462 == htonl (0xfe800000))
463
464# define IN6_IS_ADDR_SITELOCAL(a) \
465 ((((const uint32_t *) (a))[0] & htonl (0xffc00000)) \
466 == htonl (0xfec00000))
467
468# define IN6_IS_ADDR_V4MAPPED(a) \
469 ((((const uint32_t *) (a))[0] == 0) \
470 && (((const uint32_t *) (a))[1] == 0) \
471 && (((const uint32_t *) (a))[2] == htonl (0xffff)))
472
473# define IN6_IS_ADDR_V4COMPAT(a) \
474 ((((const uint32_t *) (a))[0] == 0) \
475 && (((const uint32_t *) (a))[1] == 0) \
476 && (((const uint32_t *) (a))[2] == 0) \
477 && (ntohl (((const uint32_t *) (a))[3]) > 1))
478
479# define IN6_ARE_ADDR_EQUAL(a,b) \
480 ((((const uint32_t *) (a))[0] == ((const uint32_t *) (b))[0]) \
481 && (((const uint32_t *) (a))[1] == ((const uint32_t *) (b))[1]) \
482 && (((const uint32_t *) (a))[2] == ((const uint32_t *) (b))[2]) \
483 && (((const uint32_t *) (a))[3] == ((const uint32_t *) (b))[3]))
484#endif
485
486#define IN6_IS_ADDR_MULTICAST(a) (((const uint8_t *) (a))[0] == 0xff)
487
488#if defined __USE_MISC || defined __USE_GNU
489/* Bind socket to a privileged IP port. */
490extern int bindresvport (int __sockfd, struct sockaddr_in *__sock_in) __THROW;
491
492/* The IPv6 version of this function. */
493extern int bindresvport6 (int __sockfd, struct sockaddr_in6 *__sock_in)
494 __THROW;
495#endif
496
497
498#define IN6_IS_ADDR_MC_NODELOCAL(a) \
499 (IN6_IS_ADDR_MULTICAST(a) \
500 && ((((const uint8_t *) (a))[1] & 0xf) == 0x1))
501
502#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
503 (IN6_IS_ADDR_MULTICAST(a) \
504 && ((((const uint8_t *) (a))[1] & 0xf) == 0x2))
505
506#define IN6_IS_ADDR_MC_SITELOCAL(a) \
507 (IN6_IS_ADDR_MULTICAST(a) \
508 && ((((const uint8_t *) (a))[1] & 0xf) == 0x5))
509
510#define IN6_IS_ADDR_MC_ORGLOCAL(a) \
511 (IN6_IS_ADDR_MULTICAST(a) \
512 && ((((const uint8_t *) (a))[1] & 0xf) == 0x8))
513
514#define IN6_IS_ADDR_MC_GLOBAL(a) \
515 (IN6_IS_ADDR_MULTICAST(a) \
516 && ((((const uint8_t *) (a))[1] & 0xf) == 0xe))
517
518
519#ifdef __USE_GNU
520struct cmsghdr; /* Forward declaration. */
521
522/* IPv6 packet information. */
523struct in6_pktinfo
524 {
525 struct in6_addr ipi6_addr; /* src/dst IPv6 address */
526 unsigned int ipi6_ifindex; /* send/recv interface index */
527 };
528
529/* IPv6 MTU information. */
530struct ip6_mtuinfo
531 {
532 struct sockaddr_in6 ip6m_addr; /* dst address including zone ID */
533 uint32_t ip6m_mtu; /* path MTU in host byte order */
534 };
535
536
537/* Obsolete hop-by-hop and Destination Options Processing (RFC 2292). */
538extern int inet6_option_space (int __nbytes)
539 __THROW __attribute_deprecated__;
540extern int inet6_option_init (void *__bp, struct cmsghdr **__cmsgp,
541 int __type) __THROW __attribute_deprecated__;
542extern int inet6_option_append (struct cmsghdr *__cmsg,
543 const uint8_t *__typep, int __multx,
544 int __plusy) __THROW __attribute_deprecated__;
545extern uint8_t *inet6_option_alloc (struct cmsghdr *__cmsg, int __datalen,
546 int __multx, int __plusy)
547 __THROW __attribute_deprecated__;
548extern int inet6_option_next (const struct cmsghdr *__cmsg,
549 uint8_t **__tptrp)
550 __THROW __attribute_deprecated__;
551extern int inet6_option_find (const struct cmsghdr *__cmsg,
552 uint8_t **__tptrp, int __type)
553 __THROW __attribute_deprecated__;
554
555
556/* Hop-by-Hop and Destination Options Processing (RFC 3542). */
557extern int inet6_opt_init (void *__extbuf, socklen_t __extlen) __THROW;
558extern int inet6_opt_append (void *__extbuf, socklen_t __extlen, int __offset,
559 uint8_t __type, socklen_t __len, uint8_t __align,
560 void **__databufp) __THROW;
561extern int inet6_opt_finish (void *__extbuf, socklen_t __extlen, int __offset)
562 __THROW;
563extern int inet6_opt_set_val (void *__databuf, int __offset, void *__val,
564 socklen_t __vallen) __THROW;
565extern int inet6_opt_next (void *__extbuf, socklen_t __extlen, int __offset,
566 uint8_t *__typep, socklen_t *__lenp,
567 void **__databufp) __THROW;
568extern int inet6_opt_find (void *__extbuf, socklen_t __extlen, int __offset,
569 uint8_t __type, socklen_t *__lenp,
570 void **__databufp) __THROW;
571extern int inet6_opt_get_val (void *__databuf, int __offset, void *__val,
572 socklen_t __vallen) __THROW;
573
574
575/* Routing Header Option (RFC 3542). */
576extern socklen_t inet6_rth_space (int __type, int __segments) __THROW;
577extern void *inet6_rth_init (void *__bp, socklen_t __bp_len, int __type,
578 int __segments) __THROW;
579extern int inet6_rth_add (void *__bp, const struct in6_addr *__addr) __THROW;
580extern int inet6_rth_reverse (const void *__in, void *__out) __THROW;
581extern int inet6_rth_segments (const void *__bp) __THROW;
582extern struct in6_addr *inet6_rth_getaddr (const void *__bp, int __index)
583 __THROW;
584
585
586/* Multicast source filter support. */
587
588/* Get IPv4 source filter. */
589extern int getipv4sourcefilter (int __s, struct in_addr __interface_addr,
590 struct in_addr __group, uint32_t *__fmode,
591 uint32_t *__numsrc, struct in_addr *__slist)
592 __THROW;
593
594/* Set IPv4 source filter. */
595extern int setipv4sourcefilter (int __s, struct in_addr __interface_addr,
596 struct in_addr __group, uint32_t __fmode,
597 uint32_t __numsrc,
598 const struct in_addr *__slist)
599 __THROW;
600
601
602/* Get source filter. */
603extern int getsourcefilter (int __s, uint32_t __interface_addr,
604 const struct sockaddr *__group,
605 socklen_t __grouplen, uint32_t *__fmode,
606 uint32_t *__numsrc,
607 struct sockaddr_storage *__slist) __THROW;
608
609/* Set source filter. */
610extern int setsourcefilter (int __s, uint32_t __interface_addr,
611 const struct sockaddr *__group,
612 socklen_t __grouplen, uint32_t __fmode,
613 uint32_t __numsrc,
614 const struct sockaddr_storage *__slist) __THROW;
615#endif /* use GNU */
616
617__END_DECLS
618
619#endif /* netinet/in.h */
620