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