-void dns_query_transaction_reply(DnsQueryTransaction *t, DnsPacket *p) {
- int r;
-
- assert(t);
- assert(p);
-
- if (t->state != DNS_QUERY_PENDING)
- return;
-
- if (t->received != p) {
- dns_packet_unref(t->received);
- t->received = dns_packet_ref(p);
- }
-
- if (t->tcp_fd >= 0) {
- if (DNS_PACKET_TC(p)) {
- /* Truncated via TCP? Somebody must be fucking with us */
- dns_query_transaction_set_state(t, DNS_QUERY_INVALID_REPLY);
- return;
- }
-
- if (DNS_PACKET_ID(p) != t->id) {
- /* Not the reply to our query? Somebody must be fucking with us */
- dns_query_transaction_set_state(t, DNS_QUERY_INVALID_REPLY);
- return;
- }
- }
-
- if (DNS_PACKET_TC(p)) {
- /* Response was truncated, let's try again with good old TCP */
- r = dns_query_transaction_start_tcp(t);
- if (r == -ESRCH) {
- /* No servers found? Damn! */
- dns_query_transaction_set_state(t, DNS_QUERY_NO_SERVERS);
- return;
- }
- if (r < 0) {
- /* Couldn't send? Try immediately again, with a new server */
- dns_scope_next_dns_server(t->scope);
+static void dns_query_complete(DnsQuery *q, DnsTransactionState state) {
+ assert(q);
+ assert(!IN_SET(state, DNS_TRANSACTION_NULL, DNS_TRANSACTION_PENDING));
+ assert(IN_SET(q->state, DNS_TRANSACTION_NULL, DNS_TRANSACTION_PENDING));