#include <inttypes.h>
#include <stdbool.h>
+#include <isc/async.h>
#include <isc/buffer.h>
#include <isc/hash.h>
#include <isc/hashmap.h>
+#include <isc/helper.h>
#include <isc/log.h>
#include <isc/mem.h>
#include <isc/result.h>
* asynchronously.
*/
typedef struct checksig_ctx {
+ isc_loop_t *loop;
dns_message_t *msg;
dns_view_t *view;
dns_message_cb_t cb;
}
#endif /* ifdef SKAN_MSG_DEBUG */
+static void
+checksig_done(void *arg);
+
static void
checksig_run(void *arg) {
checksig_ctx_t *chsigctx = arg;
chsigctx->result = dns_message_checksig(chsigctx->msg, chsigctx->view);
+
+ isc_async_run(chsigctx->loop, checksig_done, chsigctx);
}
static void
-checksig_cb(void *arg) {
+checksig_done(void *arg) {
checksig_ctx_t *chsigctx = arg;
dns_message_t *msg = chsigctx->msg;
chsigctx->cb(chsigctx->cbarg, chsigctx->result);
dns_view_detach(&chsigctx->view);
+ isc_loop_detach(&chsigctx->loop);
isc_mem_put(msg->mctx, chsigctx, sizeof(*chsigctx));
dns_message_detach(&msg);
}
.cb = cb,
.cbarg = cbarg,
.result = ISC_R_UNSET,
+ .loop = isc_loop_ref(loop),
};
dns_message_attach(msg, &chsigctx->msg);
dns_view_attach(view, &chsigctx->view);
dns_message_clonebuffer(msg);
- isc_work_enqueue(loop, checksig_run, checksig_cb, chsigctx);
+ isc_helper_run(loop, checksig_run, chsigctx);
return (DNS_R_WAIT);
}
#include <isc/async.h>
#include <isc/base32.h>
#include <isc/counter.h>
+#include <isc/helper.h>
#include <isc/job.h>
#include <isc/log.h>
#include <isc/md.h>
validate_async_done(dns_validator_t *val, isc_result_t result);
static isc_result_t
validate_async_run(dns_validator_t *val, isc_job_cb cb);
+static isc_result_t
+validate_helper_run(dns_validator_t *val, isc_job_cb cb);
static void
validate_dnskey(void *arg);
return (found);
}
+static void
+resume_answer_with_key_done(void *arg);
+
static void
resume_answer_with_key(void *arg) {
dns_validator_t *val = arg;
if (result == ISC_R_SUCCESS) {
val->keyset = &val->frdataset;
}
+
+ (void)validate_async_run(val, resume_answer_with_key_done);
}
static void
if (eresult == ISC_R_SUCCESS &&
rdataset->trust >= dns_trust_secure)
{
- isc_work_enqueue(val->loop, resume_answer_with_key,
- resume_answer, val);
- result = DNS_R_WAIT;
+ result = validate_helper_run(val,
+ resume_answer_with_key);
} else {
result = validate_async_run(val, resume_answer);
}
* Only extract the dst key if the keyset is secure.
*/
if (val->frdataset.trust >= dns_trust_secure) {
- isc_work_enqueue(val->loop, resume_answer_with_key,
- resume_answer_with_key_done, val);
- result = DNS_R_WAIT;
+ result = validate_helper_run(val,
+ resume_answer_with_key);
} else {
result = validate_async_run(val, resume_answer);
}
dns_rdataset_disassociate(&val->fsigrdataset);
}
- isc_work_enqueue(val->loop, resume_answer_with_key,
- resume_answer_with_key_done, val);
- return (DNS_R_WAIT);
+ return (validate_helper_run(val,
+ resume_answer_with_key));
}
break;
static void
validate_answer_finish(void *arg);
+static void
+validate_answer_signing_key_done(void *arg);
+
static void
validate_answer_signing_key(void *arg) {
dns_validator_t *val = arg;
} else {
INSIST(val->key == NULL);
}
+
+ (void)validate_async_run(val, validate_answer_signing_key_done);
}
static void
val->result = ISC_R_CANCELED;
} else if (val->key != NULL) {
/* Process with next key if we selected one */
- isc_work_enqueue(val->loop, validate_answer_signing_key,
- validate_answer_signing_key_done, val);
+ (void)validate_helper_run(val, validate_answer_signing_key);
return;
}
goto next_key;
}
- isc_work_enqueue(val->loop, validate_answer_signing_key,
- validate_answer_signing_key_done, val);
+ (void)validate_helper_run(val, validate_answer_signing_key);
return;
next_key:
return (DNS_R_WAIT);
}
+static isc_result_t
+validate_helper_run(dns_validator_t *val, isc_job_cb cb) {
+ isc_helper_run(val->loop, cb, val);
+ return (DNS_R_WAIT);
+}
+
static void
validate_async_done(dns_validator_t *val, isc_result_t result) {
if (result == DNS_R_NOVALIDSIG &&
return (ISC_R_SUCCESS);
}
+static void
+validate_dnskey_dsset_next_done(void *arg);
+
static void
validate_dnskey_dsset_next(void *arg) {
dns_validator_t *val = arg;
/* continue async run */
val->result = validate_dnskey_dsset(val);
}
+
+ validate_async_run(val, validate_dnskey_dsset_next_done);
}
static void
break;
default:
/* Continue validation until we have success or no more data */
- isc_work_enqueue(val->loop, validate_dnskey_dsset_next,
- validate_dnskey_dsset_next_done, val);
+ (void)validate_helper_run(val, validate_dnskey_dsset_next);
return;
}
/* continue async run */
result = validate_dnskey_dsset(val);
if (result != ISC_R_SUCCESS) {
- isc_work_enqueue(val->loop, validate_dnskey_dsset_next,
- validate_dnskey_dsset_next_done, val);
+ (void)validate_helper_run(val,
+ validate_dnskey_dsset_next);
return;
}
}
.options = options,
.keytable = kt,
.link = ISC_LINK_INITIALIZER,
- .loop = loop,
+ .loop = isc_loop_ref(loop),
.cb = cb,
.arg = arg,
.rdata = DNS_RDATA_INIT,
isc_counter_detach(&val->qc);
}
dns_view_detach(&val->view);
+ isc_loop_detach(&val->loop);
isc_mem_put(mctx, val, sizeof(*val));
}