/******************************************************/
/* Copyright (C) 2008 Arch Rock Corporation           */
/* License Agreement: refer to LICENSE.txt            */
/*                                                    */
/******************************************************/

#ifndef _INET_IN_H
#define _INET_IN_H    1

#include <netinet/in.h>

/*! This system call converts the character string \em src
 *  into a network address structure in the \em af address
 *  family, then copies the network address structure to 
 *  \em dst.
 *
 *  \pre \em src is a null terminated string.
 *  \post \em dst contains the correct network
 *        address corresponds to the \em src
 *
 *  @param[in] af AF address family.  See #AFEnums.
 *  @param[in] src contains an IP address string
 *  @param[out] dst copy into this network data structure
 *  \return 0 if succeed or -1 if fail and errno is set appropriately
 *    \li EINVAL if invalid parameters are passed
 */
int16_t inet_pton (int16_t af, const char *src,
		   in6_addr_t * dst);


/*! This system call converts a network address structure 
 *  defined in \em src to the character string \em dst
 *  using \em af address family.
 *
 *  \pre \em dst is a buffer large enough for the \af
 *               family address
 *  \post \em dst contains the string corresponding
 *        to the address in \em src
 *
 *  @param[in] af AF address family.  See #AFEnums.
 *  @param[in] src contains an IP address string
 *  @param[out] dst string buffer
 *  @param[in] cnt number of bytes in the buffer
 *  \return dst if succeed or NULL if fail and errno is set appropriately
 *    \li EINVAL if invalid parameters are passed
 */
const char *inet_ntop(int16_t af, const in6_addr_t *src,
		      char *dst, uint8_t cnt);

/*!  Convert a network byte order (big-endian) short, \em netshort,
 *   by returning a host byte order (little-endian) short.
 */
uint16_t ntohs(uint16_t netshort);

/*!  Convert a host byte order (little-endian) short, \em hostshort,
 *   by returning a network byte order (big-endian) short.
 */
uint16_t htons(uint16_t hostshort);

/*!  Convert a network byte order (big-endian) long, \em netlong,
 *   by returning a host byte order (little-endian) long.
 */
uint32_t ntohl(uint32_t netlong);

/*!  Convert a host byte order (little-endian) long, \em hostlong,
 *   by returning a network byte order (big-endian) long.
 */
uint32_t htonl(uint32_t hostlong);

#endif // _INET_IN_H
