Blame inet/netinet/in.h

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