Commit c3c124f1 authored by Daniel Salzman's avatar Daniel Salzman

edns: remove duplicate constants and a function

parent 739daa6b
......@@ -239,7 +239,7 @@ static int answer_edns_init(const knot_pkt_t *query, knot_pkt_t *resp,
/* Append NSID if requested and available. */
val = conf_get(conf(), C_SRV, C_NSID);
if (knot_edns_has_nsid(query->opt_rr)) {
if (knot_edns_has_option(query->opt_rr, KNOT_EDNS_OPTION_NSID)) {
conf_data(&val);
if (val.code != KNOT_EOK) {
ret = knot_edns_add_option(&qdata->opt_rr,
......
......@@ -275,13 +275,6 @@ bool knot_edns_has_option(const knot_rrset_t *opt_rr, uint16_t code)
return pos != NULL;
}
/*----------------------------------------------------------------------------*/
_public_
bool knot_edns_has_nsid(const knot_rrset_t *opt_rr)
{
return knot_edns_has_option(opt_rr, KNOT_EDNS_OPTION_NSID);
}
/*----------------------------------------------------------------------------*/
_public_
bool knot_edns_check_record(knot_rrset_t *opt_rr)
......
......@@ -26,13 +26,8 @@
#pragma once
#include <stdint.h>
#include "libknot/rrset.h"
/* Forward declaration. */
struct knot_packet;
/*! \brief Constants related to EDNS. */
enum knot_edns_const {
/*! \brief Supported EDNS version. */
......@@ -57,23 +52,13 @@ 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,
/*! \brief Extended RCODE BADVERS. */
KNOT_EDNS_RCODE_BADVERS = 16,
KNOT_EDNS_OPTION_CLIENT_SUBNET = 8
};
/* Helpers for splitting extended RCODE. */
#define KNOT_EDNS_RCODE_HI(rc) ((rc >> 4) & 0x00ff)
#define KNOT_EDNS_RCODE_LO(rc) (rc & 0x000f)
/*!
* \brief EDNS DO flag.
*
* \note Use only with unsigned 2-byte variables.
* \warning Flags are represented in machine byte order.
*/
static const uint16_t KNOT_EDNS_FLAG_DO = (uint16_t)1 << 15;
/*----------------------------------------------------------------------------*/
/* EDNS OPT RR handling functions. */
/*----------------------------------------------------------------------------*/
......
......@@ -63,6 +63,8 @@ enum offsets {
OFFSET_OPT_DATA = 4
};
static const uint16_t DO_FLAG = (uint16_t)1 << 15;
static bool check_ttl(knot_rdata_t *rdata, uint8_t ext_rcode, uint8_t ver,
uint16_t flags, char *msg, int *done)
{
......@@ -261,9 +263,8 @@ static bool test_setters(knot_rrset_t *opt_rr, int *done)
knot_edns_set_do(opt_rr);
bool success = true;
bool check = check_header(opt_rr, E_MAX_PLD2, E_VERSION2,
KNOT_EDNS_FLAG_DO, E_RCODE2,
"OPT RR setters", done);
bool check = check_header(opt_rr, E_MAX_PLD2, E_VERSION2, DO_FLAG,
E_RCODE2, "OPT RR setters", done);
success &= check;
/* OPTION(RDATA)-related setters. */
......
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