Commit 7de8c307 authored by Daniel Salzman's avatar Daniel Salzman

nameserver: modules unification + cleanup

parent eb96d1a4
......@@ -45,12 +45,12 @@ static int capture(knot_pkt_t *pkt, knot_process_t *ctx)
/*! \brief Module implementation. */
static const knot_process_module_t PROCESS_CAPTURE_MODULE = {
&begin,
&reset,
&finish,
&capture,
&noop, /* No output. */
&noop /* No error processing. */
&begin,
&reset,
&finish,
&capture,
&noop, /* No output. */
&noop /* No error processing. */
};
const knot_process_module_t *proc_capture_get_module(void)
......
......@@ -121,7 +121,7 @@ static bool dname_cname_cannot_synth(const knot_rrset_t *rrset, const knot_dname
/*! \brief DNSSEC both requested & available. */
static bool have_dnssec(struct query_data *qdata)
{
return pkt_has_dnssec(qdata->query) &&
return knot_pkt_has_dnssec(qdata->query) &&
qdata->rcode_ext != KNOT_EDNS_RCODE_BADVERS &&
zone_contents_is_signed(qdata->zone->contents);
}
......@@ -192,7 +192,7 @@ static int put_opt_rr(knot_pkt_t *pkt, struct query_data *qdata)
}
/* Set DO bit if set (DNSSEC requested). */
if (pkt_has_dnssec(query)) {
if (knot_pkt_has_dnssec(query)) {
dbg_ns("%s: setting DO=1 in OPT RR\n", __func__);
knot_edns_set_do(&opt_rr);
}
......
......@@ -52,7 +52,7 @@ int notify_query(knot_pkt_t *pkt, struct query_data *qdata)
return NS_PROC_FAIL;
}
/* RFC1996 require SOA question. */
/* RFC1996 requires SOA question. */
zone_t *zone = (zone_t *)qdata->zone;
NS_NEED_QTYPE(qdata, KNOT_RRTYPE_SOA, KNOT_RCODE_FORMERR);
......@@ -64,12 +64,11 @@ int notify_query(knot_pkt_t *pkt, struct query_data *qdata)
knot_pkt_reserve(pkt, tsig_wire_maxsize(qdata->sign.tsig_key));
/* SOA RR in answer may be included, recover serial. */
unsigned serial = 0;
const knot_pktsection_t *answer = knot_pkt_section(qdata->query, KNOT_ANSWER);
if (answer->count > 0) {
const knot_rrset_t *soa = &answer->rr[0];
if (soa->type == KNOT_RRTYPE_SOA) {
serial = knot_soa_serial(&soa->rrs);
uint32_t serial = knot_soa_serial(&soa->rrs);
NOTIFY_QLOG(LOG_INFO, "received serial %u.", serial);
} else { /* Complain, but accept N/A record. */
NOTIFY_QLOG(LOG_NOTICE, "received, bad record in answer section.");
......
......@@ -151,12 +151,12 @@ static int process_answer(knot_pkt_t *pkt, knot_process_t *ctx)
/*! \brief Module implementation. */
static const knot_process_module_t PROCESS_ANSWER_MODULE = {
&process_answer_begin,
&process_answer_reset,
&process_answer_finish,
&process_answer,
&noop, /* No output. */
&noop /* No error processing. */
&process_answer_begin,
&process_answer_reset,
&process_answer_finish,
&process_answer,
&noop, /* No output. */
&noop /* No error processing. */
};
const knot_process_module_t *process_answer_get_module(void)
......
......@@ -29,7 +29,7 @@
#include "knot/nameserver/process_query.h"
#include "knot/nameserver/tsig_ctx.h"
/* Processing module implementation. */
/* Answer processing module implementation. */
const knot_process_module_t *process_answer_get_module(void);
#define NS_PROC_ANSWER process_answer_get_module()
#define NS_PROC_ANSWER_ID 2
......
This diff is collapsed.
......@@ -31,8 +31,8 @@
#include "knot/updates/acl.h"
/* Query processing module implementation. */
extern const knot_process_module_t _process_query;
#define NS_PROC_QUERY (&_process_query)
const knot_process_module_t *process_query_get_module(void);
#define NS_PROC_QUERY process_query_get_module()
#define NS_PROC_QUERY_ID 1
/*! \brief Query processing logging common base. */
......@@ -110,62 +110,6 @@ struct rrsig_info {
knot_rrinfo_t *rrinfo; /* RR info. */
};
/*!
* \brief Initialize query processing context.
*
* \param ctx
* \param module_param
* \return MORE (awaits query)
*/
int process_query_begin(knot_process_t *ctx, void *module_param);
/*!
* \brief Reset query processing context.
*
* \param ctx
* \return MORE (awaits next query)
*/
int process_query_reset(knot_process_t *ctx);
/*!
* \brief Finish and close current query processing.
*
* \param ctx
* \return NOOP (context will be inoperable further on)
*/
int process_query_finish(knot_process_t *ctx);
/*!
* \brief Put query into query processing context.
*
* \param pkt
* \param ctx
* \retval NOOP (unsupported query)
* \retval FULL (ready to write answer)
*/
int process_query_in(knot_pkt_t *pkt, knot_process_t *ctx);
/*!
* \brief Make query response.
*
* \param pkt
* \param ctx
* \retval DONE (finished response)
* \retval FULL (partial response, send it and call again)
* \retval FAIL (failure)
*/
int process_query_out(knot_pkt_t *pkt, knot_process_t *ctx);
/*!
* \brief Make an error response.
*
* \param pkt
* \param ctx
* \retval DONE (finished response)
* \retval FAIL (failure)
*/
int process_query_err(knot_pkt_t *pkt, knot_process_t *ctx);
/*!
* \brief Check current query against ACL.
*
......@@ -187,29 +131,4 @@ bool process_query_acl_check(list_t *acl, struct query_data *qdata);
*/
int process_query_verify(struct query_data *qdata);
/*!
* \brief Sign query response if applicable.
*
* \param pkt
* \param qdata
* \retval KNOT_EOK
* \retval (other generic errors)
*/
int process_query_sign_response(knot_pkt_t *pkt, struct query_data *qdata);
int process_query_hooks(int qclass, int stage, knot_pkt_t *pkt, struct query_data *qdata);
/*! \brief Checks if DO bit is set in the packet's OPT RR. */
static inline bool pkt_has_dnssec(const knot_pkt_t *pkt)
{
return knot_pkt_has_edns(pkt) && knot_edns_do(pkt->opt_rr);
}
/*! \brief Checks if there is an NSID OPTION in the packet's OPT RR. */
static inline bool pkt_has_nsid(const knot_pkt_t *pkt)
{
return knot_pkt_has_edns(pkt)
&& knot_edns_has_option(pkt->opt_rr, KNOT_EDNS_OPTION_NSID);
}
/*! @} */
......@@ -310,4 +310,21 @@ static inline bool knot_pkt_has_tsig(const knot_pkt_t *pkt)
return pkt && pkt->tsig_rr;
}
/*!
* \brief Checks if DO bit is set in the packet's OPT RR.
*/
static inline bool knot_pkt_has_dnssec(const knot_pkt_t *pkt)
{
return knot_pkt_has_edns(pkt) && knot_edns_do(pkt->opt_rr);
}
/*!
* \brief Checks if there is an NSID OPTION in the packet's OPT RR.
*/
static inline bool knot_pkt_has_nsid(const knot_pkt_t *pkt)
{
return knot_pkt_has_edns(pkt)
&& knot_edns_has_option(pkt->opt_rr, KNOT_EDNS_OPTION_NSID);
}
/*! @} */
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