Library for Bert van Dam's book "ARM MICROCONTROLLERS" For all chapters with internet.

Dependencies:   mbed

Committer:
ICTFBI
Date:
Fri Oct 16 14:28:26 2015 +0000
Revision:
0:4edb816d21e1
Pre-update 16-10-15

Who changed what in which revision?

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