Logo Search packages:      
Sourcecode: ldns version File versions  Download package

bool ldns_rr_compare_ds ( const ldns_rr rr1,
const ldns_rr rr2 
)

returns true of the given rr's are equal. Also returns true if one record is a DS that represents the same DNSKEY record as the other record

Parameters:
[in] rr1 the first rr
[in] rr2 the second rr
Returns:
true if equal otherwise false

Definition at line 1402 of file rr.c.

References ldns_key_rr2ds(), ldns_rr_clone(), ldns_rr_compare(), ldns_rr_compare_ds(), ldns_rr_free(), ldns_rr_get_type(), ldns_rr_set_ttl(), and LDNS_RR_TYPE_DS.

Referenced by ldns_rr_compare_ds().

{
      bool result;
#ifdef HAVE_SSL
      ldns_rr *ds_repr;
#endif /* HAVE_SSL */
      ldns_rr *rr1 = ldns_rr_clone(orr1);
      ldns_rr *rr2 = ldns_rr_clone(orr2);
      
      /* set ttls to zero */
      ldns_rr_set_ttl(rr1, 0);
      ldns_rr_set_ttl(rr2, 0);

#ifdef HAVE_SSL
      if (ldns_rr_get_type(rr1) == LDNS_RR_TYPE_DS &&
          ldns_rr_get_type(rr2) == LDNS_RR_TYPE_DNSKEY) {
            ds_repr = ldns_key_rr2ds(rr2, LDNS_SHA1);
            result = (ldns_rr_compare(rr1, ds_repr) == 0);
            ldns_rr_free(ds_repr);
      } else if (ldns_rr_get_type(rr1) == LDNS_RR_TYPE_DNSKEY &&
          ldns_rr_get_type(rr2) == LDNS_RR_TYPE_DS) {
            ds_repr = ldns_key_rr2ds(rr1, LDNS_SHA1);
            result = (ldns_rr_compare(rr2, ds_repr) == 0);

            ldns_rr_free(ds_repr);
      } else {
            result = (ldns_rr_compare(rr1, rr2) == 0);
      }     
#else
            result = (ldns_rr_compare(rr1, rr2) == 0);
#endif /* HAVE_SSL */
      
      ldns_rr_free(rr1);
      ldns_rr_free(rr2);

      return result;
}


Generated by  Doxygen 1.6.0   Back to index