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