]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
add some rrset stuff - needed for dnssec
authorMiek Gieben <miekg@NLnetLabs.nl>
Thu, 24 Feb 2005 15:23:05 +0000 (15:23 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Thu, 24 Feb 2005 15:23:05 +0000 (15:23 +0000)
dnssec.c
rdata.c
rr.c

index 990031c817a0b44cabb3b6b8c3dd8cb6e4f27298..6b635007824365001feae6684af2f147e5b5241a 100644 (file)
--- a/dnssec.c
+++ b/dnssec.c
@@ -252,12 +252,8 @@ verify_rrsig_rsamd5(uint8_t *verifybuf, unsigned long length, unsigned char *sig
        return result;
 }
 
-/**
- * Verifies the rrsig of the rrset with the dnskey
- * What does result?
- */
-int
-verify_rrsig(struct t_rr *rrset, struct t_rr *rrsig, struct t_rr *dnskey)
+bool
+verify_rrsig(ldns_rr_list rrset, ldns_rr_list *rrsig, ldns_rr_list *dnskey)
 {
        /* translate rrsig+rrset to binary data */
        uint8_t *verifybuf;
diff --git a/rdata.c b/rdata.c
index 3d94fb649e08843770f7f67087a5317e75af33a0..946c716dd6b8b7cb276faf48361dddda6c3ce16a 100644 (file)
--- a/rdata.c
+++ b/rdata.c
@@ -420,3 +420,39 @@ ldns_octet(char *word, size_t *length)
     *p = '\0';
     return LDNS_STATUS_OK;
 }
+
+#if 0
+/**
+ * Compare two rdf's
+ * \param[in] rd1 the first one
+ * \parma[in] rd2 the second one
+ * \return 0 if equal
+ *         -1 if rd1 comes before rd2
+ *         +1 if rd2 comes before rd1
+ */
+int
+ldns_rdata_compare(const ldns_rdf *rd1, const ldns_rdf *rd2)
+{
+       uint16_t i1, i2, i;
+       void *d1, *d2;
+       i1 = ldns_rdf_size(rd1);
+       i2 = ldns_rdf_size(rd1);
+
+       if (i1 < i2) {
+               return -1;
+       } else if (i1 > i2) {
+               return +1;
+       } else {
+               d1 = ldns_rdf_data(rd1);
+               d2 = ldns_rdf_data(rd2);
+               for(i = 0; i < i1; i++) {
+                       if (*d1[i] < *d2[i]) {
+                               return -1;
+                       } else if (d1[i] > d2[i]) {
+                               return +1;
+                       }
+               }
+       }
+       return 0;
+}
+#endif
diff --git a/rr.c b/rr.c
index 21eeb048aad750a52ae2191135543e6dbe38679e..550be1eb7570c0d36d703cb799cf04e7275af871 100644 (file)
--- a/rr.c
+++ b/rr.c
@@ -281,6 +281,67 @@ ldns_rr_list_push_rr(ldns_rr_list *rr_list, ldns_rr *rr)
 
 }
 
+/* rrset stuff 
+ * rrset is a rr_list with the following properties
+ * 1. owner is equal
+ * 2. class is equal
+ * 3. type is equal
+ * 4. ttl is equal - although not for RRSIG
+ */
+
+/**
+ * check if an rr_list is a rrset
+ * \param[in] rr_list the rr_list to check
+ */
+bool
+ldns_is_rrset(ldns_rr_list *rr_list)
+{
+       ldns_rr_list_print(stdout, rr_list);
+       return false;
+}
+
+/**
+ * add an rr to an rrset 
+ */
+bool
+ldns_rr_set_push_rr(ldns_rr_list *rr_list, ldns_rr *rr)
+{
+       uint16_t rr_count;
+       ldns_rr *last;
+
+       rr_count = ldns_rr_list_rr_count(rr_list);
+
+       if (rr_count == 0) {
+               /* nothing there, so checking it is 
+                * not needed */
+               return ldns_rr_list_push_rr(rr_list, rr);
+       } else {
+               /* check with the final rr in the rr_list */
+               last = ldns_rr_list_rr(rr_list, rr_count);
+
+               if (ldns_rr_get_class(last) != ldns_rr_get_class(rr)) {
+                       return false;
+               }
+               if (ldns_rr_get_type(last) != ldns_rr_get_type(rr)) {
+                       return false;
+               }
+               /* only check if not equal to RRSIG */
+               if (ldns_rr_get_type(rr) != LDNS_RR_TYPE_RRSIG) {
+                       if (ldns_rr_ttl(last) != ldns_rr_ttl(rr)) {
+                               return false;
+                       }
+               }
+               /* TODO TODO 
+               if (ldns_rdata_compare(ldns_rr_owner(last),
+                                       ldns_rr_owner(rr)) != 0) {
+                       return false;
+               }
+               */
+               /* ok, still alive */
+               return ldns_rr_list_push_rr(rr_list, rr);
+       }
+}
+
 /** \cond */
 static const ldns_rdf_type type_0_wireformat[] = { LDNS_RDF_TYPE_UNKNOWN };
 static const ldns_rdf_type type_a_wireformat[] = { LDNS_RDF_TYPE_A };