diff options
author | Ondřej Surý <ondrej@sury.org> | 2012-04-18 09:04:54 +0200 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2012-04-18 09:04:54 +0200 |
commit | 34bb053aebd84a0c341bf5241e0cd70e28129e88 (patch) | |
tree | b9bcc0002c5dcb66470e12bc5b92e2c4a29651bc /src/libknot | |
parent | c5e123fb66dfd412a0d89293f893871f9a2e7d12 (diff) | |
download | knot-34bb053aebd84a0c341bf5241e0cd70e28129e88.tar.gz |
Imported Upstream version 1.0.3upstream/1.0.3
Diffstat (limited to 'src/libknot')
-rw-r--r-- | src/libknot/edns.c | 2 | ||||
-rw-r--r-- | src/libknot/nameserver/name-server.c | 17 | ||||
-rw-r--r-- | src/libknot/nameserver/name-server.h | 7 | ||||
-rw-r--r-- | src/libknot/packet/packet.c | 2 | ||||
-rw-r--r-- | src/libknot/packet/packet.h | 14 | ||||
-rw-r--r-- | src/libknot/packet/response.c | 42 |
6 files changed, 18 insertions, 66 deletions
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 { |