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

     1  /* Copyright (C) 1991-2015 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_RAW = 255,	/* Raw IP packets.  */
    85  #define IPPROTO_RAW		IPPROTO_RAW
    86  	IPPROTO_MAX
    87  };
    88  
    89  /* If __USE_KERNEL_IPV6_DEFS is defined then the user has included the kernel
    90     network headers first and we should use those ABI-identical definitions
    91     instead of our own.  */
    92  #ifndef __USE_KERNEL_IPV6_DEFS
    93  enum {
    94  	IPPROTO_HOPOPTS = 0,	/* IPv6 Hop-by-Hop options.  */
    95  #define IPPROTO_HOPOPTS		IPPROTO_HOPOPTS
    96  	IPPROTO_ROUTING = 43,	/* IPv6 routing header.  */
    97  #define IPPROTO_ROUTING		IPPROTO_ROUTING
    98  	IPPROTO_FRAGMENT = 44,	/* IPv6 fragmentation header.  */
    99  #define IPPROTO_FRAGMENT	IPPROTO_FRAGMENT
   100  	IPPROTO_ICMPV6 = 58,	/* ICMPv6.  */
   101  #define IPPROTO_ICMPV6		IPPROTO_ICMPV6
   102  	IPPROTO_NONE = 59,	/* IPv6 no next header.  */
   103  #define IPPROTO_NONE		IPPROTO_NONE
   104  	IPPROTO_DSTOPTS = 60,	/* IPv6 destination options.  */
   105  #define IPPROTO_DSTOPTS		IPPROTO_DSTOPTS
   106  	IPPROTO_MH = 135	/* IPv6 mobility header.  */
   107  #define IPPROTO_MH		IPPROTO_MH
   108  };
   109  #endif				/* !__USE_KERNEL_IPV6_DEFS */
   110  
   111  /* Type to represent a port.  */
   112  typedef uint16_t in_port_t;
   113  
   114  /* Standard well-known ports.  */
   115  enum {
   116  	IPPORT_ECHO = 7,	/* Echo service.  */
   117  	IPPORT_DISCARD = 9,	/* Discard transmissions service.  */
   118  	IPPORT_SYSTAT = 11,	/* System status service.  */
   119  	IPPORT_DAYTIME = 13,	/* Time of day service.  */
   120  	IPPORT_NETSTAT = 15,	/* Network status service.  */
   121  	IPPORT_FTP = 21,	/* File Transfer Protocol.  */
   122  	IPPORT_TELNET = 23,	/* Telnet protocol.  */
   123  	IPPORT_SMTP = 25,	/* Simple Mail Transfer Protocol.  */
   124  	IPPORT_TIMESERVER = 37,	/* Timeserver service.  */
   125  	IPPORT_NAMESERVER = 42,	/* Domain Name Service.  */
   126  	IPPORT_WHOIS = 43,	/* Internet Whois service.  */
   127  	IPPORT_MTP = 57,
   128  
   129  	IPPORT_TFTP = 69,	/* Trivial File Transfer Protocol.  */
   130  	IPPORT_RJE = 77,
   131  	IPPORT_FINGER = 79,	/* Finger service.  */
   132  	IPPORT_TTYLINK = 87,
   133  	IPPORT_SUPDUP = 95,	/* SUPDUP protocol.  */
   134  
   135  	IPPORT_EXECSERVER = 512,	/* execd service.  */
   136  	IPPORT_LOGINSERVER = 513,	/* rlogind service.  */
   137  	IPPORT_CMDSERVER = 514,
   138  	IPPORT_EFSSERVER = 520,
   139  
   140  	/* UDP ports.  */
   141  	IPPORT_BIFFUDP = 512,
   142  	IPPORT_WHOSERVER = 513,
   143  	IPPORT_ROUTESERVER = 520,
   144  
   145  	/* Ports less than this value are reserved for privileged processes.  */
   146  	IPPORT_RESERVED = 1024,
   147  
   148  	/* Ports greater this value are reserved for (non-privileged) servers.  */
   149  	IPPORT_USERRESERVED = 5000
   150  };
   151  
   152  /* Definitions of the bits in an Internet address integer.
   153  
   154     On subnets, host and network parts are found according to
   155     the subnet mask, not these masks.  */
   156  
   157  #define	IN_CLASSA(a)		((((in_addr_t)(a)) & 0x80000000) == 0)
   158  #define	IN_CLASSA_NET		0xff000000
   159  #define	IN_CLASSA_NSHIFT	24
   160  #define	IN_CLASSA_HOST		(0xffffffff & ~IN_CLASSA_NET)
   161  #define	IN_CLASSA_MAX		128
   162  
   163  #define	IN_CLASSB(a)		((((in_addr_t)(a)) & 0xc0000000) == 0x80000000)
   164  #define	IN_CLASSB_NET		0xffff0000
   165  #define	IN_CLASSB_NSHIFT	16
   166  #define	IN_CLASSB_HOST		(0xffffffff & ~IN_CLASSB_NET)
   167  #define	IN_CLASSB_MAX		65536
   168  
   169  #define	IN_CLASSC(a)		((((in_addr_t)(a)) & 0xe0000000) == 0xc0000000)
   170  #define	IN_CLASSC_NET		0xffffff00
   171  #define	IN_CLASSC_NSHIFT	8
   172  #define	IN_CLASSC_HOST		(0xffffffff & ~IN_CLASSC_NET)
   173  
   174  #define	IN_CLASSD(a)		((((in_addr_t)(a)) & 0xf0000000) == 0xe0000000)
   175  #define	IN_MULTICAST(a)		IN_CLASSD(a)
   176  
   177  #define	IN_EXPERIMENTAL(a)	((((in_addr_t)(a)) & 0xe0000000) == 0xe0000000)
   178  #define	IN_BADCLASS(a)		((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000)
   179  
   180  /* Address to accept any incoming messages.  */
   181  #define	INADDR_ANY		((in_addr_t) 0x00000000)
   182  /* Address to send to all hosts.  */
   183  #define	INADDR_BROADCAST	((in_addr_t) 0xffffffff)
   184  /* Address indicating an error return.  */
   185  #define	INADDR_NONE		((in_addr_t) 0xffffffff)
   186  
   187  /* Network number for local host loopback.  */
   188  #define	IN_LOOPBACKNET		127
   189  /* Address to loopback in software to local host.  */
   190  #ifndef INADDR_LOOPBACK
   191  # define INADDR_LOOPBACK	((in_addr_t) 0x7f000001)	/* Inet 127.0.0.1.  */
   192  #endif
   193  
   194  /* Defines for Multicast INADDR.  */
   195  #define INADDR_UNSPEC_GROUP	((in_addr_t) 0xe0000000)	/* 224.0.0.0 */
   196  #define INADDR_ALLHOSTS_GROUP	((in_addr_t) 0xe0000001)	/* 224.0.0.1 */
   197  #define INADDR_ALLRTRS_GROUP    ((in_addr_t) 0xe0000002)	/* 224.0.0.2 */
   198  #define INADDR_MAX_LOCAL_GROUP  ((in_addr_t) 0xe00000ff)	/* 224.0.0.255 */
   199  
   200  #ifndef __USE_KERNEL_IPV6_DEFS
   201  /* IPv6 address */
   202  struct in6_addr {
   203  	union {
   204  		uint8_t __u6_addr8[16];
   205  #ifdef __USE_MISC
   206  		uint16_t __u6_addr16[8];
   207  		uint32_t __u6_addr32[4];
   208  #endif
   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  #ifndef __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 source.  */
   262  	struct in_addr imr_interface;
   263  
   264  	/* IP address of interface.  */
   265  	struct in_addr imr_sourceaddr;
   266  };
   267  #endif
   268  
   269  #ifndef __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  
   365  #ifdef __OPTIMIZE__
   366  /* We can optimize calls to the conversion functions.  Either nothing has
   367     to be done or we are using directly the byte-swapping functions which
   368     often can be inlined.  */
   369  # if __BYTE_ORDER == __BIG_ENDIAN
   370  /* The host byte order is the same as network byte order,
   371     so these functions are all just identity.  */
   372  # define ntohl(x)	(x)
   373  # define ntohs(x)	(x)
   374  # define htonl(x)	(x)
   375  # define htons(x)	(x)
   376  # else
   377  #  if __BYTE_ORDER == __LITTLE_ENDIAN
   378  #   define ntohl(x)	__bswap_32 (x)
   379  #   define ntohs(x)	__bswap_16 (x)
   380  #   define htonl(x)	__bswap_32 (x)
   381  #   define htons(x)	__bswap_16 (x)
   382  #  endif
   383  # endif
   384  #endif
   385  
   386  #ifdef __GNUC__
   387  # define IN6_IS_ADDR_UNSPECIFIED(a) \
   388    (__extension__							      \
   389     ({ const struct in6_addr *__a = (const struct in6_addr *) (a);	      \
   390        __a->s6_addr32[0] == 0						      \
   391        && __a->s6_addr32[1] == 0						      \
   392        && __a->s6_addr32[2] == 0						      \
   393        && __a->s6_addr32[3] == 0; }))
   394  
   395  # define IN6_IS_ADDR_LOOPBACK(a) \
   396    (__extension__							      \
   397     ({ const struct in6_addr *__a = (const struct in6_addr *) (a);	      \
   398        __a->s6_addr32[0] == 0						      \
   399        && __a->s6_addr32[1] == 0						      \
   400        && __a->s6_addr32[2] == 0						      \
   401        && __a->s6_addr32[3] == htonl (1); }))
   402  
   403  # define IN6_IS_ADDR_LINKLOCAL(a) \
   404    (__extension__							      \
   405     ({ const struct in6_addr *__a = (const struct in6_addr *) (a);	      \
   406        (__a->s6_addr32[0] & htonl (0xffc00000)) == htonl (0xfe800000); }))
   407  
   408  # define IN6_IS_ADDR_SITELOCAL(a) \
   409    (__extension__							      \
   410     ({ const struct in6_addr *__a = (const struct in6_addr *) (a);	      \
   411        (__a->s6_addr32[0] & htonl (0xffc00000)) == htonl (0xfec00000); }))
   412  
   413  # define IN6_IS_ADDR_V4MAPPED(a) \
   414    (__extension__							      \
   415     ({ const struct in6_addr *__a = (const struct in6_addr *) (a);	      \
   416        __a->s6_addr32[0] == 0						      \
   417        && __a->s6_addr32[1] == 0						      \
   418        && __a->s6_addr32[2] == htonl (0xffff); }))
   419  
   420  # define IN6_IS_ADDR_V4COMPAT(a) \
   421    (__extension__							      \
   422     ({ const struct in6_addr *__a = (const struct in6_addr *) (a);	      \
   423        __a->s6_addr32[0] == 0						      \
   424        && __a->s6_addr32[1] == 0						      \
   425        && __a->s6_addr32[2] == 0						      \
   426        && ntohl (__a->s6_addr32[3]) > 1; }))
   427  
   428  # define IN6_ARE_ADDR_EQUAL(a,b) \
   429    (__extension__							      \
   430     ({ const struct in6_addr *__a = (const struct in6_addr *) (a);	      \
   431        const struct in6_addr *__b = (const struct in6_addr *) (b);	      \
   432        __a->s6_addr32[0] == __b->s6_addr32[0]				      \
   433        && __a->s6_addr32[1] == __b->s6_addr32[1]				      \
   434        && __a->s6_addr32[2] == __b->s6_addr32[2]				      \
   435        && __a->s6_addr32[3] == __b->s6_addr32[3]; }))
   436  #else
   437  # define IN6_IS_ADDR_UNSPECIFIED(a) \
   438  	(((const uint32_t *) (a))[0] == 0				      \
   439  	 && ((const uint32_t *) (a))[1] == 0				      \
   440  	 && ((const uint32_t *) (a))[2] == 0				      \
   441  	 && ((const uint32_t *) (a))[3] == 0)
   442  
   443  # define IN6_IS_ADDR_LOOPBACK(a) \
   444  	(((const uint32_t *) (a))[0] == 0				      \
   445  	 && ((const uint32_t *) (a))[1] == 0				      \
   446  	 && ((const uint32_t *) (a))[2] == 0				      \
   447  	 && ((const uint32_t *) (a))[3] == htonl (1))
   448  
   449  # define IN6_IS_ADDR_LINKLOCAL(a) \
   450  	((((const uint32_t *) (a))[0] & htonl (0xffc00000))		      \
   451  	 == htonl (0xfe800000))
   452  
   453  # define IN6_IS_ADDR_SITELOCAL(a) \
   454  	((((const uint32_t *) (a))[0] & htonl (0xffc00000))		      \
   455  	 == htonl (0xfec00000))
   456  
   457  # define IN6_IS_ADDR_V4MAPPED(a) \
   458  	((((const uint32_t *) (a))[0] == 0)				      \
   459  	 && (((const uint32_t *) (a))[1] == 0)				      \
   460  	 && (((const uint32_t *) (a))[2] == htonl (0xffff)))
   461  
   462  # define IN6_IS_ADDR_V4COMPAT(a) \
   463  	((((const uint32_t *) (a))[0] == 0)				      \
   464  	 && (((const uint32_t *) (a))[1] == 0)				      \
   465  	 && (((const uint32_t *) (a))[2] == 0)				      \
   466  	 && (ntohl (((const uint32_t *) (a))[3]) > 1))
   467  
   468  # define IN6_ARE_ADDR_EQUAL(a,b) \
   469  	((((const uint32_t *) (a))[0] == ((const uint32_t *) (b))[0])	      \
   470  	 && (((const uint32_t *) (a))[1] == ((const uint32_t *) (b))[1])      \
   471  	 && (((const uint32_t *) (a))[2] == ((const uint32_t *) (b))[2])      \
   472  	 && (((const uint32_t *) (a))[3] == ((const uint32_t *) (b))[3]))
   473  #endif
   474  
   475  #define IN6_IS_ADDR_MULTICAST(a) (((const uint8_t *) (a))[0] == 0xff)
   476  
   477  #ifdef __USE_MISC
   478  /* Bind socket to a privileged IP port.  */
   479  extern int bindresvport(int __sockfd, struct sockaddr_in *__sock_in) __THROW;
   480  
   481  /* The IPv6 version of this function.  */
   482  extern int bindresvport6(int __sockfd, struct sockaddr_in6 *__sock_in) __THROW;
   483  #endif
   484  
   485  #define IN6_IS_ADDR_MC_NODELOCAL(a) \
   486  	(IN6_IS_ADDR_MULTICAST(a)					      \
   487  	 && ((((const uint8_t *) (a))[1] & 0xf) == 0x1))
   488  
   489  #define IN6_IS_ADDR_MC_LINKLOCAL(a) \
   490  	(IN6_IS_ADDR_MULTICAST(a)					      \
   491  	 && ((((const uint8_t *) (a))[1] & 0xf) == 0x2))
   492  
   493  #define IN6_IS_ADDR_MC_SITELOCAL(a) \
   494  	(IN6_IS_ADDR_MULTICAST(a)					      \
   495  	 && ((((const uint8_t *) (a))[1] & 0xf) == 0x5))
   496  
   497  #define IN6_IS_ADDR_MC_ORGLOCAL(a) \
   498  	(IN6_IS_ADDR_MULTICAST(a)					      \
   499  	 && ((((const uint8_t *) (a))[1] & 0xf) == 0x8))
   500  
   501  #define IN6_IS_ADDR_MC_GLOBAL(a) \
   502  	(IN6_IS_ADDR_MULTICAST(a)					      \
   503  	 && ((((const uint8_t *) (a))[1] & 0xf) == 0xe))
   504  
   505  #ifdef __USE_GNU
   506  struct cmsghdr;			/* Forward declaration.  */
   507  
   508  #ifndef __USE_KERNEL_IPV6_DEFS
   509  /* IPv6 packet information.  */
   510  struct in6_pktinfo {
   511  	struct in6_addr ipi6_addr;	/* src/dst IPv6 address */
   512  	unsigned int ipi6_ifindex;	/* send/recv interface index */
   513  };
   514  
   515  /* IPv6 MTU information.  */
   516  struct ip6_mtuinfo {
   517  	struct sockaddr_in6 ip6m_addr;	/* dst address including zone ID */
   518  	uint32_t ip6m_mtu;	/* path MTU in host byte order */
   519  };
   520  #endif				/* !__USE_KERNEL_IPV6_DEFS */
   521  
   522  /* Obsolete hop-by-hop and Destination Options Processing (RFC 2292).  */
   523  extern int inet6_option_space(int __nbytes)
   524  __THROW __attribute_deprecated__;
   525  extern int inet6_option_init(void *__bp, struct cmsghdr **__cmsgp, int __type)
   526  __THROW __attribute_deprecated__;
   527  extern int inet6_option_append(struct cmsghdr *__cmsg, const uint8_t * __typep, int __multx, int __plusy)
   528  __THROW __attribute_deprecated__;
   529  extern uint8_t *inet6_option_alloc(struct cmsghdr *__cmsg, int __datalen, int __multx, int __plusy)
   530  __THROW __attribute_deprecated__;
   531  extern int inet6_option_next(const struct cmsghdr *__cmsg, uint8_t ** __tptrp)
   532  __THROW __attribute_deprecated__;
   533  extern int inet6_option_find(const struct cmsghdr *__cmsg, uint8_t ** __tptrp, int __type)
   534  __THROW __attribute_deprecated__;
   535  
   536  /* Hop-by-Hop and Destination Options Processing (RFC 3542).  */
   537  extern int inet6_opt_init(void *__extbuf, socklen_t __extlen) __THROW;
   538  extern int inet6_opt_append(void *__extbuf, socklen_t __extlen, int __offset, uint8_t __type, socklen_t __len, uint8_t __align, void **__databufp) __THROW;
   539  extern int inet6_opt_finish(void *__extbuf, socklen_t __extlen, int __offset) __THROW;
   540  extern int inet6_opt_set_val(void *__databuf, int __offset, void *__val, socklen_t __vallen) __THROW;
   541  extern int inet6_opt_next(void *__extbuf, socklen_t __extlen, int __offset, uint8_t * __typep, socklen_t * __lenp, void **__databufp) __THROW;
   542  extern int inet6_opt_find(void *__extbuf, socklen_t __extlen, int __offset, uint8_t __type, socklen_t * __lenp, void **__databufp) __THROW;
   543  extern int inet6_opt_get_val(void *__databuf, int __offset, void *__val, socklen_t __vallen) __THROW;
   544  
   545  /* Routing Header Option (RFC 3542).  */
   546  extern socklen_t inet6_rth_space(int __type, int __segments) __THROW;
   547  extern void *inet6_rth_init(void *__bp, socklen_t __bp_len, int __type, int __segments) __THROW;
   548  extern int inet6_rth_add(void *__bp, const struct in6_addr *__addr) __THROW;
   549  extern int inet6_rth_reverse(const void *__in, void *__out) __THROW;
   550  extern int inet6_rth_segments(const void *__bp) __THROW;
   551  extern struct in6_addr *inet6_rth_getaddr(const void *__bp, int __index) __THROW;
   552  
   553  /* Multicast source filter support.  */
   554  
   555  /* Get IPv4 source filter.  */
   556  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;
   557  
   558  /* Set IPv4 source filter.  */
   559  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;
   560  
   561  /* Get source filter.  */
   562  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;
   563  
   564  /* Set source filter.  */
   565  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;
   566  #endif				/* use GNU */
   567  
   568  __END_DECLS
   569  #endif				/* netinet/in.h */