sdk/modules/lte/altcom/api/socket/altcom_inet_ntop.c
/****************************************************************************
 * Name: altcom_inet_ntop
 *
 * Description:
 *  The altcom_inet_ntop() function converts a numeric address into a text
 *  string suitable for presentation.
 *
 * Input Parameters:
 *   af   - The af argument specifies the family of the address. This can be
 *          AF_INET or AF_INET6.
 *   src  - The src argument points to a buffer holding an address of the
 *          specified type.  The address must be in network byte order.
 *   dst  - The dest argument points to a buffer where the function stores
 *          the resulting text string; it shall not be NULL.
 *   size - The size argument specifies the size of this buffer, which must
 *          be large enough to hold the text string (ALTCOM_INET_ADDRSTRLEN
 *          characters for IPv4, ALTCOM_INET6_ADDRSTRLEN characters for
 *          IPv6).
 *
 * Returned Value:
 *   altcom_inet_ntop() returns a pointer to the buffer containing the text
 *   string if the conversion succeeds. Otherwise, NULL is returned and the
 *   errno is set to indicate the error.
 *   There follow errno values may be set:
 *
 *   EAFNOSUPPORT - The af argument is invalid.
 *   ENOSPC - The size of the inet_ntop() result buffer is inadequate
 *
 ****************************************************************************/
altcom_inet_ntop
Description:
The altcom_inet_ntop() function converts a numeric address into a text
string suitable for presentation.

Input Parameters:
af   - The af argument specifies the family of the address.

Returned Value:
altcom_inet_ntop() returns a pointer to the buffer containing the text
string if the conversion succeeds. Otherwise, NULL is returned and the
errno is set to indicate the error.
There follow errno values may be set.

The af argument is invalid.
ENOSPC - The size of the inet_ntop() result buffer is inadequate
altcom_inet_ntop Description : The altcom_inet_ntop () function converts a numeric address into a text string suitable for presentation . Input Parameters : af - The af argument specifies the family of the address . Returned Value : altcom_inet_ntop () returns a pointer to the buffer containing the text string if the conversion succeeds . Otherwise NULL is returned and the errno is set to indicate the error . There follow errno values may be set . The af argument is invalid . ENOSPC - The size of the inet_ntop () result buffer is inadequate
const char *altcom_inet_ntop(int af, const void *src, char *dst,
                             altcom_socklen_t size)
{
  int ret;
  DBGIF_ASSERT(src && dst, "Invalid parameter\n");
  switch (af)
    {
    case ALTCOM_AF_INET:
      ret = inet_ipv4_ntop(src, dst, size);
      break;
    case ALTCOM_AF_INET6:
      ret = inet_ipv6_ntop(src, dst, size);
      break;
    default:
      ret = -ALTCOM_EAFNOSUPPORT;
      break;
    }
  if (ret < 0)
    {
      altcom_seterrno(-ret);
      memset(dst, 0, size);
      return NULL;
    }
  return dst;
}
const char * altcom_inet_ntop ( int af , const void * src , char * dst , altcom_socklen_t size ) { int ret ; DBGIF_ASSERT ( src && dst , " \n " ) ; switch ( af ) { case ALTCOM_AF_INET : ret = inet_ipv4_ntop ( src , dst , size ) ; break ; case ALTCOM_AF_INET6 : ret = inet_ipv6_ntop ( src , dst , size ) ; break ; default : ret = - ALTCOM_EAFNOSUPPORT ; break ; } if ( ret < 0 ) { altcom_seterrno ( - ret ) ; memset ( dst , 0 , size ) ; return NULL ; } return dst ; }
Name: altcom_inet_ntop
 Description:
  The altcom_inet_ntop() function converts a numeric address into a text
  string suitable for presentation.
Name : altcom_inet_ntop Description : The altcom_inet_ntop () function converts a numeric address into a text string suitable for presentation .
/* Do the conversion according to the IP version */ /* Handle errors in the conversion */ /* Return success */