2015-07-08 21:40:52 +02:00
|
|
|
/****************************************************************************
|
2018-05-29 21:21:26 +02:00
|
|
|
* libs/libc/netdb/lib_gethostbyname.c
|
2015-07-08 21:40:52 +02:00
|
|
|
*
|
|
|
|
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
|
|
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
|
|
* used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <netdb.h>
|
|
|
|
|
2015-07-10 21:30:09 +02:00
|
|
|
#ifdef CONFIG_LIBC_NETDB
|
2015-07-08 21:40:52 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2018-06-08 15:07:21 +02:00
|
|
|
* Name: gethostbyname
|
2015-07-08 21:40:52 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* The 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
|
|
|
|
* 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.
|
2015-07-08 21:42:36 +02:00
|
|
|
*
|
2015-07-08 21:40:52 +02:00
|
|
|
* 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, gethostbyname() will set h_errno to
|
|
|
|
* indicate the error
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
FAR struct hostent *gethostbyname(FAR const char *name)
|
|
|
|
{
|
2020-03-31 20:21:04 +02:00
|
|
|
return gethostbyname2(name, AF_UNSPEC);
|
2015-07-08 21:40:52 +02:00
|
|
|
}
|
|
|
|
|
2015-07-10 21:30:09 +02:00
|
|
|
#endif /* CONFIG_LIBC_NETDB */
|