errinf_reply(struct module_qstate* qstate, struct iter_qstate* iq)
{
	if(qstate->env->cfg->val_log_level < 2 && !qstate->env->cfg->log_servfail)
		return;
	if((qstate->reply && qstate->reply->addrlen != 0) ||
		(iq->fail_reply && iq->fail_reply->addrlen != 0)) {
		char from[256], frm[512];
		if(qstate->reply && qstate->reply->addrlen != 0)
			addr_to_str(&qstate->reply->addr, qstate->reply->addrlen,
				from, sizeof(from));
		else
			addr_to_str(&iq->fail_reply->addr, iq->fail_reply->addrlen,
				from, sizeof(from));
		snprintf(frm, sizeof(frm), "from %s", from);
		errinf(qstate, frm);
	}
	if(iq->scrub_failures || iq->parse_failures) {
		if(iq->scrub_failures)
			errinf(qstate, "upstream response failed scrub");
		if(iq->parse_failures)
			errinf(qstate, "could not parse upstream response");
	} else if(iq->response == NULL && iq->timeout_count != 0) {
		errinf(qstate, "upstream server timeout");
	} else if(iq->response == NULL) {
		errinf(qstate, "no server to query");
		if(iq->dp) {
			if(iq->dp->target_list == NULL)
				errinf(qstate, "no addresses for nameservers");
			else	errinf(qstate, "nameserver addresses not usable");
			if(iq->dp->nslist == NULL)
				errinf(qstate, "have no nameserver names");
			if(iq->dp->bogus)
				errinf(qstate, "NS record was dnssec bogus");
		}
	}
	if(iq->response && iq->response->rep) {
		if(FLAGS_GET_RCODE(iq->response->rep->flags) != 0) {
			char rcode[256], rc[32];
			(void)sldns_wire2str_rcode_buf(
				FLAGS_GET_RCODE(iq->response->rep->flags),
				rc, sizeof(rc));
			snprintf(rcode, sizeof(rcode), "got %s", rc);
			errinf(qstate, rcode);
		} else {
			/* rcode NOERROR */
			if(iq->response->rep->an_numrrsets == 0) {
				errinf(qstate, "nodata answer");
			}
		}
	}
}
errinf_reply(struct module_qstate* qstate, struct iter_qstate* iq)
{
	if(qstate->env->cfg->val_log_level < 2 && !qstate->env->cfg->log_servfail)
		return;
	if((qstate->reply && qstate->reply->addrlen != 0) ||
		(iq->fail_reply && iq->fail_reply->addrlen != 0)) {
		char from[256], frm[512];
		if(qstate->reply && qstate->reply->addrlen != 0)
			addr_to_str(&qstate->reply->addr, qstate->reply->addrlen,
				from, sizeof(from));
		else
			addr_to_str(&iq->fail_reply->addr, iq->fail_reply->addrlen,
				from, sizeof(from));
		snprintf(frm, sizeof(frm), "from %s", from);
		errinf(qstate, frm);
	}
	if(iq->scrub_failures || iq->parse_failures) {
		if(iq->scrub_failures)
			errinf(qstate, "upstream response failed scrub");
		if(iq->parse_failures)
			errinf(qstate, "could not parse upstream response");
	} else if(iq->response == NULL && iq->timeout_count != 0) {
		errinf(qstate, "upstream server timeout");
	} else if(iq->response == NULL) {
		errinf(qstate, "no server to query");
		if(iq->dp) {
			if(iq->dp->target_list == NULL)
				errinf(qstate, "no addresses for nameservers");
			else	errinf(qstate, "nameserver addresses not usable");
			if(iq->dp->nslist == NULL)
				errinf(qstate, "have no nameserver names");
			if(iq->dp->bogus)
				errinf(qstate, "NS record was dnssec bogus");
		}
	}
	if(iq->response && iq->response->rep) {
		if(FLAGS_GET_RCODE(iq->response->rep->flags) != 0) {
			char rcode[256], rc[32];
			(void)sldns_wire2str_rcode_buf(
				FLAGS_GET_RCODE(iq->response->rep->flags),
				rc, sizeof(rc));
			snprintf(rcode, sizeof(rcode), "got %s", rc);
			errinf(qstate, rcode);
		} else {
			 
			if(iq->response->rep->an_numrrsets == 0) {
				errinf(qstate, "nodata answer");
			}
		}
	}
}