~ubuntu-branches/ubuntu/maverick/unbound/maverick-security

« back to all changes in this revision

Viewing changes to validator/val_utils.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert S. Edmonds
  • Date: 2009-12-29 21:54:26 UTC
  • mfrom: (4.2.7 sid)
  • Revision ID: james.westby@ubuntu.com-20091229215426-lah3ls3mwrtyuibo
Tags: 1.4.1-2
Invoke dh_installinit with --restart-after-upgrade; closes: #563033.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
#include "validator/val_kentry.h"
45
45
#include "validator/val_sigcrypt.h"
46
46
#include "validator/val_anchor.h"
 
47
#include "validator/val_nsec.h"
 
48
#include "validator/val_neg.h"
47
49
#include "services/cache/rrset.h"
 
50
#include "services/cache/dns.h"
48
51
#include "util/data/msgreply.h"
49
52
#include "util/data/packed_rrset.h"
50
53
#include "util/data/dname.h"
881
884
        else    *reason = "no signatures over NSEC3s";
882
885
        return 0;
883
886
}
 
887
 
 
888
struct dns_msg* 
 
889
val_find_DS(struct module_env* env, uint8_t* nm, size_t nmlen, uint16_t c, 
 
890
        struct regional* region)
 
891
{
 
892
        struct dns_msg* msg;
 
893
        struct query_info qinfo;
 
894
        struct ub_packed_rrset_key *rrset = rrset_cache_lookup(
 
895
                env->rrset_cache, nm, nmlen, LDNS_RR_TYPE_DS, c, 0, 
 
896
                *env->now, 0);
 
897
        if(rrset) {
 
898
                /* DS rrset exists. Return it to the validator immediately*/
 
899
                struct ub_packed_rrset_key* copy = packed_rrset_copy_region(
 
900
                        rrset, region, *env->now);
 
901
                lock_rw_unlock(&rrset->entry.lock);
 
902
                if(!copy)
 
903
                        return NULL;
 
904
                msg = dns_msg_create(nm, nmlen, LDNS_RR_TYPE_DS, c, region, 1);
 
905
                if(!msg)
 
906
                        return NULL;
 
907
                msg->rep->rrsets[0] = copy;
 
908
                msg->rep->rrset_count++;
 
909
                msg->rep->an_numrrsets++;
 
910
                return msg;
 
911
        }
 
912
        /* lookup in rrset and negative cache for NSEC/NSEC3 */
 
913
        qinfo.qname = nm;
 
914
        qinfo.qname_len = nmlen;
 
915
        qinfo.qtype = LDNS_RR_TYPE_DS;
 
916
        qinfo.qclass = c;
 
917
        /* do not add SOA to reply message, it is going to be used internal */
 
918
        msg = val_neg_getmsg(env->neg_cache, &qinfo, region, env->rrset_cache,
 
919
                env->scratch_buffer, *env->now, 0);
 
920
        return msg;
 
921
}