Commit 92a1c068 authored by Marek Vavrusa's avatar Marek Vavrusa

nameserver: Merged nameserver_t -> server_t

* removed redundant attributes
* removed unused parameter occurences
* moved related functions to appropriate files
* evsched has now context (server)
* zone does not point to server
* zone event planning is still in the zone loading and requires server #209
parent 26df8531
......@@ -109,8 +109,6 @@ src/knot/nameserver/internet.c
src/knot/nameserver/internet.h
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/nsec_proofs.c
src/knot/nameserver/nsec_proofs.h
src/knot/nameserver/process_query.c
......
......@@ -218,8 +218,6 @@ libknotd_la_SOURCES = \
knot/nameserver/internet.h \
knot/nameserver/ixfr.c \
knot/nameserver/ixfr.h \
knot/nameserver/name-server.c \
knot/nameserver/name-server.h \
knot/nameserver/nsec_proofs.c \
knot/nameserver/nsec_proofs.h \
knot/nameserver/process_query.c \
......
......@@ -68,13 +68,14 @@ static void evsched_settimer(event_t *e, uint32_t dt)
/*! \brief Singleton application-wide event scheduler. */
evsched_t *s_evsched = NULL;
evsched_t *evsched_new()
evsched_t *evsched_new(void *ctx)
{
evsched_t *s = malloc(sizeof(evsched_t));
if (!s) {
return NULL;
}
memset(s, 0, sizeof(evsched_t));
s->ctx = ctx;
/* Initialize event calendar. */
pthread_mutex_init(&s->rl, 0);
......
......@@ -99,6 +99,7 @@ typedef struct {
slab_cache_t alloc; /*!< Events SLAB cache. */
pthread_mutex_t lock; /*!< Events cache spin lock. */
} cache;
void *ctx;
} evsched_t;
/*!
......@@ -107,7 +108,7 @@ typedef struct {
* \retval New instance on success.
* \retval NULL on error.
*/
evsched_t *evsched_new();
evsched_t *evsched_new(void *ctx);
/*!
* \brief Deinitialize and free event scheduler instance.
......
......@@ -28,7 +28,7 @@
#include "common/lists.h"
#include "knot/knot.h"
int log_conf_hook(const struct conf_t *conf, void *data)
int log_reconfigure(const struct conf_t *conf, void *data)
{
// Data not used
int ret = 0;
......
......@@ -38,7 +38,7 @@ struct conf_t;
* \retval KNOT_EINVAL on invalid parameters.
* \retval KNOT_ENOMEM out of memory error.
*/
int log_conf_hook(const struct conf_t *conf, void *data);
int log_reconfigure(const struct conf_t *conf, void *data);
#endif /* _KNOTD_LOGCONF_H_ */
......
......@@ -26,7 +26,6 @@
#include "knot/server/zones.h"
#include "libknot/packet/wire.h"
#include "common/descriptor.h"
#include "knot/nameserver/name-server.h"
#include "libknot/tsig-op.h"
#include "libknot/rdata.h"
#include "libknot/dnssec/random.h"
......@@ -89,7 +88,6 @@ static int remote_rdata_apply(server_t *s, remote_cmdargs_t* a, remote_zonef_t *
return KNOT_EINVAL;
}
knot_nameserver_t *ns = s->nameserver;
zone_t *zone = NULL;
int ret = KNOT_EOK;
......@@ -103,10 +101,9 @@ static int remote_rdata_apply(server_t *s, remote_cmdargs_t* a, remote_zonef_t *
for (uint16_t i = 0; i < knot_rrset_rdata_rr_count(rr); i++) {
/* Refresh zones. */
const knot_dname_t *dn =
knot_rdata_ns_name(rr, i);
const knot_dname_t *dn = knot_rdata_ns_name(rr, i);
rcu_read_lock();
zone = knot_zonedb_find(ns->zone_db, dn);
zone = knot_zonedb_find(s->zone_db, dn);
if (cb(s, zone) != KNOT_EOK) {
a->rc = KNOT_RCODE_SERVFAIL;
}
......@@ -122,9 +119,7 @@ static void reschedule(server_t *server, event_t *timer, uint32_t time)
assert(server);
assert(timer);
knot_nameserver_t *nameserver = server->nameserver;
evsched_t *scheduler = ((server_t *)knot_ns_get_data(nameserver))->sched;
evsched_t *scheduler = server->sched;
evsched_cancel(scheduler, timer);
evsched_schedule(scheduler, timer, time);
}
......@@ -248,9 +243,9 @@ static int remote_c_zonestatus(server_t *s, remote_cmdargs_t* a)
int ret = KNOT_EOK;
rcu_read_lock();
knot_nameserver_t *ns = s->nameserver;
knot_zonedb_iter_t it;
knot_zonedb_iter_begin(ns->zone_db, &it);
knot_zonedb_iter_begin(s->zone_db, &it);
while(!knot_zonedb_iter_finished(&it)) {
const zone_t *zone = knot_zonedb_iter_val(&it);
......@@ -348,7 +343,7 @@ static int remote_c_refresh(server_t *s, remote_cmdargs_t* a)
dbg_server("remote: %s\n", __func__);
if (a->argc == 0) {
dbg_server_verb("remote: refreshing all zones\n");
return server_refresh(s);
return server_refresh_zones(s);
}
/* Refresh specific zones. */
......@@ -370,9 +365,8 @@ static int remote_c_flush(server_t *s, remote_cmdargs_t* a)
int ret = 0;
dbg_server_verb("remote: flushing all zones\n");
rcu_read_lock();
knot_nameserver_t *ns = s->nameserver;
knot_zonedb_iter_t it;
knot_zonedb_iter_begin(ns->zone_db, &it);
knot_zonedb_iter_begin(s->zone_db, &it);
while(!knot_zonedb_iter_finished(&it)) {
ret = remote_zone_flush(s, knot_zonedb_iter_val(&it));
knot_zonedb_iter_next(&it);
......
......@@ -183,21 +183,30 @@ int main(int argc, char **argv)
return 1;
}
// Initialize cryptographic backend
knot_crypto_init();
knot_crypto_init_threads();
// Now check if we want to daemonize
if (daemonize) {
if (daemon(1, 0) != 0) {
free(config_fn);
free(daemon_root);
fprintf(stderr, "Daemonization failed, "
"shutting down...\n");
fprintf(stderr, "Daemonization failed, shutting down...\n");
return 1;
}
}
// Initialize cryptographic backend
knot_crypto_init();
knot_crypto_init_threads();
// Create server
server_t server;
int res = server_init(&server);
if (res != KNOT_EOK) {
fprintf(stderr, "Could not initialize server: %s\n", knot_strerror(res));
free(config_fn);
free(daemon_root);
return 1;
}
// Register service and signal handler
struct sigaction emptyset;
memset(&emptyset, 0, sizeof(struct sigaction));
......@@ -242,13 +251,10 @@ int main(int argc, char **argv)
}
}
// Create server
server_t *server = server_create();
// Initialize configuration
rcu_read_lock();
conf_add_hook(conf(), CONF_LOG, log_conf_hook, 0);
conf_add_hook(conf(), CONF_ALL, server_conf_hook, server);
conf_add_hook(conf(), CONF_LOG, log_reconfigure, 0);
conf_add_hook(conf(), CONF_ALL, server_reconfigure, &server);
rcu_read_unlock();
/* POSIX 1003.1e capabilities. */
......@@ -298,7 +304,7 @@ int main(int argc, char **argv)
log_server_error("Failed to load configuration '%s'.\n",
config_fn);
}
return do_cleanup(server, config_fn, NULL);
return do_cleanup(&server, config_fn, NULL);
} else {
log_server_info("Configured %d interfaces and %d zones.\n",
conf()->ifaces_count, conf()->zones_count);
......@@ -307,7 +313,7 @@ int main(int argc, char **argv)
/* Alter privileges. */
log_update_privileges(conf()->uid, conf()->gid);
if (proc_update_privileges(conf()->uid, conf()->gid) != KNOT_EOK)
return do_cleanup(server, config_fn, NULL);
return do_cleanup(&server, config_fn, NULL);
/* Check and create PID file. */
long pid = (long)getpid();
......@@ -315,7 +321,7 @@ int main(int argc, char **argv)
char *cwd = NULL;
if (daemonize) {
if ((pidf = pid_check_and_create()) == NULL)
return do_cleanup(server, config_fn, pidf);
return do_cleanup(&server, config_fn, pidf);
log_server_info("Server started as a daemon, PID = %ld\n", pid);
log_server_info("PID stored in '%s'\n", pidf);
if ((cwd = malloc(PATH_MAX)) != NULL) {
......@@ -340,15 +346,14 @@ int main(int argc, char **argv)
log_server_info("Server running without PID file.\n");
}
/* Load zones and add hook. */
zones_ns_conf_hook(conf(), server->nameserver);
conf_add_hook(conf(), CONF_ALL, zones_ns_conf_hook, server->nameserver);
/* Populate zone database and add reconfiguration hook. */
server_update_zones(conf(), &server);
conf_add_hook(conf(), CONF_ALL, server_update_zones, &server);
// Run server
int res = 0;
log_server_info("Starting server...\n");
if ((server_start(server)) == KNOT_EOK) {
if (!knot_zonedb_size(server->nameserver->zone_db)) {
if ((server_start(&server)) == KNOT_EOK) {
if (!knot_zonedb_size(server.zone_db)) {
Please register or sign in to reply
log_server_warning("Server started, but no zones served.\n");
}
......@@ -391,7 +396,7 @@ int main(int argc, char **argv)
/* Events. */
if (ret > 0) {
ret = remote_process(server, conf()->ctl.iface,
ret = remote_process(&server, conf()->ctl.iface,
remote, buf, buflen);
switch(ret) {
case KNOT_CTL_STOP:
......@@ -405,12 +410,12 @@ int main(int argc, char **argv)
/* Interrupts. */
if (sig_req_stop) {
sig_req_stop = 0;
server_stop(server);
server_stop(&server);
break;
}
if (sig_req_reload) {
sig_req_reload = 0;
server_reload(server, config_fn);
server_reload(&server, config_fn);
}
#ifdef INTEGRITY_CHECK
if (sig_integrity_check) {
......@@ -431,7 +436,7 @@ int main(int argc, char **argv)
unlink(conf()->ctl.iface->address);
}
if ((server_wait(server)) != KNOT_EOK) {
if ((server_wait(&server)) != KNOT_EOK) {
log_server_error("An error occured while "
"waiting for server to finish.\n");
res = 1;
......@@ -449,9 +454,10 @@ int main(int argc, char **argv)
log_close();
/* Cleanup. */
if (pidf && pid_remove(pidf) < 0)
if (pidf && pid_remove(pidf) < 0) {
log_server_warning("Failed to remove PID file.\n");
do_cleanup(server, config_fn, pidf);
}
do_cleanup(&server, config_fn, pidf);
if (!daemonize) {
fflush(stdout);
......@@ -460,8 +466,9 @@ int main(int argc, char **argv)
/* Return to original working directory. */
if (cwd) {
if (chdir(cwd) != 0)
if (chdir(cwd) != 0) {
log_server_warning("Server can't change working directory.\n");
}
free(cwd);
}
......@@ -471,10 +478,8 @@ int main(int argc, char **argv)
static int do_cleanup(server_t *server, char *configf, char *pidf)
{
/* Free alloc'd variables. */
if (server) {
server_wait(server);
server_destroy(&server);
}
server_wait(server);
server_deinit(server);
free(configf);
free(pidf);
......
......@@ -179,10 +179,9 @@ int xfr_process_list(knot_pkt_t *pkt, xfr_put_cb process_item, struct query_data
#define AXFR_LOG(severity, msg...) \
ANSWER_LOG(severity, qdata, "Outgoing AXFR", msg)
int axfr_answer(knot_pkt_t *pkt, knot_nameserver_t *ns, struct query_data *qdata)
int axfr_answer(knot_pkt_t *pkt, struct query_data *qdata)
{
assert(pkt);
assert(ns);
assert(qdata);
int ret = KNOT_EOK;
......@@ -233,4 +232,59 @@ int axfr_answer(knot_pkt_t *pkt, knot_nameserver_t *ns, struct query_data *qdata
}
}
int axfr_process_answer(knot_ns_xfr_t *xfr)
{
/*
* Here we assume that 'xfr' contains TSIG information
* and the digest of the query sent to the master or the previous
* digest.
*/
dbg_ns("ns_process_axfrin: incoming packet, wire size: %zu\n",
xfr->wire_size);
int ret = xfrin_process_axfr_packet(xfr);
if (ret > 0) { // transfer finished
dbg_ns("ns_process_axfrin: AXFR finished, zone created.\n");
gettimeofday(&xfr->t_end, NULL);
/*
* Adjust zone so that node count is set properly and nodes are
* marked authoritative / delegation point.
*/
xfrin_constructed_zone_t *constr_zone =
(xfrin_constructed_zone_t *)xfr->data;
knot_zone_contents_t *zone = constr_zone->contents;
assert(zone != NULL);
log_zone_info("%s Serial %u -> %u\n", xfr->msg,
knot_zone_serial(xfr->zone->contents),
knot_zone_serial(zone));
dbg_ns_verb("ns_process_axfrin: adjusting zone.\n");
int rc = knot_zone_contents_adjust_full(zone, NULL, NULL);
if (rc != KNOT_EOK) {
return rc;
}
// save the zone contents to the xfr->data
xfr->new_contents = zone;
xfr->flags |= XFR_FLAG_AXFR_FINISHED;
assert(zone->nsec3_nodes != NULL);
// free the structure used for processing XFR
assert(constr_zone->rrsigs == NULL);
free(constr_zone);
// check zone integrity
dbg_ns_exec_verb(
int errs = knot_zone_contents_integrity_check(zone);
dbg_ns_verb("Zone integrity check: %d errors.\n", errs);
);
}
return ret;
}
#undef AXFR_LOG
......@@ -29,7 +29,7 @@
#include "libknot/packet/pkt.h"
#include "knot/zone/zonedb.h"
#include "knot/nameserver/name-server.h"
#include "knot/server/xfr-handler.h"
struct query_data;
......@@ -57,7 +57,15 @@ int xfr_process_list(knot_pkt_t *pkt, xfr_put_cb put, struct query_data *qdata);
* \retval FAIL if it encountered an error.
* \retval DONE if finished.
*/
int axfr_answer(knot_pkt_t *pkt, knot_nameserver_t *ns, struct query_data *qdata);
int axfr_answer(knot_pkt_t *pkt, struct query_data *qdata);
/*!
* \brief Processes an AXFR query response.
*
* \param xfr Persistent transfer-specific data.
*
*/
int axfr_process_answer(knot_ns_xfr_t *xfr);
#endif /* _KNOT_AXFR_H_ */
......
......@@ -18,14 +18,14 @@
#include <strings.h>
#include "knot/nameserver/chaos.h"
#include "knot/conf/conf.h"
#include "common/descriptor.h"
#include "libknot/packet/pkt.h"
/*!
* \brief Get a string result for a given TXT query.
*/
static const char *get_txt_response_string(const knot_nameserver_t *nameserver,
const knot_dname_t *qname)
static const char *get_txt_response_string(const knot_dname_t *qname)
{
char *qname_str = knot_dname_to_str(qname);
const char *response = NULL;
......@@ -91,10 +91,10 @@ static knot_rrset_t *create_txt_rrset(const knot_dname_t *owner,
* \param return KNOT_RCODE_NOERROR if the response was succesfully created,
* otherwise an RCODE representing the failure.
*/
static int answer_txt(knot_nameserver_t *nameserver, knot_pkt_t *response)
static int answer_txt(knot_pkt_t *response)
{
const knot_dname_t *qname = knot_pkt_qname(response);
const char *response_str = get_txt_response_string(nameserver, qname);
const char *response_str = get_txt_response_string(qname);
if (response_str == NULL || response_str[0] == '\0') {
return KNOT_RCODE_REFUSED;
}
......@@ -113,11 +113,11 @@ static int answer_txt(knot_nameserver_t *nameserver, knot_pkt_t *response)
return KNOT_RCODE_NOERROR;
}
int knot_chaos_answer(knot_pkt_t *pkt, knot_nameserver_t *ns)
int knot_chaos_answer(knot_pkt_t *pkt)
{
if (knot_pkt_qtype(pkt) != KNOT_RRTYPE_TXT) {
return KNOT_RCODE_REFUSED;
}
return answer_txt(ns, pkt);
return answer_txt(pkt);
}
......@@ -29,13 +29,12 @@
#include <stdlib.h>
#include <stdint.h>
#include "knot/nameserver/name-server.h"
#include "libknot/packet/pkt.h"
/*!
* \brief Create a response for a given query in the CHAOS class.
*/
int knot_chaos_answer(knot_pkt_t *pkt, knot_nameserver_t *ns);
int knot_chaos_answer(knot_pkt_t *pkt);
#endif // _KNOT_CHAOS_H_
......
......@@ -29,13 +29,15 @@
#include "libknot/packet/pkt.h"
#include "knot/zone/zonedb.h"
#include "knot/nameserver/name-server.h"
/* Query data (from query processing). */
struct query_data;
/*!
* \brief Answer query from IN class zone.
*
* \retval FAIL if it encountered an error.
* \retval DONE if finished.
*/
int internet_answer(knot_pkt_t *resp, struct query_data *qdata);
......
......@@ -241,10 +241,10 @@ static int ixfr_answer_init(struct query_data *qdata)
return KNOT_EOK;
}
static int ixfr_answer_soa(knot_pkt_t *pkt, knot_nameserver_t *ns, struct query_data *qdata)
static int ixfr_answer_soa(knot_pkt_t *pkt, struct query_data *qdata)
{
dbg_ns("%s: answering IXFR/SOA\n", __func__);
if (pkt == NULL || ns == NULL || qdata == NULL) {
if (pkt == NULL || qdata == NULL) {
return NS_PROC_FAIL;
}
......@@ -269,9 +269,9 @@ static int ixfr_answer_soa(knot_pkt_t *pkt, knot_nameserver_t *ns, struct query_
return NS_PROC_DONE;
}
int ixfr_answer(knot_pkt_t *pkt, knot_nameserver_t *ns, struct query_data *qdata)
int ixfr_answer(knot_pkt_t *pkt, struct query_data *qdata)
{
if (pkt == NULL || ns == NULL || qdata == NULL) {
if (pkt == NULL || qdata == NULL) {
return NS_PROC_FAIL;
}
......@@ -281,7 +281,7 @@ int ixfr_answer(knot_pkt_t *pkt, knot_nameserver_t *ns, struct query_data *qdata
/* If IXFR is disabled, respond with SOA. */
if (qdata->param->proc_flags & NS_QUERY_NO_IXFR) {
return ixfr_answer_soa(pkt, ns, qdata);
return ixfr_answer_soa(pkt, qdata);
}
/* Initialize on first call. */
......@@ -296,12 +296,12 @@ int ixfr_answer(knot_pkt_t *pkt, knot_nameserver_t *ns, struct query_data *qdata
break;
case KNOT_EUPTODATE: /* Our zone is same age/older, send SOA. */
IXFR_LOG(LOG_INFO, "Zone is up-to-date.");
return ixfr_answer_soa(pkt, ns, qdata);
return ixfr_answer_soa(pkt, qdata);
case KNOT_ERANGE: /* No history -> AXFR. */
case KNOT_ENOENT:
IXFR_LOG(LOG_INFO, "Incomplete history, fallback to AXFR.");
qdata->packet_type = KNOT_QUERY_AXFR; /* Solve as AXFR. */
return axfr_answer(pkt, ns, qdata);
return axfr_answer(pkt, qdata);
default: /* Server errors. */
IXFR_LOG(LOG_ERR, "Failed to start (%s).", knot_strerror(ret));
return NS_PROC_FAIL;
......@@ -332,4 +332,96 @@ int ixfr_answer(knot_pkt_t *pkt, knot_nameserver_t *ns, struct query_data *qdata
return ret;
}
int ixfr_process_answer(knot_ns_xfr_t *xfr)
{
dbg_ns("ns_process_ixfrin: incoming packet\n");
/*
* [TSIG] Here we assume that 'xfr' contains TSIG information
* and the digest of the query sent to the master or the previous
* digest.
*/
int ret = xfrin_process_ixfr_packet(xfr);
if (ret == XFRIN_RES_FALLBACK) {
dbg_ns("ns_process_ixfrin: Fallback to AXFR.\n");
ret = KNOT_ENOIXFR;
}
if (ret < 0) {
knot_pkt_free(&xfr->query);
return ret;
} else if (ret > 0) {
dbg_ns("ns_process_ixfrin: IXFR finished\n");
gettimeofday(&xfr->t_end, NULL);
knot_changesets_t *chgsets = (knot_changesets_t *)xfr->data;
if (chgsets == NULL || chgsets->first_soa == NULL) {
// nothing to be done??
dbg_ns("No changesets created for incoming IXFR!\n");
return ret;
}
// find zone associated with the changesets
/* Must not search for the zone in zonedb as it may fetch a
* different zone than the one the transfer started on. */
zone_t *zone = xfr->zone;
if (zone == NULL) {
dbg_ns("No zone found for incoming IXFR!\n");
knot_changesets_free(
(knot_changesets_t **)(&xfr->data));
return KNOT_ENOZONE;
}
switch (ret) {
case XFRIN_RES_COMPLETE:
break;
case XFRIN_RES_SOA_ONLY: {
// compare the SERIAL from the changeset with the zone's
// serial
const knot_node_t *apex = zone->contents->apex;
if (apex == NULL) {
return KNOT_ERROR;
}
const knot_rrset_t *zone_soa = knot_node_rrset(
apex, KNOT_RRTYPE_SOA);
if (zone_soa == NULL) {
return KNOT_ERROR;
}
if (ns_serial_compare(
knot_rdata_soa_serial(chgsets->first_soa),
knot_rdata_soa_serial(zone_soa))
> 0) {
if ((xfr->flags & XFR_FLAG_UDP) != 0) {
// IXFR over UDP
dbg_ns("Update did not fit.\n");
return KNOT_EIXFRSPACE;
} else {
// fallback to AXFR
dbg_ns("ns_process_ixfrin: "
"Fallback to AXFR.\n");
knot_changesets_free(
(knot_changesets_t **)&xfr->data);
knot_pkt_free(&xfr->query);
return KNOT_ENOIXFR;
}
} else {
// free changesets
dbg_ns("No update needed.\n");
knot_changesets_free(
(knot_changesets_t **)(&xfr->data));
return KNOT_ENOXFR;
}
} break;
}
}
/*! \todo In case of error, shouldn't the zone be destroyed here? */
return ret;
}
#undef IXFR_LOG
......@@ -29,7 +29,7 @@
#include "libknot/packet/pkt.h"
#include "knot/zone/zonedb.h"
#include "knot/nameserver/name-server.h"
#include "knot/server/xfr-handler.h"
struct query_data;
......@@ -40,7 +40,31 @@ struct query_data;
* \retval FAIL if it encountered an error.
* \retval DONE if finished.
*/
int ixfr_answer(knot_pkt_t *pkt, knot_nameserver_t *ns, struct query_data *qdata);
int ixfr_answer(knot_pkt_t *pkt, struct query_data *qdata);
/*!
* \brief Process an IXFR query response.
*
* \param xfr Persistent transfer-specific data.
*
* \retval KNOT_EOK If this packet was processed successfuly and another packet
* is expected. (RFC1995bis, case c)
* \retval KNOT_ENOXFR If the transfer is not taking place because server's
* SERIAL is the same as this client's SERIAL. The client
* should close the connection and do no further processing.
* (RFC1995bis case a).
* \retval KNOT_EAGAIN If the server could not fit the transfer into the packet.
* This should happen only if UDP was used. In this case
* the client should retry the request via TCP. If UDP was
* not used, it should be considered that the transfer was
* malformed and the connection should be closed.
* (RFC1995bis case b).
* \retval >0 Transfer successully finished. Changesets are created and furter
* processing is needed.
* \retval Other If any other error occured. The connection should be closed.
*
*/
int ixfr_process_answer(knot_ns_xfr_t *xfr);
#endif /* _KNOT_IXFR_H_ */
......
This diff is collapsed.
This diff is collapsed.
......@@ -360,7 +360,6 @@ fail:
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 +368,16 @@ static int query_internet(knot_pkt_t *pkt, knot_process_t *ctx)
next_state = internet_answer(pkt, data);
break;
case KNOT_QUERY_NOTIFY:
next_state = internet_notify(pkt, ns, data);
next_state = internet_notify(pkt, data);
break;
case KNOT_QUERY_AXFR:
next_state = axfr_answer(pkt, ns, data);
next_state = axfr_answer(pkt, data);
break;
case KNOT_QUERY_IXFR:
next_state = ixfr_answer(pkt, ns, data);
next_state = ixfr_answer(pkt, data);
break;
case KNOT_QUERY_UPDATE:
next_state = update_answer(pkt, ns, data);
next_state = update_answer(pkt, data);
break;
default:
/* Nothing else is supported. */
......@@ -397,7 +396,7 @@ 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 *)qdata->param->ns->data;
server_t *server = qdata->param->server;
if (server->rrl == NULL) {
return state;
}
......@@ -443,7 +442,7 @@ static int query_chaos(knot_pkt_t *pkt, knot_process_t *ctx)
return NS_PROC_FAIL;
}
data->rcode = knot_chaos_answer(pkt, data->param->ns);
data->rcode = knot_chaos_answer(pkt);
if (data->rcode != KNOT_RCODE_NOERROR) {
dbg_ns("%s: failed with RCODE=%d\n", __func__, data->rcode);
return NS_PROC_FAIL;
......@@ -490,7 +489,7 @@ static const zone_t *answer_zone_find(const knot_pkt_t *query, knot_zonedb_t *zo
static int prepare_answer(const knot_pkt_t *query, knot_pkt_t *resp, knot_process_t *ctx)
{
struct query_data *qdata = QUERY_DATA(ctx);
knot_nameserver_t *ns = qdata->param->ns;
server_t *server = qdata->param->server;
/* Initialize response. */
int ret = knot_pkt_init_response(resp, query);
...