Commit 978096e2 authored by Karel Slaný's avatar Karel Slaný Committed by Ondřej Surý

Removed qdcount from struct kr_query.

parent 28b5b985
......@@ -203,7 +203,6 @@ struct kr_zonecut {
};
struct kr_query {
struct kr_query *parent;
uint16_t qdcount;
knot_dname_t *sname;
uint16_t type;
uint16_t class;
......
......@@ -519,8 +519,8 @@ static int begin(knot_layer_t *ctx, void *module_param)
* before this layer.
*/
const struct kr_request *req = ctx->data;
const struct kr_query *qry = req->current_query;
if (qry->qdcount == 0) {
const knot_pkt_t *pkt = req->qsource.packet;
if (!pkt || knot_wire_get_qdcount(pkt->wire) == 0) {
return KNOT_STATE_FAIL;
}
return reset(ctx);
......
......@@ -54,7 +54,6 @@ static struct kr_query *query_create(knot_mm_t *pool, const knot_dname_t *name)
mm_free(pool, qry);
return NULL;
}
qry->qdcount = 1;
}
knot_dname_to_lower(qry->sname);
......
......@@ -65,7 +65,6 @@ const knot_lookup_t *kr_query_flag_names(void);
*/
struct kr_query {
struct kr_query *parent;
uint16_t qdcount; /* Can be 0 when querying server cookie. */
knot_dname_t *sname;
uint16_t stype;
uint16_t sclass;
......
......@@ -313,15 +313,21 @@ static inline uint8_t *req_cookie_option(struct kr_request *req)
* @param state original resolver state
* @param sc_present true if server cookie is present
* @param ignore_badcookie true if bad cookies should be treated as good ones
* @param qry query context
* @param req request context
* @return new resolver state
*/
static int invalid_sc_status(int state, bool sc_present, bool ignore_badcookie,
const struct kr_query *qry, knot_pkt_t *answer)
const struct kr_request *req, knot_pkt_t *answer)
{
assert(qry && answer);
assert(req && answer);
if (qry->qdcount == 0) {
const knot_pkt_t *pkt = req->qsource.packet;
if (!pkt) {
return KNOT_STATE_FAIL;
}
if (knot_wire_get_qdcount(pkt->wire) == 0) {
/* RFC7873 5.4 */
state = KNOT_STATE_DONE;
if (sc_present) {
......@@ -409,7 +415,7 @@ int check_request(knot_layer_t *ctx, void *module_param)
if (!cookies.sc) {
/* Request has no server cookie. */
return_state = invalid_sc_status(return_state, false,
ignore_badcookie, qry, answer);
ignore_badcookie, req, answer);
if (return_state == KNOT_STATE_FAIL) {
return return_state;
}
......@@ -435,7 +441,7 @@ int check_request(knot_layer_t *ctx, void *module_param)
if (ret != KNOT_EOK) {
/* Invalid server cookie. */
return_state = invalid_sc_status(return_state, true,
ignore_badcookie, qry, answer);
ignore_badcookie, req, answer);
if (return_state == KNOT_STATE_FAIL) {
return return_state;
}
......
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