]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
removed unwanted lua code (insert/delete RRs).
authorMiek Gieben <miekg@NLnetLabs.nl>
Thu, 9 Feb 2006 12:04:58 +0000 (12:04 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Thu, 9 Feb 2006 12:04:58 +0000 (12:04 +0000)
added: ldns_pkt_empty to check if a pkt is emtpy
some drill changes

Changelog
drill/chasetrace.c
drill/drill.c
drill/securetrace.c
ldns/packet.h
packet.c

index 4e1f370f3f4901c05df6484066cce880f0a04e96..42fa16ebb773f14ec1fb972b2c39c0fccc7ff4fd 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -50,6 +50,7 @@ XX Jan 2006: 1.1.0: ldns-team
        * ldns_resolver_searchlist_count: return the searchlist counter
        * ldns_zone_sort: Sort a zone
        * ldns_bgsend(): background send, returns a socket.
+       * ldns_pkt_empty(): check is a packet is empty
        Removed:
        * ldns_resolver_bgsend(): was not used in 1.0.0 and is not used
          now
index cf88ad1cb21821b22618dd1a87334c09426346ce..231c70e31e26ee48a7022bde0f61288270fc1d18 100644 (file)
@@ -73,13 +73,15 @@ do_trace(ldns_resolver *local_res, ldns_rdf *name, ldns_rr_type t,
        status = ldns_resolver_send(&p, local_res, ldns_dname_new_frm_str("."), LDNS_RR_TYPE_NS, c, 0);
        /* p can still be NULL */
 
-       if (!p) {
-               error("Nothing received\n");
-               return NULL;
-       }
+
+       if (ldns_pkt_empty(p)) {
+               warning("No root server information received\n");
+       } 
        
        if (status == LDNS_STATUS_OK) {
-               drill_pkt_print(stdout, local_res, p);
+               if (!ldns_pkt_empty(p)) {
+                       drill_pkt_print(stdout, local_res, p);
+               }
        } else {
                error("cannot use local resolver\n");
                return NULL;
index 97af06a531ff8a062d129229eb44e7386f448c38..0d8455e7b36ae379af09b42b5017b131cf5d2f4f 100644 (file)
@@ -496,7 +496,7 @@ main(int argc, char *argv[])
                        init_root();
                        qname = ldns_dname_new_frm_str(name);
                        /* don't care about return packet */
-                       result = do_secure_trace2(res, qname, type, clas, key_list);
+                       result = do_secure_trace3(res, qname, type, clas, key_list);
                        break;
                case DRILL_CHASE:
                        qname = ldns_dname_new_frm_str(name);
index 2d79c3552e281d7fc57c652e329714f2d93be44c..7cc43eb02686bd228b35c543d51155d7e19de1b5 100644 (file)
@@ -240,7 +240,7 @@ do_secure_trace3(ldns_resolver *res, ldns_rdf *name, ldns_rr_type t,
        unsigned int secure = 1;
 
        while (ldns_pkt_reply_type(p1 = ldns_resolver_query(res, name, t, c, 0)) == LDNS_PACKET_REFERRAL) {
-               ldns_pkt_print(stdout, p1);
+               drill_pkt_print(stdout, res, p1);
 
                if (secure == 1) {
                        /* Try to get the keys from the current nameserver */
@@ -271,5 +271,11 @@ do_secure_trace3(ldns_resolver *res, ldns_rdf *name, ldns_rr_type t,
                        }
                }
        }
+
+       /* we have our final answer */
+       drill_pkt_print(stdout, res, p1);
+
+       
+       
        return LDNS_STATUS_OK;
 }
index 7ca614c6dac12c18a3683dfc256562849f360a2a..e3e227b04c1b5ba8269375b1491da9d118e8a582 100644 (file)
@@ -341,6 +341,16 @@ ldns_rr_list *ldns_pkt_rr_list_by_type(ldns_pkt *p, ldns_rr_type t, ldns_pkt_sec
  */
 ldns_rr_list *ldns_pkt_rr_list_by_name_and_type(ldns_pkt *packet, ldns_rdf *ownername, ldns_rr_type type, ldns_pkt_section sec);
 
+
+/**
+ * check to see if an rr exist in the packet
+ * \param[in] pkt the packet to examine
+ * \param[in] sec in which section to look
+ * \param[in] rr the rr to look for
+ */
+bool ldns_pkt_rr(ldns_pkt *pkt, ldns_pkt_section sec, ldns_rr *rr);
+
+
 /**
  * sets the flags in a packet.
  * \param[in] pkt the packet to operate on
@@ -664,10 +674,13 @@ bool ldns_pkt_push_rr(ldns_pkt *packet, ldns_pkt_section section, ldns_rr *rr);
  */
 bool ldns_pkt_safe_push_rr(ldns_pkt *pkt, ldns_pkt_section sec, ldns_rr *rr);
 
-/* lua helper stuff KEEP THIS?? NO/YES */
-/**  TODO or remove */
-ldns_rr * ldns_pkt_get_rr(ldns_pkt *p, uint16_t n);
-ldns_rr * ldns_pkt_set_rr(ldns_pkt *p, ldns_rr *rr, uint16_t n);
-bool ldns_pkt_insert_rr(ldns_pkt *p, ldns_rr *rr, uint16_t n);
+/**
+ * check if a packet is empty
+ * \param[in] p packet
+ * \return true: empty, false: empty
+ */
+bool ldns_pkt_empty(ldns_pkt *p);
+
+
 
 #endif  /* LDNS_PACKET_H */
index 49a88df8501dd90d36b938e5a5a4c97d74b0de9d..d9529f51ab6182b8314c9bee677c210efe243d26 100644 (file)
--- a/packet.c
+++ b/packet.c
@@ -342,12 +342,6 @@ ldns_pkt_rr_list_by_name_and_type(ldns_pkt *packet, ldns_rdf *ownername, ldns_rr
        return ret;
 }
 
-/**
- * check to see if an rr exist in the packet
- * \param[in] pkt the packet to examine
- * \param[in] sec in which section to look
- * \param[in] rr the rr to look for
- */
 bool
 ldns_pkt_rr(ldns_pkt *pkt, ldns_pkt_section sec, ldns_rr *rr)
 {
@@ -371,153 +365,6 @@ ldns_pkt_rr(ldns_pkt *pkt, ldns_pkt_section sec, ldns_rr *rr)
        return false;
 }
 
-/* ldns_pkt_rr does something else */
-ldns_rr *
-ldns_pkt_get_rr(ldns_pkt *p, uint16_t n)
-{
-       ldns_rr_list *sec;
-       uint16_t count;
-
-       count = ldns_pkt_qdcount(p);
-       if (n < count) {
-               sec = ldns_pkt_question(p);
-               return ldns_rr_list_rr(sec, n - 1);
-       }
-       
-       count = ldns_pkt_qdcount(p) + ldns_pkt_ancount(p);
-       if (n < count) {
-               sec = ldns_pkt_answer(p);
-               return ldns_rr_list_rr(sec, count - n - 1);
-       }
-
-       count = ldns_pkt_qdcount(p) + ldns_pkt_ancount(p) +
-               ldns_pkt_nscount(p);
-       if (n < count) {
-               sec = ldns_pkt_authority(p);
-               return ldns_rr_list_rr(sec, count - n - 1);
-       }
-
-       count = ldns_pkt_qdcount(p) + ldns_pkt_ancount(p) +
-               ldns_pkt_nscount(p) + ldns_pkt_arcount(p);
-       if (n < count) {
-               sec = ldns_pkt_additional(p);
-               return ldns_rr_list_rr(sec, count - n - 1);
-       }
-       return NULL;
-}
-
-ldns_rr *
-ldns_pkt_set_rr(ldns_pkt *p, ldns_rr *rr, uint16_t n)
-{
-       ldns_rr_list *sec;
-       ldns_rr *r;
-       uint16_t count;
-
-       /* i break a layer here -- sue me */
-
-       /* retrieve the correct section */
-       count = ldns_pkt_qdcount(p);
-       if (n < count) {
-               sec = ldns_pkt_question(p);
-               goto success;
-       }
-       count = ldns_pkt_qdcount(p) + ldns_pkt_ancount(p);
-       if (n < count) {
-               sec = ldns_pkt_answer(p);
-               goto success;
-       }
-       count = ldns_pkt_qdcount(p) + ldns_pkt_ancount(p) +
-               ldns_pkt_nscount(p);
-       if (n < count) {
-               sec = ldns_pkt_authority(p);
-               goto success;
-       }
-       count = ldns_pkt_qdcount(p) + ldns_pkt_ancount(p) +
-               ldns_pkt_nscount(p) + ldns_pkt_arcount(p);
-       if (n < count) {
-               sec = ldns_pkt_additional(p);
-               goto success;
-       } 
-       /* still not ?? */
-       return NULL;
-       
-success:
-       r = ldns_rr_list_rr(sec, count - n - 1);
-       sec->_rrs[count - n - 1] = rr; /* replace */
-       return r;
-}
-
-/* insert rr  after n */
-bool
-ldns_pkt_insert_rr(ldns_pkt *p, ldns_rr *rr, uint16_t n)
-{
-       ldns_rr_list *sec;
-       ldns_pkt_section where;
-       uint16_t count;
-
-       /* i break a layer here -- sue me */
-
-       /* retrieve the correct section */
-       count = ldns_pkt_qdcount(p);
-       if (n < count) {
-               sec = ldns_pkt_question(p);
-               where = LDNS_SECTION_QUESTION;
-               goto success;
-       }
-       count = ldns_pkt_qdcount(p) + ldns_pkt_ancount(p);
-       if (n < count) {
-               sec = ldns_pkt_answer(p);
-               where = LDNS_SECTION_ANSWER;
-               goto success;
-       }
-       count = ldns_pkt_qdcount(p) + ldns_pkt_ancount(p) +
-               ldns_pkt_nscount(p);
-       if (n < count) {
-               sec = ldns_pkt_authority(p);
-               where = LDNS_SECTION_AUTHORITY;
-               goto success;
-       }
-       count = ldns_pkt_qdcount(p) + ldns_pkt_ancount(p) +
-               ldns_pkt_nscount(p) + ldns_pkt_arcount(p);
-       if (n < count) {
-               sec = ldns_pkt_additional(p);
-               where = LDNS_SECTION_ADDITIONAL;
-               goto success;
-       } 
-       /* still not ?? */
-       return false;
-       
-success:
-       if (ldns_rr_list_insert_rr(sec, rr, count - n - 1)) {
-               /* inc the section counter */
-               switch(where) {
-                       case LDNS_SECTION_QUESTION:
-                               ldns_pkt_set_qdcount(p,
-                                               ldns_pkt_qdcount(p) + 1);
-                               break;
-                       case LDNS_SECTION_ANSWER:
-                               ldns_pkt_set_ancount(p,
-                                               ldns_pkt_ancount(p) + 1);
-                               break;
-                       case LDNS_SECTION_AUTHORITY:
-                               ldns_pkt_set_nscount(p,
-                                               ldns_pkt_nscount(p) + 1);
-                               break;
-                       case LDNS_SECTION_ADDITIONAL:
-                               ldns_pkt_set_arcount(p,
-                                               ldns_pkt_arcount(p) + 1);
-                               break;
-                       default:
-                               /* do nothing, this is here to avoid compile warn */
-                               break;
-               }
-               return true;
-
-       } else {
-               return false;
-       }
-}
-
 uint16_t
 ldns_pkt_section_count(const ldns_pkt *packet, ldns_pkt_section s)
 {
@@ -544,6 +391,16 @@ ldns_pkt_section_count(const ldns_pkt *packet, ldns_pkt_section s)
        }
 }
 
+bool
+ldns_pkt_empty(ldns_pkt *p)
+{
+       if (ldns_pkt_section_count(p, LDNS_SECTION_ANY) > 0) {
+               return true;
+       } else
+               return false;
+}
+
+
 ldns_rr_list *
 ldns_pkt_get_section_clone(ldns_pkt *packet, ldns_pkt_section s)
 {