2015-07-08 21:40:52 +02:00
|
|
|
/****************************************************************************
|
2018-05-29 21:21:26 +02:00
|
|
|
* libs/libc/netdb/lib_gethostbynamer.c
|
2015-07-08 21:40:52 +02:00
|
|
|
*
|
2021-03-02 15:54:21 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2015-07-08 21:40:52 +02:00
|
|
|
*
|
2021-03-02 15:54:21 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2015-07-08 21:40:52 +02:00
|
|
|
*
|
2021-03-02 15:54:21 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2015-07-08 21:40:52 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* 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
|
|
|
|
2015-07-10 21:30:09 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2018-06-08 15:07:21 +02:00
|
|
|
* Name: gethostbyname_r
|
2015-07-10 21:30:09 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* The gethostbyname_r() 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.
|
|
|
|
*
|
2020-03-30 14:49:28 +02:00
|
|
|
* gethostname_r() is *not* POSIX but is similar to a Glibc extension and
|
|
|
|
* is used internally by NuttX to implement the POSIX gethostname().
|
2015-07-10 21:30:09 +02:00
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* name - The name of the host to find.
|
|
|
|
* host - Caller provided location to return the host data.
|
|
|
|
* buf - Caller provided buffer to hold string data associated with the
|
|
|
|
* host data.
|
|
|
|
* buflen - The size of the caller-provided buffer
|
2020-03-31 20:21:04 +02:00
|
|
|
* result - There host entry returned in the event of a success.
|
2015-07-10 21:30:09 +02:00
|
|
|
* h_errnop - There h_errno value returned in the event of a failure.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) is returned on success, -1 (ERROR) is returned on a failure
|
|
|
|
* with the returned h_errno value provided the reason for the failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-03-31 20:21:04 +02:00
|
|
|
int gethostbyname_r(FAR const char *name,
|
|
|
|
FAR struct hostent *host, FAR char *buf,
|
|
|
|
size_t buflen, FAR struct hostent **result,
|
|
|
|
FAR int *h_errnop)
|
2015-07-10 21:30:09 +02:00
|
|
|
{
|
2020-03-31 20:21:04 +02:00
|
|
|
return gethostbyname2_r(name, AF_UNSPEC,
|
|
|
|
host, buf, buflen, result, h_errnop);
|
2015-07-10 21:30:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_LIBC_NETDB */
|