#pragma once
typedef struct DnsTransaction DnsTransaction;
typedef enum DnsTransactionState DnsTransactionState;
enum DnsTransactionState {
DNS_TRANSACTION_NULL,
DNS_TRANSACTION_PENDING,
DNS_TRANSACTION_FAILURE,
DNS_TRANSACTION_SUCCESS,
DNS_TRANSACTION_NO_SERVERS,
DNS_TRANSACTION_TIMEOUT,
DNS_TRANSACTION_ATTEMPTS_MAX_REACHED,
DNS_TRANSACTION_INVALID_REPLY,
DNS_TRANSACTION_RESOURCES,
DNS_TRANSACTION_ABORTED,
_DNS_TRANSACTION_STATE_MAX,
_DNS_TRANSACTION_STATE_INVALID = -1
};
#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"
#include "resolved-dns-stream.h"
struct DnsTransaction {
DnsScope *scope;
DnsQuestion *question;
DnsTransactionState state;
uint16_t id;
bool initial_jitter;
DnsPacket *sent, *received;
DnsAnswer *cached;
int cached_rcode;
sd_event_source *timeout_event_source;
unsigned n_attempts;
DnsStream *stream;
Set *queries;
Set *zone_items;
unsigned block_gc;
LIST_FIELDS(DnsTransaction, transactions_by_scope);
};
int dns_transaction_new(DnsTransaction **ret, DnsScope *s, DnsQuestion *q);
DnsTransaction* dns_transaction_free(DnsTransaction *t);
void dns_transaction_gc(DnsTransaction *t);
int dns_transaction_go(DnsTransaction *t);
void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p);
void dns_transaction_complete(DnsTransaction *t, DnsTransactionState state);
const char* dns_transaction_state_to_string(DnsTransactionState p) _const_;
DnsTransactionState dns_transaction_state_from_string(const char *s) _pure_;
#define DNS_TRANSACTION_TIMEOUT_USEC (5 * USEC_PER_SEC)
#define LLMNR_TRANSACTION_TIMEOUT_USEC (1 * USEC_PER_SEC)
#define LLMNR_JITTER_INTERVAL_USEC (100 * USEC_PER_MSEC)
#define DNS_TRANSACTION_ATTEMPTS_MAX 8
#define LLMNR_TRANSACTION_ATTEMPTS_MAX 3
#define TRANSACTION_TIMEOUT_USEC(p) (p == DNS_PROTOCOL_LLMNR ? LLMNR_TRANSACTION_TIMEOUT_USEC : DNS_TRANSACTION_TIMEOUT_USEC)
#define TRANSACTION_ATTEMPTS_MAX(p) (p == DNS_PROTOCOL_LLMNR ? LLMNR_TRANSACTION_ATTEMPTS_MAX : DNS_TRANSACTION_ATTEMPTS_MAX)