NetServices Stack source

Dependents:   HelloWorld ServoInterfaceBoardExample1 4180_Lab4

Committer:
donatien
Date:
Fri Jun 11 16:05:15 2010 +0000
Revision:
0:632c9925f013

        

Who changed what in which revision?

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