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