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

bool ldns_rr_set_push_rr ( ldns_rr_list rr_list,
ldns_rr rr 
)

pushes an rr to an rrset (which really are rr_list's).

Parameters:
[in] *rr_list the rrset to push the rr to
[in] *rr the rr to push
Returns:
true if the push succeeded otherwise false

Definition at line 1022 of file rr.c.

References ldns_rdf_compare(), ldns_rr_compare(), ldns_rr_get_class(), ldns_rr_get_type(), ldns_rr_list_push_rr(), ldns_rr_list_rr(), ldns_rr_list_rr_count(), ldns_rr_owner(), ldns_rr_set_push_rr(), ldns_rr_ttl(), and LDNS_RR_TYPE_RRSIG.

Referenced by ldns_rr_set_push_rr().

{
      size_t rr_count;
      size_t i;
      ldns_rr *last;

      assert(rr != NULL);

      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 - 1);

            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;
                  }
            }
            if (ldns_rdf_compare(ldns_rr_owner(last),
                              ldns_rr_owner(rr)) != 0) {
                  return false;
            }
            /* ok, still alive - check if the rr already
             * exists - if so, dont' add it */
            for(i = 0; i < rr_count; i++) {
                  if(ldns_rr_compare(
                              ldns_rr_list_rr(rr_list, i), rr) == 0) {
                        return false;
                  }
            }
            /* it's safe, push it */
            return ldns_rr_list_push_rr(rr_list, rr);
      }
}


Generated by  Doxygen 1.6.0   Back to index