Lines Matching refs:env
104 testframe_init(struct module_env* env, struct cachedb_env* cachedb_env) in testframe_init() argument
119 0 /* no aggregation */, env)) { in testframe_init()
130 testframe_deinit(struct module_env* env, struct cachedb_env* cachedb_env) in testframe_deinit() argument
134 (void)env; in testframe_deinit()
145 testframe_lookup(struct module_env* env, struct cachedb_env* cachedb_env, in testframe_lookup() argument
150 (void)env; in testframe_lookup()
172 testframe_store(struct module_env* env, struct cachedb_env* cachedb_env, in testframe_store() argument
177 (void)env; in testframe_store()
244 cachedb_init(struct module_env* env, int id) in cachedb_init() argument
252 env->modinfo[id] = (void*)cachedb_env; in cachedb_init()
253 if(!cachedb_apply_cfg(cachedb_env, env->cfg)) { in cachedb_init()
256 env->modinfo[id] = NULL; in cachedb_init()
262 if(!(*cachedb_env->backend->init)(env, cachedb_env)) { in cachedb_init()
266 env->modinfo[id] = NULL; in cachedb_init()
274 cachedb_deinit(struct module_env* env, int id) in cachedb_deinit() argument
277 if(!env || !env->modinfo[id]) in cachedb_deinit()
279 cachedb_env = (struct cachedb_env*)env->modinfo[id]; in cachedb_deinit()
281 (*cachedb_env->backend->deinit)(env, cachedb_env); in cachedb_deinit()
284 env->modinfo[id] = NULL; in cachedb_deinit()
331 calc_hash(struct query_info* qinfo, struct module_env* env, char* buf, in calc_hash() argument
338 const char* secret = env->cfg->cachedb_secret; in calc_hash()
407 !qstate->env->cfg->serve_expired) in prep_data()
411 if (qstate->env->cfg->ede && qstate->return_msg->rep->reason_bogus != LDNS_EDE_NONE) { in prep_data()
412 edns_opt_list_append_ede(&edns.opt_list_out, qstate->env->scratch, in prep_data()
422 buf, 0, 1, qstate->env->scratch, 65535, &edns, 1, 0)) in prep_data()
429 timestamp = (uint64_t)*qstate->env->now; in prep_data()
461 if((time_t)expiry < *qstate->env->now && in good_expiry_and_qinfo()
462 (!qstate->env->cfg->serve_expired || in good_expiry_and_qinfo()
464 *qstate->env->now - (time_t)expiry > SERVE_EXPIRED_TTL))) in good_expiry_and_qinfo()
557 regional_free_all(qstate->env->scratch); in parse_data()
558 prs = (struct msg_parse*)regional_alloc(qstate->env->scratch, in parse_data()
565 if(parse_packet(buf, prs, qstate->env->scratch) != LDNS_RCODE_NOERROR) { in parse_data()
569 if(parse_extract_edns_from_response_msg(prs, &edns, qstate->env->scratch) != in parse_data()
581 if(qstate->env->cfg->ede && in parse_data()
601 if(*qstate->env->now <= (time_t)timestamp) { in parse_data()
605 adjust = *qstate->env->now - (time_t)timestamp; in parse_data()
611 if(!qstate->env->cfg->serve_expired || in parse_data()
624 if(qstate->env->cfg->aggressive_nsec) { in parse_data()
633 if(qstate->env->cfg->serve_expired && in parse_data()
634 !qstate->env->cfg->serve_expired_client_timeout && in parse_data()
635 (adjust == -1 || (time_t)expiry < *qstate->env->now)) { in parse_data()
651 calc_hash(&qstate->qinfo, qstate->env, key, sizeof(key)); in cachedb_extcache_lookup()
654 if( !(*ie->backend->lookup)(qstate->env, ie, key, in cachedb_extcache_lookup()
655 qstate->env->scratch_buffer)) { in cachedb_extcache_lookup()
660 if( !good_expiry_and_qinfo(qstate, qstate->env->scratch_buffer) ) { in cachedb_extcache_lookup()
665 if( !parse_data(qstate, qstate->env->scratch_buffer, msg_expired) ) { in cachedb_extcache_lookup()
678 calc_hash(&qstate->qinfo, qstate->env, key, sizeof(key)); in cachedb_extcache_store()
681 if(!prep_data(qstate, qstate->env->scratch_buffer)) in cachedb_extcache_store()
685 (*ie->backend->store)(qstate->env, ie, key, in cachedb_extcache_store()
686 sldns_buffer_begin(qstate->env->scratch_buffer), in cachedb_extcache_store()
687 sldns_buffer_limit(qstate->env->scratch_buffer), in cachedb_extcache_store()
708 msg = dns_cache_lookup(qstate->env, qstate->qinfo.qname, in cachedb_intcache_lookup()
711 qstate->region, qstate->env->scratch, in cachedb_intcache_lookup()
715 if(!msg && qstate->env->neg_cache && in cachedb_intcache_lookup()
716 iter_qname_indicates_dnssec(qstate->env, &qstate->qinfo)) { in cachedb_intcache_lookup()
719 msg = val_neg_getmsg(qstate->env->neg_cache, &qstate->qinfo, in cachedb_intcache_lookup()
720 qstate->region, qstate->env->rrset_cache, in cachedb_intcache_lookup()
721 qstate->env->scratch_buffer, in cachedb_intcache_lookup()
722 *qstate->env->now, 1/*add SOA*/, NULL, in cachedb_intcache_lookup()
723 qstate->env->cfg); in cachedb_intcache_lookup()
740 int serve_expired = qstate->env->cfg->serve_expired; in cachedb_intcache_store()
742 if(qstate->env->cfg->serve_expired) in cachedb_intcache_store()
753 if(qstate->env->cfg->cachedb_check_when_serve_expired) in cachedb_intcache_store()
756 (void)dns_cache_store(qstate->env, &qstate->qinfo, in cachedb_intcache_store()
760 if(qstate->env->cfg->serve_expired_client_timeout) { in cachedb_intcache_store()
835 if(qstate->env->cfg->serve_expired && msg_expired) { in cachedb_handle_query()
857 qstate->env->cfg->cachedb_check_when_serve_expired && in cachedb_handle_query()
858 !qstate->env->cfg->serve_expired_client_timeout) { in cachedb_handle_query()
888 if(qstate->env->cfg->cachedb_no_store) { in cachedb_handle_response()
905 struct cachedb_env* ie = (struct cachedb_env*)qstate->env->modinfo[id]; in cachedb_operate()
974 cachedb_get_mem(struct module_env* env, int id) in cachedb_get_mem() argument
976 struct cachedb_env* ie = (struct cachedb_env*)env->modinfo[id]; in cachedb_get_mem()
998 cachedb_is_enabled(struct module_stack* mods, struct module_env* env) in cachedb_is_enabled() argument
1004 ie = (struct cachedb_env*)env->modinfo[id]; in cachedb_is_enabled()
1012 cachedb_msg_remove_qinfo(qstate->env, &qstate->qinfo); in cachedb_msg_remove()
1015 void cachedb_msg_remove_qinfo(struct module_env* env, struct query_info* qinfo) in cachedb_msg_remove_qinfo() argument
1018 int id = modstack_find(env->modstack, "cachedb"); in cachedb_msg_remove_qinfo()
1019 struct cachedb_env* ie = (struct cachedb_env*)env->modinfo[id]; in cachedb_msg_remove_qinfo()
1022 calc_hash(qinfo, env, key, sizeof(key)); in cachedb_msg_remove_qinfo()
1023 sldns_buffer_clear(env->scratch_buffer); in cachedb_msg_remove_qinfo()
1024 sldns_buffer_write_u32(env->scratch_buffer, 0); in cachedb_msg_remove_qinfo()
1025 sldns_buffer_flip(env->scratch_buffer); in cachedb_msg_remove_qinfo()
1028 (*ie->backend->store)(env, ie, key, in cachedb_msg_remove_qinfo()
1029 sldns_buffer_begin(env->scratch_buffer), in cachedb_msg_remove_qinfo()
1030 sldns_buffer_limit(env->scratch_buffer), in cachedb_msg_remove_qinfo()