]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
adding some very lowlevel functionality. Makes you wonder why we didn't
authorMiek Gieben <miekg@NLnetLabs.nl>
Thu, 23 Jun 2005 11:48:14 +0000 (11:48 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Thu, 23 Jun 2005 11:48:14 +0000 (11:48 +0000)
need them before...

TODO
dname.c
ldns/dname.h
ldns/zone.h
zone.c

diff --git a/TODO b/TODO
index 306e78e61b33a9becf88ebfa422ad6fa9d8a4b2f..aca18aa3c5103405d7243c9530787aadfe5d7dd9 100644 (file)
--- a/TODO
+++ b/TODO
@@ -24,6 +24,7 @@ o DNSSEC
 o init function? random - load_ssl_errors()
        - SSL_load_error_str()? 
 o SERVER stuff; open connection and such - NOT DONE AT ALL - will happen in .90
+o const args for all functions
 
 To ponder and discuss:
 ----------------------
diff --git a/dname.c b/dname.c
index c0738149dbc1724100b4d53012e420a37fd63581..1d3efb84899386969d8da57d921597d80b5c247e 100644 (file)
--- a/dname.c
+++ b/dname.c
@@ -3,6 +3,8 @@
  *
  * dname specific rdata implementations
  * A dname is a rdf structure with type LDNS_RDF_TYPE_DNAME
+ * It is not a /real/ type! All function must therefor check
+ * for LDNS_RDF_TYPE_DNAME.
  *
  * a Net::DNS like library for C
  *
@@ -20,7 +22,6 @@
 #include <netdb.h>
 #include <arpa/inet.h>
 
-
 ldns_rdf *
 ldns_dname_cat_clone(ldns_rdf *rd1, ldns_rdf *rd2)
 {
@@ -111,7 +112,7 @@ ldns_dname_left_chop(ldns_rdf *d)
 }
 
 uint8_t         
-ldns_dname_label_count(ldns_rdf *r)
+ldns_dname_label_count(const ldns_rdf *r)
 {       
         uint8_t src_pos;
         uint8_t len;
@@ -168,3 +169,41 @@ ldns_dname2canonical(const ldns_rdf *rd)
                *rdd = (uint8_t)LDNS_DNAME_NORMALIZE((int)*rdd);
        }
 }
+
+bool
+ldns_dname_is_subdomain(const ldns_rdf *sub, const ldns_rdf *parent)
+{
+       uint8_t sub_lab;
+       uint8_t par_lab;
+       int8_t i;
+
+       if (ldns_rdf_get_type(sub) != LDNS_RDF_TYPE_DNAME ||
+                       ldns_rdf_get_type(parent) != LDNS_RDF_TYPE_DNAME) {
+               return false;
+       }
+
+       sub_lab = ldns_dname_label_count(sub);
+       par_lab = ldns_dname_label_count(parent);
+
+       /* if sub sits above parent, it cannot be a child/sub domain */
+       if (sub_lab < par_lab) {
+               return false;
+       }
+       
+       /* check all labels the from the parent labels, from right to left. 
+        * When they /all/ match we have found a subdomain
+        */
+       for (i = par_lab; i > 0; i--) {
+                       /* */
+       }
+       return false;
+}
+
+uint8_t *
+ldns_dname_label(ldns_rdf *rdf, uint8_t labelpos)
+{
+       rdf = rdf;
+       labelpos = labelpos;
+
+       return NULL;
+}
index 2786dd657b789390cfb36e6304fe79dc054299d2..f5849281d5e33ab4275dc9982f9e996b920e5a86 100644 (file)
@@ -37,7 +37,7 @@ ldns_rdf      *ldns_dname_left_chop(ldns_rdf *d);
  * \param[in] *r the rdf
  * \return the number of labels
  */     
-uint8_t         ldns_dname_label_count(ldns_rdf *r);
+uint8_t         ldns_dname_label_count(const ldns_rdf *r);
 
 /**
  * Create a new dname rdf from a string
@@ -53,11 +53,32 @@ ldns_rdf    *ldns_dname_new_frm_str(const char *str);
  * \return ldns_rdf*
  */
 ldns_rdf       *ldns_dname_new_frm_data(uint16_t size, const void *data);
+
 /**
  * Put a dname into canonical fmt - ie. lowercase it
  * \param[in] rdf the dname to lowercase
  * \return void
  */
-void           ldns_dname2canonical(const ldns_rdf *rdf);
+void ldns_dname2canonical(const ldns_rdf *rdf);
+
+/**
+ * test wether the name sub falls under parent (i.e. is a subdomain
+ * of parent.
+ * \param[in] sub the name to test
+ * \param[in] parent the parent's name
+ * \return true if sub falls under parent, otherwise false
+ */
+bool ldns_dname_is_subdomain(const ldns_rdf *sub, const ldns_rdf *parent);
+
+/**
+ * look inside the rdf and if it is an LDNS_RDF_TYPE_DNAME
+ * try and retrieve a specific label. The labels are numbered
+ * starting from 0 (left most).
+ * \param[in] rdf the rdf to look in
+ * \param[in] labelpos return the label with this number
+ * \return a pointer to a newly allocated buffer with the
+ * label which is NULL terminated
+ */
+uint8_t * ldns_dname_label(ldns_rdf *rdf, uint8_t labelpos);
 
 #endif /* !_LDNS_DNAME_H */
index 18887089a77c2db3a99b34ec4a95004c67c005c4..b354e75a49090441f305664b659eaf32610b0011 100644 (file)
@@ -80,5 +80,13 @@ bool ldns_zone_push_rr_list(ldns_zone *z, ldns_rr_list *list);
  */
 bool ldns_zone_push_rr(ldns_zone *z, ldns_rr *rr);
 
+/**
+ * find out if the rr is glue inside zone z
+ * \param[in] z the zone to look for glue
+ * \param[in] rr the rr to test
+ * \return true if rr is glue, otherwise false
+ */
+bool ldns_zone_rr_is_glue(ldns_zone *z, ldns_rr *rr);
+
 
 #endif /* LDNS_ZONE_H */
diff --git a/zone.c b/zone.c
index b04c22c80e0d89bc67dbeb67a8b762d14c76c79d..3fd1c335efeeb1d130fead2eea8888ac13319d8e 100644 (file)
--- a/zone.c
+++ b/zone.c
@@ -51,6 +51,15 @@ ldns_zone_push_rr(ldns_zone *z, ldns_rr *rr)
                        ldns_zone_rrs(z), rr);
 }
 
+bool
+ldns_zone_rr_is_glue(ldns_zone *z, ldns_rr *rr)
+{
+       z = z;
+       rr = rr;
+
+       return false;
+}
+
 #if 0
 /**
  * ixfr function. Work on a ldns_zone and remove and add