# inet.h File Reference

`#include <netinet/in.h>`

Include dependency graph for inet.h:

## Defines
#define | _INET_IN_H 1
## Functions
int16_t | inet_pton (int16_t af, const char *src, in6_addr_t *dst)
const char * | inet_ntop (int16_t af, const in6_addr_t *src, char *dst, uint8_t cnt)
uint16_t | ntohs (uint16_t netshort)
uint16_t | htons (uint16_t hostshort)
uint32_t | ntohl (uint32_t netlong)
uint32_t | htonl (uint32_t hostlong)

## Define Documentation

#define _INET_IN_H 1

## Function Documentation

uint32_t htonl | ( | uint32_t | hostlong | ) |

Convert a host byte order (little-endian) long, hostlong, by returning a network byte order (big-endian) long.

uint16_t htons | ( | uint16_t | hostshort | ) |

Convert a host byte order (little-endian) short, hostshort, by returning a network byte order (big-endian) short.

const char* inet_ntop | ( | int16_t | af,
|  | const in6_addr_t * | src,
|  | char * | dst,
|  | uint8_t | cnt |
| ) |  |  |

This system call converts a network address structure defined in src to the character string dst using af address family.

Precondition:
  dst is a buffer large enough for the family address

Postcondition:
  dst contains the string corresponding to the address in src

Parameters:

  `[in]` | af | AF address family. See AFEnums.
  `[in]` | src | contains an IP address string
  `[out]` | dst | string buffer
  `[in]` | cnt | number of bytes in the buffer

Returns:
  dst if succeed or NULL if fail and errno is set appropriately
  - EINVAL if invalid parameters are passed

int16_t inet_pton | ( | int16_t | af,
|  | const char * | src,
|  | in6_addr_t * | dst |
| ) |  |  |

This system call converts the character string src into a network address structure in the af address family, then copies the network address structure to dst.

Precondition:
  src is a null terminated string.

Postcondition:
  dst contains the correct network address corresponds to the src

Parameters:

  `[in]` | af | AF address family. See AFEnums.
  `[in]` | src | contains an IP address string
  `[out]` | dst | copy into this network data structure

Returns:
  0 if succeed or -1 if fail and errno is set appropriately
  - EINVAL if invalid parameters are passed

uint32_t ntohl | ( | uint32_t | netlong | ) |

Convert a network byte order (big-endian) long, netlong, by returning a host byte order (little-endian) long.

uint16_t ntohs | ( | uint16_t | netshort | ) |

Convert a network byte order (big-endian) short, netshort, by returning a host byte order (little-endian) short.