cachedb_intcache_lookup(struct module_qstate* qstate)
{
	uint8_t* dpname=NULL;
	size_t dpnamelen=0;
	struct dns_msg* msg;
	if(iter_stub_fwd_no_cache(qstate, &qstate->qinfo,
		&dpname, &dpnamelen))
		return 0; /* no cache for these queries */
	msg = dns_cache_lookup(qstate->env, qstate->qinfo.qname,
		qstate->qinfo.qname_len, qstate->qinfo.qtype,
		qstate->qinfo.qclass, qstate->query_flags,
		qstate->region, qstate->env->scratch,
		1, /* no partial messages with only a CNAME */
		dpname, dpnamelen
		);
	if(!msg && qstate->env->neg_cache &&
		iter_qname_indicates_dnssec(qstate->env, &qstate->qinfo)) {
		/* lookup in negative cache; may result in 
		 * NOERROR/NODATA or NXDOMAIN answers that need validation */
		msg = val_neg_getmsg(qstate->env->neg_cache, &qstate->qinfo,
			qstate->region, qstate->env->rrset_cache,
			qstate->env->scratch_buffer,
			*qstate->env->now, 1/*add SOA*/, NULL,
			qstate->env->cfg);
	}
	if(!msg)
		return 0;
	/* this is the returned msg */
	qstate->return_rcode = LDNS_RCODE_NOERROR;
	qstate->return_msg = msg;
	return 1;
}
cachedb_intcache_lookup(struct module_qstate* qstate)
{
	uint8_t* dpname=NULL;
	size_t dpnamelen=0;
	struct dns_msg* msg;
	if(iter_stub_fwd_no_cache(qstate, &qstate->qinfo,
		&dpname, &dpnamelen))
		return 0;  
	msg = dns_cache_lookup(qstate->env, qstate->qinfo.qname,
		qstate->qinfo.qname_len, qstate->qinfo.qtype,
		qstate->qinfo.qclass, qstate->query_flags,
		qstate->region, qstate->env->scratch,
		1,  
		dpname, dpnamelen
		);
	if(!msg && qstate->env->neg_cache &&
		iter_qname_indicates_dnssec(qstate->env, &qstate->qinfo)) {
		 
		msg = val_neg_getmsg(qstate->env->neg_cache, &qstate->qinfo,
			qstate->region, qstate->env->rrset_cache,
			qstate->env->scratch_buffer,
			*qstate->env->now, 1 , NULL,
			qstate->env->cfg);
	}
	if(!msg)
		return 0;
	 
	qstate->return_rcode = LDNS_RCODE_NOERROR;
	qstate->return_msg = msg;
	return 1;
}