]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/resolve/resolved-dns-query.h
resolved: cache stringified transaction key once per transaction
[thirdparty/systemd.git] / src / resolve / resolved-dns-query.h
index 864036acc73609675f24c60abf59d395155c156d..d7f96c3ca4cb3d72867a8686658760f070142859 100644 (file)
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <inttypes.h>
 
 #include "sd-bus.h"
-#include "util.h"
 
+#include "set.h"
+
+typedef struct DnsQueryCandidate DnsQueryCandidate;
 typedef struct DnsQuery DnsQuery;
-typedef struct DnsQueryTransaction DnsQueryTransaction;
-
-#include "resolved.h"
-#include "resolved-dns-scope.h"
-#include "resolved-dns-rr.h"
-#include "resolved-dns-packet.h"
-
-typedef enum DnsQueryState {
-        DNS_QUERY_NULL,
-        DNS_QUERY_PENDING,
-        DNS_QUERY_FAILURE,
-        DNS_QUERY_SUCCESS,
-        DNS_QUERY_NO_SERVERS,
-        DNS_QUERY_TIMEOUT,
-        DNS_QUERY_ATTEMPTS_MAX,
-        DNS_QUERY_INVALID_REPLY,
-        DNS_QUERY_RESOURCES
-} DnsQueryState;
-
-struct DnsQueryTransaction {
-        DnsQuery *query;
-        DnsScope *scope;
 
-        DnsQueryState state;
-        uint16_t id;
+#include "resolved-dns-answer.h"
+#include "resolved-dns-question.h"
+#include "resolved-dns-stream.h"
+#include "resolved-dns-search-domain.h"
 
-        sd_event_source *timeout_event_source;
-        unsigned n_attempts;
+struct DnsQueryCandidate {
+        DnsQuery *query;
+        DnsScope *scope;
 
-        DnsPacket *sent, *received;
+        DnsSearchDomain *search_domain;
 
-        /* TCP connection logic */
-        int tcp_fd;
-        sd_event_source *tcp_event_source;
-        size_t tcp_written, tcp_read;
-        be16_t tcp_read_size;
+        int error_code;
+        Set *transactions;
 
-        LIST_FIELDS(DnsQueryTransaction, transactions_by_query);
-        LIST_FIELDS(DnsQueryTransaction, transactions_by_scope);
+        LIST_FIELDS(DnsQueryCandidate, candidates_by_query);
+        LIST_FIELDS(DnsQueryCandidate, candidates_by_scope);
 };
 
 struct DnsQuery {
         Manager *manager;
 
-        DnsResourceKey *keys;
-        unsigned n_keys;
+        /* When resolving a service, we first create a TXT+SRV query,
+         * and then for the hostnames we discover auxiliary A+AAAA
+         * queries. This pointer always points from the auxiliary
+         * queries back to the TXT+SRV query. */
+        DnsQuery *auxiliary_for;
+        LIST_HEAD(DnsQuery, auxiliary_queries);
+        unsigned n_auxiliary_queries;
+        int auxiliary_result;
+
+        DnsQuestion *question;
+        uint64_t flags;
+        int ifindex;
 
-        DnsQueryState state;
-        unsigned n_cname;
+        DnsTransactionState state;
+        unsigned n_cname_redirects;
 
+        LIST_HEAD(DnsQueryCandidate, candidates);
         sd_event_source *timeout_event_source;
 
-        DnsPacket *received;
+        /* Discovered data */
+        DnsAnswer *answer;
+        int answer_rcode;
+        DnsProtocol answer_protocol;
+        int answer_family;
+        DnsSearchDomain *answer_search_domain;
+        bool answer_authenticated;
 
         /* Bus client information */
         sd_bus_message *request;
-        unsigned char request_family;
-        const char *request_hostname;
+        int request_family;
+        bool request_address_valid;
         union in_addr_union request_address;
+        unsigned block_all_complete;
 
+        /* Completion callback */
         void (*complete)(DnsQuery* q);
+        unsigned block_ready;
+
+        sd_bus_track *bus_track;
 
-        LIST_HEAD(DnsQueryTransaction, transactions);
         LIST_FIELDS(DnsQuery, queries);
+        LIST_FIELDS(DnsQuery, auxiliary_queries);
 };
 
-int dns_query_new(Manager *m, DnsQuery **q, DnsResourceKey *keys, unsigned n_keys);
+DnsQueryCandidate* dns_query_candidate_free(DnsQueryCandidate *c);
+void dns_query_candidate_notify(DnsQueryCandidate *c);
+
+int dns_query_new(Manager *m, DnsQuery **q, DnsQuestion *question, int family, uint64_t flags);
 DnsQuery *dns_query_free(DnsQuery *q);
-int dns_query_start(DnsQuery *q);
-int dns_query_follow_cname(DnsQuery *q, const char *name);
-int dns_query_matches_rr(DnsQuery *q, DnsResourceRecord *rr);
-int dns_query_matches_cname(DnsQuery *q, DnsResourceRecord *rr);
-
-DnsQueryTransaction* dns_query_transaction_free(DnsQueryTransaction *t);
-void dns_query_transaction_reply(DnsQueryTransaction *t, DnsPacket *p);
-void dns_query_finish(DnsQuery *q);
+
+int dns_query_make_auxiliary(DnsQuery *q, DnsQuery *auxiliary_for);
+
+int dns_query_go(DnsQuery *q);
+void dns_query_ready(DnsQuery *q);
+
+int dns_query_process_cname(DnsQuery *q);
+
+int dns_query_bus_track(DnsQuery *q, sd_bus_message *m);
 
 DEFINE_TRIVIAL_CLEANUP_FUNC(DnsQuery*, dns_query_free);