From: Miek Gieben Date: Thu, 24 Feb 2005 15:23:05 +0000 (+0000) Subject: add some rrset stuff - needed for dnssec X-Git-Tag: release-0.50~371 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=518f237cea702b3a977d474fd785a9ef9ff9fdd2;p=thirdparty%2Fldns.git add some rrset stuff - needed for dnssec --- diff --git a/dnssec.c b/dnssec.c index 990031c8..6b635007 100644 --- 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 3d94fb64..946c716d 100644 --- 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 21eeb048..550be1eb 100644 --- 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 };