Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 211 lines (177 sloc) 7.075 kb
483ff1c @yangtse Constantine Sapuntzakis threaded resolver enhancements
yangtse authored
1 #ifndef HEADER_CURL_HOSTIP_H
2 #define HEADER_CURL_HOSTIP_H
ba4e69b @bagder updated source code boilerplate/header
authored
3 /***************************************************************************
8d76d40 @bagder removed trailing whitespace
authored
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
ae1912c @bagder Initial revision
authored
8 * \___|\___/|_| \_\_____|
9 *
67eb679 @bagder ipv6: only probe once
authored
10 * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
ae1912c @bagder Initial revision
authored
11 *
ba4e69b @bagder updated source code boilerplate/header
authored
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at http://curl.haxx.se/docs/copyright.html.
8d76d40 @bagder removed trailing whitespace
authored
15 *
24dee48 @bagder dual-license fix
authored
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
ba4e69b @bagder updated source code boilerplate/header
authored
18 * furnished to do so, under the terms of the COPYING file.
ae1912c @bagder Initial revision
authored
19 *
24dee48 @bagder dual-license fix
authored
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
ae1912c @bagder Initial revision
authored
22 *
ba4e69b @bagder updated source code boilerplate/header
authored
23 ***************************************************************************/
ae1912c @bagder Initial revision
authored
24
2cff251 @bagder Curl_resolv() now returns a different struct, and it contains a referenc...
authored
25 #include "setup.h"
8d7f402 Make cach'ing work with threads now, there are now three cases:
Sterling Hughes authored
26 #include "hash.h"
0ce97f7 @yangtse Use our Curl_addrinfo definition even when an addrinfo struct is availab...
yangtse authored
27 #include "curl_addrinfo.h"
7de2f92 @bagder async resolvers: further cleanups
authored
28 #include "asyn.h"
8d7f402 Make cach'ing work with threads now, there are now three cases:
Sterling Hughes authored
29
a6c915a @yangtse fix compiler warning: external declaration in primary source file
yangtse authored
30 #ifdef HAVE_SETJMP_H
31 #include <setjmp.h>
32 #endif
33
afdfa4b @gknauf minor patches to enable building for NetWare CLIB.
gknauf authored
34 #ifdef NETWARE
ac02d37 @gknauf moved ugly NetWare hack to hostip.h so that hostip.c uses it too.
gknauf authored
35 #undef in_addr_t
afdfa4b @gknauf minor patches to enable building for NetWare CLIB.
gknauf authored
36 #define in_addr_t unsigned long
ac02d37 @gknauf moved ugly NetWare hack to hostip.h so that hostip.c uses it too.
gknauf authored
37 #endif
38
c39858a @bagder Source cleanups. The major one being that we now _always_ use a Curl_add...
authored
39 /* Allocate enough memory to hold the full name information structs and
40 * everything. OSF1 is known to require at least 8872 bytes. The buffer
41 * required for storing all possible aliases and IP numbers is according to
42 * Stevens' Unix Network Programming 2nd edition, p. 304: 8192 bytes!
43 */
44 #define CURL_HOSTENT_SIZE 9000
45
46 #define CURL_TIMEOUT_RESOLVE 300 /* when using asynch methods, we allow this
47 many seconds for a name resolve */
48
49 #define CURL_ASYNC_SUCCESS CURLE_OK
50
f6e2bfd @bagder Jun-ichiro itojun Hagino's IPv6 adjustments
authored
51 struct addrinfo;
48dc74a @bagder more transparant support for IPv6 name resolving
authored
52 struct hostent;
53 struct SessionHandle;
b736123 @bagder ares awareness/usage/support added. If configure --enable-ares is used, ...
authored
54 struct connectdata;
f6e2bfd @bagder Jun-ichiro itojun Hagino's IPv6 adjustments
authored
55
56f17d2 @bagder I made the torture test on test 530 go through. This was actually due to
authored
56 /*
57 * Curl_global_host_cache_init() initializes and sets up a global DNS cache.
58 * Global DNS cache is general badness. Do not use. This will be removed in
59 * a future version. Use the share interface instead!
60 *
991505e @bagder Woops, partly revert my previous commit and do it slightly differently i...
authored
61 * Returns a struct curl_hash pointer on success, NULL on failure.
56f17d2 @bagder I made the torture test on test 530 go through. This was actually due to
authored
62 */
991505e @bagder Woops, partly revert my previous commit and do it slightly differently i...
authored
63 struct curl_hash *Curl_global_host_cache_init(void);
8d7f402 Make cach'ing work with threads now, there are now three cases:
Sterling Hughes authored
64 void Curl_global_host_cache_dtor(void);
6de7dc5 @bagder Sterling Hughes' provided initial DNS cache source code.
authored
65
2cff251 @bagder Curl_resolv() now returns a different struct, and it contains a referenc...
authored
66 struct Curl_dns_entry {
67 Curl_addrinfo *addr;
fb5f332 @bagder - Constantine Sapuntzakis posted bug #2891595
authored
68 /* timestamp == 0 -- entry not in hostcache
69 timestamp != 0 -- entry is in hostcache */
2cff251 @bagder Curl_resolv() now returns a different struct, and it contains a referenc...
authored
70 time_t timestamp;
71 long inuse; /* use-counter, make very sure you decrease this
72 when you're done using the address you received */
73 };
74
66eb98b @bagder unlock dns cache entries with a function call instead of a variable fidd...
authored
75 /*
76 * Curl_resolv() returns an entry with the info for the specified host
77 * and port.
78 *
79 * The returned data *MUST* be "unlocked" with Curl_resolv_unlock() after
80 * use, or we'll leak memory!
81 */
245e312 @bagder Made defines instead of plain numbers for the Curl_resolv() return code ...
authored
82 /* return codes */
4adcf7e @dfandrich Moved all signal-based name resolution timeout handling into a single ne...
dfandrich authored
83 #define CURLRESOLV_TIMEDOUT -2
245e312 @bagder Made defines instead of plain numbers for the Curl_resolv() return code ...
authored
84 #define CURLRESOLV_ERROR -1
85 #define CURLRESOLV_RESOLVED 0
86 #define CURLRESOLV_PENDING 1
a55c70d Constify 'hostname' and 'service' to various resolver functions.
Gisle Vanem authored
87 int Curl_resolv(struct connectdata *conn, const char *hostname,
245e312 @bagder Made defines instead of plain numbers for the Curl_resolv() return code ...
authored
88 int port, struct Curl_dns_entry **dnsentry);
4adcf7e @dfandrich Moved all signal-based name resolution timeout handling into a single ne...
dfandrich authored
89 int Curl_resolv_timeout(struct connectdata *conn, const char *hostname,
90 int port, struct Curl_dns_entry **dnsentry,
bdf1724 @yangtse take 2 at fixing compiler warning: argument might be clobbered by `longj...
yangtse authored
91 long timeoutms);
2cff251 @bagder Curl_resolv() now returns a different struct, and it contains a referenc...
authored
92
67eb679 @bagder ipv6: only probe once
authored
93 #ifdef CURLRES_IPV6
94 /*
95 * Curl_ipv6works() returns TRUE if ipv6 seems to work.
96 */
97 bool Curl_ipv6works(void);
98 #else
99 #define Curl_ipv6works() FALSE
100 #endif
101
648e82f @bagder Major hostip.c cleanup and split into multiple files and easier #ifdef
authored
102 /*
103 * Curl_ipvalid() checks what CURL_IPRESOLVE_* requirements that might've
104 * been set and returns TRUE if they are OK.
105 */
a1f32ff @bagder ip_version: moved to connection struct
authored
106 bool Curl_ipvalid(struct connectdata *conn);
648e82f @bagder Major hostip.c cleanup and split into multiple files and easier #ifdef
authored
107
24d84da @bagder asynch resolvers: cleanup
authored
108
ca015f1 @novikov-dorogatv asynch resolvers: unified
novikov-dorogatv authored
109 /*
648e82f @bagder Major hostip.c cleanup and split into multiple files and easier #ifdef
authored
110 * Curl_getaddrinfo() is the generic low-level name resolve API within this
111 * source file. There are several versions of this function - for different
112 * name resolve layers (selected at build-time). They all take this same set
113 * of arguments
114 */
115 Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
a55c70d Constify 'hostname' and 'service' to various resolver functions.
Gisle Vanem authored
116 const char *hostname,
648e82f @bagder Major hostip.c cleanup and split into multiple files and easier #ifdef
authored
117 int port,
118 int *waitp);
119
686d907 @bagder First curl_multi_socket() commit. Should primarily be considered as an i...
authored
120
66eb98b @bagder unlock dns cache entries with a function call instead of a variable fidd...
authored
121 /* unlock a previously resolved dns entry */
686d907 @bagder First curl_multi_socket() commit. Should primarily be considered as an i...
authored
122 void Curl_resolv_unlock(struct SessionHandle *data,
123 struct Curl_dns_entry *dns);
66eb98b @bagder unlock dns cache entries with a function call instead of a variable fidd...
authored
124
2cff251 @bagder Curl_resolv() now returns a different struct, and it contains a referenc...
authored
125 /* for debugging purposes only: */
126 void Curl_scan_cache_used(void *user, void *ptr);
6de7dc5 @bagder Sterling Hughes' provided initial DNS cache source code.
authored
127
7ea837a @bagder adjusted to the new dns cache function to hide more hostip internals
authored
128 /* make a new dns cache and return the handle */
043d70f @bagder Use plain structs and not typedef'ed ones in the hash and linked-list co...
authored
129 struct curl_hash *Curl_mk_dnscache(void);
5d9ae88 @bagder getaddrinfo() cleanups
authored
130
3788f25 @bagder added a library-wide interface for doing dns cache pruning, and no longe...
authored
131 /* prune old entries from the DNS cache */
132 void Curl_hostcache_prune(struct SessionHandle *data);
133
9f341f9 @bagder Gisle Vanem's improved verbose output and timeout handling when connecti...
authored
134 /* Return # of adresses in a Curl_addrinfo struct */
135 int Curl_num_addresses (const Curl_addrinfo *addr);
136
c2c800d @yangtse Move curl_dofreeaddrinfo() and curl_dofreeaddrinfo()
yangtse authored
137 #if defined(CURLDEBUG) && defined(HAVE_GETNAMEINFO)
43369b8 @yangtse Fix compiler warning.
yangtse authored
138 int curl_dogetnameinfo(GETNAMEINFO_QUAL_ARG1 GETNAMEINFO_TYPE_ARG1 sa,
139 GETNAMEINFO_TYPE_ARG2 salen,
140 char *host, GETNAMEINFO_TYPE_ARG46 hostlen,
141 char *serv, GETNAMEINFO_TYPE_ARG46 servlen,
142 GETNAMEINFO_TYPE_ARG7 flags,
5d9ae88 @bagder getaddrinfo() cleanups
authored
143 int line, const char *source);
144 #endif
ae1912c @bagder Initial revision
authored
145
483ff1c @yangtse Constantine Sapuntzakis threaded resolver enhancements
yangtse authored
146 /* IPv4 threadsafe resolve function used for synch and asynch builds */
147 Curl_addrinfo *Curl_ipv4_resolve_r(const char * hostname, int port);
148
bcc29cd @dfandrich Fixed compilation when the synchronous resolver is used
dfandrich authored
149 CURLcode Curl_async_resolved(struct connectdata *conn,
150 bool *protocol_connect);
151
152 #ifndef CURLRES_ASYNCH
153 #define Curl_async_resolved(x,y) CURLE_OK
154 #endif
155
bfc4c33 @yangtse Constantine Sapuntzakis refactoring of async callbacks, allowing
yangtse authored
156 /*
157 * Curl_addrinfo_callback() is used when we build with any asynch specialty.
158 * Handles end of async request processing. Inserts ai into hostcache when
159 * status is CURL_ASYNC_SUCCESS. Twiddles fields in conn to indicate async
bcc29cd @dfandrich Fixed compilation when the synchronous resolver is used
dfandrich authored
160 * request completed whether successful or failed.
bfc4c33 @yangtse Constantine Sapuntzakis refactoring of async callbacks, allowing
yangtse authored
161 */
162 CURLcode Curl_addrinfo_callback(struct connectdata *conn,
163 int status,
164 Curl_addrinfo *ai);
648e82f @bagder Major hostip.c cleanup and split into multiple files and easier #ifdef
authored
165
166 /*
9f92657 @bagder Gisle corrected two comments
authored
167 * Curl_printable_address() returns a printable version of the 1st address
168 * given in the 'ip' argument. The result will be stored in the buf that is
169 * bufsize bytes big.
648e82f @bagder Major hostip.c cleanup and split into multiple files and easier #ifdef
authored
170 */
c39858a @bagder Source cleanups. The major one being that we now _always_ use a Curl_add...
authored
171 const char *Curl_printable_address(const Curl_addrinfo *ip,
648e82f @bagder Major hostip.c cleanup and split into multiple files and easier #ifdef
authored
172 char *buf, size_t bufsize);
173
174 /*
175 * Curl_cache_addr() stores a 'Curl_addrinfo' struct in the DNS cache.
176 *
177 * Returns the Curl_dns_entry entry pointer or NULL if the storage failed.
178 */
179 struct Curl_dns_entry *
180 Curl_cache_addr(struct SessionHandle *data, Curl_addrinfo *addr,
a55c70d Constify 'hostname' and 'service' to various resolver functions.
Gisle Vanem authored
181 const char *hostname, int port);
648e82f @bagder Major hostip.c cleanup and split into multiple files and easier #ifdef
authored
182
e615d11 @bagder Setup and use CURL_INADDR_NONE all over instead of INADDR_NONE. We setup
authored
183 #ifndef INADDR_NONE
184 #define CURL_INADDR_NONE (in_addr_t) ~0
185 #else
186 #define CURL_INADDR_NONE INADDR_NONE
187 #endif
188
a6c915a @yangtse fix compiler warning: external declaration in primary source file
yangtse authored
189 #ifdef HAVE_SIGSETJMP
190 /* Forward-declaration of variable defined in hostip.c. Beware this
191 * is a global and unique instance. This is used to store the return
192 * address that we can jump back to from inside a signal handler.
193 * This is not thread-safe stuff.
194 */
195 extern sigjmp_buf curl_jmpenv;
196 #endif
e615d11 @bagder Setup and use CURL_INADDR_NONE all over instead of INADDR_NONE. We setup
authored
197
8d0a504 CURLOPT_DNS_SERVERS: set name servers if possible
Jason Glasgow authored
198 /*
199 * Function provided by the resolver backend to set DNS servers to use.
200 */
201 CURLcode Curl_set_dns_servers(struct SessionHandle *data, char *servers);
202
2caa454 @bagder resolve: don't leak pre-populated dns entries
authored
203 /*
204 * Destroy the hostcache of this handle.
205 */
206 void Curl_hostcache_destroy(struct SessionHandle *data);
207
5e0a44e @bagder CURLOPT_RESOLVE: avoid adding already present host names
authored
208 CURLcode Curl_loadhostpairs(struct SessionHandle *data);
209
483ff1c @yangtse Constantine Sapuntzakis threaded resolver enhancements
yangtse authored
210 #endif /* HEADER_CURL_HOSTIP_H */
Something went wrong with that request. Please try again.