Commit 75607a95 authored by Marek Vavrusa's avatar Marek Vavrusa

Split packet processing API from name-server.h to libknot/processing

parent c7874a03
......@@ -113,10 +113,10 @@ src/knot/nameserver/ixfr.c
src/knot/nameserver/ixfr.h
src/knot/nameserver/name-server.c
src/knot/nameserver/name-server.h
src/knot/nameserver/ns_proc_query.c
src/knot/nameserver/ns_proc_query.h
src/knot/nameserver/nsec_proofs.c
src/knot/nameserver/nsec_proofs.h
src/knot/nameserver/process_query.c
src/knot/nameserver/process_query.h
src/knot/nameserver/update.c
src/knot/nameserver/update.h
src/knot/other/debug.h
......@@ -205,6 +205,8 @@ src/libknot/packet/compr.h
src/libknot/packet/pkt.c
src/libknot/packet/pkt.h
src/libknot/packet/wire.h
src/libknot/processing/process.c
src/libknot/processing/process.h
src/libknot/rdata.h
src/libknot/rrset-dump.c
src/libknot/rrset-dump.h
......@@ -284,8 +286,8 @@ tests/fdset.c
tests/hattrie.c
tests/hhash.c
tests/journal.c
tests/ns.c
tests/pkt.c
tests/process_query.c
tests/rrl.c
tests/rrset.c
tests/runtests.c
......
......@@ -113,6 +113,8 @@ libknot_la_SOURCES = \
libknot/packet/compr.c \
libknot/packet/compr.h \
libknot/packet/wire.h \
libknot/processing/process.c \
libknot/processing/process.h \
libknot/dname.c \
libknot/consts.h \
libknot/edns.h \
......@@ -240,8 +242,8 @@ libknotd_la_SOURCES = \
knot/nameserver/ixfr.h \
knot/nameserver/name-server.c \
knot/nameserver/name-server.h \
knot/nameserver/ns_proc_query.c \
knot/nameserver/ns_proc_query.h \
knot/nameserver/process_query.c \
knot/nameserver/process_query.h \
knot/nameserver/nsec_proofs.c \
knot/nameserver/nsec_proofs.h \
knot/nameserver/update.c \
......
......@@ -18,7 +18,7 @@
#include "knot/nameserver/axfr.h"
#include "knot/nameserver/internet.h"
#include "knot/nameserver/ns_proc_query.h"
#include "knot/nameserver/process_query.h"
#include "libknot/util/debug.h"
#include "common/descriptor.h"
#include "common/lists.h"
......
......@@ -2,7 +2,7 @@
#include "knot/nameserver/internet.h"
#include "knot/nameserver/nsec_proofs.h"
#include "knot/nameserver/ns_proc_query.h"
#include "knot/nameserver/process_query.h"
#include "libknot/common.h"
#include "libknot/rdata.h"
#include "libknot/util/debug.h"
......
......@@ -67,10 +67,10 @@ int internet_answer(knot_pkt_t *resp, struct query_data *qdata);
/*! \brief Require authentication. */
#define NS_NEED_AUTH(acl, qdata) \
if (!ns_proc_query_acl_check((acl), (qdata))) { \
if (!process_query_acl_check((acl), (qdata))) { \
return NS_PROC_FAIL; \
} else { \
if (ns_proc_query_verify(qdata) != KNOT_EOK) { \
if (process_query_verify(qdata) != KNOT_EOK) { \
return NS_PROC_FAIL; \
} \
}
......
......@@ -3,7 +3,7 @@
#include "knot/nameserver/ixfr.h"
#include "knot/nameserver/axfr.h"
#include "knot/nameserver/internet.h"
#include "knot/nameserver/ns_proc_query.h"
#include "knot/nameserver/process_query.h"
#include "libknot/util/debug.h"
#include "libknot/rdata.h"
#include "knot/server/zones.h"
......
......@@ -484,99 +484,3 @@ void knot_ns_destroy(knot_nameserver_t **nameserver)
free(*nameserver);
*nameserver = NULL;
}
/* State -> string translation table. */
#ifdef KNOT_NS_DEBUG
#define NS_STATE_STR(x) _state_table[x]
static const char* _state_table[] = {
[NS_PROC_NOOP] = "NOOP",
[NS_PROC_MORE] = "MORE",
[NS_PROC_FULL] = "FULL",
[NS_PROC_DONE] = "DONE",
[NS_PROC_FAIL] = "FAIL"
};
#endif /* KNOT_NS_DEBUG */
int ns_proc_begin(ns_proc_context_t *ctx, void *module_param, const ns_proc_module_t *module)
{
/* Only in inoperable state. */
if (ctx->state != NS_PROC_NOOP) {
return NS_PROC_NOOP;
}
#ifdef KNOT_NS_DEBUG
/* Check module API. */
assert(module->begin);
assert(module->in);
assert(module->out);
assert(module->err);
assert(module->reset);
assert(module->finish);
#endif /* KNOT_NS_DEBUG */
ctx->module = module;
ctx->state = module->begin(ctx, module_param);
dbg_ns("%s -> %s\n", __func__, NS_STATE_STR(ctx->state));
return ctx->state;
}
int ns_proc_reset(ns_proc_context_t *ctx)
{
ctx->state = ctx->module->reset(ctx);
dbg_ns("%s -> %s\n", __func__, NS_STATE_STR(ctx->state));
return ctx->state;
}
int ns_proc_finish(ns_proc_context_t *ctx)
{
/* Only in operable state. */
if (ctx->state == NS_PROC_NOOP) {
return NS_PROC_NOOP;
}
ctx->state = ctx->module->finish(ctx);
dbg_ns("%s -> %s\n", __func__, NS_STATE_STR(ctx->state));
return ctx->state;
}
int ns_proc_in(const uint8_t *wire, uint16_t wire_len, ns_proc_context_t *ctx)
{
/* Only if expecting data. */
if (ctx->state != NS_PROC_MORE) {
return NS_PROC_NOOP;
}
knot_pkt_t *pkt = knot_pkt_new((uint8_t *)wire, wire_len, &ctx->mm);
knot_pkt_parse(pkt, 0);
ctx->state = ctx->module->in(pkt, ctx);
dbg_ns("%s -> %s\n", __func__, NS_STATE_STR(ctx->state));
return ctx->state;
}
int ns_proc_out(uint8_t *wire, uint16_t *wire_len, ns_proc_context_t *ctx)
{
knot_pkt_t *pkt = knot_pkt_new(wire, *wire_len, &ctx->mm);
switch(ctx->state) {
case NS_PROC_FULL: ctx->state = ctx->module->out(pkt, ctx); break;
case NS_PROC_FAIL: ctx->state = ctx->module->err(pkt, ctx); break;
default:
assert(0); /* Improper use. */
knot_pkt_free(&pkt);
return NS_PROC_NOOP;
}
/* Accept only finished result. */
if (ctx->state != NS_PROC_FAIL) {
*wire_len = pkt->size;
} else {
*wire_len = 0;
}
knot_pkt_free(&pkt);
dbg_ns("%s -> %s\n", __func__, NS_STATE_STR(ctx->state));
return ctx->state;
}
......@@ -296,116 +296,6 @@ int knot_ns_tsig_required(int packet_nr);
*/
void knot_ns_destroy(knot_nameserver_t **nameserver);
/* ^^^
* NG processing API below, everything upwards should be slowly moved to appropriate
* files or removed.
*/
/*! \brief Main packet processing states.
* Each state describes the current machine processing step
* and determines readiness for next action.
*/
enum ns_proc_state {
NS_PROC_NOOP = 0, /* N/A */
NS_PROC_MORE = 1 << 0, /* More input data. */
NS_PROC_FULL = 1 << 1, /* Has output data. */
NS_PROC_DONE = 1 << 2, /* Finished. */
NS_PROC_FAIL = 1 << 3 /* Error. */
};
/* Forward declarations. */
struct ns_proc_module;
/*! \brief Packte processing context. */
typedef struct ns_proc_context
{
int state;
mm_ctx_t mm;
uint16_t type;
knot_nameserver_t *ns;
void *data;
/* Module implementation. */
const struct ns_proc_module *module;
} ns_proc_context_t;
/*! \brief Packet processing module API. */
typedef struct ns_proc_module {
int (*begin)(ns_proc_context_t *ctx, void *module_param);
int (*reset)(ns_proc_context_t *ctx);
int (*finish)(ns_proc_context_t *ctx);
int (*in)(knot_pkt_t *pkt, ns_proc_context_t *ctx);
int (*out)(knot_pkt_t *pkt, ns_proc_context_t *ctx);
int (*err)(knot_pkt_t *pkt, ns_proc_context_t *ctx);
} ns_proc_module_t;
/*! \brief Packet signing context.
* \todo This should be later moved to TSIG files when refactoring. */
typedef struct ns_sign_context {
knot_tsig_key_t *tsig_key;
uint8_t *tsig_buf;
uint8_t *tsig_digest;
size_t tsig_buflen;
size_t tsig_digestlen;
uint8_t tsig_runlen;
uint64_t tsig_time_signed;
size_t pkt_count;
} ns_sign_context_t;
/*!
* \brief Initialize packet processing context.
*
* Allowed from states: NOOP
*
* \param ctx Context.
* \param module_param Parameters for given module.
* \param module Module API.
* \return (module specific state)
*/
int ns_proc_begin(ns_proc_context_t *ctx, void *module_param, const ns_proc_module_t *module);
/*!
* \brief Reset current packet processing context.
* \param ctx Context.
* \return (module specific state)
*/
int ns_proc_reset(ns_proc_context_t *ctx);
/*!
* \brief Finish and close packet processing context.
*
* Allowed from states: MORE, FULL, DONE, FAIL
*
* \param ctx Context.
* \return (module specific state)
*/
int ns_proc_finish(ns_proc_context_t *ctx);
/*!
* \brief Input more data into packet processing.
*
* Allowed from states: MORE
*
* \param wire Source data.
* \param wire_len Source data length.
* \param ctx Context.
* \return (module specific state)
*/
int ns_proc_in(const uint8_t *wire, uint16_t wire_len, ns_proc_context_t *ctx);
/*!
* \brief Write out output from packet processing.
*
* Allowed from states: FULL, FAIL
*
* \param wire Destination.
* \param wire_len Destination length.
* \param ctx Context.
* \return (module specific state)
*/
int ns_proc_out(uint8_t *wire, uint16_t *wire_len, ns_proc_context_t *ctx);
#endif /* _KNOTNAME_SERVER_H_ */
/*! @} */
#include <config.h>
#include "knot/nameserver/nsec_proofs.h"
#include "knot/nameserver/ns_proc_query.h"
#include "knot/nameserver/process_query.h"
#include "libknot/common.h"
#include "libknot/rdata.h"
......
......@@ -2,7 +2,7 @@
#include <stdio.h>
#include <urcu.h>
#include "knot/nameserver/ns_proc_query.h"
#include "knot/nameserver/process_query.h"
#include "libknot/consts.h"
#include "libknot/util/debug.h"
#include "libknot/common.h"
......@@ -23,38 +23,38 @@
/* Forward decls. */
static const knot_zone_t *answer_zone_find(const knot_pkt_t *pkt, knot_zonedb_t *zonedb);
static int prepare_answer(const knot_pkt_t *query, knot_pkt_t *resp, ns_proc_context_t *ctx);
static int query_internet(knot_pkt_t *pkt, ns_proc_context_t *ctx);
static int query_chaos(knot_pkt_t *pkt, ns_proc_context_t *ctx);
static int ratelimit_apply(int state, knot_pkt_t *pkt, ns_proc_context_t *ctx);
static int prepare_answer(const knot_pkt_t *query, knot_pkt_t *resp, knot_process_t *ctx);
static int query_internet(knot_pkt_t *pkt, knot_process_t *ctx);
static int query_chaos(knot_pkt_t *pkt, knot_process_t *ctx);
static int ratelimit_apply(int state, knot_pkt_t *pkt, knot_process_t *ctx);
/*! \brief Module implementation. */
const ns_proc_module_t _ns_proc_query = {
&ns_proc_query_begin,
&ns_proc_query_reset,
&ns_proc_query_finish,
&ns_proc_query_in,
&ns_proc_query_out,
&ns_proc_query_err
const knot_process_module_t _process_query = {
&process_query_begin,
&process_query_reset,
&process_query_finish,
&process_query_in,
&process_query_out,
&process_query_err
};
/*! \brief Accessor to query-specific data. */
#define QUERY_DATA(ctx) ((struct query_data *)(ctx)->data)
/*! \brief Reinitialize query data structure. */
static void query_data_init(ns_proc_context_t *ctx, void *module_param)
static void query_data_init(knot_process_t *ctx, void *module_param)
{
/* Initialize persistent data. */
struct query_data *data = QUERY_DATA(ctx);
memset(data, 0, sizeof(struct query_data));
data->mm = &ctx->mm;
data->param = (struct ns_proc_query_param*)module_param;
data->param = (struct process_query_param*)module_param;
/* Initialize list. */
init_list(&data->wildcards);
}
int ns_proc_query_begin(ns_proc_context_t *ctx, void *module_param)
int process_query_begin(knot_process_t *ctx, void *module_param)
{
/* Initialize context. */
assert(ctx);
......@@ -68,13 +68,13 @@ int ns_proc_query_begin(ns_proc_context_t *ctx, void *module_param)
return NS_PROC_MORE;
}
int ns_proc_query_reset(ns_proc_context_t *ctx)
int process_query_reset(knot_process_t *ctx)
{
assert(ctx);
struct query_data *qdata = QUERY_DATA(ctx);
/* Remember persistent parameters. */
struct ns_proc_query_param *module_param = qdata->param;
struct process_query_param *module_param = qdata->param;
/* Free allocated data. */
knot_pkt_free(&qdata->query);
......@@ -89,15 +89,15 @@ int ns_proc_query_reset(ns_proc_context_t *ctx)
/* Await packet. */
return NS_PROC_MORE;
}
int ns_proc_query_finish(ns_proc_context_t *ctx)
int process_query_finish(knot_process_t *ctx)
{
ns_proc_query_reset(ctx);
process_query_reset(ctx);
ctx->mm.free(ctx->data);
ctx->data = NULL;
return NS_PROC_NOOP;
}
int ns_proc_query_in(knot_pkt_t *pkt, ns_proc_context_t *ctx)
int process_query_in(knot_pkt_t *pkt, knot_process_t *ctx)
{
assert(pkt && ctx);
struct query_data *qdata = QUERY_DATA(ctx);
......@@ -122,7 +122,7 @@ int ns_proc_query_in(knot_pkt_t *pkt, ns_proc_context_t *ctx)
return NS_PROC_FULL;
}
int ns_proc_query_out(knot_pkt_t *pkt, ns_proc_context_t *ctx)
int process_query_out(knot_pkt_t *pkt, knot_process_t *ctx)
{
assert(pkt && ctx);
struct query_data *qdata = QUERY_DATA(ctx);
......@@ -178,7 +178,7 @@ int ns_proc_query_out(knot_pkt_t *pkt, ns_proc_context_t *ctx)
/* Transaction security (if applicable). */
if (next_state == NS_PROC_DONE || next_state == NS_PROC_FULL) {
if (ns_proc_query_sign_response(pkt, qdata) != KNOT_EOK) {
if (process_query_sign_response(pkt, qdata) != KNOT_EOK) {
next_state = NS_PROC_FAIL;
}
}
......@@ -192,7 +192,7 @@ finish:
return next_state;
}
int ns_proc_query_err(knot_pkt_t *pkt, ns_proc_context_t *ctx)
int process_query_err(knot_pkt_t *pkt, knot_process_t *ctx)
{
assert(pkt && ctx);
struct query_data *qdata = QUERY_DATA(ctx);
......@@ -214,14 +214,14 @@ int ns_proc_query_err(knot_pkt_t *pkt, ns_proc_context_t *ctx)
knot_wire_set_rcode(pkt->wire, qdata->rcode);
/* Transaction security (if applicable). */
if (ns_proc_query_sign_response(pkt, qdata) != KNOT_EOK) {
if (process_query_sign_response(pkt, qdata) != KNOT_EOK) {
return NS_PROC_FAIL;
}
return NS_PROC_DONE;
}
bool ns_proc_query_acl_check(acl_t *acl, struct query_data *qdata)
bool process_query_acl_check(acl_t *acl, struct query_data *qdata)
{
knot_pkt_t *query = qdata->query;
const sockaddr_t *query_source = &qdata->param->query_source;
......@@ -253,10 +253,10 @@ bool ns_proc_query_acl_check(acl_t *acl, struct query_data *qdata)
return true;
}
int ns_proc_query_verify(struct query_data *qdata)
int process_query_verify(struct query_data *qdata)
{
knot_pkt_t *query = qdata->query;
ns_sign_context_t *ctx = &qdata->sign;
knot_sign_context_t *ctx = &qdata->sign;
/* NOKEY => no verification. */
if (query->tsig_rr == NULL) {
......@@ -303,11 +303,11 @@ int ns_proc_query_verify(struct query_data *qdata)
return ret;
}
int ns_proc_query_sign_response(knot_pkt_t *pkt, struct query_data *qdata)
int process_query_sign_response(knot_pkt_t *pkt, struct query_data *qdata)
{
int ret = KNOT_EOK;
knot_pkt_t *query = qdata->query;
ns_sign_context_t *ctx = &qdata->sign;
knot_sign_context_t *ctx = &qdata->sign;
/* KEY provided and verified TSIG or BADTIME allows signing. */
if (ctx->tsig_key != NULL && knot_tsig_can_sign(qdata->rcode_tsig)) {
......@@ -358,9 +358,10 @@ fail:
/*!
* \brief Create a response for a given query in the INTERNET class.
*/
static int query_internet(knot_pkt_t *pkt, ns_proc_context_t *ctx)
static int query_internet(knot_pkt_t *pkt, knot_process_t *ctx)
{
struct query_data *data = QUERY_DATA(ctx);
knot_nameserver_t *ns = data->param->ns;
int next_state = NS_PROC_FAIL;
dbg_ns("%s(%p, %p, pkt_type=%u)\n", __func__, pkt, ctx, data->packet_type);
......@@ -369,16 +370,16 @@ static int query_internet(knot_pkt_t *pkt, ns_proc_context_t *ctx)
next_state = internet_answer(pkt, data);
break;
case KNOT_QUERY_NOTIFY:
next_state = internet_notify(pkt, ctx->ns, data);
next_state = internet_notify(pkt, ns, data);
break;
case KNOT_QUERY_AXFR:
next_state = axfr_answer(pkt, ctx->ns, data);
next_state = axfr_answer(pkt, ns, data);
break;
case KNOT_QUERY_IXFR:
next_state = ixfr_answer(pkt, ctx->ns, data);
next_state = ixfr_answer(pkt, ns, data);
break;
case KNOT_QUERY_UPDATE:
next_state = update_answer(pkt, ctx->ns, data);
next_state = update_answer(pkt, ns, data);
break;
default:
/* Nothing else is supported. */
......@@ -393,11 +394,11 @@ static int query_internet(knot_pkt_t *pkt, ns_proc_context_t *ctx)
/*!
* \brief Apply rate limit.
*/
static int ratelimit_apply(int state, knot_pkt_t *pkt, ns_proc_context_t *ctx)
static int ratelimit_apply(int state, knot_pkt_t *pkt, knot_process_t *ctx)
{
/* Check if rate limiting applies. */
struct query_data *qdata = QUERY_DATA(ctx);
server_t *server = (server_t *)ctx->ns->data;
server_t *server = (server_t *)qdata->param->ns->data;
if (server->rrl == NULL) {
return state;
}
......@@ -417,7 +418,7 @@ static int ratelimit_apply(int state, knot_pkt_t *pkt, ns_proc_context_t *ctx)
/* Now it is slip or drop. */
if (rrl_slip_roll(conf()->rrl_slip)) {
/* Answer slips. */
if (ns_proc_query_err(pkt, ctx) != KNOT_EOK) {
if (process_query_err(pkt, ctx) != KNOT_EOK) {
return NS_PROC_FAIL;
}
knot_wire_set_tc(pkt->wire);
......@@ -432,7 +433,7 @@ static int ratelimit_apply(int state, knot_pkt_t *pkt, ns_proc_context_t *ctx)
/*!
* \brief Create a response for a given query in the CHAOS class.
*/
static int query_chaos(knot_pkt_t *pkt, ns_proc_context_t *ctx)
static int query_chaos(knot_pkt_t *pkt, knot_process_t *ctx)
{
dbg_ns("%s(%p, %p)\n", __func__, pkt, ctx);
struct query_data *data = QUERY_DATA(ctx);
......@@ -443,7 +444,7 @@ static int query_chaos(knot_pkt_t *pkt, ns_proc_context_t *ctx)
return NS_PROC_FAIL;
}
data->rcode = knot_chaos_answer(pkt, ctx->ns);
data->rcode = knot_chaos_answer(pkt, data->param->ns);
if (data->rcode != KNOT_RCODE_NOERROR) {
dbg_ns("%s: failed with RCODE=%d\n", __func__, data->rcode);
return NS_PROC_FAIL;
......@@ -487,7 +488,7 @@ static const knot_zone_t *answer_zone_find(const knot_pkt_t *pkt, knot_zonedb_t
}
/*! \brief Initialize response, sizes and find zone from which we're going to answer. */
static int prepare_answer(const knot_pkt_t *query, knot_pkt_t *resp, ns_proc_context_t *ctx)
static int prepare_answer(const knot_pkt_t *query, knot_pkt_t *resp, knot_process_t *ctx)
{
int ret = knot_pkt_init_response(resp, query);
if (ret != KNOT_EOK) {
......@@ -499,6 +500,7 @@ static int prepare_answer(const knot_pkt_t *query, knot_pkt_t *resp, ns_proc_con
* Already checked for absence of compression and length.
*/
struct query_data *qdata = QUERY_DATA(ctx);
knot_nameserver_t *ns = qdata->param->ns;
const knot_dname_t *qname = knot_pkt_qname(query);
memcpy(qdata->orig_qname, qname, query->qname_size);
ret = knot_dname_to_lower((knot_dname_t *)qname);
......@@ -508,7 +510,7 @@ static int prepare_answer(const knot_pkt_t *query, knot_pkt_t *resp, ns_proc_con
}
/* Find zone for QNAME. */
qdata->zone = answer_zone_find(query, ctx->ns->zone_db);
qdata->zone = answer_zone_find(query, ns->zone_db);
/* Update maximal answer size. */
if (qdata->param->proc_flags & NS_QUERY_LIMIT_SIZE) {
......@@ -519,7 +521,7 @@ static int prepare_answer(const knot_pkt_t *query, knot_pkt_t *resp, ns_proc_con
if (!knot_pkt_have_edns(query)) {
return KNOT_EOK;
}
ret = knot_pkt_add_opt(resp, ctx->ns->opt_rr, knot_pkt_have_nsid(query));
ret = knot_pkt_add_opt(resp, ns->opt_rr, knot_pkt_have_nsid(query));
if (ret != KNOT_EOK) {
dbg_ns("%s: can't add OPT RR (%d)\n", __func__, ret);
return ret;
......
/*!
* \file ns_proc_query.h
* \file process_query.h
*
* \author Marek Vavrusa <marek.vavrusa@nic.cz>
*
......@@ -24,15 +24,16 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _KNOT_NS_PROC_QUERY_H_
#define _KNOT_NS_PROC_QUERY_H_
#ifndef _PROCESS_QUERY_H_
#define _PROCESS_QUERY_H_
#include "libknot/processing/process.h"
#include "knot/nameserver/name-server.h"
#include "common/acl.h"
/* Query processing module implementation. */
extern const ns_proc_module_t _ns_proc_query;
#define NS_PROC_QUERY (&_ns_proc_query)
extern const knot_process_module_t _process_query;
#define NS_PROC_QUERY (&_process_query)
#define NS_PROC_QUERY_ID 1
/*! \brief Query processing logging common base. */
......@@ -56,7 +57,7 @@ extern const ns_proc_module_t _ns_proc_query;
NS_PROC_LOG(severity, qdata, what " of '%s' to '%s:%d': ", msg)
/* Query processing specific flags. */
enum ns_proc_query_flag {
enum process_query_flag {
NS_QUERY_NO_AXFR = 1 << 0, /* Don't process AXFR */
NS_QUERY_NO_IXFR = 1 << 1, /* Don't process IXFR */
NS_QUERY_LIMIT_ANY = 1 << 2, /* Limit ANY QTYPE (respond with TC=1) */
......@@ -65,9 +66,10 @@ enum ns_proc_query_flag {
};
/* Module load parameters. */
struct ns_proc_query_param {
struct process_query_param {
uint16_t proc_flags;
sockaddr_t query_source;
knot_nameserver_t *ns;
};
/*! \brief Query processing intermediate data. */
......@@ -89,10 +91,10 @@ struct query_data {
/* Extensions. */
void *ext;
void (*ext_cleanup)(struct query_data*); /*!< Extensions cleanup callback. */
ns_sign_context_t sign; /*!< Signing context. */
knot_sign_context_t sign; /*!< Signing context. */
/* Everything below should be kept on reset. */
struct ns_proc_query_param *param; /*!< Module parameters. */
struct process_query_param *param; /*!< Module parameters. */
mm_ctx_t *mm; /*!< Memory context. */
};
......@@ -110,7 +112,7 @@ struct wildcard_hit {
* \param module_param
* \return MORE (awaits query)
*/
int ns_proc_query_begin(ns_proc_context_t *ctx, void *module_param);
int process_query_begin(knot_process_t *ctx, void *module_param);
/*!
* \brief Reset query processing context.
......@@ -118,7 +120,7 @@ int ns_proc_query_begin(ns_proc_context_t *ctx, void *module_param);
* \param ctx
* \return MORE (awaits next query)
*/
int ns_proc_query_reset(ns_proc_context_t *ctx);
int process_query_reset(knot_process_t *ctx);
/*!
* \brief Finish and close current query processing.
......@@ -126,7 +128,7 @@ int ns_proc_query_reset(ns_proc_context_t *ctx);
* \param ctx
* \return NOOP (context will be inoperable further on)
*/
int ns_proc_query_finish(ns_proc_context_t *ctx);
int process_query_finish(knot_process_t *ctx);
/*!
* \brief Put query into query processing context.
......@@ -136,7 +138,7 @@ int ns_proc_query_finish(ns_proc_context_t *ctx);
* \retval NOOP (unsupported query)
* \retval FULL (ready to write answer)
*/
int ns_proc_query_in(knot_pkt_t *pkt, ns_proc_context_t *ctx);
int process_query_in(knot_pkt_t *pkt, knot_process_t *ctx);
/*!
* \brief Make query response.
......@@ -147,7 +149,7 @@ int ns_proc_query_in(knot_pkt_t *pkt, ns_proc_context_t *ctx);
* \retval FULL (partial response, send it and call again)
* \retval FAIL (failure)
*/
int ns_proc_query_out(knot_pkt_t *pkt, ns_proc_context_t *ctx);
int process_query_out(knot_pkt_t *pkt, knot_process_t *ctx);
/*!
* \brief Make an error response.
......@@ -157,7 +159,7 @@ int ns_proc_query_out(knot_pkt_t *pkt, ns_proc_context_t *ctx);
* \retval DONE (finished response)
* \retval FAIL (failure)
*/
int ns_proc_query_err(knot_pkt_t *pkt, ns_proc_context_t *ctx);
int process_query_err(knot_pkt_t *pkt, knot_process_t *ctx);
/*!
* \brief Check current query against ACL.
......@@ -166,7 +168,7 @@ int ns_proc_query_err(knot_pkt_t *pkt, ns_proc_context_t *ctx);
* \param qdata
* \return true if accepted, false if denied.
*/
bool ns_proc_query_acl_check(acl_t *acl, struct query_data *qdata);
bool process_query_acl_check(acl_t *acl, struct query_data *qdata);
/*!
* \brief Verify current query transaction security and update query data.
......@@ -178,7 +180,7 @@ bool ns_proc_query_acl_check(acl_t *acl, struct query_data *qdata);
* \retval KNOT_TSIG_EBADTIME
* \retval (other generic errors)
*/
int ns_proc_query_verify(struct query_data *qdata);
int process_query_verify(struct query_data *qdata);
/*!
* \brief Sign query response if applicable.
......@@ -188,8 +190,8 @@ int ns_proc_query_verify(struct query_data *qdata);
* \retval KNOT_EOK
* \retval (other generic errors)
*/
int ns_proc_query_sign_response(knot_pkt_t *pkt, struct query_data *qdata);
int process_query_sign_response(knot_pkt_t *pkt, struct query_data *qdata);
#endif /* _KNOT_NS_PROC_QUERY_H_ */
#endif /* _PROCESS_QUERY_H_ */
/*! @} */
......@@ -2,7 +2,7 @@
#include "knot/nameserver/update.h"
#include "knot/nameserver/internet.h"
#include "knot/nameserver/ns_proc_query.h"