2015-10-21 10:29:02 +02:00
|
|
|
/* dns-stuff.c - DNS related code including CERT RR (rfc-4398)
|
2006-06-16 13:49:27 +02:00
|
|
|
* Copyright (C) 2006 Free Software Foundation, Inc.
|
2015-10-21 10:29:02 +02:00
|
|
|
* Copyright (C) 2006, 2015 Werner Koch
|
2006-06-16 13:49:27 +02:00
|
|
|
*
|
|
|
|
* This file is part of GnuPG.
|
|
|
|
*
|
Change license for some files in common to LGPLv3+/GPLv2+.
Having the LGPL on the common GnuPG code helps to share code
between GnuPG and related projects (like GPGME and Libassuan). This
is good for interoperability and to reduces bugs.
* common/asshelp.c, common/asshelp.h, common/asshelp2.c, common/b64dec.c
* common/b64enc.c, common/convert.c, common/dns-cert.c
* common/dns-cert.h common/exechelp-posix.c, common/exechelp-w32.c
* common/exechelp-w32ce.c, common/exechelp.h, common/get-passphrase.c
* common/get-passphrase.h, common/gettime.c, common/gpgrlhelp.c
* common/helpfile.c, common/homedir.c, common/http.c, common/http.h
* common/i18n.c, common/init.c, common/init.h, common/iobuf.c
* common/iobuf.h, common/localename.c, common/membuf.c, common/membuf.h
* common/miscellaneous.c, common/openpgp-oid.c, common/openpgpdefs.h
* common/percent.c, common/pka.c, common/pka.h, common/session-env.c
* common/session-env.h, common/sexp-parse.h, common/sexputil.c
* common/signal.c, common/srv.c, common/srv.h, common/ssh-utils.c
* common/ssh-utils.h, common/sysutils.c, common/sysutils.h
* common/tlv.c, common/tlv.h, common/ttyio.c, common/ttyio.h
* common/userids.c, common/userids.h, common/xasprintf.c: Change
license to LGPLv3+/GPLv2+/
2012-04-20 15:43:06 +02:00
|
|
|
* This file is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of either
|
2006-06-16 13:49:27 +02:00
|
|
|
*
|
Change license for some files in common to LGPLv3+/GPLv2+.
Having the LGPL on the common GnuPG code helps to share code
between GnuPG and related projects (like GPGME and Libassuan). This
is good for interoperability and to reduces bugs.
* common/asshelp.c, common/asshelp.h, common/asshelp2.c, common/b64dec.c
* common/b64enc.c, common/convert.c, common/dns-cert.c
* common/dns-cert.h common/exechelp-posix.c, common/exechelp-w32.c
* common/exechelp-w32ce.c, common/exechelp.h, common/get-passphrase.c
* common/get-passphrase.h, common/gettime.c, common/gpgrlhelp.c
* common/helpfile.c, common/homedir.c, common/http.c, common/http.h
* common/i18n.c, common/init.c, common/init.h, common/iobuf.c
* common/iobuf.h, common/localename.c, common/membuf.c, common/membuf.h
* common/miscellaneous.c, common/openpgp-oid.c, common/openpgpdefs.h
* common/percent.c, common/pka.c, common/pka.h, common/session-env.c
* common/session-env.h, common/sexp-parse.h, common/sexputil.c
* common/signal.c, common/srv.c, common/srv.h, common/ssh-utils.c
* common/ssh-utils.h, common/sysutils.c, common/sysutils.h
* common/tlv.c, common/tlv.h, common/ttyio.c, common/ttyio.h
* common/userids.c, common/userids.h, common/xasprintf.c: Change
license to LGPLv3+/GPLv2+/
2012-04-20 15:43:06 +02:00
|
|
|
* - the GNU Lesser General Public License as published by the Free
|
|
|
|
* Software Foundation; either version 3 of the License, or (at
|
|
|
|
* your option) any later version.
|
|
|
|
*
|
|
|
|
* or
|
|
|
|
*
|
|
|
|
* - the GNU General Public License as published by the Free
|
|
|
|
* Software Foundation; either version 2 of the License, or (at
|
|
|
|
* your option) any later version.
|
|
|
|
*
|
|
|
|
* or both in parallel, as here.
|
|
|
|
*
|
|
|
|
* This file is distributed in the hope that it will be useful,
|
2006-06-16 13:49:27 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2016-11-05 12:02:19 +01:00
|
|
|
* along with this program; if not, see <https://www.gnu.org/licenses/>.
|
2006-06-16 13:49:27 +02:00
|
|
|
*/
|
2015-10-21 10:29:02 +02:00
|
|
|
#ifndef GNUPG_DIRMNGR_DNS_STUFF_H
|
|
|
|
#define GNUPG_DIRMNGR_DNS_STUFF_H
|
2006-06-16 13:49:27 +02:00
|
|
|
|
2015-10-21 17:55:56 +02:00
|
|
|
#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
|
|
|
|
|
2015-10-24 16:27:47 +02:00
|
|
|
/*
|
|
|
|
* Flags used with resolve_dns_addr.
|
|
|
|
*/
|
|
|
|
#define DNS_NUMERICHOST 1 /* Force numeric output format. */
|
|
|
|
#define DNS_WITHBRACKET 2 /* Put brackets around numeric v6
|
|
|
|
addresses. */
|
2015-02-25 12:03:21 +01:00
|
|
|
|
2015-10-24 16:27:47 +02:00
|
|
|
/*
|
|
|
|
* Constants for use with get_dns_cert.
|
|
|
|
*/
|
2015-02-25 12:03:21 +01:00
|
|
|
#define DNS_CERTTYPE_ANY 0 /* Internal catch all type. */
|
|
|
|
/* Certificate types according to RFC-4398: */
|
|
|
|
#define DNS_CERTTYPE_PKIX 1 /* X.509 as per PKIX. */
|
|
|
|
#define DNS_CERTTYPE_SPKI 2 /* SPKI certificate. */
|
|
|
|
#define DNS_CERTTYPE_PGP 3 /* OpenPGP packet. */
|
|
|
|
#define DNS_CERTTYPE_IPKIX 4 /* The URL of an X.509 data object. */
|
|
|
|
#define DNS_CERTTYPE_ISPKI 5 /* The URL of an SPKI certificate. */
|
|
|
|
#define DNS_CERTTYPE_IPGP 6 /* The fingerprint
|
|
|
|
and URL of an OpenPGP packet. */
|
|
|
|
#define DNS_CERTTYPE_ACPKIX 7 /* Attribute Certificate. */
|
|
|
|
#define DNS_CERTTYPE_IACPKIX 8 /* The URL of an Attribute Certificate. */
|
|
|
|
#define DNS_CERTTYPE_URI 253 /* URI private. */
|
|
|
|
#define DNS_CERTTYPE_OID 254 /* OID private. */
|
2015-10-06 19:57:00 +02:00
|
|
|
/* Hacks for our implementation. */
|
|
|
|
#define DNS_CERTTYPE_RRBASE 1024 /* Base of special constants. */
|
|
|
|
#define DNS_CERTTYPE_RR61 (DNS_CERTTYPE_RRBASE + 61)
|
2015-02-25 12:03:21 +01:00
|
|
|
|
2015-10-24 16:27:47 +02:00
|
|
|
|
|
|
|
|
2015-10-21 17:55:56 +02:00
|
|
|
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;
|
2017-04-13 07:33:33 +02:00
|
|
|
struct sockaddr_storage addr[1];
|
2015-10-21 17:55:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-10-22 09:22:41 +02:00
|
|
|
struct srventry
|
|
|
|
{
|
|
|
|
unsigned short priority;
|
|
|
|
unsigned short weight;
|
|
|
|
unsigned short port;
|
|
|
|
int run_count;
|
2015-10-22 09:52:51 +02:00
|
|
|
char target[1025];
|
2015-10-22 09:22:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-12-19 23:27:02 +01:00
|
|
|
/* Set verbosity and debug mode for this module. */
|
|
|
|
void set_dns_verbose (int verbose, int debug);
|
|
|
|
|
2017-01-24 16:36:28 +01:00
|
|
|
/* Set the Disable-IPv4 flag so that the name resolver does not return
|
|
|
|
* A addresses. */
|
|
|
|
void set_dns_disable_ipv4 (int yes);
|
|
|
|
|
2017-04-03 20:56:12 +02:00
|
|
|
/* Set the Disable-IPv6 flag so that the name resolver does not return
|
|
|
|
* AAAA addresses. */
|
|
|
|
void set_dns_disable_ipv6 (int yes);
|
|
|
|
|
2016-12-20 09:53:58 +01:00
|
|
|
/* Set the timeout for libdns requests to SECONDS. */
|
|
|
|
void set_dns_timeout (int seconds);
|
|
|
|
|
2016-12-01 15:45:51 +01:00
|
|
|
/* Calling this function with YES set to True forces the use of the
|
|
|
|
* standard resolver even if dirmngr has been built with support for
|
|
|
|
* an alternative resolver. */
|
|
|
|
void enable_standard_resolver (int yes);
|
|
|
|
|
|
|
|
/* Return true if the standard resolver is used. */
|
|
|
|
int standard_resolver_p (void);
|
|
|
|
|
2016-12-14 15:36:25 +01:00
|
|
|
/* Calling this function with YES switches libdns into recursive mode.
|
|
|
|
* It has no effect on the standard resolver. */
|
|
|
|
void enable_recursive_resolver (int yes);
|
|
|
|
|
|
|
|
/* Return true iff the recursive resolver is used. */
|
|
|
|
int recursive_resolver_p (void);
|
|
|
|
|
2017-01-03 12:03:28 +01:00
|
|
|
/* Put this module eternally into Tor mode. When called agained with
|
|
|
|
* NEW_CIRCUIT request a new TOR circuit for the next DNS query. */
|
|
|
|
void enable_dns_tormode (int new_circuit);
|
2017-02-01 17:54:14 +01:00
|
|
|
void disable_dns_tormode (void);
|
2015-10-21 10:29:02 +02:00
|
|
|
|
2015-11-12 13:20:18 +01:00
|
|
|
/* Change the default IP address of the nameserver to IPADDR. The
|
|
|
|
address needs to be a numerical IP address and will be used for the
|
|
|
|
next DNS query. Note that this is only used in Tor mode. */
|
|
|
|
void set_dns_nameserver (const char *ipaddr);
|
|
|
|
|
2016-12-16 21:00:14 +01:00
|
|
|
/* SIGHUP action handler for this module. */
|
|
|
|
void reload_dns_stuff (int force);
|
2015-11-12 13:20:18 +01:00
|
|
|
|
2015-10-21 17:55:56 +02:00
|
|
|
void free_dns_addrinfo (dns_addrinfo_t ai);
|
|
|
|
|
2015-10-24 16:27:47 +02:00
|
|
|
/* Function similar to getaddrinfo. */
|
2018-07-25 14:35:04 +02:00
|
|
|
gpg_error_t resolve_dns_name (ctrl_t ctrl,
|
|
|
|
const char *name, unsigned short port,
|
2015-10-21 17:55:56 +02:00
|
|
|
int want_family, int want_socktype,
|
|
|
|
dns_addrinfo_t *r_dai, char **r_canonname);
|
|
|
|
|
2015-10-24 16:27:47 +02:00
|
|
|
/* Function similar to getnameinfo. */
|
2018-07-25 14:35:04 +02:00
|
|
|
gpg_error_t resolve_dns_addr (ctrl_t ctrl,
|
|
|
|
const struct sockaddr_storage *addr, int addrlen,
|
2015-10-24 16:27:47 +02:00
|
|
|
unsigned int flags, char **r_name);
|
|
|
|
|
|
|
|
/* Return true if NAME is a numerical IP address. */
|
|
|
|
int is_ip_address (const char *name);
|
|
|
|
|
2015-10-26 16:32:03 +01:00
|
|
|
/* Return true if NAME is an onion address. */
|
|
|
|
int is_onion_address (const char *name);
|
|
|
|
|
2015-10-25 16:38:07 +01:00
|
|
|
/* Get the canonical name for NAME. */
|
2018-07-25 14:35:04 +02:00
|
|
|
gpg_error_t get_dns_cname (ctrl_t ctrl, const char *name, char **r_cname);
|
2015-10-25 16:38:07 +01:00
|
|
|
|
2017-04-28 03:06:33 +02:00
|
|
|
/* Return a CERT record or an arbitrary RR. */
|
2018-07-25 14:35:04 +02:00
|
|
|
gpg_error_t get_dns_cert (ctrl_t ctrl,
|
|
|
|
const char *name, int want_certtype,
|
2015-04-23 15:42:56 +02:00
|
|
|
void **r_key, size_t *r_keylen,
|
2012-02-07 10:15:57 +01:00
|
|
|
unsigned char **r_fpr, size_t *r_fprlen,
|
|
|
|
char **r_url);
|
2011-11-30 17:14:08 +01:00
|
|
|
|
2016-12-19 23:27:02 +01:00
|
|
|
/* Return an array of SRV records. */
|
2018-07-25 14:35:04 +02:00
|
|
|
gpg_error_t get_dns_srv (ctrl_t ctrl,
|
|
|
|
const char *name,
|
2017-01-08 18:04:59 +01:00
|
|
|
const char *service, const char *proto,
|
2016-12-19 23:27:02 +01:00
|
|
|
struct srventry **list, unsigned int *r_count);
|
2006-06-16 13:49:27 +02:00
|
|
|
|
|
|
|
|
2015-10-21 10:29:02 +02:00
|
|
|
#endif /*GNUPG_DIRMNGR_DNS_STUFF_H*/
|