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