rrset_expired_above(struct module_env* env, uint8_t** qname, size_t* qnamelen,
	uint16_t searchtype, uint16_t qclass, time_t now, uint8_t* expiretop,
	size_t expiretoplen)
{
	struct ub_packed_rrset_key *rrset;
	uint8_t lablen;

	while(*qnamelen > 0) {
		/* look one label higher */
		lablen = **qname;
		*qname += lablen + 1;
		*qnamelen -= lablen + 1;
		if(*qnamelen <= 0)
			break;

		/* looks up with a time of 0, to see expired entries */
		if((rrset = rrset_cache_lookup(env->rrset_cache, *qname,
			*qnamelen, searchtype, qclass, 0, 0, 0))) {
			struct packed_rrset_data* data =
				(struct packed_rrset_data*)rrset->entry.data;
			if(now > data->ttl) {
				/* it is expired, this is not wanted */
				lock_rw_unlock(&rrset->entry.lock);
				log_nametypeclass(VERB_ALGO, "this rrset is expired", *qname, searchtype, qclass);
				return 1;
			}
			/* it is not expired, continue looking */
			lock_rw_unlock(&rrset->entry.lock);
		}

		/* do not look above the expiretop. */
		if(expiretop && *qnamelen == expiretoplen &&
			query_dname_compare(*qname, expiretop)==0)
			break;
	}
	return 0;
}
rrset_expired_above(struct module_env* env, uint8_t** qname, size_t* qnamelen,
	uint16_t searchtype, uint16_t qclass, time_t now, uint8_t* expiretop,
	size_t expiretoplen)
{
	struct ub_packed_rrset_key *rrset;
	uint8_t lablen;

	while(*qnamelen > 0) {
		 
		lablen = **qname;
		*qname += lablen + 1;
		*qnamelen -= lablen + 1;
		if(*qnamelen <= 0)
			break;

		 
		if((rrset = rrset_cache_lookup(env->rrset_cache, *qname,
			*qnamelen, searchtype, qclass, 0, 0, 0))) {
			struct packed_rrset_data* data =
				(struct packed_rrset_data*)rrset->entry.data;
			if(now > data->ttl) {
				 
				lock_rw_unlock(&rrset->entry.lock);
				log_nametypeclass(VERB_ALGO, "this rrset is expired", *qname, searchtype, qclass);
				return 1;
			}
			 
			lock_rw_unlock(&rrset->entry.lock);
		}

		 
		if(expiretop && *qnamelen == expiretoplen &&
			query_dname_compare(*qname, expiretop)==0)
			break;
	}
	return 0;
}