summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2012-04-18 09:04:54 +0200
committerOndřej Surý <ondrej@sury.org>2012-04-18 09:04:54 +0200
commit34bb053aebd84a0c341bf5241e0cd70e28129e88 (patch)
treeb9bcc0002c5dcb66470e12bc5b92e2c4a29651bc /src
parentc5e123fb66dfd412a0d89293f893871f9a2e7d12 (diff)
downloadknot-34bb053aebd84a0c341bf5241e0cd70e28129e88.tar.gz
Imported Upstream version 1.0.3upstream/1.0.3
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.in4
-rw-r--r--src/common/acl.c1
-rw-r--r--src/common/fdset_epoll.c6
-rw-r--r--src/common/fdset_kqueue.c2
-rw-r--r--src/knot/server/tcp-handler.c3
-rw-r--r--src/knot/server/udp-handler.c5
-rw-r--r--src/knot/server/xfr-handler.c2
-rw-r--r--src/knot/server/zones.c11
-rw-r--r--src/knot/server/zones.h3
-rw-r--r--src/knot/zone/zone-dump.c145
-rw-r--r--src/knot/zone/zone-load.c4
-rw-r--r--src/libknot/edns.c2
-rw-r--r--src/libknot/nameserver/name-server.c17
-rw-r--r--src/libknot/nameserver/name-server.h7
-rw-r--r--src/libknot/packet/packet.c2
-rw-r--r--src/libknot/packet/packet.h14
-rw-r--r--src/libknot/packet/response.c42
17 files changed, 175 insertions, 95 deletions
diff --git a/src/Makefile.in b/src/Makefile.in
index bc8db39..f35f211 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -220,6 +220,7 @@ CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -247,6 +248,7 @@ LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
@@ -275,6 +277,7 @@ abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
@@ -307,7 +310,6 @@ libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
-lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
diff --git a/src/common/acl.c b/src/common/acl.c
index a3cabd4..c8e0488 100644
--- a/src/common/acl.c
+++ b/src/common/acl.c
@@ -17,6 +17,7 @@
#include <string.h>
#include <stdlib.h>
#include <assert.h>
+#include <sys/socket.h>
#include "common/acl.h"
diff --git a/src/common/fdset_epoll.c b/src/common/fdset_epoll.c
index f6f42f0..d4481b5 100644
--- a/src/common/fdset_epoll.c
+++ b/src/common/fdset_epoll.c
@@ -108,8 +108,8 @@ int fdset_epoll_remove(fdset_t *fdset, int fd)
--fdset->nfds;
/* Trim excessive memory if possible (retval is not interesting). */
- mreserve((char **)&fdset->events, sizeof(struct epoll_event), fdset->nfds,
- OS_FDS_CHUNKSIZE, &fdset->reserved);
+ mreserve((char **)&fdset->events, sizeof(struct epoll_event),
+ fdset->nfds + 1, OS_FDS_CHUNKSIZE, &fdset->reserved);
return 0;
}
@@ -173,7 +173,7 @@ int fdset_epoll_next(fdset_t *fdset, fdset_it_t *it)
}
/* Check boundaries. */
- if (it->pos >= fdset->polled) {
+ if (it->pos >= fdset->polled || it->pos >= fdset->nfds) {
return -1;
}
diff --git a/src/common/fdset_kqueue.c b/src/common/fdset_kqueue.c
index 2c7dd52..108c572 100644
--- a/src/common/fdset_kqueue.c
+++ b/src/common/fdset_kqueue.c
@@ -226,7 +226,7 @@ int fdset_kqueue_next(fdset_t *fdset, fdset_it_t *it)
}
/* Check boundaries. */
- if (it->pos >= fdset->polled) {
+ if (it->pos >= fdset->polled || it->pos >= fdset->nfds) {
return -1;
}
diff --git a/src/knot/server/tcp-handler.c b/src/knot/server/tcp-handler.c
index e53e286..5f79096 100644
--- a/src/knot/server/tcp-handler.c
+++ b/src/knot/server/tcp-handler.c
@@ -207,7 +207,8 @@ static int tcp_handle(tcp_worker_t *w, int fd, uint8_t *qbuf, size_t qbuf_maxlen
case KNOT_QUERY_NORMAL:
//res = knot_ns_answer_normal(ns, packet, qbuf, &resp_len);
if (zones_normal_query_answer(ns, packet, &addr,
- qbuf, &resp_len) == KNOT_EOK) {
+ qbuf, &resp_len,
+ NS_TRANSPORT_TCP) == KNOT_EOK) {
res = KNOTD_EOK;
}
break;
diff --git a/src/knot/server/udp-handler.c b/src/knot/server/udp-handler.c
index 73c557d..80bc011 100644
--- a/src/knot/server/udp-handler.c
+++ b/src/knot/server/udp-handler.c
@@ -122,7 +122,7 @@ int udp_handle(int fd, uint8_t *qbuf, size_t qbuflen, size_t *resp_len,
/* Query types. */
case KNOT_QUERY_NORMAL:
res = zones_normal_query_answer(ns, packet, addr, qbuf,
- resp_len);
+ resp_len, NS_TRANSPORT_UDP);
// res = knot_ns_answer_normal(ns, packet, qbuf,
// resp_len);
break;
@@ -144,7 +144,8 @@ int udp_handle(int fd, uint8_t *qbuf, size_t qbuflen, size_t *resp_len,
*/
knot_packet_set_qtype(packet, KNOT_RRTYPE_SOA);
res = zones_normal_query_answer(ns, packet, addr,
- qbuf, resp_len);
+ qbuf, resp_len,
+ NS_TRANSPORT_UDP);
// res = knot_ns_answer_normal(ns, packet, qbuf,
// resp_len);
break;
diff --git a/src/knot/server/xfr-handler.c b/src/knot/server/xfr-handler.c
index 8e6d6ca..2ba2417 100644
--- a/src/knot/server/xfr-handler.c
+++ b/src/knot/server/xfr-handler.c
@@ -1493,7 +1493,7 @@ int xfr_worker(dthread_t *thread)
/* Iterate fdset. */
knot_ns_xfr_t *data = 0;
int rfd = evqueue_pollfd(w->q);
- fdset_it_t it;
+ fdset_it_t it = {0};
fdset_begin(w->fdset, &it);
int rfd_event = 0;
while(nfds > 0) {
diff --git a/src/knot/server/zones.c b/src/knot/server/zones.c
index ba6340d..3de4a6a 100644
--- a/src/knot/server/zones.c
+++ b/src/knot/server/zones.c
@@ -1978,7 +1978,8 @@ int zones_xfr_check_zone(knot_ns_xfr_t *xfr, knot_rcode_t *rcode)
int zones_normal_query_answer(knot_nameserver_t *nameserver,
knot_packet_t *query, const sockaddr_t *addr,
- uint8_t *resp_wire, size_t *rsize)
+ uint8_t *resp_wire, size_t *rsize,
+ knot_ns_transport_t transport)
{
rcu_read_lock();
@@ -1986,7 +1987,9 @@ int zones_normal_query_answer(knot_nameserver_t *nameserver,
const knot_zone_t *zone = NULL;
dbg_zones_verb("Preparing response structure.\n");
- int ret = knot_ns_prep_normal_response(nameserver, query, &resp, &zone);
+ int ret = knot_ns_prep_normal_response(nameserver, query, &resp, &zone,
+ (transport == NS_TRANSPORT_TCP)
+ ? *rsize : 0);
// check for TSIG in the query
if (knot_packet_additional_rrset_count(query) > 0) {
@@ -2917,7 +2920,9 @@ int zones_store_changesets(knot_ns_xfr_t *xfr)
/* Retain journal for changeset writing. */
journal_t *j = journal_retain(zd->ixfr_db);
-
+ if (j == NULL) {
+ return KNOTD_EBUSY;
+ }
int ret = 0;
/* Begin writing to journal. */
diff --git a/src/knot/server/zones.h b/src/knot/server/zones.h
index 08f9df6..bb95b93 100644
--- a/src/knot/server/zones.h
+++ b/src/knot/server/zones.h
@@ -151,7 +151,8 @@ int zones_xfr_check_zone(knot_ns_xfr_t *xfr, knot_rcode_t *rcode);
*/
int zones_normal_query_answer(knot_nameserver_t *nameserver,
knot_packet_t *query, const sockaddr_t *addr,
- uint8_t *response_wire, size_t *rsize);
+ uint8_t *response_wire, size_t *rsize,
+ knot_ns_transport_t transport);
/*!
* \brief Processes normal response packet.
diff --git a/src/knot/zone/zone-dump.c b/src/knot/zone/zone-dump.c
index 64b743c..31be9b0 100644
--- a/src/knot/zone/zone-dump.c
+++ b/src/knot/zone/zone-dump.c
@@ -51,6 +51,8 @@
* or raw data stored like this: data_len [data]
*/
+static const size_t BUFFER_SIZE = 4096;
+
static inline int write_to_file_crc(const void *src,
size_t size, size_t n, int fd,
crc_t *crc)
@@ -129,8 +131,93 @@ static int write_wrapper(const void *src,
return 1;
}
} else {
- assert(stream == NULL && written_bytes == NULL);
- return write_to_file_crc(src, size, n, fd, crc);
+ /* Write to buffer first, if possible. */
+ if (*written_bytes + (size * n) < BUFFER_SIZE) {
+ dbg_zdump_detail("zdump: write_wrapper: Fits to "
+ "buffer. Remaining=%d.\n",
+ BUFFER_SIZE - *written_bytes);
+ int ret = write_to_stream(src, size, n,
+ stream,
+ BUFFER_SIZE, written_bytes);
+ if (ret != KNOT_EOK) {
+ dbg_zdump("zdump: write_wrapper: "
+ "Could not write to "
+ "stream. Reason: %s.\n",
+ knot_strerror(ret));
+ /* Intentional! */
+ return 0;
+ } else {
+ /* Intentional! */
+ return 1;
+ }
+ } else {
+ /* Fill remainder of buffer. */
+ size_t remainder = BUFFER_SIZE - *written_bytes;
+ dbg_zdump_detail("zdump: write_wrapper: "
+ "Flushing buffer, "
+ "appending %d bytes.\n", remainder);
+ int ret = write_to_stream(src, 1,
+ remainder,
+ stream,
+ BUFFER_SIZE,
+ written_bytes);
+ if (ret != KNOT_EOK) {
+ dbg_zdump("zdump: write_wrapper: "
+ "Could not write to stream: %s\n",
+ knot_strerror(ret));
+ // failure
+ return 0;
+ }
+
+ assert(*written_bytes == BUFFER_SIZE);
+
+ /* Buffer is filled, write to the actual file. */
+ ret = write_to_file_crc(stream, 1,
+ *written_bytes, fd, crc);
+ if (!ret) {
+ dbg_zdump("zdump: write_wrapper: "
+ "Could not write to file.\n");
+ // failure
+ return 0;
+ }
+
+ /* Reset counter. */
+ *written_bytes = 0;
+
+ /* Write remaining data to new buffer. */
+ if ((size * n) - remainder > BUFFER_SIZE) {
+ /* Write through. */
+ dbg_zdump("zdump: Attempting buffer write "
+ "through. Total: %d bytes.\n",
+ (size * n) - remainder);
+ ret = write_to_file_crc(src + remainder, 1,
+ (size * n) - remainder,
+ fd, crc);
+ if (!ret) {
+ dbg_zdump("zdump: write_wrapper: "
+ "Could not write rest of buffer to "
+ "file: %s.\n", knot_strerror(ret));
+ // failure
+ return 0;
+ }
+ } else {
+ /* Normal buffer filling. */
+ ret = write_to_stream(src + remainder,
+ 1, (size * n) - remainder,
+ stream, BUFFER_SIZE,
+ written_bytes);
+ if (ret != KNOT_EOK) {
+ dbg_zdump("zdump: write_wrapper: "
+ "Could not write rest of buffer to "
+ "stream: %s.\n", knot_strerror(ret));
+ // failure
+ return 0;
+ }
+ }
+
+ // OK
+ return 1;
+ }
}
}
@@ -718,16 +805,24 @@ static void dump_dname_from_tree(knot_dname_t *dname,
return;
}
+ uint8_t *buffer = (uint8_t *)arg->arg5;
+ size_t *written_bytes = (size_t *)arg->arg6;
crc_t *crc = (crc_t*)arg->arg2;
- arg->error_code = dump_dname_with_id(dname, fd, NULL, 0, NULL, crc);
+
+ arg->error_code = dump_dname_with_id(dname, fd, buffer,
+ BUFFER_SIZE, written_bytes, crc);
}
static int knot_dump_dname_table(const knot_dname_table_t *dname_table,
- int fd, crc_t *crc)
+ int fd, crc_t *crc, uint8_t *buffer,
+ size_t *written_bytes)
{
arg_t arg;
- arg.arg1 = &fd;
arg.arg2 = crc;
+ arg.arg5 = buffer;
+ arg.arg6 = written_bytes;
+ arg.arg1 = &fd;
+ assert(arg.arg1 == &fd);
arg.error_code = KNOT_EOK;
/* Go through the tree and dump each dname along with its ID. */
knot_dname_table_tree_inorder_apply(dname_table,
@@ -771,9 +866,13 @@ static void dump_node_to_file(knot_node_t *node, void *data)
fd = *fd_pointer;
}
+ uint8_t *buffer = (uint8_t *)arg->arg5;
+ size_t *written_bytes = (size_t *)arg->arg6;
+
arg->error_code =
knot_node_dump_binary(node,
- fd, NULL, 0, NULL, (crc_t *)arg->arg7);
+ fd, buffer, BUFFER_SIZE, written_bytes,
+ (crc_t *)arg->arg7);
}
char *knot_zdump_crc_file(const char* filename)
@@ -799,6 +898,11 @@ int knot_zdump_binary(knot_zone_contents_t *zone, int fd,
dbg_zdump("zdump: Bad arguments.\n");
return KNOT_EBADARG;
}
+
+ dbg_zdump("zdump: Dumping zone %p.\n", zone);
+
+ uint8_t buffer[BUFFER_SIZE];
+ size_t written_bytes = 0;
arg_t arguments;
/* Memory to be derefenced in the save_node_from_tree function. */
@@ -863,7 +967,7 @@ int knot_zdump_binary(knot_zone_contents_t *zone, int fd,
/* Start writing header - magic bytes. */
static const uint8_t MAGIC[MAGIC_LENGTH] = MAGIC_BYTES;
if (!write_wrapper(&MAGIC, sizeof(uint8_t), MAGIC_LENGTH,
- fd, NULL, 0, NULL, crc)) {
+ fd, buffer, BUFFER_SIZE, &written_bytes, crc)) {
dbg_zdump("zdump: Cannot write magic bytes.\n");
return KNOT_ERROR;
}
@@ -871,13 +975,14 @@ int knot_zdump_binary(knot_zone_contents_t *zone, int fd,
/* Write source file length. */
uint32_t sflen = strlen(sfilename) + 1;
if (!write_wrapper(&sflen, sizeof(uint32_t), 1, fd,
- NULL, 0, NULL, crc)) {
+ buffer, BUFFER_SIZE, &written_bytes, crc)) {
dbg_zdump("zdump: Cannot write source file length.\n");
return KNOT_ERROR;
}
/* Write source file. */
- if (!write_wrapper(sfilename, sflen, 1, fd, NULL, 0, NULL, crc)) {
+ if (!write_wrapper(sfilename, sflen, 1, fd, buffer,
+ BUFFER_SIZE, &written_bytes, crc)) {
dbg_zdump("zdump: Cannot write source file name.\n");
return KNOT_ERROR;
}
@@ -887,20 +992,20 @@ int knot_zdump_binary(knot_zone_contents_t *zone, int fd,
/* Start writing compiled data. */
if (!write_wrapper(&normal_node_count, sizeof(normal_node_count), 1, fd,
- NULL, 0, NULL, crc)) {
+ buffer, BUFFER_SIZE, &written_bytes, crc)) {
dbg_zdump("zdump: Cannot write node count.\n");
return KNOT_ERROR;
}
if (!write_wrapper(&nsec3_node_count, sizeof(nsec3_node_count), 1, fd,
- NULL, 0, NULL, crc)) {
+ buffer, BUFFER_SIZE, &written_bytes, crc)) {
dbg_zdump("zdump: Cannot write NSEC3 node count.\n");
return KNOT_ERROR;
}
uint32_t auth_node_count = zone->node_count;
if (!write_wrapper(&auth_node_count,
sizeof(auth_node_count),
- 1, fd, NULL, 0, NULL, crc)) {
+ 1, fd, buffer, BUFFER_SIZE, &written_bytes, crc)) {
dbg_zdump("zdump: Cannot write authoritative node count.\n");
return KNOT_ERROR;
}
@@ -909,13 +1014,15 @@ int knot_zdump_binary(knot_zone_contents_t *zone, int fd,
assert(zone->dname_table);
uint32_t total_dnames = zone->dname_table->id_counter;
if (!write_wrapper(&total_dnames,
- sizeof(total_dnames), 1, fd, NULL, 0, NULL, crc)) {
+ sizeof(total_dnames), 1, fd,
+ buffer, BUFFER_SIZE, &written_bytes, crc)) {
dbg_zdump("zdump: Cannot write dname count.\n");
return KNOT_ERROR;
}
/* Write dname table. */
- if (knot_dump_dname_table(zone->dname_table, fd, crc)
+ if (knot_dump_dname_table(zone->dname_table, fd, crc, buffer,
+ &written_bytes)
!= KNOT_EOK) {
dbg_zdump("zdump: Cannot write dname table.\n");
return KNOT_ERROR;
@@ -923,6 +1030,8 @@ int knot_zdump_binary(knot_zone_contents_t *zone, int fd,
arguments.arg1 = &fd;
arguments.arg3 = zone;
+ arguments.arg5 = buffer;
+ arguments.arg6 = &written_bytes;
arguments.arg7 = crc;
arguments.error_code = KNOT_EOK;
@@ -947,7 +1056,15 @@ int knot_zdump_binary(knot_zone_contents_t *zone, int fd,
return arguments.error_code;
}
+ /* Finish the dump. */
+ if (!write_to_file_crc(buffer, 1, written_bytes, fd, crc)) {
+ dbg_zdump("zdump: Failed to finalize dump.\n");
+ return KNOT_ERROR;
+ }
+
+
*crc = crc_finalize(*crc);
+ dbg_zdump("zdump: Zone %p dumped successfully.\n", zone);
return KNOT_EOK;
}
diff --git a/src/knot/zone/zone-load.c b/src/knot/zone/zone-load.c
index cee138f..b8c9beb 100644
--- a/src/knot/zone/zone-load.c
+++ b/src/knot/zone/zone-load.c
@@ -659,7 +659,7 @@ static knot_node_t *knot_load_node(FILE *f, knot_dname_t **id_array)
dbg_zload_detail("zload: load_node: Node owner id: %d.\n", dname_id);
dbg_zload_exec_detail(
char *name = knot_dname_to_str(owner);
- dbg_zload_detail("zload: load_node: Node owned by: %s.\n");
+ dbg_zload_detail("zload: load_node: Node owned by: %s.\n", name);
free(name);
);
dbg_zload_detail("zload: load_node: Number of RRSets in a node: %d.\n",
@@ -1226,7 +1226,7 @@ knot_zone_t *knot_zload_load(zloader_t *loader)
if (knot_zone_contents_add_nsec3_node(contents, nsec3_first,
0, 0, 0)
!= 0) {
- dbg_zload(stderr, "zload: load: "
+ dbg_zload("zload: load: "
"cannot add first nsec3 node, "
"exiting.\n");
knot_zone_deep_free(&zone, 0);
diff --git a/src/libknot/edns.c b/src/libknot/edns.c
index d421be7..ea630dd 100644
--- a/src/libknot/edns.c
+++ b/src/libknot/edns.c
@@ -370,7 +370,7 @@ short knot_edns_to_wire(const knot_opt_rr_t *opt_rr, uint8_t *wire,
uint8_t *pos = wire;
- dbg_edns_detail("Putting OPT RR to the wire format. Size: %zu, "
+ dbg_edns_detail("Putting OPT RR to the wire format. Size: %d, "
"position: %zu\n",
opt_rr->size, (size_t)(pos - wire));
diff --git a/src/libknot/nameserver/name-server.c b/src/libknot/nameserver/name-server.c
index e1ccdd4..213534c 100644
--- a/src/libknot/nameserver/name-server.c
+++ b/src/libknot/nameserver/name-server.c
@@ -2877,7 +2877,7 @@ void knot_ns_error_response_full(knot_nameserver_t *nameserver,
int knot_ns_prep_normal_response(knot_nameserver_t *nameserver,
knot_packet_t *query, knot_packet_t **resp,
- const knot_zone_t **zone)
+ const knot_zone_t **zone, size_t max_size)
{
dbg_ns("knot_ns_prep_normal_response()\n");
@@ -2894,8 +2894,8 @@ int knot_ns_prep_normal_response(knot_nameserver_t *nameserver,
ret = knot_packet_parse_rest(query);
if (ret != KNOT_EOK) {
- dbg_ns("Failed to parse rest of the query: "
- "%s.\n", knot_strerror(ret));
+ dbg_ns("Failed to parse rest of the query: %s.\n",
+ knot_strerror(ret));
return ret;
}
@@ -2917,11 +2917,14 @@ int knot_ns_prep_normal_response(knot_nameserver_t *nameserver,
size_t resp_max_size = 0;
- //assert(*rsize >= MAX_UDP_PAYLOAD);
-
knot_packet_dump(query);
-
- if (knot_query_edns_supported(query)) {
+
+ if (max_size > 0) {
+ // if TCP is used, buffer size is the only constraint
+ assert(max_size > 0);
+ resp_max_size = max_size;
+ } else if (knot_query_edns_supported(query)) {
+ assert(max_size == 0);
if (knot_edns_get_payload(&query->opt_rr) <
knot_edns_get_payload(nameserver->opt_rr)) {
resp_max_size = knot_edns_get_payload(&query->opt_rr);
diff --git a/src/libknot/nameserver/name-server.h b/src/libknot/nameserver/name-server.h
index 42fa0f2..d40a7d9 100644
--- a/src/libknot/nameserver/name-server.h
+++ b/src/libknot/nameserver/name-server.h
@@ -157,6 +157,11 @@ enum knot_ns_xfr_flag_t {
XFR_FLAG_AXFR_FINISHED = 1 << 2
};
+typedef enum knot_ns_transport {
+ NS_TRANSPORT_UDP = 1 << 0,
+ NS_TRANSPORT_TCP = 1 << 1
+} knot_ns_transport_t;
+
/*!
* \brief XFR request types.
*/
@@ -235,7 +240,7 @@ void knot_ns_error_response_full(knot_nameserver_t *nameserver,
int knot_ns_prep_normal_response(knot_nameserver_t *nameserver,
knot_packet_t *query, knot_packet_t **resp,
- const knot_zone_t **zone);
+ const knot_zone_t **zone, size_t max_size);
/*!
* \brief Creates a response for the given normal query using the data of the
diff --git a/src/libknot/packet/packet.c b/src/libknot/packet/packet.c
index 6fc97b8..ed73afa 100644
--- a/src/libknot/packet/packet.c
+++ b/src/libknot/packet/packet.c
@@ -1503,7 +1503,7 @@ void knot_packet_dump(const knot_packet_t *packet)
dbg_packet("DNS packet:\n-----------------------------\n");
dbg_packet("\nHeader:\n");
- dbg_packet(" ID: %u", packet->header.id);
+ dbg_packet(" ID: %u\n", packet->header.id);
dbg_packet(" FLAGS: %s %s %s %s %s %s %s\n",
knot_wire_flags_get_qr(packet->header.flags1) ? "qr" : "",
knot_wire_flags_get_aa(packet->header.flags1) ? "aa" : "",
diff --git a/src/libknot/packet/packet.h b/src/libknot/packet/packet.h
index 8f76ae2..c798133 100644
--- a/src/libknot/packet/packet.h
+++ b/src/libknot/packet/packet.h
@@ -206,16 +206,6 @@ enum {
*/
PREALLOC_RR_OWNER = 256,
-// /*! \brief Space for Answer RRSets. */
-// PREALLOC_ANSWER = DEFAULT_ANCOUNT * sizeof(knot_dname_t *),
-// /*! \brief Space for Authority RRSets. */
-// PREALLOC_AUTHORITY = DEFAULT_NSCOUNT * sizeof(knot_dname_t *),
-// /*! \brief Space for Additional RRSets. */
-// PREALLOC_ADDITIONAL = DEFAULT_ARCOUNT * sizeof(knot_dname_t *),
-// /*! \brief Total size for Answer, Authority and Additional RRSets. */
-// PREALLOC_RRSETS = PREALLOC_ANSWER
-// + PREALLOC_AUTHORITY
-// + PREALLOC_ADDITIONAL,
/*! \brief Space for one part of the compression table (domain names).*/
PREALLOC_DOMAINS =
DEFAULT_DOMAINS_IN_RESPONSE * sizeof(knot_dname_t *),
@@ -224,10 +214,6 @@ enum {
DEFAULT_DOMAINS_IN_RESPONSE * sizeof(size_t),
PREALLOC_COMPRESSION = PREALLOC_DOMAINS + PREALLOC_OFFSETS,
-// /*! \brief Space for temporary RRSets. */
-// PREALLOC_TMP_RRSETS =
-// DEFAULT_TMP_RRSETS * sizeof(knot_rrset_t *),
-
PREALLOC_QUERY = PREALLOC_PACKET
+ PREALLOC_QNAME
+ PREALLOC_RRSETS(DEFAULT_ANCOUNT_QUERY)
diff --git a/src/libknot/packet/response.c b/src/libknot/packet/response.c
index 3c7236e..d113cdf 100644
--- a/src/libknot/packet/response.c
+++ b/src/libknot/packet/response.c
@@ -521,20 +521,14 @@ static int knot_response_rr_to_wire(const knot_rrset_t *rrset,
// put rest of RR 'header'
knot_wire_write_u16(*rrset_wire, rrset->type);
dbg_response(" Type: %u\n", rrset->type);
- dbg_response(" Type in wire: ");
- dbg_response_hex((char *)*rrset_wire, 2);
*rrset_wire += 2;
knot_wire_write_u16(*rrset_wire, rrset->rclass);
dbg_response(" Class: %u\n", rrset->rclass);
- dbg_response(" Class in wire: ");
- dbg_response_hex((char *)*rrset_wire, 2);
*rrset_wire += 2;
knot_wire_write_u32(*rrset_wire, rrset->ttl);
dbg_response(" TTL: %u\n", rrset->ttl);
- dbg_response(" TTL in wire: ");
- dbg_response_hex((char *)*rrset_wire, 4);
*rrset_wire += 4;
// save space for RDLENGTH
@@ -592,26 +586,6 @@ static int knot_response_rr_to_wire(const knot_rrset_t *rrset,
compr->wire_pos += dname->size;
break;
}
-// case KNOT_RDATA_WF_BINARYWITHLENGTH: {
-// uint16_t *raw_data =
-// knot_rdata_item(rdata, i)->raw_data;
-
-// if (size + raw_data[0] + 1 > max_size) {
-// return KNOT_ESPACE;
-// }
-
-// // copy also the rdata item size
-// assert(raw_data[0] < 256);
-// **rrset_wire = raw_data[0];
-// *rrset_wire += 1;
-// memcpy(*rrset_wire, raw_data + 1, raw_data[0]);
-// dbg_response("Raw data size: %d\n",
-// raw_data[0] + 1);
-// *rrset_wire += raw_data[0];
-// rdlength += raw_data[0] + 1;
-// compr->wire_pos += raw_data[0] + 1;
-// break;
-// }
default: {
uint16_t *raw_data =
knot_rdata_item(rdata, i)->raw_data;
@@ -996,22 +970,6 @@ int knot_response_add_opt(knot_packet_t *resp,
memcpy(resp->opt_rr.options[i].data,
opt_rr->options[i].data,
resp->opt_rr.options[i].length);
-
-// struct knot_opt_option option;
-// option = opt_rr->options[i];
-
-// /* Do not add NSID unless specified. */
-// if ((option.code != EDNS_OPTION_NSID) || (add_nsid)) {
-// int ret =
-// knot_edns_add_option(&resp->opt_rr,
-// option.code,
-// option.length,
-// option.data);
-// if (ret != KNOT_EOK) {
-// dbg_response("Could not "
-// "copy option to EDNS!\n");
-// }
-// }
}
resp->opt_rr.size = opt_rr->size;
} else {