Commit 970a12c7 authored by Marek Vavruša's avatar Marek Vavruša

lib/resolve: initialize answer from query (if provided)

parent 9b3f8b44
......@@ -216,7 +216,7 @@ int kr_resolve_query(struct kr_request *request, const knot_dname_t *qname, uint
return KNOT_STATE_FAIL;
}
/* Create answer packet */
/* Initialize answer packet */
knot_pkt_t *answer = request->answer;
knot_wire_set_qr(answer->wire);
knot_wire_clear_aa(answer->wire);
......@@ -233,7 +233,10 @@ int kr_resolve_consume(struct kr_request *request, knot_pkt_t *packet)
struct kr_query *qry = kr_rplan_current(rplan);
/* Empty resolution plan, push packet as the new query */
if (kr_rplan_empty(&request->rplan)) {
if (kr_rplan_empty(rplan)) {
if (knot_pkt_init_response(request->answer, packet) != 0) {
return KNOT_STATE_FAIL;
}
const knot_dname_t *qname = knot_pkt_qname(packet);
uint16_t qclass = knot_pkt_qclass(packet);
uint16_t qtype = knot_pkt_qtype(packet);
......
......@@ -145,7 +145,7 @@ int kr_rplan_pop(struct kr_rplan *rplan, struct kr_query *qry)
struct kr_query *kr_rplan_current(struct kr_rplan *rplan)
{
if (rplan == NULL || EMPTY_LIST(rplan->pending)) {
if (kr_rplan_empty(rplan)) {
return NULL;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment