diff options
Diffstat (limited to 'libs/libcurl/src/hostip.h')
-rw-r--r-- | libs/libcurl/src/hostip.h | 214 |
1 files changed, 82 insertions, 132 deletions
diff --git a/libs/libcurl/src/hostip.h b/libs/libcurl/src/hostip.h index af0bde47f8..331a4a57d8 100644 --- a/libs/libcurl/src/hostip.h +++ b/libs/libcurl/src/hostip.h @@ -27,8 +27,9 @@ #include "curl_setup.h"
#include "hash.h"
#include "curl_addrinfo.h"
-#include "timeval.h" /* for timediff_t */
+#include "curlx/timeval.h" /* for timediff_t */
#include "asyn.h"
+#include "httpsrr.h"
#include <setjmp.h>
@@ -53,44 +54,12 @@ struct hostent; struct Curl_easy;
struct connectdata;
-/*
- * Curl_global_host_cache_init() initializes and sets up a global DNS cache.
- * Global DNS cache is general badness. Do not use. This will be removed in
- * a future version. Use the share interface instead!
- *
- * Returns a struct Curl_hash pointer on success, NULL on failure.
- */
-struct Curl_hash *Curl_global_host_cache_init(void);
-
-#ifdef USE_HTTPSRR
-
-#define CURL_MAXLEN_host_name 253
-
-struct Curl_https_rrinfo {
- size_t len; /* raw encoded length */
- unsigned char *val; /* raw encoded octets */
- /*
- * fields from HTTPS RR, with the mandatory fields
- * first (priority, target), then the others in the
- * order of the keytag numbers defined at
- * https://datatracker.ietf.org/doc/html/rfc9460#section-14.3.2
- */
- uint16_t priority;
- char *target;
- char *alpns; /* keytag = 1 */
- bool no_def_alpn; /* keytag = 2 */
- /*
- * we do not support ports (keytag = 3) as we do not support
- * port-switching yet
- */
- unsigned char *ipv4hints; /* keytag = 4 */
- size_t ipv4hints_len;
- unsigned char *echconfiglist; /* keytag = 5 */
- size_t echconfiglist_len;
- unsigned char *ipv6hints; /* keytag = 6 */
- size_t ipv6hints_len;
+enum alpnid {
+ ALPN_none = 0,
+ ALPN_h1 = CURLALTSVC_H1,
+ ALPN_h2 = CURLALTSVC_H2,
+ ALPN_h3 = CURLALTSVC_H3
};
-#endif
struct Curl_dns_entry {
struct Curl_addrinfo *addr;
@@ -107,6 +76,10 @@ struct Curl_dns_entry { char hostname[1];
};
+struct Curl_dnscache {
+ struct Curl_hash entries;
+};
+
bool Curl_host_is_ipnum(const char *hostname);
/*
@@ -116,22 +89,24 @@ bool Curl_host_is_ipnum(const char *hostname); * The returned data *MUST* be "released" with Curl_resolv_unlink() after
* use, or we will leak memory!
*/
-/* return codes */
-enum resolve_t {
- CURLRESOLV_TIMEDOUT = -2,
- CURLRESOLV_ERROR = -1,
- CURLRESOLV_RESOLVED = 0,
- CURLRESOLV_PENDING = 1
-};
-enum resolve_t Curl_resolv(struct Curl_easy *data,
- const char *hostname,
- int port,
- bool allowDOH,
- struct Curl_dns_entry **dnsentry);
-enum resolve_t Curl_resolv_timeout(struct Curl_easy *data,
- const char *hostname, int port,
- struct Curl_dns_entry **dnsentry,
- timediff_t timeoutms);
+CURLcode Curl_resolv(struct Curl_easy *data,
+ const char *hostname,
+ int port,
+ int ip_version,
+ bool allowDOH,
+ struct Curl_dns_entry **dnsentry);
+
+CURLcode Curl_resolv_blocking(struct Curl_easy *data,
+ const char *hostname,
+ int port,
+ int ip_version,
+ struct Curl_dns_entry **dnsentry);
+
+CURLcode Curl_resolv_timeout(struct Curl_easy *data,
+ const char *hostname, int port,
+ int ip_version,
+ struct Curl_dns_entry **dnsentry,
+ timediff_t timeoutms);
#ifdef USE_IPV6
/*
@@ -142,49 +117,25 @@ bool Curl_ipv6works(struct Curl_easy *data); #define Curl_ipv6works(x) FALSE
#endif
-/*
- * Curl_ipvalid() checks what CURL_IPRESOLVE_* requirements that might've
- * been set and returns TRUE if they are OK.
- */
-bool Curl_ipvalid(struct Curl_easy *data, struct connectdata *conn);
-
-
-/*
- * Curl_getaddrinfo() is the generic low-level name resolve API within this
- * source file. There are several versions of this function - for different
- * name resolve layers (selected at build-time). They all take this same set
- * of arguments
- */
-struct Curl_addrinfo *Curl_getaddrinfo(struct Curl_easy *data,
- const char *hostname,
- int port,
- int *waitp);
-
/* unlink a dns entry, potentially shared with a cache */
void Curl_resolv_unlink(struct Curl_easy *data,
struct Curl_dns_entry **pdns);
/* init a new dns cache */
-void Curl_init_dnscache(struct Curl_hash *hash, size_t hashsize);
+void Curl_dnscache_init(struct Curl_dnscache *dns, size_t hashsize);
+
+void Curl_dnscache_destroy(struct Curl_dnscache *dns);
/* prune old entries from the DNS cache */
-void Curl_hostcache_prune(struct Curl_easy *data);
+void Curl_dnscache_prune(struct Curl_easy *data);
/* IPv4 threadsafe resolve function used for synch and asynch builds */
struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname, int port);
-CURLcode Curl_once_resolved(struct Curl_easy *data, bool *protocol_connect);
-
-/*
- * Curl_addrinfo_callback() is used when we build with any asynch specialty.
- * Handles end of async request processing. Inserts ai into hostcache when
- * status is CURL_ASYNC_SUCCESS. Twiddles fields in conn to indicate async
- * request completed whether successful or failed.
- */
-CURLcode Curl_addrinfo_callback(struct Curl_easy *data,
- int status,
- struct Curl_addrinfo *ai);
+CURLcode Curl_once_resolved(struct Curl_easy *data,
+ struct Curl_dns_entry *dns,
+ bool *protocol_connect);
/*
* Curl_printable_address() returns a printable version of the 1st address
@@ -195,73 +146,72 @@ void Curl_printable_address(const struct Curl_addrinfo *ip, char *buf, size_t bufsize);
/*
- * Curl_fetch_addr() fetches a 'Curl_dns_entry' already in the DNS cache.
+ * Make a `Curl_dns_entry`.
+ * Creates a dnscache entry *without* adding it to a dnscache. This allows
+ * further modifications of the entry *before* then adding it to a cache.
*
- * Returns the Curl_dns_entry entry pointer or NULL if not in the cache.
+ * The entry is created with a reference count of 1.
+ * Use `Curl_resolv_unlink()` to release your hold on it.
*
- * The returned data *MUST* be "released" with Curl_resolv_unlink() after
- * use, or we will leak memory!
+ * The call takes ownership of `addr`and makes a copy of `hostname`.
+ *
+ * Returns entry or NULL on OOM.
*/
struct Curl_dns_entry *
-Curl_fetch_addr(struct Curl_easy *data,
- const char *hostname,
- int port);
+Curl_dnscache_mk_entry(struct Curl_easy *data,
+ struct Curl_addrinfo *addr,
+ const char *hostname,
+ size_t hostlen, /* length or zero */
+ int port,
+ bool permanent);
/*
- * Curl_cache_addr() stores a 'Curl_addrinfo' struct in the DNS cache.
- * @param permanent iff TRUE, entry will never become stale
- * Returns the Curl_dns_entry entry pointer or NULL if the storage failed.
+ * Curl_dnscache_get() fetches a 'Curl_dns_entry' already in the DNS cache.
+ *
+ * Returns the Curl_dns_entry entry pointer or NULL if not in the cache.
+ *
+ * The returned data *MUST* be "released" with Curl_resolv_unlink() after
+ * use, or we will leak memory!
*/
struct Curl_dns_entry *
-Curl_cache_addr(struct Curl_easy *data, struct Curl_addrinfo *addr,
- const char *hostname, size_t hostlen, int port,
- bool permanent);
-
-#ifndef INADDR_NONE
-#define CURL_INADDR_NONE (in_addr_t) ~0
-#else
-#define CURL_INADDR_NONE INADDR_NONE
-#endif
-
-/*
- * Function provided by the resolver backend to set DNS servers to use.
- */
-CURLcode Curl_set_dns_servers(struct Curl_easy *data, char *servers);
+Curl_dnscache_get(struct Curl_easy *data,
+ const char *hostname,
+ int port, int ip_version);
/*
- * Function provided by the resolver backend to set
- * outgoing interface to use for DNS requests
+ * Curl_dnscache_addr() adds `entry` to the cache, increasing its
+ * reference count on success.
*/
-CURLcode Curl_set_dns_interface(struct Curl_easy *data,
- const char *interf);
-
-/*
- * Function provided by the resolver backend to set
- * local IPv4 address to use as source address for DNS requests
- */
-CURLcode Curl_set_dns_local_ip4(struct Curl_easy *data,
- const char *local_ip4);
-
-/*
- * Function provided by the resolver backend to set
- * local IPv6 address to use as source address for DNS requests
- */
-CURLcode Curl_set_dns_local_ip6(struct Curl_easy *data,
- const char *local_ip6);
-
-/*
- * Clean off entries from the cache
- */
-void Curl_hostcache_clean(struct Curl_easy *data, struct Curl_hash *hash);
+CURLcode Curl_dnscache_add(struct Curl_easy *data,
+ struct Curl_dns_entry *entry);
/*
* Populate the cache with specified entries from CURLOPT_RESOLVE.
*/
CURLcode Curl_loadhostpairs(struct Curl_easy *data);
+
+#ifdef USE_CURL_ASYNC
CURLcode Curl_resolv_check(struct Curl_easy *data,
struct Curl_dns_entry **dns);
+#else
+#define Curl_resolv_check(x,y) CURLE_NOT_BUILT_IN
+#endif
int Curl_resolv_getsock(struct Curl_easy *data,
curl_socket_t *socks);
CURLcode Curl_resolver_error(struct Curl_easy *data);
+
+#ifdef CURLRES_SYNCH
+/*
+ * Curl_sync_getaddrinfo() is the non-async low-level name resolve API.
+ * There are several versions of this function - depending on IPV6
+ * support and platform.
+ */
+struct Curl_addrinfo *Curl_sync_getaddrinfo(struct Curl_easy *data,
+ const char *hostname,
+ int port,
+ int ip_version);
+
+#endif
+
#endif /* HEADER_CURL_HOSTIP_H */
|