Commit decdc3a2 authored by Marek Vavruša's avatar Marek Vavruša

process_answer: stub implementation

parent c3c931a9
......@@ -17,6 +17,7 @@
#include "knot/nameserver/axfr.h"
#include "knot/nameserver/internet.h"
#include "knot/nameserver/process_query.h"
#include "knot/nameserver/process_answer.h"
#include "knot/updates/xfr-in.h"
#include "common/debug.h"
#include "common/descriptor.h"
......
......@@ -2,6 +2,7 @@
#include "knot/nameserver/axfr.h"
#include "knot/nameserver/internet.h"
#include "knot/nameserver/process_query.h"
#include "knot/nameserver/process_answer.h"
#include "knot/updates/xfr-in.h"
#include "common/debug.h"
#include "common/descriptor.h"
......
......@@ -42,6 +42,10 @@
int notify_create_request(const zone_t *zone, knot_pkt_t *pkt)
{
if (zone == NULL || pkt == NULL) {
return KNOT_EINVAL;
}
zone_contents_t *contents = zone->contents;
if (contents == NULL) {
return KNOT_EINVAL; /* Not valid for stub zones. */
......@@ -50,9 +54,8 @@ int notify_create_request(const zone_t *zone, knot_pkt_t *pkt)
knot_wire_set_aa(pkt->wire);
knot_wire_set_opcode(pkt->wire, KNOT_OPCODE_NOTIFY);
knot_rrset_t soa_rr = knot_node_rrset(contents->apex, KNOT_RRTYPE_SOA);
assert(!knot_rrset_empty(&soa_rr));
return knot_pkt_put_question(pkt, soa_rr.owner, soa_rr.rclass, soa_rr.type);
knot_dname_t *apex = contents->apex->owner;
return knot_pkt_put_question(pkt, apex, KNOT_CLASS_IN, KNOT_RRTYPE_SOA);
}
int notify_process_response(knot_pkt_t *notify, int msgid)
......
......@@ -56,7 +56,7 @@ int process_query_begin(knot_process_t *ctx, void *module_param)
/* Initialize context. */
assert(ctx);
ctx->type = NS_PROC_QUERY_ID;
ctx->data = ctx->mm.alloc(ctx->mm.ctx, sizeof(struct query_data));
ctx->data = mm_alloc(&ctx->mm, sizeof(struct query_data));
/* Initialize persistent data. */
query_data_init(ctx, module_param);
......@@ -221,7 +221,7 @@ int process_query_err(knot_pkt_t *pkt, knot_process_t *ctx)
bool process_query_acl_check(acl_t *acl, struct query_data *qdata)
{
knot_pkt_t *query = qdata->query;
struct sockaddr_storage *query_source = qdata->param->query_source;
struct sockaddr_storage *query_source = qdata->param->remote;
const knot_dname_t *key_name = NULL;
knot_tsig_algorithm_t key_alg = KNOT_TSIG_ALG_NULL;
......@@ -405,7 +405,7 @@ static int ratelimit_apply(int state, knot_pkt_t *pkt, knot_process_t *ctx)
if (!EMPTY_LIST(qdata->wildcards)) {
rrl_rq.flags = RRL_WILDCARD;
}
if (rrl_query(server->rrl, qdata->param->query_source,
if (rrl_query(server->rrl, qdata->param->remote,
&rrl_rq, qdata->zone) == KNOT_EOK) {
/* Rate limiting not applied. */
return state;
......
......@@ -39,7 +39,7 @@ extern const knot_process_module_t _process_query;
/*! \brief Query processing logging common base. */
#define NS_PROC_LOG(severity, qdata, what, msg, ...) do { \
char addr_str[SOCKADDR_STRLEN] = {0}; \
sockaddr_tostr((qdata)->param->query_source, addr_str, sizeof(addr_str)); \
sockaddr_tostr((qdata)->param->remote, addr_str, sizeof(addr_str)); \
char *zone_str = knot_dname_to_str(knot_pkt_qname((qdata)->query)); \
log_msg(LOG_SERVER, severity, what msg "\n", \
zone_str, addr_str, ##__VA_ARGS__); \
......@@ -66,9 +66,9 @@ enum process_query_flag {
/* Module load parameters. */
struct process_query_param {
uint16_t proc_flags;
int query_socket;
struct sockaddr_storage *query_source;
server_t *server;
int socket;
struct sockaddr_storage *remote;
};
/*! \brief Query processing intermediate data. */
......
......@@ -42,8 +42,8 @@ static int update_forward(knot_pkt_t *pkt, struct query_data *qdata)
/* Don't set TSIG key, as it's only forwarded. */
/* Copy query originator data. */
rq->fwd_src_fd = qdata->param->query_socket;
memcpy(&rq->fwd_addr, qdata->param->query_source, sizeof(struct sockaddr_storage));
rq->fwd_src_fd = qdata->param->socket;
memcpy(&rq->fwd_addr, qdata->param->remote, sizeof(struct sockaddr_storage));
rq->packet_nr = knot_wire_get_id(query->wire);
/* Duplicate query to keep it in memory during forwarding. */
......@@ -250,7 +250,7 @@ static int zones_process_update_auth(struct query_data *qdata)
zone_t *zone = (zone_t *)qdata->zone;
conf_zone_t *zone_config = zone->conf;
knot_tsig_key_t *tsig_key = qdata->sign.tsig_key;
const struct sockaddr_storage *addr = qdata->param->query_source;
const struct sockaddr_storage *addr = qdata->param->remote;
/* Create log message prefix. */
char *keytag = NULL;
......
......@@ -100,8 +100,8 @@ static int tcp_handle(tcp_context_t *tcp, int fd,
struct sockaddr_storage ss;
memset(&ss, 0, sizeof(struct sockaddr_storage));
struct process_query_param param = {0};
param.query_socket = fd;
param.query_source = &ss;
param.socket = fd;
param.remote = &ss;
param.server = tcp->server;
rx->iov_len = KNOT_WIRE_MAX_PKTSIZE;
tx->iov_len = KNOT_WIRE_MAX_PKTSIZE;
......
......@@ -118,11 +118,11 @@ int udp_handle(udp_context_t *udp, int fd, struct sockaddr_storage *ss,
/* Create query processing parameter. */
struct process_query_param param = {0};
param.query_source = ss;
param.remote = ss;
param.proc_flags = NS_QUERY_NO_AXFR|NS_QUERY_NO_IXFR; /* No transfers. */
param.proc_flags |= NS_QUERY_LIMIT_SIZE; /* Enforce UDP packet size limit. */
param.proc_flags |= NS_QUERY_LIMIT_ANY; /* Limit ANY over UDP (depends on zone as well). */
param.query_socket = fd;
param.socket = fd;
param.server = udp->server;
/* Rate limit is applied? */
......
......@@ -150,7 +150,7 @@ int main(int argc, char *argv[])
memset(&ss, 0, sizeof(struct sockaddr_storage));
sockaddr_set(&ss, AF_INET, "127.0.0.1", 53);
struct process_query_param param = {0};
param.query_source = &ss;
param.remote = &ss;
param.server = &server;
/* Query processor (CH zone) */
......
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