KallistiOS  2.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Data Structures | Macros | Typedefs | Variables
in.h File Reference

Definitions for the Internet address family. More...

#include <sys/cdefs.h>
#include <inttypes.h>
#include <sys/socket.h>
#include <arpa/inet.h>

Go to the source code of this file.

Data Structures

struct  in_addr
 Structure used to store an IPv4 address. More...
struct  in6_addr
 Structure used to store an IPv6 address. More...
struct  sockaddr_in
 Structure used to store an IPv4 address for a socket. More...
struct  sockaddr_in6
 Structure used to store an IPv6 address for a socket. More...

Macros

#define s6_addr   __s6_addr.__s6_addr8
#define INADDR_ANY   0x00000000
 Local IPv4 host address.
#define INADDR_BROADCAST   0xFFFFFFFF
 IPv4 broadcast address.
#define INADDR_NONE   0xFFFFFFFF
 IPv4 error address.
#define IN6ADDR_ANY_INIT
 Initialize an IPv6 local host address.
#define IN6ADDR_LOOPBACK_INIT
 Initialize an IPv6 loopback address.
#define INET_ADDRSTRLEN   16
 Length of a string form of a maximal IPv4 address.
#define INET6_ADDRSTRLEN   46
 Length of a string form of a maximal IPv6 address.
#define IPPROTO_IP   0
 Internet Protocol Version 4.
#define IPPROTO_ICMP   1
 Internet Control Message Protocol.
#define IPPROTO_TCP   6
 Transmission Control Protocol.
#define IPPROTO_UDP   17
 User Datagram Protocol.
#define IPPROTO_IPV6   41
 Internet Protocol Version 6.
#define IP_TTL   24
 TTL for unicast (get/set)
#define IPV6_JOIN_GROUP   17
 Join a multicast group (set)
#define IPV6_LEAVE_GROUP   18
 Leave a multicast group (set)
#define IPV6_MULTICAST_HOPS   19
 Hop limit for multicast (get/set)
#define IPV6_MULTICAST_IF   20
 Multicast interface (get/set)
#define IPV6_MULTICAST_LOOP   21
 Multicasts loopback (get/set)
#define IPV6_UNICAST_HOPS   22
 Hop limit for unicast (get/set)
#define IPV6_V6ONLY   23
 IPv6 only – no IPv4 (get/set)
#define IN6_IS_ADDR_UNSPECIFIED(a)
 Test if an IPv6 Address is unspecified.
#define IN6_IS_ADDR_LOOPBACK(a)
 Test if an IPv6 Address is a loopback address.
#define IN6_IS_ADDR_V4MAPPED(a)
 Test if an IPv6 Address is an IPv4 mapped address.
#define IN6_IS_ADDR_V4COMPAT(a)
 Test if an IPv6 Address is an IPv4 compatibility address.
#define IN6_IS_ADDR_LINKLOCAL(a)
 Test if an IPv6 Address is a link-local address.
#define IN6_IS_ADDR_SITELOCAL(a)
 Test if an IPv6 Address is a site-local address.
#define IN6_IS_ADDR_MULTICAST(a)   ((a)->__s6_addr.__s6_addr8[0] == 0xFF)
 Test if an IPv6 Address is a multicast address.
#define IN6_IS_ADDR_MC_NODELOCAL(a)
 Test if an IPv6 Address is a node-local multicast address.
#define IN6_IS_ADDR_MC_LINKLOCAL(a)
 Test if an IPv6 Address is a link-local multicast address.
#define IN6_IS_ADDR_MC_SITELOCAL(a)
 Test if an IPv6 Address is a site-local multicast address.
#define IN6_IS_ADDR_MC_ORGLOCAL(a)
 Test if an IPv6 Address is an organization-local multicast address.
#define IN6_IS_ADDR_MC_GLOBAL(a)
 Test if an IPv6 Address is a global multicast address.

Typedefs

typedef uint16_t in_port_t
 16-bit type used to store a value for an internet port.
typedef uint32_t in_addr_t
 32-bit value used to store an IPv4 address.

Variables

struct in6_addr in6addr_any
 IPv6 local host address.
struct in6_addr in6addr_loopback
 IPv6 loopback address.

Detailed Description

Definitions for the Internet address family.

This file contains the standard definitions (as directed by the POSIX 2008 standard) for internet-related functionality in the AF_INET address family. This does is not guaranteed to have everything that one might have in a fully-standard compliant implementation of the POSIX standard.

Author:
Lawrence Sebald

Macro Definition Documentation

#define IN6_IS_ADDR_LINKLOCAL (   a)
Value:
(((a)->__s6_addr.__s6_addr8[0] == 0xFE) && \
(((a)->__s6_addr.__s6_addr8[1] & 0xC0) == 0x80))

Test if an IPv6 Address is a link-local address.

This macro tests whether an IPv6 address (struct in6_addr *) is a link-local address.

Parameters:
aThe address to test (struct in6_addr *)
Returns:
Nonzero if the address is link-local, 0 otherwise.
#define IN6_IS_ADDR_LOOPBACK (   a)
Value:
((a)->__s6_addr.__s6_addr32[0] == 0 && \
(a)->__s6_addr.__s6_addr32[1] == 0 && \
(a)->__s6_addr.__s6_addr32[2] == 0 && \
(a)->__s6_addr.__s6_addr16[6] == 0 && \
(a)->__s6_addr.__s6_addr8[14] == 0 && \
(a)->__s6_addr.__s6_addr8[15] == 1)

Test if an IPv6 Address is a loopback address.

This macro tests whether an IPv6 address (struct in6_addr *) is a loopback address.

Parameters:
aThe address to test (struct in6_addr *)
Returns:
Nonzero if the address is a loopback, 0 otherwise.
#define IN6_IS_ADDR_MC_GLOBAL (   a)
Value:
(((a)->__s6_addr.__s6_addr8[1] & 0x0F) == 0x0E))

Test if an IPv6 Address is a global multicast address.

This macro tests whether an IPv6 address (struct in6_addr *) is a global multicast address.

Parameters:
aThe address to test (struct in6_addr *)
Returns:
Nonzero if the address is a global multicast address, 0 otherwise.
#define IN6_IS_ADDR_MC_LINKLOCAL (   a)
Value:
(((a)->__s6_addr.__s6_addr8[1] & 0x0F) == 0x02))

Test if an IPv6 Address is a link-local multicast address.

This macro tests whether an IPv6 address (struct in6_addr *) is a link-local multicast address.

Parameters:
aThe address to test (struct in6_addr *)
Returns:
Nonzero if the address is a link-local multicast address, 0 otherwise.
#define IN6_IS_ADDR_MC_NODELOCAL (   a)
Value:
(((a)->__s6_addr.__s6_addr8[1] & 0x0F) == 0x01))

Test if an IPv6 Address is a node-local multicast address.

This macro tests whether an IPv6 address (struct in6_addr *) is a node-local multicast address.

Parameters:
aThe address to test (struct in6_addr *)
Returns:
Nonzero if the address is a node-local multicast address, 0 otherwise.
#define IN6_IS_ADDR_MC_ORGLOCAL (   a)
Value:
(((a)->__s6_addr.__s6_addr8[1] & 0x0F) == 0x08))

Test if an IPv6 Address is an organization-local multicast address.

This macro tests whether an IPv6 address (struct in6_addr *) is an organization-local multicast address.

Parameters:
aThe address to test (struct in6_addr *)
Returns:
Nonzero if the address is an organization-local multicast address, 0 otherwise.
#define IN6_IS_ADDR_MC_SITELOCAL (   a)
Value:
(((a)->__s6_addr.__s6_addr8[1] & 0x0F) == 0x05))

Test if an IPv6 Address is a site-local multicast address.

This macro tests whether an IPv6 address (struct in6_addr *) is a site-local multicast address.

Parameters:
aThe address to test (struct in6_addr *)
Returns:
Nonzero if the address is a site-local multicast address, 0 otherwise.
#define IN6_IS_ADDR_MULTICAST (   a)    ((a)->__s6_addr.__s6_addr8[0] == 0xFF)

Test if an IPv6 Address is a multicast address.

This macro tests whether an IPv6 address (struct in6_addr *) is a multicast address.

Parameters:
aThe address to test (struct in6_addr *)
Returns:
Nonzero if the address is multicast, 0 otherwise.
#define IN6_IS_ADDR_SITELOCAL (   a)
Value:
(((a)->__s6_addr.__s6_addr8[0] == 0xFE) && \
(((a)->__s6_addr.__s6_addr8[1] & 0xC0) == 0xC0))

Test if an IPv6 Address is a site-local address.

This macro tests whether an IPv6 address (struct in6_addr *) is a site-local address.

Parameters:
aThe address to test (struct in6_addr *)
Returns:
Nonzero if the address is site-local, 0 otherwise.
#define IN6_IS_ADDR_UNSPECIFIED (   a)
Value:
((a)->__s6_addr.__s6_addr32[0] == 0 && \
(a)->__s6_addr.__s6_addr32[1] == 0 && \
(a)->__s6_addr.__s6_addr32[2] == 0 && \
(a)->__s6_addr.__s6_addr32[3] == 0)

Test if an IPv6 Address is unspecified.

This macro tests whether an IPv6 address (struct in6_addr *) is an unspecified address.

Parameters:
aThe address to test (struct in6_addr *)
Returns:
Nonzero if the address is unspecified, 0 otherwise.
#define IN6_IS_ADDR_V4COMPAT (   a)
Value:
((a)->__s6_addr.__s6_addr32[0] == 0 && \
(a)->__s6_addr.__s6_addr32[1] == 0 && \
(a)->__s6_addr.__s6_addr32[2] == 0 && \
(a)->__s6_addr.__s6_addr32[3] != 0 && \
(a)->__s6_addr.__s6_addr8[15] != 1)

Test if an IPv6 Address is an IPv4 compatibility address.

This macro tests whether an IPv6 address (struct in6_addr *) is an IPv4 compatibility address.

Parameters:
aThe address to test (struct in6_addr *)
Returns:
Nonzero if the address is IPv4 compat, 0 otherwise.
#define IN6_IS_ADDR_V4MAPPED (   a)
Value:
((a)->__s6_addr.__s6_addr32[0] == 0 && \
(a)->__s6_addr.__s6_addr32[1] == 0 && \
(a)->__s6_addr.__s6_addr16[4] == 0 && \
(a)->__s6_addr.__s6_addr16[5] == 0xFFFF)

Test if an IPv6 Address is an IPv4 mapped address.

This macro tests whether an IPv6 address (struct in6_addr *) is an IPv4 mapped address.

Parameters:
aThe address to test (struct in6_addr *)
Returns:
Nonzero if the address is IPv4 mapped, 0 otherwise.
#define IN6ADDR_ANY_INIT
Value:
{{{ 0, 0, 0, 0, 0, 0, 0, 0, \
0, 0, 0, 0, 0, 0, 0, 0 }}}

Initialize an IPv6 local host address.

This macro can be used to initialize a struct in6_addr to any lcoal address. It functions similarly to INADDR_ANY for IPv4.

#define IN6ADDR_LOOPBACK_INIT
Value:
{{{ 0, 0, 0, 0, 0, 0, 0, 0, \
0, 0, 0, 0, 0, 0, 0, 1 }}}

Initialize an IPv6 loopback address.

This macro can be used to initialize a struct in6_addr to the loopback address.

#define INADDR_ANY   0x00000000

Local IPv4 host address.

This address can be used by many things if you prefer to not specify the local address, and would rather it be detected automatically.

#define INADDR_BROADCAST   0xFFFFFFFF

IPv4 broadcast address.

This address is the normal IPv4 broadcast address (255.255.255.255).

#define INADDR_NONE   0xFFFFFFFF

IPv4 error address.

This address is non-standard, but is available on many systems. It is used to detect failure from some functions that normally return addresses (such as the inet_addr function).

#define INET6_ADDRSTRLEN   46

Length of a string form of a maximal IPv6 address.

#define INET_ADDRSTRLEN   16

Length of a string form of a maximal IPv4 address.

#define IPPROTO_ICMP   1

Internet Control Message Protocol.

#define IPPROTO_IP   0

Internet Protocol Version 4.

#define IPPROTO_IPV6   41

Internet Protocol Version 6.

#define IPPROTO_TCP   6

Transmission Control Protocol.

#define IPPROTO_UDP   17

User Datagram Protocol.

#define s6_addr   __s6_addr.__s6_addr8

Typedef Documentation

typedef uint32_t in_addr_t

32-bit value used to store an IPv4 address.

typedef uint16_t in_port_t

16-bit type used to store a value for an internet port.


Variable Documentation

struct in6_addr in6addr_any

IPv6 local host address.

This constant variable contains the IPv6 local host address.

struct in6_addr in6addr_loopback

IPv6 loopback address.

This constant variable contains the IPv6 loopback address.