modernc.org/cc@v1.0.1/v2/headers/linux_arm/usr/include/netinet/in.h (about)

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