Inet.h functions

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files
- Examples

Functions
Inet.h functions
Evil

This header provides functions ported from Unix in arpa/inet.h. More...

## Functions
int | evil_inet_pton (int af, const char *src, void *dst)
| Convert IPv4 and IPv6 addresses from text to binary form. More...
const char * | evil_inet_ntop (int af, const char *src, void *dst, size_t size)
| Convert IPv4 and IPv6 addresses from binary to text form. More...

## Detailed Description

This header provides functions ported from Unix in arpa/inet.h.

## Function Documentation

int evil_inet_pton | ( | int | af,
|  | const char * | src,
|  | void * | dst
| ) |  |

Convert IPv4 and IPv6 addresses from text to binary form.

Parameters

  af | The address family.
  src | The address to convert.
  dst | The converted address structure.

Returns
  1 on success, 0 or -1 otherwise.

This function converts IPv4 and IPv6 addresses from `src` to the binary form `dst`. The following address families to pass to `af` are currently supported:

- i AF_INET: `src` points to a character string containing an IPv4 network address in dotted-decimal format, "ddd.ddd.ddd.ddd", where ddd is a decimal number of up to three digits in the range 0 to
  1. The address is converted to a struct in_addr and copied to dst, which must be sizeof(struct in_addr) (4) bytes (32 bits) long.
- AF_INET6: `src` points to a character string containing an IPv6 network address. The address is converted to a struct in6_addr and copied to dst, which must be sizeof(struct in6_addr) (16) bytes (128 bits) long. The allowed formats for IPv6 addresses follow these rules:
  1. The preferred format is x:x:x:x:x:x:x:x. This form consists of eight hexadecimal numbers, each of which expresses a 16-bit value (i.e., each x can be up to 4 hex digits).
  2. A series of contiguous zero values in the preferred format can be abbreviated to ::. Only one instance of :: can occur in an address. For example, the loopback address 0:0:0:0:0:0:0:1 can be abbreviated as ::1. The wildcard address, consisting of all zeros, can be written as ::.
  3. An alternate format is useful for expressing IPv4-mapped IPv6 addresses. This form is written as x:x:x:x:x:x:d.d.d.d, where the six leading xs are hexadecimal values that define the six most-significant 16-bit pieces of the address (i.e., 96 bits), and the ds express a value in dotted-decimal notation that defines the least significant 32 bits of the address. An example of such an address is :: FFFF:204.152.189.116.

On success this function returns 1 (network address was successfully converted). 0 is returned if `src` does not contain a character string representing a valid network address in the specified address family. If af does not contain a valid address family, -1 is returned and errno is set to EAFNOSUPPORT.

See also
  evil_inet_ntop()
  inet_ntop()

Conformity: POSIX.1-2001.

Supported OS: Windows XP, CE.

const char* evil_inet_ntop | ( | int | af,
|  | const char * | src,
|  | void * | dst,
|  | size_t | size
| ) |  |

Convert IPv4 and IPv6 addresses from binary to text form.

Parameters

  af | The address family.
  src | The address structure to convert.
  dst | A buffer containing the converted string.
  size | The size of the buffer.

Returns
  1 on success, 0 otherwise.

This function converts the network address structure `src` in the `af` address family into a character string. The resulting string is copied to the buffer pointed to by `dst`, which must be a non-NULL pointer. The caller specifies the number of bytes available in this buffer in the argument `size`. The following address families to pass to `af` are currently supported:

- AF_INET: `src` points to a struct in_addr (in network byte order) which is converted to an IPv4 network address in the dotted-decimal format, "ddd.ddd.ddd.ddd". The buffer `dst` must be at least INET_ADDRSTRLEN bytes long.
- AF_INET6: `src` points to a struct in6_addr (in network byte order) which is converted to a representation of this address in the most appropriate IPv6 network address format for this address. The buffer `dst` must be at least INET6_ADDRSTRLEN bytes long.

On success, this function returns a non-NULL pointer to `dst`. NULL is returned if there was an error, with errno set to indicate the error.

See also
  evil_inet_pton()
  inet_pton()

Conformity: POSIX.1-2001.

Supported OS: Windows XP, CE.