2 * Redistribution and use in source and binary forms, with or without modification,
\r
3 * are permitted provided that the following conditions are met:
\r
5 * 1. Redistributions of source code must retain the above copyright notice,
\r
6 * this list of conditions and the following disclaimer.
\r
7 * 2. Redistributions in binary form must reproduce the above copyright notice,
\r
8 * this list of conditions and the following disclaimer in the documentation
\r
9 * and/or other materials provided with the distribution.
\r
10 * 3. The name of the author may not be used to endorse or promote products
\r
11 * derived from this software without specific prior written permission.
\r
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
\r
14 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
\r
15 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
\r
16 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
\r
17 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
\r
18 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
\r
19 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
\r
20 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
\r
21 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
\r
24 * This file is part of the lwIP TCP/IP stack.
\r
26 * Author: Simon Goldschmidt
\r
30 #include "lwip/opt.h"
\r
32 #if LWIP_DNS && LWIP_SOCKET
\r
34 #include "lwip/sockets.h"
\r
36 /* some rarely used options */
\r
37 #ifndef LWIP_DNS_API_DECLARE_H_ERRNO
\r
38 #define LWIP_DNS_API_DECLARE_H_ERRNO 1
\r
41 #ifndef LWIP_DNS_API_DEFINE_ERRORS
\r
42 #define LWIP_DNS_API_DEFINE_ERRORS 1
\r
45 #ifndef LWIP_DNS_API_DECLARE_STRUCTS
\r
46 #define LWIP_DNS_API_DECLARE_STRUCTS 1
\r
49 #if LWIP_DNS_API_DEFINE_ERRORS
\r
50 /** Errors used by the DNS API functions, h_errno can be one of them */
\r
51 #define EAI_NONAME 200
\r
52 #define EAI_SERVICE 201
\r
53 #define EAI_FAIL 202
\r
54 #define EAI_MEMORY 203
\r
56 #define HOST_NOT_FOUND 210
\r
58 #define NO_RECOVERY 212
\r
59 #define TRY_AGAIN 213
\r
60 #endif /* LWIP_DNS_API_DEFINE_ERRORS */
\r
62 #if LWIP_DNS_API_DECLARE_STRUCTS
\r
64 char *h_name; /* Official name of the host. */
\r
65 char **h_aliases; /* A pointer to an array of pointers to alternative host names,
\r
66 terminated by a null pointer. */
\r
67 int h_addrtype; /* Address type. */
\r
68 int h_length; /* The length, in bytes, of the address. */
\r
69 char **h_addr_list; /* A pointer to an array of pointers to network addresses (in
\r
70 network byte order) for the host, terminated by a null pointer. */
\r
71 #define h_addr h_addr_list[0] /* for backward compatibility */
\r
75 int ai_flags; /* Input flags. */
\r
76 int ai_family; /* Address family of socket. */
\r
77 int ai_socktype; /* Socket type. */
\r
78 int ai_protocol; /* Protocol of socket. */
\r
79 socklen_t ai_addrlen; /* Length of socket address. */
\r
80 struct sockaddr *ai_addr; /* Socket address of socket. */
\r
81 char *ai_canonname; /* Canonical name of service location. */
\r
82 struct addrinfo *ai_next; /* Pointer to next in list. */
\r
84 #endif /* LWIP_DNS_API_DECLARE_STRUCTS */
\r
86 #if LWIP_DNS_API_DECLARE_H_ERRNO
\r
87 /* application accessable error code set by the DNS API functions */
\r
89 #endif /* LWIP_DNS_API_DECLARE_H_ERRNO*/
\r
91 struct hostent *lwip_gethostbyname(const char *name);
\r
92 int lwip_gethostbyname_r(const char *name, struct hostent *ret, char *buf,
\r
93 size_t buflen, struct hostent **result, int *h_errnop);
\r
94 void lwip_freeaddrinfo(struct addrinfo *ai);
\r
95 int lwip_getaddrinfo(const char *nodename,
\r
96 const char *servname,
\r
97 const struct addrinfo *hints,
\r
98 struct addrinfo **res);
\r
100 #if LWIP_COMPAT_SOCKETS
\r
101 #define gethostbyname(name) lwip_gethostbyname(name)
\r
102 #define gethostbyname_r(name, ret, buf, buflen, result, h_errnop) \
\r
103 lwip_gethostbyname_r(name, ret, buf, buflen, result, h_errnop)
\r
104 #define freeaddrinfo(addrinfo) lwip_freeaddrinfo(a)
\r
105 #define getaddrinfo(nodname, servname, hints, res) \
\r
106 lwip_getaddrinfo(nodname, servname, hints, res)
\r
107 #endif /* LWIP_COMPAT_SOCKETS */
\r
109 #endif /* LWIP_DNS && LWIP_SOCKET */
\r