Version of http://mbed.org/cookbook/NetServicesTribute with setting set the same for LPC2368

Dependents:   UDPSocketExample 24LCxx_I2CApp WeatherPlatform_pachube HvZServerLib ... more

Committer:
simon
Date:
Tue Nov 23 14:15:36 2010 +0000
Revision:
0:350011bf8be7
Experimental version for testing UDP

Who changed what in which revision?

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