const RESOLVE_REPLY *smtpd_resolve_addr(const char *addr) { /* * Sanity check. */ if (smtpd_resolve_cache == 0) msg_panic("smtpd_resolve_addr: missing initialization"); /* * Reply from the read-through cache. */ return (const RESOLVE_REPLY *) ctable_locate(smtpd_resolve_cache, addr); }
int smtp_tls_policy_cache_query(DSN_BUF *why, SMTP_TLS_POLICY *tls, SMTP_ITERATOR *iter) { VSTRING *key; /* * Create an empty TLS Policy cache on the fly. */ if (policy_cache == 0) policy_cache = ctable_create(CACHE_SIZE, policy_create, policy_delete, (void *) 0); /* * Query the TLS Policy cache, with a search key that reflects our shared * values that also appear in other cache and table search keys. */ key = vstring_alloc(100); smtp_key_prefix(key, ":", iter, SMTP_KEY_FLAG_NEXTHOP | SMTP_KEY_FLAG_HOSTNAME | SMTP_KEY_FLAG_PORT); ctable_newcontext(policy_cache, (void *) iter); *tls = *(SMTP_TLS_POLICY *) ctable_locate(policy_cache, STR(key)); vstring_free(key); /* * Report errors. Both error and non-error results are cached. We must * therefore copy the cached DSN buffer content to the caller's buffer. */ if (tls->level == TLS_LEV_INVALID) { /* XXX Simplify this by implementing a "copy" primitive. */ dsb_update(why, STR(tls->why->status), STR(tls->why->action), STR(tls->why->mtype), STR(tls->why->mname), STR(tls->why->dtype), STR(tls->why->dtext), "%s", STR(tls->why->reason)); return (0); } else { return (1); } }