diff options
author | Werner Koch <[email protected]> | 2015-10-21 15:55:56 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2015-10-21 15:56:56 +0000 |
commit | 8bccbf477878fd99baa96e11db9db99aaf1e8d91 (patch) | |
tree | 42269f195e79c317dd9ab64699e481d77a904d40 /dirmngr/dns-stuff.h | |
parent | common: Add more replacement error codes. (diff) | |
download | gnupg-8bccbf477878fd99baa96e11db9db99aaf1e8d91.tar.gz gnupg-8bccbf477878fd99baa96e11db9db99aaf1e8d91.zip |
dirmngr: Implement a getaddrinfo wrapper.
* dirmngr/dns-stuff.h: Include some header files.
(dns_addinfo_t, dns_addrinfo_s): New.
* dirmngr/dns-stuff.c: Always include DNS related headers.
(free_dns_addrinfo): New.
(resolve_name_standard): New.
(resolve_dns_name): New.
* dirmngr/t-dns-stuff.c: Include netdb.h.
(main): Keep old default mode with no args but else print outout of
resolve_dns_name. Revamp option parser.
--
This wrapper allows us to switch to ADNS and thus Tor for standard
name resultion.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'dirmngr/dns-stuff.h')
-rw-r--r-- | dirmngr/dns-stuff.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/dirmngr/dns-stuff.h b/dirmngr/dns-stuff.h index aea0e69f6..090e79b4d 100644 --- a/dirmngr/dns-stuff.h +++ b/dirmngr/dns-stuff.h @@ -30,6 +30,16 @@ #ifndef GNUPG_DIRMNGR_DNS_STUFF_H #define GNUPG_DIRMNGR_DNS_STUFF_H +#ifdef HAVE_W32_SYSTEM +# ifdef HAVE_WINSOCK2_H +# include <winsock2.h> +# endif +# include <windows.h> +#else +# include <sys/types.h> +# include <sys/socket.h> +#endif + #define DNS_CERTTYPE_ANY 0 /* Internal catch all type. */ /* Certificate types according to RFC-4398: */ @@ -48,10 +58,31 @@ #define DNS_CERTTYPE_RRBASE 1024 /* Base of special constants. */ #define DNS_CERTTYPE_RR61 (DNS_CERTTYPE_RRBASE + 61) +struct dns_addrinfo_s; +typedef struct dns_addrinfo_s *dns_addrinfo_t; +struct dns_addrinfo_s +{ + dns_addrinfo_t next; + int family; + int socktype; + int protocol; + int addrlen; + struct sockaddr addr[1]; +}; + + + /* Calling this function switches the DNS code into Tor mode if possibe. Return 0 on success. */ gpg_error_t enable_dns_tormode (void); +void free_dns_addrinfo (dns_addrinfo_t ai); + +/* Provide function similar to getaddrinfo. */ +gpg_error_t resolve_dns_name (const char *name, unsigned short port, + int want_family, int want_socktype, + dns_addrinfo_t *r_dai, char **r_canonname); + /* Return a CERT record or an arbitray RR. */ gpg_error_t get_dns_cert (const char *name, int want_certtype, void **r_key, size_t *r_keylen, |