sdk/modules/lte/altcom/api/socket/altcom_gethostbyname.c
/****************************************************************************
 * Name: altcom_gethostbyname
 *
 * Description:
 *   The altcom_gethostbyname() function returns a structure of type hostent
 *   for the given host name. Here name is either a hostname, or an IPv4
 *   address in standard dot notation (as for inet_addr(3)), or an IPv6
 *   address in colon (and possibly dot) notation.
 *
 *   If name is an IPv4 or IPv6 address, no lookup is performed and
 *   altcom_gethostbyname_r() simply copies name into the h_name field
 *   and its struct in_addr equivalent into the h_addr_list[0] field of the
 *   returned hostent structure.
 *
 * Input Parameters:
 *   name - The name of the host to find.
 *
 * Returned Value:
 *   Upon successful completion, this function will return a pointer to a
 *   hostent structure if the requested entry was found, and a null pointer
 *   if the end of the database was reached or the requested entry was not
 *   found.
 *
 *   Upon unsuccessful completion, altcom_gethostbyname() will set h_errno to
 *   indicate the error
 *
 ****************************************************************************/
altcom_gethostbyname
Description:
The altcom_gethostbyname() function returns a structure of type hostent
for the given host name. Here name is either a hostname, or an IPv4
address in standard dot notation (as for inet_addr(3)), or an IPv6
address in colon (and possibly dot) notation.

If name is an IPv4 or IPv6 address, no lookup is performed and
altcom_gethostbyname_r() simply copies name into the h_name field
and its struct in_addr equivalent into the h_addr_list[0] field of the
returned hostent structure.

Input Parameters:
name - The name of the host to find.

Returned Value:
Upon successful completion, this function will return a pointer to a
hostent structure if the requested entry was found, and a null pointer
if the end of the database was reached or the requested entry was not
found.

Upon unsuccessful completion, altcom_gethostbyname() will set h_errno to
indicate the error
altcom_gethostbyname Description : The altcom_gethostbyname () function returns a structure of type hostent for the given host name . Here name is either a hostname or an IPv4 address in standard dot notation ( as for inet_addr ( 3 )) or an IPv6 address in colon ( and possibly dot ) notation . If name is an IPv4 or IPv6 address no lookup is performed and altcom_gethostbyname_r () simply copies name into the h_name field and its struct in_addr equivalent into the h_addr_list [ 0 ] field of the returned hostent structure . Input Parameters : name - The name of the host to find . Returned Value : Upon successful completion this function will return a pointer to a hostent structure if the requested entry was found and a null pointer if the end of the database was reached or the requested entry was not found . Upon unsuccessful completion altcom_gethostbyname () will set h_errno to indicate the error
struct altcom_hostent *altcom_gethostbyname(const char *name)
{
  int32_t                      ret;
  uint32_t                     namelen = 0;
  static struct altcom_hostent s_hostent;
  if (!altcom_isinit())
    {
      DBGIF_LOG_ERROR("Not intialized\n");
      return NULL;
    }
  if (!name)
    {
      DBGIF_LOG_ERROR("Invalid param\n");
      return NULL;
    }
  namelen = strlen(name);
  if (!namelen || APICMD_GETHOSTBYNAME_NAME_MAX_LENGTH < namelen)
    {
      DBGIF_LOG1_ERROR("Invalid param. namelen = [%d]\n", namelen);
      return NULL;
    }
  ret = gethostbyname_request(name, namelen, &s_hostent);
  if (GETHOSTBYNAME_REQ_SUCCESS != ret)
    {
      return NULL;
    }
  return &s_hostent;
}
struct altcom_hostent * altcom_gethostbyname ( const char * name ) { int32_t ret ; uint32_t namelen = 0 ; static struct altcom_hostent s_hostent ; if ( ! altcom_isinit ( ) ) { DBGIF_LOG_ERROR ( " \n " ) ; return NULL ; } if ( ! name ) { DBGIF_LOG_ERROR ( " \n " ) ; return NULL ; } namelen = strlen ( name ) ; if ( ! namelen || APICMD_GETHOSTBYNAME_NAME_MAX_LENGTH < namelen ) { DBGIF_LOG1_ERROR ( " \n " , namelen ) ; return NULL ; } ret = gethostbyname_request ( name , namelen , & s_hostent ) ; if ( GETHOSTBYNAME_REQ_SUCCESS != ret ) { return NULL ; } return & s_hostent ; }
Name: altcom_gethostbyname
 Description:
   The altcom_gethostbyname() function returns a structure of type hostent
   for the given host name.
Name : altcom_gethostbyname Description : The altcom_gethostbyname () function returns a structure of type hostent for the given host name .