resolve: make manager_monitor_send() take DnsQuery*
This commit is contained in:
@@ -589,7 +589,7 @@ void dns_query_complete(DnsQuery *q, DnsTransactionState state) {
|
||||
|
||||
q->state = state;
|
||||
|
||||
(void) manager_monitor_send(q->manager, q->state, q->answer_rcode, q->answer_errno, q->question_idna, q->question_utf8, q->question_bypass, q->collected_questions, q->answer);
|
||||
(void) manager_monitor_send(q->manager, q);
|
||||
|
||||
dns_query_stop(q);
|
||||
if (q->complete)
|
||||
|
||||
@@ -1098,17 +1098,7 @@ static int dns_question_to_json(DnsQuestion *q, JsonVariant **ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int manager_monitor_send(
|
||||
Manager *m,
|
||||
int state,
|
||||
int rcode,
|
||||
int error,
|
||||
DnsQuestion *question_idna,
|
||||
DnsQuestion *question_utf8,
|
||||
DnsPacket *question_bypass,
|
||||
DnsQuestion *collected_questions,
|
||||
DnsAnswer *answer) {
|
||||
|
||||
int manager_monitor_send(Manager *m, DnsQuery *q) {
|
||||
_cleanup_(json_variant_unrefp) JsonVariant *jquestion = NULL, *jcollected_questions = NULL, *janswer = NULL;
|
||||
_cleanup_(dns_question_unrefp) DnsQuestion *merged = NULL;
|
||||
Varlink *connection;
|
||||
@@ -1121,14 +1111,14 @@ int manager_monitor_send(
|
||||
return 0;
|
||||
|
||||
/* Merge all questions into one */
|
||||
r = dns_question_merge(question_idna, question_utf8, &merged);
|
||||
r = dns_question_merge(q->question_idna, q->question_utf8, &merged);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to merge UTF8/IDNA questions: %m");
|
||||
|
||||
if (question_bypass) {
|
||||
if (q->question_bypass) {
|
||||
_cleanup_(dns_question_unrefp) DnsQuestion *merged2 = NULL;
|
||||
|
||||
r = dns_question_merge(merged, question_bypass->question, &merged2);
|
||||
r = dns_question_merge(merged, q->question_bypass->question, &merged2);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to merge UTF8/IDNA questions and DNS packet question: %m");
|
||||
|
||||
@@ -1142,11 +1132,11 @@ int manager_monitor_send(
|
||||
return log_error_errno(r, "Failed to convert question to JSON: %m");
|
||||
|
||||
/* Generate a JSON array of the questions preceding the current one in the CNAME chain */
|
||||
r = dns_question_to_json(collected_questions, &jcollected_questions);
|
||||
r = dns_question_to_json(q->collected_questions, &jcollected_questions);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to convert question to JSON: %m");
|
||||
|
||||
DNS_ANSWER_FOREACH_ITEM(rri, answer) {
|
||||
DNS_ANSWER_FOREACH_ITEM(rri, q->answer) {
|
||||
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
|
||||
|
||||
r = dns_resource_record_to_json(rri->rr, &v);
|
||||
@@ -1169,9 +1159,9 @@ int manager_monitor_send(
|
||||
|
||||
SET_FOREACH(connection, m->varlink_subscription) {
|
||||
r = varlink_notifyb(connection,
|
||||
JSON_BUILD_OBJECT(JSON_BUILD_PAIR("state", JSON_BUILD_STRING(dns_transaction_state_to_string(state))),
|
||||
JSON_BUILD_PAIR_CONDITION(state == DNS_TRANSACTION_RCODE_FAILURE, "rcode", JSON_BUILD_INTEGER(rcode)),
|
||||
JSON_BUILD_PAIR_CONDITION(state == DNS_TRANSACTION_ERRNO, "errno", JSON_BUILD_INTEGER(error)),
|
||||
JSON_BUILD_OBJECT(JSON_BUILD_PAIR("state", JSON_BUILD_STRING(dns_transaction_state_to_string(q->state))),
|
||||
JSON_BUILD_PAIR_CONDITION(q->state == DNS_TRANSACTION_RCODE_FAILURE, "rcode", JSON_BUILD_INTEGER(q->answer_rcode)),
|
||||
JSON_BUILD_PAIR_CONDITION(q->state == DNS_TRANSACTION_ERRNO, "errno", JSON_BUILD_INTEGER(q->answer_errno)),
|
||||
JSON_BUILD_PAIR("question", JSON_BUILD_VARIANT(jquestion)),
|
||||
JSON_BUILD_PAIR_CONDITION(jcollected_questions, "collectedQuestions", JSON_BUILD_VARIANT(jcollected_questions)),
|
||||
JSON_BUILD_PAIR_CONDITION(janswer, "answer", JSON_BUILD_VARIANT(janswer))));
|
||||
|
||||
@@ -176,7 +176,7 @@ int manager_start(Manager *m);
|
||||
|
||||
uint32_t manager_find_mtu(Manager *m);
|
||||
|
||||
int manager_monitor_send(Manager *m, int state, int rcode, int error, DnsQuestion *question_idna, DnsQuestion *question_utf8, DnsPacket *question_bypass, DnsQuestion *collected_questions, DnsAnswer *answer);
|
||||
int manager_monitor_send(Manager *m, DnsQuery *q);
|
||||
|
||||
int manager_write(Manager *m, int fd, DnsPacket *p);
|
||||
int manager_send(Manager *m, int fd, int ifindex, int family, const union in_addr_union *destination, uint16_t port, const union in_addr_union *source, DnsPacket *p);
|
||||
|
||||
Reference in New Issue
Block a user