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

int ldns_rr_compare_no_rdata ( const ldns_rr rr1,
const ldns_rr rr2 
)

compares two rrs, up to the rdata.

Parameters:
[in] rr1 the first one
[in] rr2 the second one
Returns:
0 if equal -1 if rr1 comes before rr2 +1 if rr2 comes before rr1

Definition at line 1288 of file rr.c.

References ldns_rdf_size(), ldns_rr_compare_no_rdata(), ldns_rr_get_class(), ldns_rr_get_type(), ldns_rr_owner(), and ldns_rr_uncompressed_size().

Referenced by ldns_rr_compare(), and ldns_rr_compare_no_rdata().

{
      size_t rr1_len;
      size_t rr2_len;
        size_t offset;

      assert(rr1 != NULL);
      assert(rr2 != NULL);

      rr1_len = ldns_rr_uncompressed_size(rr1);
      rr2_len = ldns_rr_uncompressed_size(rr2);

      if (ldns_dname_compare(ldns_rr_owner(rr1), ldns_rr_owner(rr2)) < 0) {
            return -1;
      } else if (ldns_dname_compare(ldns_rr_owner(rr1), ldns_rr_owner(rr2)) > 0) {
            return 1;
      }

        if (ldns_rr_get_class(rr1) != ldns_rr_get_class(rr2)) {
            return ldns_rr_get_class(rr2) - ldns_rr_get_class(rr1);
        }

        if (ldns_rr_get_type(rr1) != ldns_rr_get_type(rr2)) {
            return ldns_rr_get_type(rr2) - ldns_rr_get_type(rr1);
        }
        
        /* offset is the owername length + ttl + type + class + rdlen == start of wire format rdata */
        offset = ldns_rdf_size(ldns_rr_owner(rr1)) + 4 + 2 + 2 + 2;
        /* if either record doesn't have any RDATA... */
        if (offset > rr1_len || offset > rr2_len) {
            if (rr1_len == rr2_len) {
              return 0;
            }
            return ((int) rr2_len - (int) rr1_len);
        }

      return 0;
}


Generated by  Doxygen 1.6.0   Back to index