2000-04-19 23:23:31 +00:00
|
|
|
/*
|
2011-03-01 23:48:07 +00:00
|
|
|
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
2000-04-19 23:23:31 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
2021-06-03 08:37:05 +02:00
|
|
|
*
|
2000-04-19 23:23:31 +00:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
2018-02-23 09:53:12 +01:00
|
|
|
*
|
2000-04-19 23:23:31 +00:00
|
|
|
* See the COPYRIGHT file distributed with this work for additional
|
2000-05-06 01:16:07 +00:00
|
|
|
* information regarding copyright ownership.
|
2000-04-19 23:23:31 +00:00
|
|
|
*/
|
|
|
|
|
2021-10-05 16:49:47 +02:00
|
|
|
#pragma once
|
2000-04-19 23:23:31 +00:00
|
|
|
|
2005-04-27 04:57:32 +00:00
|
|
|
/*! \file */
|
|
|
|
|
2018-03-28 14:19:37 +02:00
|
|
|
#include <inttypes.h>
|
2018-04-17 08:29:14 -07:00
|
|
|
#include <stdbool.h>
|
2018-03-28 14:19:37 +02:00
|
|
|
|
2018-08-07 16:46:53 +02:00
|
|
|
#include <isc/attributes.h>
|
2000-04-19 23:23:31 +00:00
|
|
|
#include <isc/buffer.h>
|
2001-08-08 22:54:55 +00:00
|
|
|
#include <isc/formatcheck.h>
|
2000-04-19 23:23:31 +00:00
|
|
|
#include <isc/list.h>
|
2022-07-26 13:03:40 +02:00
|
|
|
#include <isc/loop.h>
|
2018-11-07 13:04:13 -05:00
|
|
|
#include <isc/magic.h>
|
2000-06-21 17:48:32 +00:00
|
|
|
#include <isc/mem.h>
|
2020-12-17 11:40:29 +01:00
|
|
|
#include <isc/netmgr.h>
|
2020-09-05 16:37:24 -07:00
|
|
|
#include <isc/refcount.h>
|
2000-06-21 17:48:32 +00:00
|
|
|
#include <isc/sockaddr.h>
|
2021-10-03 00:27:52 -07:00
|
|
|
#include <isc/time.h>
|
2000-04-19 23:23:31 +00:00
|
|
|
|
2025-07-14 10:50:21 +02:00
|
|
|
#include <dns/fixedname.h>
|
2000-06-21 17:48:32 +00:00
|
|
|
#include <dns/rdatalist.h>
|
2020-02-12 13:59:18 +01:00
|
|
|
|
2000-06-21 17:48:32 +00:00
|
|
|
#include <dst/dst.h>
|
2020-02-12 13:59:18 +01:00
|
|
|
|
2017-11-23 16:58:12 +11:00
|
|
|
#ifdef __APPLE__
|
|
|
|
#include <TargetConditionals.h>
|
|
|
|
#endif /* ifdef __APPLE__ */
|
|
|
|
|
2005-03-31 02:36:05 +00:00
|
|
|
#define MXSERV 20
|
2000-08-09 00:09:36 +00:00
|
|
|
#define MXNAME (DNS_NAME_MAXTEXT + 1)
|
2000-04-19 23:23:31 +00:00
|
|
|
#define MXRD 32
|
2005-04-27 04:57:32 +00:00
|
|
|
/*% Buffer Size */
|
2000-04-19 23:23:31 +00:00
|
|
|
#define BUFSIZE 512
|
2000-06-23 02:56:10 +00:00
|
|
|
#define COMMSIZE 0xffff
|
2001-10-04 03:20:23 +00:00
|
|
|
#ifndef RESOLV_CONF
|
2005-04-27 04:57:32 +00:00
|
|
|
/*% location of resolve.conf */
|
2001-10-04 03:20:23 +00:00
|
|
|
#define RESOLV_CONF "/etc/resolv.conf"
|
|
|
|
#endif /* ifndef RESOLV_CONF */
|
2005-04-27 04:57:32 +00:00
|
|
|
/*% output buffer */
|
2000-05-24 19:27:01 +00:00
|
|
|
#define OUTPUTBUF 32767
|
2005-04-27 04:57:32 +00:00
|
|
|
/*% Max RR Limit */
|
2000-11-21 20:55:00 +00:00
|
|
|
#define MAXRRLIMIT 0xffffffff
|
|
|
|
#define MAXTIMEOUT 0xffff
|
2005-04-27 04:57:32 +00:00
|
|
|
/*% Max number of tries */
|
2000-11-21 21:40:12 +00:00
|
|
|
#define MAXTRIES 0xffffffff
|
2005-04-27 04:57:32 +00:00
|
|
|
/*% Max number of dots */
|
2000-11-21 20:55:00 +00:00
|
|
|
#define MAXNDOTS 0xffff
|
2005-04-27 04:57:32 +00:00
|
|
|
/*% Max number of ports */
|
2000-11-21 20:55:00 +00:00
|
|
|
#define MAXPORT 0xffff
|
2005-04-27 04:57:32 +00:00
|
|
|
/*% Max serial number */
|
2000-11-21 20:55:00 +00:00
|
|
|
#define MAXSERIAL 0xffffffff
|
2020-05-08 12:39:16 -07:00
|
|
|
/*% Max query ID */
|
|
|
|
#define MAXQID 0xffff
|
2000-07-05 19:31:26 +00:00
|
|
|
|
2005-04-27 04:57:32 +00:00
|
|
|
/*% Default TCP Timeout */
|
2000-07-18 01:28:20 +00:00
|
|
|
#define TCP_TIMEOUT 10
|
2005-04-27 04:57:32 +00:00
|
|
|
/*% Default UDP Timeout */
|
2000-07-18 01:28:20 +00:00
|
|
|
#define UDP_TIMEOUT 5
|
2000-07-10 17:25:59 +00:00
|
|
|
|
2000-09-21 22:46:39 +00:00
|
|
|
#define SERVER_TIMEOUT 1
|
|
|
|
|
2000-05-06 01:16:07 +00:00
|
|
|
#define LOOKUP_LIMIT 64
|
2020-07-29 12:34:54 +10:00
|
|
|
|
|
|
|
#define DEFAULT_EDNS_VERSION 0
|
2020-09-30 18:18:05 +02:00
|
|
|
#define DEFAULT_EDNS_BUFSIZE 1232
|
2020-07-29 12:34:54 +10:00
|
|
|
|
2021-01-27 15:49:27 +01:00
|
|
|
#define DEFAULT_HTTPS_QUERY "?dns="
|
|
|
|
|
2005-04-27 04:57:32 +00:00
|
|
|
/*%
|
2000-07-05 19:31:26 +00:00
|
|
|
* Lookup_limit is just a limiter, keeping too many lookups from being
|
2000-05-06 01:16:07 +00:00
|
|
|
* created. It's job is mainly to prevent the program from running away
|
|
|
|
* in a tight loop of constant lookups. It's value is arbitrary.
|
|
|
|
*/
|
2000-07-05 19:31:26 +00:00
|
|
|
|
2000-04-19 23:23:31 +00:00
|
|
|
typedef struct dig_lookup dig_lookup_t;
|
2018-08-07 16:46:53 +02:00
|
|
|
typedef struct dig_query dig_query_t;
|
2000-04-19 23:23:31 +00:00
|
|
|
typedef struct dig_server dig_server_t;
|
2000-07-14 16:35:30 +00:00
|
|
|
typedef ISC_LIST(dig_server_t) dig_serverlist_t;
|
2000-05-02 23:23:12 +00:00
|
|
|
typedef struct dig_searchlist dig_searchlist_t;
|
2000-04-19 23:23:31 +00:00
|
|
|
|
2020-11-05 15:22:38 +01:00
|
|
|
#define DIG_LOOKUP_MAGIC ISC_MAGIC('D', 'i', 'g', 'l')
|
|
|
|
|
|
|
|
#define DIG_VALID_LOOKUP(x) ISC_MAGIC_VALID((x), DIG_LOOKUP_MAGIC)
|
|
|
|
|
2018-11-07 13:04:13 -05:00
|
|
|
#define DIG_QUERY_MAGIC ISC_MAGIC('D', 'i', 'g', 'q')
|
|
|
|
|
|
|
|
#define DIG_VALID_QUERY(x) ISC_MAGIC_VALID((x), DIG_QUERY_MAGIC)
|
|
|
|
|
2005-04-27 04:57:32 +00:00
|
|
|
/*% The dig_lookup structure */
|
2000-04-19 23:23:31 +00:00
|
|
|
struct dig_lookup {
|
2020-11-05 15:22:38 +01:00
|
|
|
unsigned int magic;
|
|
|
|
isc_refcount_t references;
|
2025-05-27 14:41:24 +10:00
|
|
|
bool aaonly, adflag, badcookie, besteffort, cdflag, cleared, coflag,
|
|
|
|
comments, dns64prefix, dnssec, doing_xfr, done_as_is, ednsneg,
|
|
|
|
expandaaaa, svcparamkeycompat, expire, fuzzing, header_only,
|
2025-02-10 13:22:58 +00:00
|
|
|
identify, /*%< Append an "on server <foo>" message */
|
2022-03-14 17:42:08 +11:00
|
|
|
identify_previous_line, /*% Prepend a "Nameserver <foo>:"
|
|
|
|
message, with newline and tab */
|
2022-01-13 13:29:09 +01:00
|
|
|
idnin, idnout, ignore, multiline, need_search, new_search,
|
|
|
|
noclass, nocrypto, nottl, ns_search_only, /*%< dig +nssearch,
|
|
|
|
host -C */
|
Fix a crash in dig NS search mode
In special NS search mode, after the initial lookup, dig starts the
followup lookup with discovered NS servers in the queries list. If one
of those queries then fail, dig, as usual, tries to start the next query
in the list, which results in a crash, because the NS search mode is
special in a way that the queries are running in parallel, so the next
query is usually already started.
Apply some special logic in `recv_done()` function to deal with the
described situation when handling the query result for the NS search
mode. Particularly, print a warning message for the failed query,
and do not try to start the next query in the list. Also, set a non-zero
exit code if all the queries in the followup lookup fail.
2022-05-19 20:44:32 +00:00
|
|
|
ns_search_success, nsid, /*% Name Server ID (RFC 5001) */
|
|
|
|
onesoa, pending, /*%< Pending a successful answer */
|
2019-07-25 20:26:13 +10:00
|
|
|
print_unknown_format, qr, raflag, recurse, section_additional,
|
|
|
|
section_answer, section_authority, section_question,
|
|
|
|
seenbadcookie, sendcookie, servfail_stops,
|
|
|
|
setqid, /*% use a speciied query ID */
|
2025-03-12 10:02:05 +11:00
|
|
|
showbadcookie, showbadvers, stats, tcflag, tcp_keepalive,
|
|
|
|
tcp_mode, tcp_mode_set, tls_mode, /*% connect using TLS */
|
|
|
|
trace, /*% dig +trace */
|
2019-07-25 20:26:13 +10:00
|
|
|
trace_root, /*% initial query for either +trace or +nssearch */
|
2024-06-13 07:53:59 +10:00
|
|
|
ttlunits, use_usec, waiting_connect, zflag, zoneversion;
|
2019-07-25 20:26:13 +10:00
|
|
|
char textname[MXNAME]; /*% Name we're going to be looking up */
|
2018-08-07 16:46:53 +02:00
|
|
|
char cmdline[MXNAME];
|
|
|
|
dns_rdatatype_t rdtype;
|
|
|
|
dns_rdatatype_t qrdtype;
|
2000-07-18 01:28:20 +00:00
|
|
|
dns_rdataclass_t rdclass;
|
2018-08-07 16:46:53 +02:00
|
|
|
bool rdtypeset;
|
|
|
|
bool rdclassset;
|
|
|
|
char name_space[BUFSIZE];
|
|
|
|
char oname_space[BUFSIZE];
|
|
|
|
isc_buffer_t renderbuf;
|
|
|
|
char *sendspace;
|
|
|
|
dns_name_t *name;
|
|
|
|
isc_interval_t interval;
|
|
|
|
dns_message_t *sendmsg;
|
|
|
|
dns_name_t *oname;
|
2000-04-19 23:23:31 +00:00
|
|
|
ISC_LINK(dig_lookup_t) link;
|
|
|
|
ISC_LIST(dig_query_t) q;
|
2012-10-18 17:50:07 -05:00
|
|
|
ISC_LIST(dig_query_t) connecting;
|
2018-08-07 16:46:53 +02:00
|
|
|
dig_query_t *current_query;
|
|
|
|
dig_serverlist_t my_server_list;
|
2000-05-02 23:23:12 +00:00
|
|
|
dig_searchlist_t *origin;
|
2018-08-07 16:46:53 +02:00
|
|
|
dig_query_t *xfr_q;
|
|
|
|
uint32_t retries;
|
|
|
|
int nsfound;
|
2020-07-29 12:34:54 +10:00
|
|
|
int16_t udpsize;
|
2018-08-07 16:46:53 +02:00
|
|
|
int16_t edns;
|
2025-03-12 10:02:05 +11:00
|
|
|
int16_t original_edns;
|
2018-08-07 16:46:53 +02:00
|
|
|
int16_t padding;
|
|
|
|
uint32_t ixfr_serial;
|
|
|
|
isc_buffer_t rdatabuf;
|
|
|
|
char rdatastore[MXNAME];
|
|
|
|
dst_context_t *tsigctx;
|
|
|
|
isc_buffer_t *querysig;
|
|
|
|
uint32_t msgcounter;
|
|
|
|
dns_fixedname_t fdomain;
|
|
|
|
isc_sockaddr_t *ecs_addr;
|
|
|
|
char *cookie;
|
|
|
|
dns_ednsopt_t *ednsopts;
|
|
|
|
unsigned int ednsoptscnt;
|
|
|
|
unsigned int ednsflags;
|
|
|
|
dns_opcode_t opcode;
|
|
|
|
int rrcomments;
|
2020-05-08 12:39:16 -07:00
|
|
|
uint16_t qid;
|
2021-01-27 15:49:27 +01:00
|
|
|
struct {
|
|
|
|
bool http_plain;
|
|
|
|
bool https_mode;
|
|
|
|
bool https_get;
|
|
|
|
char *https_path;
|
|
|
|
};
|
2022-01-19 13:10:08 +02:00
|
|
|
struct {
|
|
|
|
bool tls_ca_set;
|
|
|
|
char *tls_ca_file;
|
|
|
|
bool tls_hostname_set;
|
|
|
|
char *tls_hostname;
|
|
|
|
bool tls_cert_file_set;
|
|
|
|
char *tls_cert_file;
|
|
|
|
bool tls_key_file_set;
|
|
|
|
char *tls_key_file;
|
|
|
|
isc_tlsctx_cache_t *tls_ctx_cache;
|
|
|
|
};
|
2023-10-16 22:54:13 +03:00
|
|
|
struct {
|
|
|
|
bool proxy_mode;
|
|
|
|
bool proxy_plain;
|
|
|
|
bool proxy_local;
|
|
|
|
isc_sockaddr_t proxy_src_addr;
|
|
|
|
isc_sockaddr_t proxy_dst_addr;
|
|
|
|
};
|
2022-03-14 17:42:08 +11:00
|
|
|
isc_stdtime_t fuzztime;
|
2000-04-19 23:23:31 +00:00
|
|
|
};
|
|
|
|
|
2005-04-27 04:57:32 +00:00
|
|
|
/*% The dig_query structure */
|
2000-04-19 23:23:31 +00:00
|
|
|
struct dig_query {
|
2018-08-07 16:46:53 +02:00
|
|
|
unsigned int magic;
|
2000-04-19 23:23:31 +00:00
|
|
|
dig_lookup_t *lookup;
|
2022-03-20 13:54:39 +00:00
|
|
|
bool started;
|
2020-11-04 12:40:13 +01:00
|
|
|
bool first_soa_rcvd;
|
|
|
|
bool second_rr_rcvd;
|
|
|
|
bool first_repeat_rcvd;
|
|
|
|
bool warn_id;
|
Fix query context management issues in dighost.c
For the reference, the _cancel_lookup() function iterates through
the lookup's queries list and detaches them. In the ideal scenario,
that should be the last reference and the query will be destroyed
after that, but it is also possible that we are still expecting a
callback, which also holds a reference (for example, _cancel_lookup()
could have been called from recv_done(), when send_done() was still
not executed).
The start_udp() and start_tcp() functions are currently designed in
slightly different ways: start_udp() creates a new query attachment
`connectquery`, to be called in the callback function, while
start_tcp() does not, which is a bug, but is hidden by the fact
that when the query is being erroneously destroyed prematurely (before
_cancel_lookup() is called) in the result of that, it also gets
de-listed from the lookup's queries' list, so _cancel_lookup() doesn't
even try to detach it.
For better understanding, here's an illustration of the query's
references count changes, and from where it was changed:
UDP
---
1. _new_query() -> refcount = 1 (initial)
2. start_udp() -> refcount = 2 (lookup->current_query)
3. start_udp() -> refcount = 3 (connectquery)
4. udp_ready() -> refcount = 4 (readquery)
5. udp_ready() -> refcount = 5 (sendquery)
6. udp_ready() -> refcount = 4 (lookup->current_query)
7. udp_ready() -> refcount = 3 (connectquery)
8. send_done() -> refcount = 2 (sendquery)
9. recv_done() -> refcount = 1 (readquery)
10. _cancel_lookup() -> refcount = 0 (initial)
11. the query gets destroyed and removed from `lookup->q`
TCP, fortunate scenario
-----------------------
1. _new_query() -> refcount = 1 (initial)
2. start_tcp() -> refcount = 2 (lookup->current_query)
3. launch_next_query() -> refcount = 3 (readquery)
4. launch_next_query() -> refcount = 4 (sendquery)
5. tcp_connected() -> refcount = 3 (lookup->current_query)
6. tcp_connected() -> refcount = 2 (bug, there was no connectquery)
7. send_done() -> refcount = 1 (sendquery)
8. recv_done() -> refcount = 0 (readquery)
9. the query gets prematurely destroyed and removed from `lookup->q`
10. _cancel_lookup() -> the query is not in `lookup->q`
TCP, unfortunate scenario, revealing the bug
--------------------------------------------
1. _new_query() -> refcount = 1 (initial)
2. start_tcp() -> refcount = 2 (lookup->current_query)
3. launch_next_query() -> refcount = 3 (readquery)
4. launch_next_query() -> refcount = 4 (sendquery)
5. tcp_connected() -> refcount = 3 (lookup->current_query)
6. tcp_connected() -> refcount = 2 (bug, there was no connectquery)
7. recv_done() -> refcount = 1 (readquery)
8. _cancel_lookup() -> refcount = 0 (the query was in `lookup->q`)
9. we hit an assertion here when trying to destroy the query, because
sendhandle is not detached (which is done by send_done()).
10. send_done() -> this never happens
This commit does the following:
1. Add a `connectquery` attachment in start_tcp(), like done in
start_udp().
2. Add missing _cancel_lookup() calls for error scenarios, which
were possibly missing because before fixing the bug, calling
_cancel_lookup() and then calling query_detach() would cause
an assertion.
3. Log a debug message and call isc_nm_cancelread(query->readhandle)
for every query in the lookup from inside the _cancel_lookup()
function, like it is done in _cancel_all().
4. Add a `canceled` property for the query which becomes `true` when
the lookup (and subsequently, its queries) are canceled.
5. Use the `canceled` property in the network manager callbacks to
know that the query was canceled, and act like `eresult` was equal
to `ISC_R_CANCELED`.
2022-03-02 00:06:34 +00:00
|
|
|
bool canceled;
|
2018-08-07 16:46:53 +02:00
|
|
|
uint32_t first_rr_serial;
|
|
|
|
uint32_t second_rr_serial;
|
|
|
|
uint32_t msg_count;
|
|
|
|
uint32_t rr_count;
|
|
|
|
bool ixfr_axfr;
|
|
|
|
char *servname;
|
|
|
|
char *userarg;
|
2020-09-05 16:37:24 -07:00
|
|
|
isc_buffer_t sendbuf;
|
2018-08-07 16:46:53 +02:00
|
|
|
char *recvspace, *tmpsendspace, lengthspace[4];
|
2020-11-04 12:40:13 +01:00
|
|
|
isc_refcount_t references;
|
2020-09-05 16:37:24 -07:00
|
|
|
isc_nmhandle_t *handle;
|
|
|
|
isc_nmhandle_t *readhandle;
|
|
|
|
isc_nmhandle_t *sendhandle;
|
2000-04-19 23:23:31 +00:00
|
|
|
ISC_LINK(dig_query_t) link;
|
2012-10-18 17:50:07 -05:00
|
|
|
ISC_LINK(dig_query_t) clink;
|
2000-04-19 23:23:31 +00:00
|
|
|
isc_sockaddr_t sockaddr;
|
2018-08-07 16:46:53 +02:00
|
|
|
isc_time_t time_sent;
|
|
|
|
isc_time_t time_recv;
|
|
|
|
uint64_t byte_count;
|
2022-07-26 13:03:45 +02:00
|
|
|
isc_timer_t *timer;
|
2000-04-19 23:23:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct dig_server {
|
|
|
|
char servername[MXNAME];
|
2004-09-06 01:24:44 +00:00
|
|
|
char userarg[MXNAME];
|
2000-04-19 23:23:31 +00:00
|
|
|
ISC_LINK(dig_server_t) link;
|
|
|
|
};
|
|
|
|
|
2000-05-02 23:23:12 +00:00
|
|
|
struct dig_searchlist {
|
|
|
|
char origin[MXNAME];
|
|
|
|
ISC_LINK(dig_searchlist_t) link;
|
|
|
|
};
|
2005-07-04 03:03:21 +00:00
|
|
|
|
|
|
|
typedef ISC_LIST(dig_searchlist_t) dig_searchlistlist_t;
|
|
|
|
typedef ISC_LIST(dig_lookup_t) dig_lookuplist_t;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Externals from dighost.c
|
|
|
|
*/
|
|
|
|
|
2018-08-07 16:46:53 +02:00
|
|
|
extern dig_lookuplist_t lookup_list;
|
|
|
|
extern dig_serverlist_t server_list;
|
2005-07-04 03:03:21 +00:00
|
|
|
extern dig_searchlistlist_t search_list;
|
2018-08-07 16:46:53 +02:00
|
|
|
extern unsigned int extrabytes;
|
2020-02-12 13:59:18 +01:00
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
extern bool check_ra, have_ipv4, have_ipv6, specified_source, usesearch,
|
2019-08-30 14:23:29 +10:00
|
|
|
showsearch, yaml;
|
2018-08-07 16:46:53 +02:00
|
|
|
extern in_port_t port;
|
2020-07-22 08:59:42 +02:00
|
|
|
extern bool port_set;
|
2018-08-07 16:46:53 +02:00
|
|
|
extern unsigned int timeout;
|
2020-09-05 16:37:24 -07:00
|
|
|
extern isc_refcount_t sendcount;
|
2018-08-07 16:46:53 +02:00
|
|
|
extern int ndots;
|
|
|
|
extern int lookup_counter;
|
|
|
|
extern int exitcode;
|
2020-09-05 16:37:24 -07:00
|
|
|
extern isc_sockaddr_t localaddr;
|
2018-08-07 16:46:53 +02:00
|
|
|
extern char keynametext[MXNAME];
|
|
|
|
extern char keyfile[MXNAME];
|
|
|
|
extern char keysecret[MXNAME];
|
2023-12-07 18:07:55 +11:00
|
|
|
extern dst_algorithm_t hmac_alg;
|
2018-08-07 16:46:53 +02:00
|
|
|
extern unsigned int digestbits;
|
|
|
|
extern dns_tsigkey_t *tsigkey;
|
|
|
|
extern bool validated;
|
2022-07-26 13:03:40 +02:00
|
|
|
extern isc_loop_t *mainloop;
|
2018-08-07 16:46:53 +02:00
|
|
|
extern bool free_now;
|
|
|
|
extern bool debugging, debugtiming, memdebugging;
|
|
|
|
extern bool keep_open;
|
2005-07-04 03:03:21 +00:00
|
|
|
|
2018-08-07 16:46:53 +02:00
|
|
|
extern int tries;
|
|
|
|
extern int fatalexit;
|
|
|
|
extern bool verbose;
|
2005-07-04 03:03:21 +00:00
|
|
|
|
2000-06-01 18:49:22 +00:00
|
|
|
/*
|
|
|
|
* Routines in dighost.c.
|
|
|
|
*/
|
2008-12-16 02:57:24 +00:00
|
|
|
isc_result_t
|
2015-04-17 02:57:02 +02:00
|
|
|
get_address(char *host, in_port_t myport, isc_sockaddr_t *sockaddr);
|
2000-07-05 19:31:26 +00:00
|
|
|
|
2011-02-25 23:11:13 +00:00
|
|
|
int
|
2011-12-07 17:23:28 +00:00
|
|
|
getaddresses(dig_lookup_t *lookup, const char *host, isc_result_t *resultp);
|
2011-02-25 23:11:13 +00:00
|
|
|
|
2000-10-23 23:13:21 +00:00
|
|
|
isc_result_t
|
2018-11-02 14:23:01 +00:00
|
|
|
get_reverse(char *reverse, size_t len, char *value, bool strict);
|
2000-10-23 23:13:21 +00:00
|
|
|
|
2024-07-11 16:15:40 +03:00
|
|
|
ISC_NORETURN void
|
2018-08-07 16:46:53 +02:00
|
|
|
fatal(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);
|
2000-07-05 19:31:26 +00:00
|
|
|
|
2017-11-23 16:58:12 +11:00
|
|
|
void
|
|
|
|
warn(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);
|
|
|
|
|
2024-07-11 16:15:40 +03:00
|
|
|
ISC_NORETURN void
|
2018-08-07 16:46:53 +02:00
|
|
|
digexit(void);
|
2023-01-30 15:26:52 +11:00
|
|
|
|
|
|
|
void
|
|
|
|
cleanup_openssl_refs(void);
|
2017-11-23 16:58:12 +11:00
|
|
|
|
2000-04-29 00:12:56 +00:00
|
|
|
void
|
2001-08-08 22:54:55 +00:00
|
|
|
debug(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);
|
2000-07-05 19:31:26 +00:00
|
|
|
|
2000-05-05 18:22:16 +00:00
|
|
|
void
|
2000-06-01 18:49:22 +00:00
|
|
|
check_result(isc_result_t result, const char *msg);
|
2000-07-05 19:31:26 +00:00
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
bool
|
2000-04-26 18:34:17 +00:00
|
|
|
setup_lookup(dig_lookup_t *lookup);
|
2000-07-05 19:31:26 +00:00
|
|
|
|
2007-04-03 23:06:39 +00:00
|
|
|
void
|
|
|
|
destroy_lookup(dig_lookup_t *lookup);
|
|
|
|
|
2000-04-26 18:34:17 +00:00
|
|
|
void
|
2000-05-12 01:02:37 +00:00
|
|
|
do_lookup(dig_lookup_t *lookup);
|
2000-07-05 19:31:26 +00:00
|
|
|
|
2000-04-26 18:34:17 +00:00
|
|
|
void
|
2000-07-05 19:31:26 +00:00
|
|
|
start_lookup(void);
|
|
|
|
|
2000-07-10 18:02:31 +00:00
|
|
|
void
|
2022-07-26 13:03:40 +02:00
|
|
|
onrun_callback(void *arg);
|
|
|
|
|
|
|
|
void
|
|
|
|
run_loop(void *arg);
|
2000-07-10 18:02:31 +00:00
|
|
|
|
2000-05-09 18:05:13 +00:00
|
|
|
void
|
2025-05-28 22:43:38 +02:00
|
|
|
setup_libs(int argc, char **argv);
|
2000-07-05 19:31:26 +00:00
|
|
|
|
2000-05-09 18:05:13 +00:00
|
|
|
void
|
2018-04-17 08:29:14 -07:00
|
|
|
setup_system(bool ipv4only, bool ipv6only);
|
2000-07-05 19:31:26 +00:00
|
|
|
|
2009-09-15 03:13:44 +00:00
|
|
|
isc_result_t
|
2018-03-28 14:19:37 +02:00
|
|
|
parse_uint(uint32_t *uip, const char *value, uint32_t max, const char *desc);
|
2009-09-15 03:13:44 +00:00
|
|
|
|
2014-09-13 19:13:59 +10:00
|
|
|
isc_result_t
|
2018-03-28 14:19:37 +02:00
|
|
|
parse_xint(uint32_t *uip, const char *value, uint32_t max, const char *desc);
|
2014-09-13 19:13:59 +10:00
|
|
|
|
2014-02-19 15:51:02 -08:00
|
|
|
isc_result_t
|
|
|
|
parse_netprefix(isc_sockaddr_t **sap, const char *value);
|
|
|
|
|
2009-09-15 03:13:44 +00:00
|
|
|
void
|
2023-04-11 19:01:31 -07:00
|
|
|
parse_hmac(const char *algname);
|
2009-09-15 03:13:44 +00:00
|
|
|
|
2000-06-01 18:49:22 +00:00
|
|
|
dig_lookup_t *
|
2018-04-17 08:29:14 -07:00
|
|
|
requeue_lookup(dig_lookup_t *lookold, bool servers);
|
2000-05-09 18:05:13 +00:00
|
|
|
|
2000-07-13 18:52:58 +00:00
|
|
|
dig_lookup_t *
|
|
|
|
make_empty_lookup(void);
|
|
|
|
|
|
|
|
dig_lookup_t *
|
2018-04-17 08:29:14 -07:00
|
|
|
clone_lookup(dig_lookup_t *lookold, bool servers);
|
2000-07-13 18:52:58 +00:00
|
|
|
|
2000-07-14 16:35:30 +00:00
|
|
|
dig_server_t *
|
2004-09-06 01:24:44 +00:00
|
|
|
make_server(const char *servname, const char *userarg);
|
2000-07-14 16:35:30 +00:00
|
|
|
|
2002-08-12 18:25:25 +00:00
|
|
|
void
|
|
|
|
flush_server_list(void);
|
|
|
|
|
|
|
|
void
|
|
|
|
set_nameserver(char *opt);
|
|
|
|
|
2000-07-14 16:35:30 +00:00
|
|
|
void
|
|
|
|
clone_server_list(dig_serverlist_t src, dig_serverlist_t *dest);
|
2000-04-26 18:34:17 +00:00
|
|
|
|
2000-07-14 17:57:27 +00:00
|
|
|
void
|
|
|
|
cancel_all(void);
|
|
|
|
|
|
|
|
void
|
|
|
|
destroy_libs(void);
|
|
|
|
|
2001-01-18 05:12:44 +00:00
|
|
|
void
|
|
|
|
set_search_domain(char *domain);
|
|
|
|
|
2000-06-01 18:49:22 +00:00
|
|
|
/*
|
2017-08-10 22:51:24 -07:00
|
|
|
* Routines to be defined in dig.c, host.c, and nslookup.c. and
|
|
|
|
* then assigned to the appropriate function pointer
|
2000-06-01 18:49:22 +00:00
|
|
|
*/
|
2018-08-07 16:46:53 +02:00
|
|
|
extern isc_result_t (*dighost_printmessage)(dig_query_t *query,
|
2019-07-16 23:44:20 -07:00
|
|
|
const isc_buffer_t *msgbuf,
|
|
|
|
dns_message_t *msg, bool headers);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Print an error message in the appropriate format.
|
|
|
|
*/
|
|
|
|
extern void (*dighost_error)(const char *format, ...);
|
|
|
|
|
2019-08-30 14:23:29 +10:00
|
|
|
/*
|
|
|
|
* Print a warning message in the appropriate format.
|
|
|
|
*/
|
|
|
|
extern void (*dighost_warning)(const char *format, ...);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Print a comment in the appropriate format.
|
|
|
|
*/
|
|
|
|
extern void (*dighost_comments)(dig_lookup_t *lookup, const char *format, ...);
|
|
|
|
|
2005-04-27 04:57:32 +00:00
|
|
|
/*%<
|
2001-01-24 19:28:34 +00:00
|
|
|
* Print the final result of the lookup.
|
|
|
|
*/
|
2000-07-05 19:31:26 +00:00
|
|
|
|
2019-07-16 23:44:20 -07:00
|
|
|
extern void (*dighost_received)(unsigned int bytes, isc_sockaddr_t *from,
|
|
|
|
dig_query_t *query);
|
2005-04-27 04:57:32 +00:00
|
|
|
/*%<
|
2001-01-24 19:28:34 +00:00
|
|
|
* Print a message about where and when the response
|
|
|
|
* was received from, like the final comment in the
|
|
|
|
* output of "dig".
|
|
|
|
*/
|
2000-07-05 19:31:26 +00:00
|
|
|
|
2017-08-10 22:51:24 -07:00
|
|
|
extern void (*dighost_trying)(char *frm, dig_lookup_t *lookup);
|
2000-07-05 19:31:26 +00:00
|
|
|
|
2017-08-10 22:51:24 -07:00
|
|
|
extern void (*dighost_shutdown)(void);
|
2000-09-21 23:47:41 +00:00
|
|
|
|
2017-11-23 16:58:12 +11:00
|
|
|
extern void (*dighost_pre_exit_hook)(void);
|
|
|
|
|
2014-04-18 09:52:12 +10:00
|
|
|
void
|
|
|
|
save_opt(dig_lookup_t *lookup, char *code, char *value);
|
|
|
|
|
2014-04-18 07:27:50 -07:00
|
|
|
void
|
|
|
|
setup_file_key(void);
|
|
|
|
void
|
|
|
|
setup_text_key(void);
|
|
|
|
|
2017-08-10 22:51:24 -07:00
|
|
|
/*
|
|
|
|
* Routines exported from dig.c for use by dig for iOS
|
|
|
|
*/
|
|
|
|
|
2020-09-12 13:23:52 -07:00
|
|
|
/*%
|
2017-08-10 22:51:24 -07:00
|
|
|
* Call once only to set up libraries, parse global
|
|
|
|
* parameters and initial command line query parameters
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
dig_setup(int argc, char **argv);
|
|
|
|
|
2020-09-12 13:23:52 -07:00
|
|
|
/*%
|
2017-08-10 22:51:24 -07:00
|
|
|
* Call to supply new parameters for the next lookup
|
|
|
|
*/
|
|
|
|
void
|
2018-04-17 08:29:14 -07:00
|
|
|
dig_query_setup(bool, bool, int argc, char **argv);
|
2017-08-10 22:51:24 -07:00
|
|
|
|
2020-09-12 13:23:52 -07:00
|
|
|
/*%
|
2017-08-10 22:51:24 -07:00
|
|
|
* set the main application event cycle running
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
dig_startup(void);
|
|
|
|
|
2020-09-12 13:23:52 -07:00
|
|
|
/*%
|
|
|
|
* Activate/deactivate IDN filtering of output.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
dig_idnsetup(dig_lookup_t *lookup, bool active);
|
|
|
|
|
|
|
|
/*%
|
2017-08-10 22:51:24 -07:00
|
|
|
* Cleans up the application
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
dig_shutdown(void);
|
|
|
|
|
2022-01-19 13:10:08 +02:00
|
|
|
bool
|
|
|
|
dig_lookup_is_tls(const dig_lookup_t *lookup);
|