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