A version of LWIP, provided for backwards compatibility.

Dependents:   AA_DemoBoard DemoBoard HelloServerDemo DemoBoard_RangeIndicator ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers netdb.h Source File

netdb.h

00001 /*
00002  * Redistribution and use in source and binary forms, with or without modification, 
00003  * are permitted provided that the following conditions are met:
00004  *
00005  * 1. Redistributions of source code must retain the above copyright notice,
00006  *    this list of conditions and the following disclaimer.
00007  * 2. Redistributions in binary form must reproduce the above copyright notice,
00008  *    this list of conditions and the following disclaimer in the documentation
00009  *    and/or other materials provided with the distribution.
00010  * 3. The name of the author may not be used to endorse or promote products
00011  *    derived from this software without specific prior written permission. 
00012  *
00013  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
00014  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
00015  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
00016  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
00017  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
00018  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
00019  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
00020  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
00021  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
00022  * OF SUCH DAMAGE.
00023  *
00024  * This file is part of the lwIP TCP/IP stack.
00025  * 
00026  * Author: Simon Goldschmidt
00027  *
00028  */
00029 
00030 #include "lwip/opt.h"
00031 
00032 #if LWIP_DNS && LWIP_SOCKET
00033 
00034 #include "lwip/sockets.h"
00035 
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif
00039 
00040 /* some rarely used options */
00041 #ifndef LWIP_DNS_API_DECLARE_H_ERRNO
00042 #define LWIP_DNS_API_DECLARE_H_ERRNO 1
00043 #endif
00044 
00045 #ifndef LWIP_DNS_API_DEFINE_ERRORS
00046 #define LWIP_DNS_API_DEFINE_ERRORS 1
00047 #endif
00048 
00049 #ifndef LWIP_DNS_API_DECLARE_STRUCTS
00050 #define LWIP_DNS_API_DECLARE_STRUCTS 1
00051 #endif
00052 
00053 #if LWIP_DNS_API_DEFINE_ERRORS
00054 /** Errors used by the DNS API functions, h_errno can be one of them */
00055 #define EAI_NONAME      200
00056 #define EAI_SERVICE     201
00057 #define EAI_FAIL        202
00058 #define EAI_MEMORY      203
00059 
00060 #define HOST_NOT_FOUND  210
00061 #define NO_DATA         211
00062 #define NO_RECOVERY     212
00063 #define TRY_AGAIN       213
00064 #endif /* LWIP_DNS_API_DEFINE_ERRORS */
00065 
00066 #if LWIP_DNS_API_DECLARE_STRUCTS
00067 struct hostent {
00068     char  *h_name;      /* Official name of the host. */
00069     char **h_aliases;   /* A pointer to an array of pointers to alternative host names,
00070                            terminated by a null pointer. */
00071     int    h_addrtype;  /* Address type. */
00072     int    h_length;    /* The length, in bytes, of the address. */
00073     char **h_addr_list; /* A pointer to an array of pointers to network addresses (in
00074                            network byte order) for the host, terminated by a null pointer. */
00075 #define h_addr h_addr_list[0] /* for backward compatibility */
00076 };
00077 
00078 struct addrinfo {
00079     int               ai_flags;      /* Input flags. */
00080     int               ai_family;     /* Address family of socket. */
00081     int               ai_socktype;   /* Socket type. */
00082     int               ai_protocol;   /* Protocol of socket. */
00083     socklen_t         ai_addrlen;    /* Length of socket address. */
00084     struct sockaddr  *ai_addr;       /* Socket address of socket. */
00085     char             *ai_canonname;  /* Canonical name of service location. */
00086     struct addrinfo  *ai_next;       /* Pointer to next in list. */
00087 };
00088 #endif /* LWIP_DNS_API_DECLARE_STRUCTS */
00089 
00090 #if LWIP_DNS_API_DECLARE_H_ERRNO
00091 /* application accessable error code set by the DNS API functions */
00092 extern int h_errno;
00093 #endif /* LWIP_DNS_API_DECLARE_H_ERRNO*/
00094 
00095 struct hostent *lwip_gethostbyname(const char *name);
00096 int lwip_gethostbyname_r(const char *name, struct hostent *ret, char *buf,
00097                 size_t buflen, struct hostent **result, int *h_errnop);
00098 void lwip_freeaddrinfo(struct addrinfo *ai);
00099 int lwip_getaddrinfo(const char *nodename,
00100        const char *servname,
00101        const struct addrinfo *hints,
00102        struct addrinfo **res);
00103 
00104 #if LWIP_COMPAT_SOCKETS
00105 #define gethostbyname(name) lwip_gethostbyname(name)
00106 #define gethostbyname_r(name, ret, buf, buflen, result, h_errnop) \
00107        lwip_gethostbyname_r(name, ret, buf, buflen, result, h_errnop)
00108 #define freeaddrinfo(addrinfo) lwip_freeaddrinfo(a)
00109 #define getaddrinfo(nodname, servname, hints, res) \
00110        lwip_getaddrinfo(nodname, servname, hints, res)
00111 #endif /* LWIP_COMPAT_SOCKETS */
00112 
00113 #ifdef __cplusplus
00114 }
00115 #endif
00116 
00117 #endif /* LWIP_DNS && LWIP_SOCKET */