Blame inet/netinet/in.h

Packit 6c4009
/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#ifndef	_NETINET_IN_H
Packit 6c4009
#define	_NETINET_IN_H	1
Packit 6c4009
Packit 6c4009
#include <features.h>
Packit 6c4009
#include <bits/stdint-uintn.h>
Packit 6c4009
#include <sys/socket.h>
Packit 6c4009
#include <bits/types.h>
Packit 6c4009
Packit 6c4009
Packit 6c4009
__BEGIN_DECLS
Packit 6c4009
Packit 6c4009
/* Internet address.  */
Packit 6c4009
typedef uint32_t in_addr_t;
Packit 6c4009
struct in_addr
Packit 6c4009
  {
Packit 6c4009
    in_addr_t s_addr;
Packit 6c4009
  };
Packit 6c4009
Packit 6c4009
/* Get system-specific definitions.  */
Packit 6c4009
#include <bits/in.h>
Packit 6c4009
Packit 6c4009
/* Standard well-defined IP protocols.  */
Packit 6c4009
enum
Packit 6c4009
  {
Packit 6c4009
    IPPROTO_IP = 0,	   /* Dummy protocol for TCP.  */
Packit 6c4009
#define IPPROTO_IP		IPPROTO_IP
Packit 6c4009
    IPPROTO_ICMP = 1,	   /* Internet Control Message Protocol.  */
Packit 6c4009
#define IPPROTO_ICMP		IPPROTO_ICMP
Packit 6c4009
    IPPROTO_IGMP = 2,	   /* Internet Group Management Protocol. */
Packit 6c4009
#define IPPROTO_IGMP		IPPROTO_IGMP
Packit 6c4009
    IPPROTO_IPIP = 4,	   /* IPIP tunnels (older KA9Q tunnels use 94).  */
Packit 6c4009
#define IPPROTO_IPIP		IPPROTO_IPIP
Packit 6c4009
    IPPROTO_TCP = 6,	   /* Transmission Control Protocol.  */
Packit 6c4009
#define IPPROTO_TCP		IPPROTO_TCP
Packit 6c4009
    IPPROTO_EGP = 8,	   /* Exterior Gateway Protocol.  */
Packit 6c4009
#define IPPROTO_EGP		IPPROTO_EGP
Packit 6c4009
    IPPROTO_PUP = 12,	   /* PUP protocol.  */
Packit 6c4009
#define IPPROTO_PUP		IPPROTO_PUP
Packit 6c4009
    IPPROTO_UDP = 17,	   /* User Datagram Protocol.  */
Packit 6c4009
#define IPPROTO_UDP		IPPROTO_UDP
Packit 6c4009
    IPPROTO_IDP = 22,	   /* XNS IDP protocol.  */
Packit 6c4009
#define IPPROTO_IDP		IPPROTO_IDP
Packit 6c4009
    IPPROTO_TP = 29,	   /* SO Transport Protocol Class 4.  */
Packit 6c4009
#define IPPROTO_TP		IPPROTO_TP
Packit 6c4009
    IPPROTO_DCCP = 33,	   /* Datagram Congestion Control Protocol.  */
Packit 6c4009
#define IPPROTO_DCCP		IPPROTO_DCCP
Packit 6c4009
    IPPROTO_IPV6 = 41,     /* IPv6 header.  */
Packit 6c4009
#define IPPROTO_IPV6		IPPROTO_IPV6
Packit 6c4009
    IPPROTO_RSVP = 46,	   /* Reservation Protocol.  */
Packit 6c4009
#define IPPROTO_RSVP		IPPROTO_RSVP
Packit 6c4009
    IPPROTO_GRE = 47,	   /* General Routing Encapsulation.  */
Packit 6c4009
#define IPPROTO_GRE		IPPROTO_GRE
Packit 6c4009
    IPPROTO_ESP = 50,      /* encapsulating security payload.  */
Packit 6c4009
#define IPPROTO_ESP		IPPROTO_ESP
Packit 6c4009
    IPPROTO_AH = 51,       /* authentication header.  */
Packit 6c4009
#define IPPROTO_AH		IPPROTO_AH
Packit 6c4009
    IPPROTO_MTP = 92,	   /* Multicast Transport Protocol.  */
Packit 6c4009
#define IPPROTO_MTP		IPPROTO_MTP
Packit 6c4009
    IPPROTO_BEETPH = 94,   /* IP option pseudo header for BEET.  */
Packit 6c4009
#define IPPROTO_BEETPH		IPPROTO_BEETPH
Packit 6c4009
    IPPROTO_ENCAP = 98,	   /* Encapsulation Header.  */
Packit 6c4009
#define IPPROTO_ENCAP		IPPROTO_ENCAP
Packit 6c4009
    IPPROTO_PIM = 103,	   /* Protocol Independent Multicast.  */
Packit 6c4009
#define IPPROTO_PIM		IPPROTO_PIM
Packit 6c4009
    IPPROTO_COMP = 108,	   /* Compression Header Protocol.  */
Packit 6c4009
#define IPPROTO_COMP		IPPROTO_COMP
Packit 6c4009
    IPPROTO_SCTP = 132,	   /* Stream Control Transmission Protocol.  */
Packit 6c4009
#define IPPROTO_SCTP		IPPROTO_SCTP
Packit 6c4009
    IPPROTO_UDPLITE = 136, /* UDP-Lite protocol.  */
Packit 6c4009
#define IPPROTO_UDPLITE		IPPROTO_UDPLITE
Packit 6c4009
    IPPROTO_MPLS = 137,    /* MPLS in IP.  */
Packit 6c4009
#define IPPROTO_MPLS		IPPROTO_MPLS
Packit 6c4009
    IPPROTO_RAW = 255,	   /* Raw IP packets.  */
Packit 6c4009
#define IPPROTO_RAW		IPPROTO_RAW
Packit 6c4009
    IPPROTO_MAX
Packit 6c4009
  };
Packit 6c4009
Packit 6c4009
/* If __USE_KERNEL_IPV6_DEFS is 1 then the user has included the kernel
Packit 6c4009
   network headers first and we should use those ABI-identical definitions
Packit 6c4009
   instead of our own, otherwise 0.  */
Packit 6c4009
#if !__USE_KERNEL_IPV6_DEFS
Packit 6c4009
enum
Packit 6c4009
  {
Packit 6c4009
    IPPROTO_HOPOPTS = 0,   /* IPv6 Hop-by-Hop options.  */
Packit 6c4009
#define IPPROTO_HOPOPTS		IPPROTO_HOPOPTS
Packit 6c4009
    IPPROTO_ROUTING = 43,  /* IPv6 routing header.  */
Packit 6c4009
#define IPPROTO_ROUTING		IPPROTO_ROUTING
Packit 6c4009
    IPPROTO_FRAGMENT = 44, /* IPv6 fragmentation header.  */
Packit 6c4009
#define IPPROTO_FRAGMENT	IPPROTO_FRAGMENT
Packit 6c4009
    IPPROTO_ICMPV6 = 58,   /* ICMPv6.  */
Packit 6c4009
#define IPPROTO_ICMPV6		IPPROTO_ICMPV6
Packit 6c4009
    IPPROTO_NONE = 59,     /* IPv6 no next header.  */
Packit 6c4009
#define IPPROTO_NONE		IPPROTO_NONE
Packit 6c4009
    IPPROTO_DSTOPTS = 60,  /* IPv6 destination options.  */
Packit 6c4009
#define IPPROTO_DSTOPTS		IPPROTO_DSTOPTS
Packit 6c4009
    IPPROTO_MH = 135       /* IPv6 mobility header.  */
Packit 6c4009
#define IPPROTO_MH		IPPROTO_MH
Packit 6c4009
  };
Packit 6c4009
#endif /* !__USE_KERNEL_IPV6_DEFS */
Packit 6c4009
Packit 6c4009
/* Type to represent a port.  */
Packit 6c4009
typedef uint16_t in_port_t;
Packit 6c4009
Packit 6c4009
/* Standard well-known ports.  */
Packit 6c4009
enum
Packit 6c4009
  {
Packit 6c4009
    IPPORT_ECHO = 7,		/* Echo service.  */
Packit 6c4009
    IPPORT_DISCARD = 9,		/* Discard transmissions service.  */
Packit 6c4009
    IPPORT_SYSTAT = 11,		/* System status service.  */
Packit 6c4009
    IPPORT_DAYTIME = 13,	/* Time of day service.  */
Packit 6c4009
    IPPORT_NETSTAT = 15,	/* Network status service.  */
Packit 6c4009
    IPPORT_FTP = 21,		/* File Transfer Protocol.  */
Packit 6c4009
    IPPORT_TELNET = 23,		/* Telnet protocol.  */
Packit 6c4009
    IPPORT_SMTP = 25,		/* Simple Mail Transfer Protocol.  */
Packit 6c4009
    IPPORT_TIMESERVER = 37,	/* Timeserver service.  */
Packit 6c4009
    IPPORT_NAMESERVER = 42,	/* Domain Name Service.  */
Packit 6c4009
    IPPORT_WHOIS = 43,		/* Internet Whois service.  */
Packit 6c4009
    IPPORT_MTP = 57,
Packit 6c4009
Packit 6c4009
    IPPORT_TFTP = 69,		/* Trivial File Transfer Protocol.  */
Packit 6c4009
    IPPORT_RJE = 77,
Packit 6c4009
    IPPORT_FINGER = 79,		/* Finger service.  */
Packit 6c4009
    IPPORT_TTYLINK = 87,
Packit 6c4009
    IPPORT_SUPDUP = 95,		/* SUPDUP protocol.  */
Packit 6c4009
Packit 6c4009
Packit 6c4009
    IPPORT_EXECSERVER = 512,	/* execd service.  */
Packit 6c4009
    IPPORT_LOGINSERVER = 513,	/* rlogind service.  */
Packit 6c4009
    IPPORT_CMDSERVER = 514,
Packit 6c4009
    IPPORT_EFSSERVER = 520,
Packit 6c4009
Packit 6c4009
    /* UDP ports.  */
Packit 6c4009
    IPPORT_BIFFUDP = 512,
Packit 6c4009
    IPPORT_WHOSERVER = 513,
Packit 6c4009
    IPPORT_ROUTESERVER = 520,
Packit 6c4009
Packit 6c4009
    /* Ports less than this value are reserved for privileged processes.  */
Packit 6c4009
    IPPORT_RESERVED = 1024,
Packit 6c4009
Packit 6c4009
    /* Ports greater this value are reserved for (non-privileged) servers.  */
Packit 6c4009
    IPPORT_USERRESERVED = 5000
Packit 6c4009
  };
Packit 6c4009
Packit 6c4009
/* Definitions of the bits in an Internet address integer.
Packit 6c4009
Packit 6c4009
   On subnets, host and network parts are found according to
Packit 6c4009
   the subnet mask, not these masks.  */
Packit 6c4009
Packit 6c4009
#define	IN_CLASSA(a)		((((in_addr_t)(a)) & 0x80000000) == 0)
Packit 6c4009
#define	IN_CLASSA_NET		0xff000000
Packit 6c4009
#define	IN_CLASSA_NSHIFT	24
Packit 6c4009
#define	IN_CLASSA_HOST		(0xffffffff & ~IN_CLASSA_NET)
Packit 6c4009
#define	IN_CLASSA_MAX		128
Packit 6c4009
Packit 6c4009
#define	IN_CLASSB(a)		((((in_addr_t)(a)) & 0xc0000000) == 0x80000000)
Packit 6c4009
#define	IN_CLASSB_NET		0xffff0000
Packit 6c4009
#define	IN_CLASSB_NSHIFT	16
Packit 6c4009
#define	IN_CLASSB_HOST		(0xffffffff & ~IN_CLASSB_NET)
Packit 6c4009
#define	IN_CLASSB_MAX		65536
Packit 6c4009
Packit 6c4009
#define	IN_CLASSC(a)		((((in_addr_t)(a)) & 0xe0000000) == 0xc0000000)
Packit 6c4009
#define	IN_CLASSC_NET		0xffffff00
Packit 6c4009
#define	IN_CLASSC_NSHIFT	8
Packit 6c4009
#define	IN_CLASSC_HOST		(0xffffffff & ~IN_CLASSC_NET)
Packit 6c4009
Packit 6c4009
#define	IN_CLASSD(a)		((((in_addr_t)(a)) & 0xf0000000) == 0xe0000000)
Packit 6c4009
#define	IN_MULTICAST(a)		IN_CLASSD(a)
Packit 6c4009
Packit 6c4009
#define	IN_EXPERIMENTAL(a)	((((in_addr_t)(a)) & 0xe0000000) == 0xe0000000)
Packit 6c4009
#define	IN_BADCLASS(a)		((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000)
Packit 6c4009
Packit 6c4009
/* Address to accept any incoming messages.  */
Packit 6c4009
#define	INADDR_ANY		((in_addr_t) 0x00000000)
Packit 6c4009
/* Address to send to all hosts.  */
Packit 6c4009
#define	INADDR_BROADCAST	((in_addr_t) 0xffffffff)
Packit 6c4009
/* Address indicating an error return.  */
Packit 6c4009
#define	INADDR_NONE		((in_addr_t) 0xffffffff)
Packit 6c4009
Packit 6c4009
/* Network number for local host loopback.  */
Packit 6c4009
#define	IN_LOOPBACKNET		127
Packit 6c4009
/* Address to loopback in software to local host.  */
Packit 6c4009
#ifndef INADDR_LOOPBACK
Packit 6c4009
# define INADDR_LOOPBACK	((in_addr_t) 0x7f000001) /* Inet 127.0.0.1.  */
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* Defines for Multicast INADDR.  */
Packit 6c4009
#define INADDR_UNSPEC_GROUP	((in_addr_t) 0xe0000000) /* 224.0.0.0 */
Packit 6c4009
#define INADDR_ALLHOSTS_GROUP	((in_addr_t) 0xe0000001) /* 224.0.0.1 */
Packit 6c4009
#define INADDR_ALLRTRS_GROUP    ((in_addr_t) 0xe0000002) /* 224.0.0.2 */
Packit 6c4009
#define INADDR_MAX_LOCAL_GROUP  ((in_addr_t) 0xe00000ff) /* 224.0.0.255 */
Packit 6c4009
Packit 6c4009
#if !__USE_KERNEL_IPV6_DEFS
Packit 6c4009
/* IPv6 address */
Packit 6c4009
struct in6_addr
Packit 6c4009
  {
Packit 6c4009
    union
Packit 6c4009
      {
Packit 6c4009
	uint8_t	__u6_addr8[16];
Packit 6c4009
	uint16_t __u6_addr16[8];
Packit 6c4009
	uint32_t __u6_addr32[4];
Packit 6c4009
      } __in6_u;
Packit 6c4009
#define s6_addr			__in6_u.__u6_addr8
Packit 6c4009
#ifdef __USE_MISC
Packit 6c4009
# define s6_addr16		__in6_u.__u6_addr16
Packit 6c4009
# define s6_addr32		__in6_u.__u6_addr32
Packit 6c4009
#endif
Packit 6c4009
  };
Packit 6c4009
#endif /* !__USE_KERNEL_IPV6_DEFS */
Packit 6c4009
Packit 6c4009
extern const struct in6_addr in6addr_any;        /* :: */
Packit 6c4009
extern const struct in6_addr in6addr_loopback;   /* ::1 */
Packit 6c4009
#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
Packit 6c4009
#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
Packit 6c4009
Packit 6c4009
#define INET_ADDRSTRLEN 16
Packit 6c4009
#define INET6_ADDRSTRLEN 46
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Structure describing an Internet socket address.  */
Packit 6c4009
struct sockaddr_in
Packit 6c4009
  {
Packit 6c4009
    __SOCKADDR_COMMON (sin_);
Packit 6c4009
    in_port_t sin_port;			/* Port number.  */
Packit 6c4009
    struct in_addr sin_addr;		/* Internet address.  */
Packit 6c4009
Packit 6c4009
    /* Pad to size of `struct sockaddr'.  */
Packit 6c4009
    unsigned char sin_zero[sizeof (struct sockaddr) -
Packit 6c4009
			   __SOCKADDR_COMMON_SIZE -
Packit 6c4009
			   sizeof (in_port_t) -
Packit 6c4009
			   sizeof (struct in_addr)];
Packit 6c4009
  };
Packit 6c4009
Packit 6c4009
#if !__USE_KERNEL_IPV6_DEFS
Packit 6c4009
/* Ditto, for IPv6.  */
Packit 6c4009
struct sockaddr_in6
Packit 6c4009
  {
Packit 6c4009
    __SOCKADDR_COMMON (sin6_);
Packit 6c4009
    in_port_t sin6_port;	/* Transport layer port # */
Packit 6c4009
    uint32_t sin6_flowinfo;	/* IPv6 flow information */
Packit 6c4009
    struct in6_addr sin6_addr;	/* IPv6 address */
Packit 6c4009
    uint32_t sin6_scope_id;	/* IPv6 scope-id */
Packit 6c4009
  };
Packit 6c4009
#endif /* !__USE_KERNEL_IPV6_DEFS */
Packit 6c4009
Packit 6c4009
#ifdef __USE_MISC
Packit 6c4009
/* IPv4 multicast request.  */
Packit 6c4009
struct ip_mreq
Packit 6c4009
  {
Packit 6c4009
    /* IP multicast address of group.  */
Packit 6c4009
    struct in_addr imr_multiaddr;
Packit 6c4009
Packit 6c4009
    /* Local IP address of interface.  */
Packit 6c4009
    struct in_addr imr_interface;
Packit 6c4009
  };
Packit 6c4009
Packit 6c4009
struct ip_mreq_source
Packit 6c4009
  {
Packit 6c4009
    /* IP multicast address of group.  */
Packit 6c4009
    struct in_addr imr_multiaddr;
Packit 6c4009
Packit 6c4009
    /* IP address of interface.  */
Packit 6c4009
    struct in_addr imr_interface;
Packit 6c4009
Packit 6c4009
    /* IP address of source.  */
Packit 6c4009
    struct in_addr imr_sourceaddr;
Packit 6c4009
  };
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#if !__USE_KERNEL_IPV6_DEFS
Packit 6c4009
/* Likewise, for IPv6.  */
Packit 6c4009
struct ipv6_mreq
Packit 6c4009
  {
Packit 6c4009
    /* IPv6 multicast address of group */
Packit 6c4009
    struct in6_addr ipv6mr_multiaddr;
Packit 6c4009
Packit 6c4009
    /* local interface */
Packit 6c4009
    unsigned int ipv6mr_interface;
Packit 6c4009
  };
Packit 6c4009
#endif /* !__USE_KERNEL_IPV6_DEFS */
Packit 6c4009
Packit 6c4009
#ifdef __USE_MISC
Packit 6c4009
/* Multicast group request.  */
Packit 6c4009
struct group_req
Packit 6c4009
  {
Packit 6c4009
    /* Interface index.  */
Packit 6c4009
    uint32_t gr_interface;
Packit 6c4009
Packit 6c4009
    /* Group address.  */
Packit 6c4009
    struct sockaddr_storage gr_group;
Packit 6c4009
  };
Packit 6c4009
Packit 6c4009
struct group_source_req
Packit 6c4009
  {
Packit 6c4009
    /* Interface index.  */
Packit 6c4009
    uint32_t gsr_interface;
Packit 6c4009
Packit 6c4009
    /* Group address.  */
Packit 6c4009
    struct sockaddr_storage gsr_group;
Packit 6c4009
Packit 6c4009
    /* Source address.  */
Packit 6c4009
    struct sockaddr_storage gsr_source;
Packit 6c4009
  };
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Full-state filter operations.  */
Packit 6c4009
struct ip_msfilter
Packit 6c4009
  {
Packit 6c4009
    /* IP multicast address of group.  */
Packit 6c4009
    struct in_addr imsf_multiaddr;
Packit 6c4009
Packit 6c4009
    /* Local IP address of interface.  */
Packit 6c4009
    struct in_addr imsf_interface;
Packit 6c4009
Packit 6c4009
    /* Filter mode.  */
Packit 6c4009
    uint32_t imsf_fmode;
Packit 6c4009
Packit 6c4009
    /* Number of source addresses.  */
Packit 6c4009
    uint32_t imsf_numsrc;
Packit 6c4009
    /* Source addresses.  */
Packit 6c4009
    struct in_addr imsf_slist[1];
Packit 6c4009
  };
Packit 6c4009
Packit 6c4009
#define IP_MSFILTER_SIZE(numsrc) (sizeof (struct ip_msfilter) \
Packit 6c4009
				  - sizeof (struct in_addr)		      \
Packit 6c4009
				  + (numsrc) * sizeof (struct in_addr))
Packit 6c4009
Packit 6c4009
struct group_filter
Packit 6c4009
  {
Packit 6c4009
    /* Interface index.  */
Packit 6c4009
    uint32_t gf_interface;
Packit 6c4009
Packit 6c4009
    /* Group address.  */
Packit 6c4009
    struct sockaddr_storage gf_group;
Packit 6c4009
Packit 6c4009
    /* Filter mode.  */
Packit 6c4009
    uint32_t gf_fmode;
Packit 6c4009
Packit 6c4009
    /* Number of source addresses.  */
Packit 6c4009
    uint32_t gf_numsrc;
Packit 6c4009
    /* Source addresses.  */
Packit 6c4009
    struct sockaddr_storage gf_slist[1];
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
#define GROUP_FILTER_SIZE(numsrc) (sizeof (struct group_filter) \
Packit 6c4009
				   - sizeof (struct sockaddr_storage)	      \
Packit 6c4009
				   + ((numsrc)				      \
Packit 6c4009
				      * sizeof (struct sockaddr_storage)))
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* Functions to convert between host and network byte order.
Packit 6c4009
Packit 6c4009
   Please note that these functions normally take `unsigned long int' or
Packit 6c4009
   `unsigned short int' values as arguments and also return them.  But
Packit 6c4009
   this was a short-sighted decision since on different systems the types
Packit 6c4009
   may have different representations but the values are always the same.  */
Packit 6c4009
Packit 6c4009
extern uint32_t ntohl (uint32_t __netlong) __THROW __attribute__ ((__const__));
Packit 6c4009
extern uint16_t ntohs (uint16_t __netshort)
Packit 6c4009
     __THROW __attribute__ ((__const__));
Packit 6c4009
extern uint32_t htonl (uint32_t __hostlong)
Packit 6c4009
     __THROW __attribute__ ((__const__));
Packit 6c4009
extern uint16_t htons (uint16_t __hostshort)
Packit 6c4009
     __THROW __attribute__ ((__const__));
Packit 6c4009
Packit 6c4009
#include <endian.h>
Packit 6c4009
Packit 6c4009
/* Get machine dependent optimized versions of byte swapping functions.  */
Packit 6c4009
#include <bits/byteswap.h>
Packit 6c4009
#include <bits/uintn-identity.h>
Packit 6c4009
Packit 6c4009
#ifdef __OPTIMIZE__
Packit 6c4009
/* We can optimize calls to the conversion functions.  Either nothing has
Packit 6c4009
   to be done or we are using directly the byte-swapping functions which
Packit 6c4009
   often can be inlined.  */
Packit 6c4009
# if __BYTE_ORDER == __BIG_ENDIAN
Packit 6c4009
/* The host byte order is the same as network byte order,
Packit 6c4009
   so these functions are all just identity.  */
Packit 6c4009
# define ntohl(x)	__uint32_identity (x)
Packit 6c4009
# define ntohs(x)	__uint16_identity (x)
Packit 6c4009
# define htonl(x)	__uint32_identity (x)
Packit 6c4009
# define htons(x)	__uint16_identity (x)
Packit 6c4009
# else
Packit 6c4009
#  if __BYTE_ORDER == __LITTLE_ENDIAN
Packit 6c4009
#   define ntohl(x)	__bswap_32 (x)
Packit 6c4009
#   define ntohs(x)	__bswap_16 (x)
Packit 6c4009
#   define htonl(x)	__bswap_32 (x)
Packit 6c4009
#   define htons(x)	__bswap_16 (x)
Packit 6c4009
#  endif
Packit 6c4009
# endif
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#ifdef __GNUC__
Packit 6c4009
# define IN6_IS_ADDR_UNSPECIFIED(a) \
Packit 6c4009
  (__extension__							      \
Packit 6c4009
   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);	      \
Packit 6c4009
      __a->__in6_u.__u6_addr32[0] == 0					      \
Packit 6c4009
      && __a->__in6_u.__u6_addr32[1] == 0				      \
Packit 6c4009
      && __a->__in6_u.__u6_addr32[2] == 0				      \
Packit 6c4009
      && __a->__in6_u.__u6_addr32[3] == 0; }))
Packit 6c4009
Packit 6c4009
# define IN6_IS_ADDR_LOOPBACK(a) \
Packit 6c4009
  (__extension__							      \
Packit 6c4009
   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);	      \
Packit 6c4009
      __a->__in6_u.__u6_addr32[0] == 0					      \
Packit 6c4009
      && __a->__in6_u.__u6_addr32[1] == 0				      \
Packit 6c4009
      && __a->__in6_u.__u6_addr32[2] == 0				      \
Packit 6c4009
      && __a->__in6_u.__u6_addr32[3] == htonl (1); }))
Packit 6c4009
Packit 6c4009
# define IN6_IS_ADDR_LINKLOCAL(a) \
Packit 6c4009
  (__extension__							      \
Packit 6c4009
   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);	      \
Packit 6c4009
      (__a->__in6_u.__u6_addr32[0] & htonl (0xffc00000)) == htonl (0xfe800000); }))
Packit 6c4009
Packit 6c4009
# define IN6_IS_ADDR_SITELOCAL(a) \
Packit 6c4009
  (__extension__							      \
Packit 6c4009
   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);	      \
Packit 6c4009
      (__a->__in6_u.__u6_addr32[0] & htonl (0xffc00000)) == htonl (0xfec00000); }))
Packit 6c4009
Packit 6c4009
# define IN6_IS_ADDR_V4MAPPED(a) \
Packit 6c4009
  (__extension__							      \
Packit 6c4009
   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);	      \
Packit 6c4009
      __a->__in6_u.__u6_addr32[0] == 0					      \
Packit 6c4009
      && __a->__in6_u.__u6_addr32[1] == 0				      \
Packit 6c4009
      && __a->__in6_u.__u6_addr32[2] == htonl (0xffff); }))
Packit 6c4009
Packit 6c4009
# define IN6_IS_ADDR_V4COMPAT(a) \
Packit 6c4009
  (__extension__							      \
Packit 6c4009
   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);	      \
Packit 6c4009
      __a->__in6_u.__u6_addr32[0] == 0					      \
Packit 6c4009
      && __a->__in6_u.__u6_addr32[1] == 0				      \
Packit 6c4009
      && __a->__in6_u.__u6_addr32[2] == 0				      \
Packit 6c4009
      && ntohl (__a->__in6_u.__u6_addr32[3]) > 1; }))
Packit 6c4009
Packit 6c4009
# define IN6_ARE_ADDR_EQUAL(a,b) \
Packit 6c4009
  (__extension__							      \
Packit 6c4009
   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);	      \
Packit 6c4009
      const struct in6_addr *__b = (const struct in6_addr *) (b);	      \
Packit 6c4009
      __a->__in6_u.__u6_addr32[0] == __b->__in6_u.__u6_addr32[0]	      \
Packit 6c4009
      && __a->__in6_u.__u6_addr32[1] == __b->__in6_u.__u6_addr32[1]	      \
Packit 6c4009
      && __a->__in6_u.__u6_addr32[2] == __b->__in6_u.__u6_addr32[2]	      \
Packit 6c4009
      && __a->__in6_u.__u6_addr32[3] == __b->__in6_u.__u6_addr32[3]; }))
Packit 6c4009
#else
Packit 6c4009
# define IN6_IS_ADDR_UNSPECIFIED(a) \
Packit 6c4009
	(((const uint32_t *) (a))[0] == 0				      \
Packit 6c4009
	 && ((const uint32_t *) (a))[1] == 0				      \
Packit 6c4009
	 && ((const uint32_t *) (a))[2] == 0				      \
Packit 6c4009
	 && ((const uint32_t *) (a))[3] == 0)
Packit 6c4009
Packit 6c4009
# define IN6_IS_ADDR_LOOPBACK(a) \
Packit 6c4009
	(((const uint32_t *) (a))[0] == 0				      \
Packit 6c4009
	 && ((const uint32_t *) (a))[1] == 0				      \
Packit 6c4009
	 && ((const uint32_t *) (a))[2] == 0				      \
Packit 6c4009
	 && ((const uint32_t *) (a))[3] == htonl (1))
Packit 6c4009
Packit 6c4009
# define IN6_IS_ADDR_LINKLOCAL(a) \
Packit 6c4009
	((((const uint32_t *) (a))[0] & htonl (0xffc00000))		      \
Packit 6c4009
	 == htonl (0xfe800000))
Packit 6c4009
Packit 6c4009
# define IN6_IS_ADDR_SITELOCAL(a) \
Packit 6c4009
	((((const uint32_t *) (a))[0] & htonl (0xffc00000))		      \
Packit 6c4009
	 == htonl (0xfec00000))
Packit 6c4009
Packit 6c4009
# define IN6_IS_ADDR_V4MAPPED(a) \
Packit 6c4009
	((((const uint32_t *) (a))[0] == 0)				      \
Packit 6c4009
	 && (((const uint32_t *) (a))[1] == 0)				      \
Packit 6c4009
	 && (((const uint32_t *) (a))[2] == htonl (0xffff)))
Packit 6c4009
Packit 6c4009
# define IN6_IS_ADDR_V4COMPAT(a) \
Packit 6c4009
	((((const uint32_t *) (a))[0] == 0)				      \
Packit 6c4009
	 && (((const uint32_t *) (a))[1] == 0)				      \
Packit 6c4009
	 && (((const uint32_t *) (a))[2] == 0)				      \
Packit 6c4009
	 && (ntohl (((const uint32_t *) (a))[3]) > 1))
Packit 6c4009
Packit 6c4009
# define IN6_ARE_ADDR_EQUAL(a,b) \
Packit 6c4009
	((((const uint32_t *) (a))[0] == ((const uint32_t *) (b))[0])	      \
Packit 6c4009
	 && (((const uint32_t *) (a))[1] == ((const uint32_t *) (b))[1])      \
Packit 6c4009
	 && (((const uint32_t *) (a))[2] == ((const uint32_t *) (b))[2])      \
Packit 6c4009
	 && (((const uint32_t *) (a))[3] == ((const uint32_t *) (b))[3]))
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#define IN6_IS_ADDR_MULTICAST(a) (((const uint8_t *) (a))[0] == 0xff)
Packit 6c4009
Packit 6c4009
#ifdef __USE_MISC
Packit 6c4009
/* Bind socket to a privileged IP port.  */
Packit 6c4009
extern int bindresvport (int __sockfd, struct sockaddr_in *__sock_in) __THROW;
Packit 6c4009
Packit 6c4009
/* The IPv6 version of this function.  */
Packit 6c4009
extern int bindresvport6 (int __sockfd, struct sockaddr_in6 *__sock_in)
Packit 6c4009
     __THROW;
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
Packit 6c4009
#define IN6_IS_ADDR_MC_NODELOCAL(a) \
Packit 6c4009
	(IN6_IS_ADDR_MULTICAST(a)					      \
Packit 6c4009
	 && ((((const uint8_t *) (a))[1] & 0xf) == 0x1))
Packit 6c4009
Packit 6c4009
#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
Packit 6c4009
	(IN6_IS_ADDR_MULTICAST(a)					      \
Packit 6c4009
	 && ((((const uint8_t *) (a))[1] & 0xf) == 0x2))
Packit 6c4009
Packit 6c4009
#define IN6_IS_ADDR_MC_SITELOCAL(a) \
Packit 6c4009
	(IN6_IS_ADDR_MULTICAST(a)					      \
Packit 6c4009
	 && ((((const uint8_t *) (a))[1] & 0xf) == 0x5))
Packit 6c4009
Packit 6c4009
#define IN6_IS_ADDR_MC_ORGLOCAL(a) \
Packit 6c4009
	(IN6_IS_ADDR_MULTICAST(a)					      \
Packit 6c4009
	 && ((((const uint8_t *) (a))[1] & 0xf) == 0x8))
Packit 6c4009
Packit 6c4009
#define IN6_IS_ADDR_MC_GLOBAL(a) \
Packit 6c4009
	(IN6_IS_ADDR_MULTICAST(a)					      \
Packit 6c4009
	 && ((((const uint8_t *) (a))[1] & 0xf) == 0xe))
Packit 6c4009
Packit 6c4009
Packit 6c4009
#ifdef __USE_GNU
Packit 6c4009
struct cmsghdr;			/* Forward declaration.  */
Packit 6c4009
Packit 6c4009
#if !__USE_KERNEL_IPV6_DEFS
Packit 6c4009
/* IPv6 packet information.  */
Packit 6c4009
struct in6_pktinfo
Packit 6c4009
  {
Packit 6c4009
    struct in6_addr ipi6_addr;	/* src/dst IPv6 address */
Packit 6c4009
    unsigned int ipi6_ifindex;	/* send/recv interface index */
Packit 6c4009
  };
Packit 6c4009
Packit 6c4009
/* IPv6 MTU information.  */
Packit 6c4009
struct ip6_mtuinfo
Packit 6c4009
  {
Packit 6c4009
    struct sockaddr_in6 ip6m_addr; /* dst address including zone ID */
Packit 6c4009
    uint32_t ip6m_mtu;		   /* path MTU in host byte order */
Packit 6c4009
  };
Packit 6c4009
#endif /* !__USE_KERNEL_IPV6_DEFS */
Packit 6c4009
Packit 6c4009
/* Obsolete hop-by-hop and Destination Options Processing (RFC 2292).  */
Packit 6c4009
extern int inet6_option_space (int __nbytes)
Packit 6c4009
     __THROW __attribute_deprecated__;
Packit 6c4009
extern int inet6_option_init (void *__bp, struct cmsghdr **__cmsgp,
Packit 6c4009
			      int __type) __THROW __attribute_deprecated__;
Packit 6c4009
extern int inet6_option_append (struct cmsghdr *__cmsg,
Packit 6c4009
				const uint8_t *__typep, int __multx,
Packit 6c4009
				int __plusy) __THROW __attribute_deprecated__;
Packit 6c4009
extern uint8_t *inet6_option_alloc (struct cmsghdr *__cmsg, int __datalen,
Packit 6c4009
				    int __multx, int __plusy)
Packit 6c4009
     __THROW __attribute_deprecated__;
Packit 6c4009
extern int inet6_option_next (const struct cmsghdr *__cmsg,
Packit 6c4009
			      uint8_t **__tptrp)
Packit 6c4009
     __THROW __attribute_deprecated__;
Packit 6c4009
extern int inet6_option_find (const struct cmsghdr *__cmsg,
Packit 6c4009
			      uint8_t **__tptrp, int __type)
Packit 6c4009
     __THROW __attribute_deprecated__;
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Hop-by-Hop and Destination Options Processing (RFC 3542).  */
Packit 6c4009
extern int inet6_opt_init (void *__extbuf, socklen_t __extlen) __THROW;
Packit 6c4009
extern int inet6_opt_append (void *__extbuf, socklen_t __extlen, int __offset,
Packit 6c4009
			     uint8_t __type, socklen_t __len, uint8_t __align,
Packit 6c4009
			     void **__databufp) __THROW;
Packit 6c4009
extern int inet6_opt_finish (void *__extbuf, socklen_t __extlen, int __offset)
Packit 6c4009
     __THROW;
Packit 6c4009
extern int inet6_opt_set_val (void *__databuf, int __offset, void *__val,
Packit 6c4009
			      socklen_t __vallen) __THROW;
Packit 6c4009
extern int inet6_opt_next (void *__extbuf, socklen_t __extlen, int __offset,
Packit 6c4009
			   uint8_t *__typep, socklen_t *__lenp,
Packit 6c4009
			   void **__databufp) __THROW;
Packit 6c4009
extern int inet6_opt_find (void *__extbuf, socklen_t __extlen, int __offset,
Packit 6c4009
			   uint8_t __type, socklen_t *__lenp,
Packit 6c4009
			   void **__databufp) __THROW;
Packit 6c4009
extern int inet6_opt_get_val (void *__databuf, int __offset, void *__val,
Packit 6c4009
			      socklen_t __vallen) __THROW;
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Routing Header Option (RFC 3542).  */
Packit 6c4009
extern socklen_t inet6_rth_space (int __type, int __segments) __THROW;
Packit 6c4009
extern void *inet6_rth_init (void *__bp, socklen_t __bp_len, int __type,
Packit 6c4009
			     int __segments) __THROW;
Packit 6c4009
extern int inet6_rth_add (void *__bp, const struct in6_addr *__addr) __THROW;
Packit 6c4009
extern int inet6_rth_reverse (const void *__in, void *__out) __THROW;
Packit 6c4009
extern int inet6_rth_segments (const void *__bp) __THROW;
Packit 6c4009
extern struct in6_addr *inet6_rth_getaddr (const void *__bp, int __index)
Packit 6c4009
     __THROW;
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Multicast source filter support.  */
Packit 6c4009
Packit 6c4009
/* Get IPv4 source filter.  */
Packit 6c4009
extern int getipv4sourcefilter (int __s, struct in_addr __interface_addr,
Packit 6c4009
				struct in_addr __group, uint32_t *__fmode,
Packit 6c4009
				uint32_t *__numsrc, struct in_addr *__slist)
Packit 6c4009
     __THROW;
Packit 6c4009
Packit 6c4009
/* Set IPv4 source filter.  */
Packit 6c4009
extern int setipv4sourcefilter (int __s, struct in_addr __interface_addr,
Packit 6c4009
				struct in_addr __group, uint32_t __fmode,
Packit 6c4009
				uint32_t __numsrc,
Packit 6c4009
				const struct in_addr *__slist)
Packit 6c4009
     __THROW;
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Get source filter.  */
Packit 6c4009
extern int getsourcefilter (int __s, uint32_t __interface_addr,
Packit 6c4009
			    const struct sockaddr *__group,
Packit 6c4009
			    socklen_t __grouplen, uint32_t *__fmode,
Packit 6c4009
			    uint32_t *__numsrc,
Packit 6c4009
			    struct sockaddr_storage *__slist) __THROW;
Packit 6c4009
Packit 6c4009
/* Set source filter.  */
Packit 6c4009
extern int setsourcefilter (int __s, uint32_t __interface_addr,
Packit 6c4009
			    const struct sockaddr *__group,
Packit 6c4009
			    socklen_t __grouplen, uint32_t __fmode,
Packit 6c4009
			    uint32_t __numsrc,
Packit 6c4009
			    const struct sockaddr_storage *__slist) __THROW;
Packit 6c4009
#endif	/* use GNU */
Packit 6c4009
Packit 6c4009
__END_DECLS
Packit 6c4009
Packit 6c4009
#endif	/* netinet/in.h */