}
-int answer_from_pkt(kr_layer_t *ctx, knot_pkt_t *pkt, uint16_t type,
+int answer_from_pkt(struct kr_query *qry, knot_pkt_t *pkt, uint16_t type,
const struct entry_h *eh, const void *eh_bound, uint32_t new_ttl)
{
- struct kr_request *req = ctx->req;
- struct kr_query *qry = req->current_query;
-
const uint16_t msgid = knot_wire_get_id(pkt->wire);
/* Ensure the wire buffer is large enough. Strategy: fit and at least double. */
if (pkt_len > pkt->max_size) {
pkt->max_size = MIN(KNOT_WIRE_MAX_PKTSIZE,
MAX(pkt->max_size * 2, pkt_len));
- mm_free(&ctx->req->pool, pkt->wire); /* no-op, but... */
- pkt->wire = mm_alloc(&ctx->req->pool, pkt->max_size);
+ mm_free(&qry->request->pool, pkt->wire); /* no-op, but... */
+ pkt->wire = mm_alloc(&qry->request->pool, pkt->max_size);
pkt->compr.wire = pkt->wire;
/* TODO: ^^ nicer way how to replace knot_pkt_t::wire ? */
}
/* The whole file only exports peek_nosync().
* Forwards for larger chunks of code: */
-static int found_exact_hit(kr_layer_t *ctx, knot_pkt_t *pkt, knot_db_val_t val,
+static int found_exact_hit(struct kr_query *qry, knot_pkt_t *pkt, knot_db_val_t val,
uint8_t lowest_rank);
static int closest_NS(struct kr_cache *cache, struct key *k, entry_list_t el,
struct kr_query *qry, bool only_NS, bool is_DS);
-static int answer_simple_hit(kr_layer_t *ctx, knot_pkt_t *pkt, uint16_t type,
+static int answer_simple_hit(struct kr_query *qry, knot_pkt_t *pkt, uint16_t type,
const struct entry_h *eh, const void *eh_bound, uint32_t new_ttl);
-static int answer_dname_hit(kr_layer_t *ctx, knot_pkt_t *pkt, const knot_dname_t *dname_owner,
+static int answer_dname_hit(struct kr_query *qry, knot_pkt_t *pkt, const knot_dname_t *dname_owner,
const struct entry_h *eh, const void *eh_bound, uint32_t new_ttl);
static int try_wild(struct key *k, struct answer *ans, const knot_dname_t *clencl_name,
uint16_t type, uint8_t lowest_rank,
ret = cache_op(cache, read, &key, &val, 1);
if (!ret) {
/* found an entry: test conditions, materialize into pkt, etc. */
- ret = found_exact_hit(ctx, pkt, val, lowest_rank);
+ ret = found_exact_hit(qry, pkt, val, lowest_rank);
}
}
if (!ret) {
return ctx->state;
const int32_t new_ttl = get_new_ttl(v.data, qry, qry->sname,
KNOT_RRTYPE_CNAME, qry->timestamp.tv_sec);
- ret = answer_simple_hit(ctx, pkt, KNOT_RRTYPE_CNAME, v.data,
+ ret = answer_simple_hit(qry, pkt, KNOT_RRTYPE_CNAME, v.data,
knot_db_val_bound(v), new_ttl);
return ret == kr_ok() ? KR_STATE_DONE : ctx->state;
}
/* TTL: for simplicity, we just ask for TTL of the generated CNAME. */
const int32_t new_ttl = get_new_ttl(v.data, qry, qry->sname,
KNOT_RRTYPE_CNAME, qry->timestamp.tv_sec);
- ret = answer_dname_hit(ctx, pkt, k->zname, v.data,
+ ret = answer_dname_hit(qry, pkt, k->zname, v.data,
knot_db_val_bound(v), new_ttl);
return ret == kr_ok() ? KR_STATE_DONE : ctx->state;
}
if (kr_fails_assert((ret) >= 0)) return kr_error((ret)); \
} while (false)
-static int answer_simple_hit(kr_layer_t *ctx, knot_pkt_t *pkt, uint16_t type,
+static int answer_simple_hit(struct kr_query *qry, knot_pkt_t *pkt, uint16_t type,
const struct entry_h *eh, const void *eh_bound, uint32_t new_ttl)
{
- struct kr_request *req = ctx->req;
- struct kr_query *qry = req->current_query;
-
/* All OK, so start constructing the (pseudo-)packet. */
int ret = pkt_renew(pkt, qry->sname, qry->stype);
CHECK_RET(ret);
return kr_ok();
}
-static int answer_dname_hit(kr_layer_t *ctx, knot_pkt_t *pkt, const knot_dname_t *dname_owner,
+static int answer_dname_hit(struct kr_query *qry, knot_pkt_t *pkt, const knot_dname_t *dname_owner,
const struct entry_h *eh, const void *eh_bound, uint32_t new_ttl)
{
- struct kr_request *req = ctx->req;
- struct kr_query *qry = req->current_query;
-
/* All OK, so start constructing the (pseudo-)packet. */
int ret = pkt_renew(pkt, qry->sname, qry->stype);
CHECK_RET(ret);
#undef CHECK_RET
/** TODO: description; see the single call site for now. */
-static int found_exact_hit(kr_layer_t *ctx, knot_pkt_t *pkt, knot_db_val_t val,
+static int found_exact_hit(struct kr_query *qry, knot_pkt_t *pkt, knot_db_val_t val,
uint8_t lowest_rank)
{
- struct kr_request *req = ctx->req;
- struct kr_query *qry = req->current_query;
-
int ret = entry_h_seek(&val, qry->stype);
if (ret) return ret;
const struct entry_h *eh = entry_h_consistent_E(val, qry->stype);
* possible that we could generate a higher-security negative proof.
* Rank is high-enough so we take it to save time searching;
* in practice this also helps in some incorrect zones (live-signed). */
- return answer_from_pkt (ctx, pkt, qry->stype, eh, eh_bound, new_ttl);
+ return answer_from_pkt (qry, pkt, qry->stype, eh, eh_bound, new_ttl);
} else {
- return answer_simple_hit(ctx, pkt, qry->stype, eh, eh_bound, new_ttl);
+ return answer_simple_hit(qry, pkt, qry->stype, eh, eh_bound, new_ttl);
}
}