]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
Changes:
authorWouter Wijngaards <wouter@NLnetLabs.nl>
Mon, 17 Sep 2007 13:39:43 +0000 (13:39 +0000)
committerWouter Wijngaards <wouter@NLnetLabs.nl>
Mon, 17 Sep 2007 13:39:43 +0000 (13:39 +0000)
o edns is added when DO bit is set by pkt2wire.
o size_t case in rdlen of nsec3 next owner name, for 255 long next
  owner names.
o salt string2host from 5+len to 1+len. Fixes, some sort of typo?
o added NSEC3 keysigning types to the keysize calculation routine.
o added DO flag (set on returned message) and copy_query to returned
  message options to ldns-testpackets.

examples/ldns-testpkts.c
examples/ldns-testpkts.h
packet.c
rr_functions.c
str2host.c
wire2host.c

index 5bdc85b65b074390f15f3033f6ad096405f1a593..b01795344ba26980a28d16df29b618342d8a48a4 100644 (file)
@@ -184,6 +184,8 @@ static void replyline(const char* line, ldns_pkt *reply)
                        ldns_pkt_set_ra(reply, true);
                } else if(str_keyword(&parse, "AD")) {
                        ldns_pkt_set_ad(reply, true);
+               } else if(str_keyword(&parse, "DO")) {
+                       ldns_pkt_set_edns_do(reply, true);
                } else {
                        error("could not parse REPLY: '%s'", parse);
                }
@@ -200,6 +202,8 @@ static void adjustline(const char* line, struct entry* e,
                        return;
                if(str_keyword(&parse, "copy_id")) {
                        e->copy_id = true;
+               } else if(str_keyword(&parse, "copy_query")) {
+                       e->copy_query = true;
                } else if(str_keyword(&parse, "sleep=")) {
                        e->sleeptime = (unsigned int) strtol(parse, (char**)&parse, 10);
                        while(isspace(*parse)) 
@@ -230,6 +234,7 @@ static struct entry* new_entry()
        e->match_transport = transport_any;
        e->reply_list = NULL;
        e->copy_id = false;
+       e->copy_query = false;
        e->sleeptime = 0;
        e->next = NULL;
        return e;
@@ -692,6 +697,12 @@ adjust_packet(struct entry* match, ldns_pkt* answer_pkt, ldns_pkt* query_pkt)
        /* copy & adjust packet */
        if(match->copy_id)
                ldns_pkt_set_id(answer_pkt, ldns_pkt_id(query_pkt));
+       if(match->copy_query) {
+               ldns_rr_list* list = ldns_pkt_get_section_clone(query_pkt,
+                       LDNS_SECTION_QUESTION);
+               ldns_rr_list_deep_free(ldns_pkt_question(answer_pkt));
+               ldns_pkt_set_question(answer_pkt, list);
+       }
        if(match->sleeptime > 0) {
                verbose(3, "sleeping for %d seconds\n", match->sleeptime);
                sleep(match->sleeptime);
index 558cc737308aa6fd8b4acb9cce59dea28432dbc6..df9ee5237f5b4067f1cd04d51d79adb50fb12440 100644 (file)
                (opcode)  QUERY IQUERY STATUS NOTIFY UPDATE
                (rcode)   NOERROR FORMERR SERVFAIL NXDOMAIN NOTIMPL YXDOMAIN
                                YXRRSET NXRRSET NOTAUTH NOTZONE
-               (flags)   QR AA TC RD CD RA AD
+               (flags)   QR AA TC RD CD RA AD DO
        REPLY ...
        ; any additional actions to do.
        ; 'copy_id' copies the ID from the query to the answer.
        ADJUST copy_id
+       ; 'copy_query' copies the query name, type and class to the answer.
+       ADJUST copy_query
        ; 'sleep=10' sleeps for 10 seconds before giving the answer (TCP is open)
        ADJUST [sleep=<num>]    ; sleep before giving any reply
        ADJUST [packet_sleep=<num>]  ; sleep before this packet in sequence
@@ -174,6 +176,8 @@ struct entry {
        /** how to adjust the reply packet */
        /** copy over the ID from the query into the answer */
        bool copy_id; 
+       /** copy the query nametypeclass from query into the answer */
+       bool copy_query;
        /** in seconds */
        unsigned int sleeptime; 
 
index 7ebd15e804b55bcffa1412aae23df263241b4443..6312944946c660f4217683bbdc5425e6fa8f78dd 100644 (file)
--- a/packet.c
+++ b/packet.c
@@ -698,7 +698,8 @@ bool
 ldns_pkt_edns(const ldns_pkt *pkt) {
        return (ldns_pkt_edns_udp_size(pkt) > 0 ||
                ldns_pkt_edns_extended_rcode(pkt) > 0 ||
-               ldns_pkt_edns_data(pkt)
+               ldns_pkt_edns_data(pkt) ||
+               ldns_pkt_edns_do(pkt)
               );
 }
 
index c40750f4c514f790fd6243730626ecd6456d1657..11c6761cc78c93adac450a22d9b51ef51f0f97a7 100644 (file)
@@ -282,6 +282,7 @@ ldns_rr_dnskey_key_size_raw(const unsigned char* keydata,
        
        switch (alg) {
                case LDNS_SIGN_DSA:
+               case LDNS_SIGN_DSA_NSEC3:
                        if (len > 0) {
                                t = keydata[0];
                                return (64 + t*8)*8;
@@ -291,6 +292,7 @@ ldns_rr_dnskey_key_size_raw(const unsigned char* keydata,
                        break;
                case LDNS_SIGN_RSAMD5:
                case LDNS_SIGN_RSASHA1:
+               case LDNS_SIGN_RSASHA1_NSEC3:
                        if (len > 0) {
                                if (keydata[0] == 0) {
                                        /* big exponent */
index 39a5828580eab45d3c0724b86008db801b623dc7..95e3f54f377f23bb91259799e2a1e5150d126738 100644 (file)
@@ -144,10 +144,10 @@ ldns_str2rdf_nsec3_salt(ldns_rdf **rd, const char *salt_str)
        data = LDNS_XMALLOC(uint8_t, 1 + salt_length);
        data[0] = salt_length;
        memcpy(&data[1], salt, salt_length);
-       *rd = ldns_rdf_new_frm_data(LDNS_RDF_TYPE_NSEC3_SALT, 5 + salt_length, data);
+       *rd = ldns_rdf_new_frm_data(LDNS_RDF_TYPE_NSEC3_SALT, 1 + salt_length, data);
        LDNS_FREE(data);
-       return LDNS_STATUS_OK;
 
+       return LDNS_STATUS_OK;
 }
 
 ldns_status
index 006fc77ed0dc6511823de301eef70cc2e3d8f0a5..b6d43dccf9688bb555bf6dd6300b2fa940a9e02a 100644 (file)
@@ -221,7 +221,7 @@ ldns_wire2rdf(ldns_rr *rr, const uint8_t *wire, size_t max, size_t *pos)
                case LDNS_RDF_TYPE_B32_EXT:
                case LDNS_RDF_TYPE_NSEC3_NEXT_OWNER:
                        /* length is stored in first byte */
-                       cur_rdf_length = (uint8_t) wire[*pos] + 1;
+                       cur_rdf_length = ((size_t) wire[*pos]) + 1;
                        break;
                case LDNS_RDF_TYPE_APL:
                case LDNS_RDF_TYPE_B64: