]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
API CHANGE
authorMiek Gieben <miekg@NLnetLabs.nl>
Mon, 12 Dec 2005 20:43:58 +0000 (20:43 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Mon, 12 Dec 2005 20:43:58 +0000 (20:43 +0000)
add an extra var to these function so that the
previous ownername is used when current one
hasn't one specified - which is valid zone file
syntax

examples/configure.ac
examples/ldns-splitzone.c
higher.c
ldns/rdata.h
ldns/rr.h
rdata.c
rr.c
zone.c

index e917eee34e525b7e8665d5a73138716755d0a71e..8397671b10cc9a3a00605716c7a9e0c15db80c74 100644 (file)
@@ -44,15 +44,10 @@ AC_CHECK_HEADER(ldns/dns.h,,  [
        ], [AC_INCLUDES_DEFAULT]
 )
 
-AC_CHECK_LIB(pcap, pcap_open_offline,, [
-       AC_MSG_ERROR([Can't find pcap library (needed for dpa)])
-       ]
-)
-
-AC_CHECK_HEADER(pcap.h,,  [
-       AC_MSG_ERROR([Can't find pcap library headers (needed for dpa)])
-       ], [AC_INCLUDES_DEFAULT]
-)
+#AC_CHECK_LIB(pcap, pcap_open_offline,, [
+#      AC_MSG_ERROR([Can't find pcap library (needed for dpa)])
+#      ]
+#)
 
 AC_CHECK_FUNCS(isblank)
 
index 390182befc03413c398ef2212007cf111bb493d1..d5588e5627459b9571553f169b85ff74705bd38b 100644 (file)
@@ -42,14 +42,15 @@ main(int argc, char **argv)
        int line_nr;
        size_t split;
        size_t i;
-       bool splitting;
+       int splitting;
        size_t file_counter;
        char filename[255];
 
        progname = strdup(argv[0]);
        split = 0;
-       splitting = false; /* when true we are about to split */
+       splitting = 0; /* when true we are about to split */
        file_counter = 1;
+       lastname = NULL;
 
        while ((c = getopt(argc, argv, "n:")) != -1) {
                switch(c) {
@@ -112,8 +113,27 @@ main(int argc, char **argv)
                ldns_rr_print(stdout, 
                                ldns_rr_list_rr(zrrs, i));
 
-               lastname = ldns_rr_owner(ldns_rr_list_rr(zrrs, i));
 
+               if (i > 0 && (i % split) == 0) {
+                       printf("%d %d\n", i, (i & split));
+                       splitting = 1;
+               }
+
+               if (splitting == 1 && 
+                               ldns_dname_compare(ldns_rr_owner(ldns_rr_list_rr(zrrs, i)), lastname) == 0) {
+                       /* equal names, don't split yet */
+               } else {
+                       /* now we are ready to split */
+                       splitting = 2;
+               }
+               if (splitting == 2) {
+                       /* SPLIT */
+                       printf("LDNS INTENT TO SPLIT !!!! \n");
+                       lastname = NULL;
+                       continue;
+               }
+               
+               lastname = ldns_rr_owner(ldns_rr_list_rr(zrrs, i));
        }
 /*     fclose(fp); */
 
index 9d702c8c0fa8efdabe77996eb711810367c8905d..bdb0e9213d7053e2f12e2a733dce3b1278a12b7f 100644 (file)
--- a/higher.c
+++ b/higher.c
@@ -207,7 +207,7 @@ ldns_get_rr_list_hosts_frm_fp_l(FILE *fp, int *line_nr)
                                } else {
                                        snprintf(rr_str, LDNS_MAX_LINELEN, "%s IN A %s", word, addr);
                                }
-                               rr = ldns_rr_new_frm_str(rr_str, 0, NULL);
+                               rr = ldns_rr_new_frm_str(rr_str, 0, NULL, NULL);
                                if (rr) {
                                                ldns_rr_list_push_rr(list, ldns_rr_clone(rr));
                                }
@@ -338,7 +338,7 @@ ldns_update_send_simple_addr(const char *fqdn, const char *zone,
                snprintf(rrstr, rrstrlen, "%s IN %s %s", fqdn,
                    strchr(ipaddr, ':') ? "AAAA" : "A", ipaddr);
 
-               up_rr = ldns_rr_new_frm_str(rrstr, ttl, NULL);
+               up_rr = ldns_rr_new_frm_str(rrstr, ttl, NULL, NULL);
                if (!up_rr) {
                        ldns_rr_list_deep_free(up_rrlist);
                        free(rrstr);
index 7c14dd68c8702c89224b576cc50423fa15e91e84..a199d1cd1040adf4ccc4c0c83bcc2c842817f23e 100644 (file)
@@ -333,16 +333,6 @@ ldns_status     ldns_octet(char *word, size_t *length);
  */
 ldns_rdf       *ldns_rdf_clone(const ldns_rdf *rd);
 
-/**
- * concatenate two rdfs (of the same type!) together. Left
- * is modified in this operation.
- * \param[in] left the left part of the new rdf
- * \param[in] right the right part of the new rdf
- * \return true when it succeeds otherwise false
- */
-bool ldns_rdf_cat(ldns_rdf *left, ldns_rdf *right);
-
-
 /**
  * compares two rdf's on their wire formats.
  * (To order dnames according to rfc4034, use ldns_dname_compare)
index bd2914717ec81e7cedc9fa151c172a4a288858a9..1497e0aa88685aad1da20a3a122862c9f9b06f70 100644 (file)
--- a/ldns/rr.h
+++ b/ldns/rr.h
@@ -267,9 +267,11 @@ void ldns_rr_free(ldns_rr *rr);
  * \param[in] str the string to convert
  * \param[in] default_ttl pointer to a default ttl for the rr. If 0 DEF_TTL will be used
  * \param[in] origin when the owner is relative add this
+ * \param prev the previous ownername. the function overwrite this with
+ * the current found ownername.
  * \return the new rr
  */
-ldns_rr* ldns_rr_new_frm_str(const char *str, uint16_t default_ttl, ldns_rdf *origin);
+ldns_rr* ldns_rr_new_frm_str(const char *str, uint16_t default_ttl, ldns_rdf *origin, ldns_rdf **prev);
 
 /**
  * creates a new rr from a file containing a string.
@@ -278,9 +280,11 @@ ldns_rr* ldns_rr_new_frm_str(const char *str, uint16_t default_ttl, ldns_rdf *or
  *            the pointer will be updated if the file contains a $TTL directive
  * \param[in] origin when the owner is relative add this
  *           the pointer will be updated if the file contains a $ORIGIN directive
+ * \param[in] prev when the owner is whitespaces use this as the * ownername
+ *            the pointer will be updated after the call
  * \return ldns_rr*
  */
-ldns_rr* ldns_rr_new_frm_fp(FILE *fp, uint16_t *default_ttl, ldns_rdf **origin);
+ldns_rr* ldns_rr_new_frm_fp(FILE *fp, uint16_t *default_ttl, ldns_rdf **origin, ldns_rdf **prev);
 
 /**
  * creates a new rr from a file containing a string.
@@ -290,9 +294,11 @@ ldns_rr* ldns_rr_new_frm_fp(FILE *fp, uint16_t *default_ttl, ldns_rdf **origin);
  * \param[in] origin when the owner is relative add this
  *           the pointer will be updated if the file contains a $ORIGIN directive
  * \param[in] line_nr pointer to an integer containing the current line number (for debugging purposes)
+ * \param[in] prev when the owner is whitespaces use this as the * ownername
+ *            the pointer will be updated after the call
  * \return ldns_rr*
  */
-ldns_rr* ldns_rr_new_frm_fp_l(FILE *fp, uint16_t *default_ttl, ldns_rdf **origin, int *line_nr);
+ldns_rr* ldns_rr_new_frm_fp_l(FILE *fp, uint16_t *default_ttl, ldns_rdf **origin, ldns_rdf **prev, int *line_nr);
 
 /**
  * sets the owner in the rr structure.
diff --git a/rdata.c b/rdata.c
index ffac05372071c9c649057a0d2b6c39e9a237474f..41c7283dd8615c61557ddc67af49be708b768de2 100644 (file)
--- a/rdata.c
+++ b/rdata.c
@@ -193,32 +193,6 @@ ldns_rdf_clone(const ldns_rdf *r)
                                ldns_rdf_data(r)));
 }
 
-/* we modify left! */
-bool
-ldns_rdf_cat(ldns_rdf *left, ldns_rdf *right)
-{
-       uint8_t *d;
-       size_t new;
-
-       if (ldns_rdf_get_type(left) != ldns_rdf_get_type(right)) {
-               return false;
-       }
-
-       d = ldns_rdf_data(left);
-       new =ldns_rdf_size(left) + ldns_rdf_size(right);
-
-       d = LDNS_XREALLOC(d, uint8_t, new);
-       if (!d) {
-               return false;
-       }
-
-       /* this -1 is ONLY TEST WITH LDNS_RDF_TYPE_DNAME XXX */
-       memcpy(d + ldns_rdf_size(left) - 1, ldns_rdf_data(right), ldns_rdf_size(right));
-       ldns_rdf_set_size(left, new); 
-       ldns_rdf_set_data(left, d);
-       return true;
-}
-
 void
 ldns_rdf_deep_free(ldns_rdf *rd)
 {
diff --git a/rr.c b/rr.c
index ab16ee909f58338491ac06701880fac9cee6957d..1ea8bde5d54f57f8bf7de90b005281bca9c40b91 100644 (file)
--- a/rr.c
+++ b/rr.c
@@ -90,7 +90,7 @@ ldns_rr_free(ldns_rr *rr)
  * miek.nl. IN MX 10 elektron.atoom.net
  */
 ldns_rr *
-ldns_rr_new_frm_str(const char *str, uint16_t default_ttl, ldns_rdf *origin)
+ldns_rr_new_frm_str(const char *str, uint16_t default_ttl, ldns_rdf *origin, ldns_rdf **prev)
 {
        ldns_rr *new;
        const ldns_rr_descriptor *desc;
@@ -153,6 +153,7 @@ ldns_rr_new_frm_str(const char *str, uint16_t default_ttl, ldns_rdf *origin)
                ldns_rr_free(new);
                return NULL;
        }
+       
        if (ldns_bget_token(rr_buf, ttl, "\t\n ", 21) == -1) {
                LDNS_FREE(owner); 
                LDNS_FREE(ttl); 
@@ -253,7 +254,11 @@ ldns_rr_new_frm_str(const char *str, uint16_t default_ttl, ldns_rdf *origin)
                }
        } else {
                if (strlen(owner) == 0) {
-                       if (origin) {
+                       /* no ownername was given, try prev, if that fails 
+                        * origin, else default to root */
+                       if (prev) {
+                               ldns_rr_set_owner(new, ldns_rdf_clone(*prev));
+                       } else if (origin) {
                                ldns_rr_set_owner(new, ldns_rdf_clone(origin));
                        } else {
                                ldns_rr_set_owner(new, ldns_dname_new_frm_str("."));
@@ -272,7 +277,10 @@ ldns_rr_new_frm_str(const char *str, uint16_t default_ttl, ldns_rdf *origin)
                                        ldns_buffer_free(rr_buf);
                                        ldns_rr_free(new);
                                        return NULL;
-                               }
+                               } 
+                       }
+                       if (prev) {
+                               *prev = ldns_rr_owner(new);
                        }
                }
        }
@@ -355,9 +363,8 @@ ldns_rr_new_frm_str(const char *str, uint16_t default_ttl, ldns_rdf *origin)
                                                /* check if the origin should be concatenated */
                                                if (ldns_rr_descriptor_field_type(desc, r_cnt) == LDNS_RDF_TYPE_DNAME &&
                                                                rd_strlen > 1 &&
-                                                               rd[rd_strlen - 1] != '.' &&
-                                                               origin) {
-                                                       if (!ldns_rdf_cat(r, origin)) {
+                                                               !ldns_dname_str_absolute(rd) && origin) {
+                                                       if (!ldns_dname_cat(r, origin)) {
                                                                /* don't know if to quit */
                                                                /* return NULL;*/
                                                        }
@@ -385,13 +392,13 @@ ldns_rr_new_frm_str(const char *str, uint16_t default_ttl, ldns_rdf *origin)
 }
 
 ldns_rr *
-ldns_rr_new_frm_fp(FILE *fp, uint16_t *ttl, ldns_rdf **origin)
+ldns_rr_new_frm_fp(FILE *fp, uint16_t *ttl, ldns_rdf **origin, ldns_rdf **prev)
 {
-       return ldns_rr_new_frm_fp_l(fp, ttl, origin, NULL);
+       return ldns_rr_new_frm_fp_l(fp, ttl, origin, prev, NULL);
 }
 
 ldns_rr *
-ldns_rr_new_frm_fp_l(FILE *fp, uint16_t *default_ttl, ldns_rdf **origin, int *line_nr)
+ldns_rr_new_frm_fp_l(FILE *fp, uint16_t *default_ttl, ldns_rdf **origin, ldns_rdf **prev, int *line_nr)
 {
         char *line;
        ldns_rr *rr;
@@ -430,11 +437,10 @@ ldns_rr_new_frm_fp_l(FILE *fp, uint16_t *default_ttl, ldns_rdf **origin, int *li
                        *default_ttl = (uint16_t) atoi(keyword + 5);
                }
        } else {
-
                if (origin) {
-                       rr = ldns_rr_new_frm_str((const char*) line, ttl, *origin);
+                       rr = ldns_rr_new_frm_str((const char*) line, ttl, *origin, prev);
                } else {
-                       rr = ldns_rr_new_frm_str((const char*) line, ttl, NULL);
+                       rr = ldns_rr_new_frm_str((const char*) line, ttl, NULL, prev);
                }
        
        }
diff --git a/zone.c b/zone.c
index 301dba7d92ac359622c797400aeff4fa6fa385eb..5c3c901410685a77ed4db23e94788ebdf0d949fc 100644 (file)
--- a/zone.c
+++ b/zone.c
@@ -162,7 +162,7 @@ ldns_zone_new_frm_fp_l(FILE *fp, ldns_rdf *origin, uint16_t ttl, ldns_rr_class c
        uint16_t my_ttl = ttl;
        ldns_rr_class my_class = c;
        ldns_rr *last_rr = NULL;
-
+       ldns_rdf *my_prev = NULL;
        uint8_t i;
 
        newzone = ldns_zone_new();
@@ -180,7 +180,7 @@ ldns_zone_new_frm_fp_l(FILE *fp, ldns_rdf *origin, uint16_t ttl, ldns_rr_class c
        
        i = 0;
        do {
-               rr = ldns_rr_new_frm_fp_l(fp, &my_ttl, &my_origin, line_nr);
+               rr = ldns_rr_new_frm_fp_l(fp, &my_ttl, &my_origin, &my_prev, line_nr);
                i++;
        } while (!rr && i <= 9);
 
@@ -214,7 +214,7 @@ ldns_zone_new_frm_fp_l(FILE *fp, ldns_rdf *origin, uint16_t ttl, ldns_rr_class c
        }
 
        while(!feof(fp)) {
-               rr = ldns_rr_new_frm_fp_l(fp, &my_ttl, &my_origin, line_nr);
+               rr = ldns_rr_new_frm_fp_l(fp, &my_ttl, &my_origin, &my_prev, line_nr);
                if (rr) {
                        last_rr = rr;
                        if (!ldns_zone_push_rr(newzone, rr)) {