Skip to content
Snippets Groups Projects
Commit b9e15b93 authored by Marek Vavruša's avatar Marek Vavruša
Browse files

edns: set EXT-RCODE correctly

fixes #282
parent b5f2e404
No related branches found
No related tags found
No related merge requests found
......@@ -314,6 +314,12 @@ static int answer_edns_put(knot_pkt_t *resp, struct query_data *qdata)
return KNOT_EOK;
}
/* Write back extended RCODE. */
if (qdata->rcode_ext != 0) {
knot_wire_set_rcode(resp->wire, KNOT_EDNS_RCODE_LO(qdata->rcode_ext));
knot_edns_set_ext_rcode(&qdata->opt_rr, KNOT_EDNS_RCODE_HI(qdata->rcode_ext));
}
/* Reclaim reserved size. */
int ret = knot_pkt_reclaim(resp, knot_edns_wire_size(&qdata->opt_rr));
if (ret != KNOT_EOK) {
......
......@@ -56,9 +56,15 @@ enum knot_edns_const {
/*! \brief NSID option code. */
KNOT_EDNS_OPTION_NSID = 3,
/*! \brief EDNS client subnet option code. */
KNOT_EDNS_OPTION_CLIENT_SUBNET = 8
KNOT_EDNS_OPTION_CLIENT_SUBNET = 8,
/*! \brief Extended RCODE BADVERS. */
KNOT_EDNS_RCODE_BADVERS = 16,
};
/* Helpers for splitting extended RCODE. */
#define KNOT_EDNS_RCODE_HI(rc) (rc >> 4)
#define KNOT_EDNS_RCODE_LO(rc) (rc & 0x000f)
/*!
* \brief EDNS DO flag.
*
......@@ -67,10 +73,6 @@ enum knot_edns_const {
*/
static const uint16_t KNOT_EDNS_FLAG_DO = (uint16_t)1 << 15;
/*! \brief Extended RCODE BADVERS. */
static const uint8_t KNOT_EDNS_RCODE_BADVERS = 16;
/*----------------------------------------------------------------------------*/
/* EDNS OPT RR handling functions. */
/*----------------------------------------------------------------------------*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment