diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-07-22 21:48:41 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-07-23 02:00:40 +0200 |
commit | faa133f3aa7a18f26563dc5d6b95898cb315c37a (patch) | |
tree | 17b1a2aaba6b5a8e04e1fa361d5e9324ea249589 /src/resolve/resolved-dns-query.h | |
parent | a3eca41994de42f5448b35e8815d3009b2b5df38 (diff) |
resolved: rework logic so that we can share transactions between queries of different clients
Diffstat (limited to 'src/resolve/resolved-dns-query.h')
-rw-r--r-- | src/resolve/resolved-dns-query.h | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/src/resolve/resolved-dns-query.h b/src/resolve/resolved-dns-query.h index 2b814cca42..2756048be5 100644 --- a/src/resolve/resolved-dns-query.h +++ b/src/resolve/resolved-dns-query.h @@ -25,6 +25,7 @@ #include "sd-bus.h" #include "util.h" +#include "set.h" typedef struct DnsQuery DnsQuery; typedef struct DnsQueryTransaction DnsQueryTransaction; @@ -33,6 +34,8 @@ typedef struct DnsQueryTransaction DnsQueryTransaction; #include "resolved-dns-scope.h" #include "resolved-dns-rr.h" #include "resolved-dns-packet.h" +#include "resolved-dns-question.h" +#include "resolved-dns-answer.h" typedef enum DnsQueryState { DNS_QUERY_NULL, @@ -43,50 +46,53 @@ typedef enum DnsQueryState { DNS_QUERY_TIMEOUT, DNS_QUERY_ATTEMPTS_MAX, DNS_QUERY_INVALID_REPLY, - DNS_QUERY_RESOURCES + DNS_QUERY_RESOURCES, + DNS_QUERY_ABORTED, } DnsQueryState; struct DnsQueryTransaction { - DnsQuery *query; DnsScope *scope; + DnsQuestion *question; + DnsQueryState state; uint16_t id; + DnsPacket *sent, *received; + DnsAnswer *cached; + sd_event_source *timeout_event_source; unsigned n_attempts; - DnsPacket *sent, *received; - /* TCP connection logic */ int tcp_fd; sd_event_source *tcp_event_source; size_t tcp_written, tcp_read; be16_t tcp_read_size; - /* Data from cache */ - DnsResourceRecord **cached_rrs; - unsigned n_cached_rrs; + /* Queries this transaction is referenced by and that shall by + * notified about this specific transaction completing. */ + Set *queries; + + unsigned block_gc; - LIST_FIELDS(DnsQueryTransaction, transactions_by_query); LIST_FIELDS(DnsQueryTransaction, transactions_by_scope); }; struct DnsQuery { Manager *manager; - - DnsResourceKey *keys; - unsigned n_keys; + DnsQuestion *question; DnsQueryState state; - unsigned n_cname; + unsigned n_cname_redirects; sd_event_source *timeout_event_source; /* Discovered data */ DnsPacket *received; - DnsResourceRecord **cached_rrs; - unsigned n_cached_rrs; + DnsAnswer *answer; + int answer_ifindex; + int answer_rcode; /* Bus client information */ sd_bus_message *request; @@ -96,28 +102,24 @@ struct DnsQuery { /* Completion callback */ void (*complete)(DnsQuery* q); - unsigned block_finish; + unsigned block_ready; + + Set *transactions; - LIST_HEAD(DnsQueryTransaction, transactions); LIST_FIELDS(DnsQuery, queries); }; DnsQueryTransaction* dns_query_transaction_free(DnsQueryTransaction *t); -void dns_query_transaction_reply(DnsQueryTransaction *t, DnsPacket *p); +void dns_query_transaction_complete(DnsQueryTransaction *t, DnsQueryState state); + +void dns_query_transaction_process_reply(DnsQueryTransaction *t, DnsPacket *p); -int dns_query_new(Manager *m, DnsQuery **q, DnsResourceKey *keys, unsigned n_keys); +int dns_query_new(Manager *m, DnsQuery **q, DnsQuestion *question); DnsQuery *dns_query_free(DnsQuery *q); int dns_query_go(DnsQuery *q); -int dns_query_cname_redirect(DnsQuery *q, const char *name); -void dns_query_finish(DnsQuery *q); - -int dns_query_matches_rr(DnsQuery *q, DnsResourceRecord *rr); -int dns_query_matches_cname(DnsQuery *q, DnsResourceRecord *rr); +void dns_query_ready(DnsQuery *q); -/* What we found */ -int dns_query_get_rrs(DnsQuery *q, DnsResourceRecord *** rrs); -int dns_query_get_rcode(DnsQuery *q); -int dns_query_get_ifindex(DnsQuery *q); +int dns_query_cname_redirect(DnsQuery *q, const char *name); DEFINE_TRIVIAL_CLEANUP_FUNC(DnsQuery*, dns_query_free); |