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

     1  /* Copyright (C) 1991-2018 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 <bits/stdint-uintn.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  		uint16_t __u6_addr16[8];
   208  		uint32_t __u6_addr32[4];
   209  	} __in6_u;
   210  #define s6_addr			__in6_u.__u6_addr8
   211  #ifdef __USE_MISC
   212  # define s6_addr16		__in6_u.__u6_addr16
   213  # define s6_addr32		__in6_u.__u6_addr32
   214  #endif
   215  };
   216  #endif				/* !__USE_KERNEL_IPV6_DEFS */
   217  
   218  extern const struct in6_addr in6addr_any;	/* :: */
   219  extern const struct in6_addr in6addr_loopback;	/* ::1 */
   220  #define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
   221  #define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
   222  
   223  #define INET_ADDRSTRLEN 16
   224  #define INET6_ADDRSTRLEN 46
   225  
   226  /* Structure describing an Internet socket address.  */
   227  struct sockaddr_in {
   228  	__SOCKADDR_COMMON(sin_);
   229  	in_port_t sin_port;	/* Port number.  */
   230  	struct in_addr sin_addr;	/* Internet address.  */
   231  
   232  	/* Pad to size of `struct sockaddr'.  */
   233  	unsigned char sin_zero[sizeof(struct sockaddr) - __SOCKADDR_COMMON_SIZE - sizeof(in_port_t) - sizeof(struct in_addr)];
   234  };
   235  
   236  #if !__USE_KERNEL_IPV6_DEFS
   237  /* Ditto, for IPv6.  */
   238  struct sockaddr_in6 {
   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  #endif				/* !__USE_KERNEL_IPV6_DEFS */
   246  
   247  #ifdef __USE_MISC
   248  /* IPv4 multicast request.  */
   249  struct ip_mreq {
   250  	/* IP multicast address of group.  */
   251  	struct in_addr imr_multiaddr;
   252  
   253  	/* Local IP address of interface.  */
   254  	struct in_addr imr_interface;
   255  };
   256  
   257  struct ip_mreq_source {
   258  	/* IP multicast address of group.  */
   259  	struct in_addr imr_multiaddr;
   260  
   261  	/* IP address of interface.  */
   262  	struct in_addr imr_interface;
   263  
   264  	/* IP address of source.  */
   265  	struct in_addr imr_sourceaddr;
   266  };
   267  #endif
   268  
   269  #if !__USE_KERNEL_IPV6_DEFS
   270  /* Likewise, for IPv6.  */
   271  struct ipv6_mreq {
   272  	/* IPv6 multicast address of group */
   273  	struct in6_addr ipv6mr_multiaddr;
   274  
   275  	/* local interface */
   276  	unsigned int ipv6mr_interface;
   277  };
   278  #endif				/* !__USE_KERNEL_IPV6_DEFS */
   279  
   280  #ifdef __USE_MISC
   281  /* Multicast group request.  */
   282  struct group_req {
   283  	/* Interface index.  */
   284  	uint32_t gr_interface;
   285  
   286  	/* Group address.  */
   287  	struct sockaddr_storage gr_group;
   288  };
   289  
   290  struct group_source_req {
   291  	/* Interface index.  */
   292  	uint32_t gsr_interface;
   293  
   294  	/* Group address.  */
   295  	struct sockaddr_storage gsr_group;
   296  
   297  	/* Source address.  */
   298  	struct sockaddr_storage gsr_source;
   299  };
   300  
   301  /* Full-state filter operations.  */
   302  struct ip_msfilter {
   303  	/* IP multicast address of group.  */
   304  	struct in_addr imsf_multiaddr;
   305  
   306  	/* Local IP address of interface.  */
   307  	struct in_addr imsf_interface;
   308  
   309  	/* Filter mode.  */
   310  	uint32_t imsf_fmode;
   311  
   312  	/* Number of source addresses.  */
   313  	uint32_t imsf_numsrc;
   314  	/* Source addresses.  */
   315  	struct in_addr imsf_slist[1];
   316  };
   317  
   318  #define IP_MSFILTER_SIZE(numsrc) (sizeof (struct ip_msfilter) \
   319  				  - sizeof (struct in_addr)		      \
   320  				  + (numsrc) * sizeof (struct in_addr))
   321  
   322  struct group_filter {
   323  	/* Interface index.  */
   324  	uint32_t gf_interface;
   325  
   326  	/* Group address.  */
   327  	struct sockaddr_storage gf_group;
   328  
   329  	/* Filter mode.  */
   330  	uint32_t gf_fmode;
   331  
   332  	/* Number of source addresses.  */
   333  	uint32_t gf_numsrc;
   334  	/* Source addresses.  */
   335  	struct sockaddr_storage gf_slist[1];
   336  };
   337  
   338  #define GROUP_FILTER_SIZE(numsrc) (sizeof (struct group_filter) \
   339  				   - sizeof (struct sockaddr_storage)	      \
   340  				   + ((numsrc)				      \
   341  				      * sizeof (struct sockaddr_storage)))
   342  #endif
   343  
   344  /* Functions to convert between host and network byte order.
   345  
   346     Please note that these functions normally take `unsigned long int' or
   347     `unsigned short int' values as arguments and also return them.  But
   348     this was a short-sighted decision since on different systems the types
   349     may have different representations but the values are always the same.  */
   350  
   351  extern uint32_t ntohl(uint32_t __netlong)
   352  __THROW __attribute__ ((__const__));
   353  extern uint16_t ntohs(uint16_t __netshort)
   354  __THROW __attribute__ ((__const__));
   355  extern uint32_t htonl(uint32_t __hostlong)
   356  __THROW __attribute__ ((__const__));
   357  extern uint16_t htons(uint16_t __hostshort)
   358  __THROW __attribute__ ((__const__));
   359  
   360  #include <endian.h>
   361  
   362  /* Get machine dependent optimized versions of byte swapping functions.  */
   363  #include <bits/byteswap.h>
   364  #include <bits/uintn-identity.h>
   365  
   366  #ifdef __OPTIMIZE__
   367  /* We can optimize calls to the conversion functions.  Either nothing has
   368     to be done or we are using directly the byte-swapping functions which
   369     often can be inlined.  */
   370  # if __BYTE_ORDER == __BIG_ENDIAN
   371  /* The host byte order is the same as network byte order,
   372     so these functions are all just identity.  */
   373  # define ntohl(x)	__uint32_identity (x)
   374  # define ntohs(x)	__uint16_identity (x)
   375  # define htonl(x)	__uint32_identity (x)
   376  # define htons(x)	__uint16_identity (x)
   377  # else
   378  #  if __BYTE_ORDER == __LITTLE_ENDIAN
   379  #   define ntohl(x)	__bswap_32 (x)
   380  #   define ntohs(x)	__bswap_16 (x)
   381  #   define htonl(x)	__bswap_32 (x)
   382  #   define htons(x)	__bswap_16 (x)
   383  #  endif
   384  # endif
   385  #endif
   386  
   387  #ifdef __GNUC__
   388  # define IN6_IS_ADDR_UNSPECIFIED(a) \
   389    (__extension__							      \
   390     ({ const struct in6_addr *__a = (const struct in6_addr *) (a);	      \
   391        __a->__in6_u.__u6_addr32[0] == 0					      \
   392        && __a->__in6_u.__u6_addr32[1] == 0				      \
   393        && __a->__in6_u.__u6_addr32[2] == 0				      \
   394        && __a->__in6_u.__u6_addr32[3] == 0; }))
   395  
   396  # define IN6_IS_ADDR_LOOPBACK(a) \
   397    (__extension__							      \
   398     ({ const struct in6_addr *__a = (const struct in6_addr *) (a);	      \
   399        __a->__in6_u.__u6_addr32[0] == 0					      \
   400        && __a->__in6_u.__u6_addr32[1] == 0				      \
   401        && __a->__in6_u.__u6_addr32[2] == 0				      \
   402        && __a->__in6_u.__u6_addr32[3] == htonl (1); }))
   403  
   404  # define IN6_IS_ADDR_LINKLOCAL(a) \
   405    (__extension__							      \
   406     ({ const struct in6_addr *__a = (const struct in6_addr *) (a);	      \
   407        (__a->__in6_u.__u6_addr32[0] & htonl (0xffc00000)) == htonl (0xfe800000); }))
   408  
   409  # define IN6_IS_ADDR_SITELOCAL(a) \
   410    (__extension__							      \
   411     ({ const struct in6_addr *__a = (const struct in6_addr *) (a);	      \
   412        (__a->__in6_u.__u6_addr32[0] & htonl (0xffc00000)) == htonl (0xfec00000); }))
   413  
   414  # define IN6_IS_ADDR_V4MAPPED(a) \
   415    (__extension__							      \
   416     ({ const struct in6_addr *__a = (const struct in6_addr *) (a);	      \
   417        __a->__in6_u.__u6_addr32[0] == 0					      \
   418        && __a->__in6_u.__u6_addr32[1] == 0				      \
   419        && __a->__in6_u.__u6_addr32[2] == htonl (0xffff); }))
   420  
   421  # define IN6_IS_ADDR_V4COMPAT(a) \
   422    (__extension__							      \
   423     ({ const struct in6_addr *__a = (const struct in6_addr *) (a);	      \
   424        __a->__in6_u.__u6_addr32[0] == 0					      \
   425        && __a->__in6_u.__u6_addr32[1] == 0				      \
   426        && __a->__in6_u.__u6_addr32[2] == 0				      \
   427        && ntohl (__a->__in6_u.__u6_addr32[3]) > 1; }))
   428  
   429  # define IN6_ARE_ADDR_EQUAL(a,b) \
   430    (__extension__							      \
   431     ({ const struct in6_addr *__a = (const struct in6_addr *) (a);	      \
   432        const struct in6_addr *__b = (const struct in6_addr *) (b);	      \
   433        __a->__in6_u.__u6_addr32[0] == __b->__in6_u.__u6_addr32[0]	      \
   434        && __a->__in6_u.__u6_addr32[1] == __b->__in6_u.__u6_addr32[1]	      \
   435        && __a->__in6_u.__u6_addr32[2] == __b->__in6_u.__u6_addr32[2]	      \
   436        && __a->__in6_u.__u6_addr32[3] == __b->__in6_u.__u6_addr32[3]; }))
   437  #else
   438  # define IN6_IS_ADDR_UNSPECIFIED(a) \
   439  	(((const uint32_t *) (a))[0] == 0				      \
   440  	 && ((const uint32_t *) (a))[1] == 0				      \
   441  	 && ((const uint32_t *) (a))[2] == 0				      \
   442  	 && ((const uint32_t *) (a))[3] == 0)
   443  
   444  # define IN6_IS_ADDR_LOOPBACK(a) \
   445  	(((const uint32_t *) (a))[0] == 0				      \
   446  	 && ((const uint32_t *) (a))[1] == 0				      \
   447  	 && ((const uint32_t *) (a))[2] == 0				      \
   448  	 && ((const uint32_t *) (a))[3] == htonl (1))
   449  
   450  # define IN6_IS_ADDR_LINKLOCAL(a) \
   451  	((((const uint32_t *) (a))[0] & htonl (0xffc00000))		      \
   452  	 == htonl (0xfe800000))
   453  
   454  # define IN6_IS_ADDR_SITELOCAL(a) \
   455  	((((const uint32_t *) (a))[0] & htonl (0xffc00000))		      \
   456  	 == htonl (0xfec00000))
   457  
   458  # define IN6_IS_ADDR_V4MAPPED(a) \
   459  	((((const uint32_t *) (a))[0] == 0)				      \
   460  	 && (((const uint32_t *) (a))[1] == 0)				      \
   461  	 && (((const uint32_t *) (a))[2] == htonl (0xffff)))
   462  
   463  # define IN6_IS_ADDR_V4COMPAT(a) \
   464  	((((const uint32_t *) (a))[0] == 0)				      \
   465  	 && (((const uint32_t *) (a))[1] == 0)				      \
   466  	 && (((const uint32_t *) (a))[2] == 0)				      \
   467  	 && (ntohl (((const uint32_t *) (a))[3]) > 1))
   468  
   469  # define IN6_ARE_ADDR_EQUAL(a,b) \
   470  	((((const uint32_t *) (a))[0] == ((const uint32_t *) (b))[0])	      \
   471  	 && (((const uint32_t *) (a))[1] == ((const uint32_t *) (b))[1])      \
   472  	 && (((const uint32_t *) (a))[2] == ((const uint32_t *) (b))[2])      \
   473  	 && (((const uint32_t *) (a))[3] == ((const uint32_t *) (b))[3]))
   474  #endif
   475  
   476  #define IN6_IS_ADDR_MULTICAST(a) (((const uint8_t *) (a))[0] == 0xff)
   477  
   478  #ifdef __USE_MISC
   479  /* Bind socket to a privileged IP port.  */
   480  extern int bindresvport(int __sockfd, struct sockaddr_in *__sock_in) __THROW;
   481  
   482  /* The IPv6 version of this function.  */
   483  extern int bindresvport6(int __sockfd, struct sockaddr_in6 *__sock_in) __THROW;
   484  #endif
   485  
   486  #define IN6_IS_ADDR_MC_NODELOCAL(a) \
   487  	(IN6_IS_ADDR_MULTICAST(a)					      \
   488  	 && ((((const uint8_t *) (a))[1] & 0xf) == 0x1))
   489  
   490  #define IN6_IS_ADDR_MC_LINKLOCAL(a) \
   491  	(IN6_IS_ADDR_MULTICAST(a)					      \
   492  	 && ((((const uint8_t *) (a))[1] & 0xf) == 0x2))
   493  
   494  #define IN6_IS_ADDR_MC_SITELOCAL(a) \
   495  	(IN6_IS_ADDR_MULTICAST(a)					      \
   496  	 && ((((const uint8_t *) (a))[1] & 0xf) == 0x5))
   497  
   498  #define IN6_IS_ADDR_MC_ORGLOCAL(a) \
   499  	(IN6_IS_ADDR_MULTICAST(a)					      \
   500  	 && ((((const uint8_t *) (a))[1] & 0xf) == 0x8))
   501  
   502  #define IN6_IS_ADDR_MC_GLOBAL(a) \
   503  	(IN6_IS_ADDR_MULTICAST(a)					      \
   504  	 && ((((const uint8_t *) (a))[1] & 0xf) == 0xe))
   505  
   506  #ifdef __USE_GNU
   507  struct cmsghdr;			/* Forward declaration.  */
   508  
   509  #if !__USE_KERNEL_IPV6_DEFS
   510  /* IPv6 packet information.  */
   511  struct in6_pktinfo {
   512  	struct in6_addr ipi6_addr;	/* src/dst IPv6 address */
   513  	unsigned int ipi6_ifindex;	/* send/recv interface index */
   514  };
   515  
   516  /* IPv6 MTU information.  */
   517  struct ip6_mtuinfo {
   518  	struct sockaddr_in6 ip6m_addr;	/* dst address including zone ID */
   519  	uint32_t ip6m_mtu;	/* path MTU in host byte order */
   520  };
   521  #endif				/* !__USE_KERNEL_IPV6_DEFS */
   522  
   523  /* Obsolete hop-by-hop and Destination Options Processing (RFC 2292).  */
   524  extern int inet6_option_space(int __nbytes)
   525  __THROW __attribute_deprecated__;
   526  extern int inet6_option_init(void *__bp, struct cmsghdr **__cmsgp, int __type)
   527  __THROW __attribute_deprecated__;
   528  extern int inet6_option_append(struct cmsghdr *__cmsg, const uint8_t * __typep, int __multx, int __plusy)
   529  __THROW __attribute_deprecated__;
   530  extern uint8_t *inet6_option_alloc(struct cmsghdr *__cmsg, int __datalen, int __multx, int __plusy)
   531  __THROW __attribute_deprecated__;
   532  extern int inet6_option_next(const struct cmsghdr *__cmsg, uint8_t ** __tptrp)
   533  __THROW __attribute_deprecated__;
   534  extern int inet6_option_find(const struct cmsghdr *__cmsg, uint8_t ** __tptrp, int __type)
   535  __THROW __attribute_deprecated__;
   536  
   537  /* Hop-by-Hop and Destination Options Processing (RFC 3542).  */
   538  extern int inet6_opt_init(void *__extbuf, socklen_t __extlen) __THROW;
   539  extern int inet6_opt_append(void *__extbuf, socklen_t __extlen, int __offset, uint8_t __type, socklen_t __len, uint8_t __align, void **__databufp) __THROW;
   540  extern int inet6_opt_finish(void *__extbuf, socklen_t __extlen, int __offset) __THROW;
   541  extern int inet6_opt_set_val(void *__databuf, int __offset, void *__val, socklen_t __vallen) __THROW;
   542  extern int inet6_opt_next(void *__extbuf, socklen_t __extlen, int __offset, uint8_t * __typep, socklen_t * __lenp, void **__databufp) __THROW;
   543  extern int inet6_opt_find(void *__extbuf, socklen_t __extlen, int __offset, uint8_t __type, socklen_t * __lenp, void **__databufp) __THROW;
   544  extern int inet6_opt_get_val(void *__databuf, int __offset, void *__val, socklen_t __vallen) __THROW;
   545  
   546  /* Routing Header Option (RFC 3542).  */
   547  extern socklen_t inet6_rth_space(int __type, int __segments) __THROW;
   548  extern void *inet6_rth_init(void *__bp, socklen_t __bp_len, int __type, int __segments) __THROW;
   549  extern int inet6_rth_add(void *__bp, const struct in6_addr *__addr) __THROW;
   550  extern int inet6_rth_reverse(const void *__in, void *__out) __THROW;
   551  extern int inet6_rth_segments(const void *__bp) __THROW;
   552  extern struct in6_addr *inet6_rth_getaddr(const void *__bp, int __index) __THROW;
   553  
   554  /* Multicast source filter support.  */
   555  
   556  /* Get IPv4 source filter.  */
   557  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;
   558  
   559  /* Set IPv4 source filter.  */
   560  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;
   561  
   562  /* Get source filter.  */
   563  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;
   564  
   565  /* Set source filter.  */
   566  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;
   567  #endif				/* use GNU */
   568  
   569  __END_DECLS
   570  #endif				/* netinet/in.h */