diff options
Diffstat (limited to 'src/libcharon/control')
-rw-r--r-- | src/libcharon/control/controller.c | 25 | ||||
-rw-r--r-- | src/libcharon/control/controller.h | 14 |
2 files changed, 30 insertions, 9 deletions
diff --git a/src/libcharon/control/controller.c b/src/libcharon/control/controller.c index 531797100..0f247962b 100644 --- a/src/libcharon/control/controller.c +++ b/src/libcharon/control/controller.c @@ -240,7 +240,7 @@ METHOD(job_t, initiate_execute, void, METHOD(controller_t, initiate, status_t, private_controller_t *this, peer_cfg_t *peer_cfg, child_cfg_t *child_cfg, - controller_cb_t callback, void *param) + controller_cb_t callback, void *param, u_int timeout) { interface_job_t job = { .listener = { @@ -267,7 +267,11 @@ METHOD(controller_t, initiate, status_t, } else { - charon->bus->listen(charon->bus, &job.listener.public, &job.public); + if (charon->bus->listen(charon->bus, &job.listener.public, &job.public, + timeout)) + { + job.listener.status = OUT_OF_RES; + } } return job.listener.status; } @@ -296,7 +300,7 @@ METHOD(job_t, terminate_ike_execute, void, METHOD(controller_t, terminate_ike, status_t, controller_t *this, u_int32_t unique_id, - controller_cb_t callback, void *param) + controller_cb_t callback, void *param, u_int timeout) { ike_sa_t *ike_sa; interface_job_t job = { @@ -333,7 +337,11 @@ METHOD(controller_t, terminate_ike, status_t, } else { - charon->bus->listen(charon->bus, &job.listener.public, &job.public); + if (charon->bus->listen(charon->bus, &job.listener.public, &job.public, + timeout)) + { + job.listener.status = OUT_OF_RES; + } /* checkin of the ike_sa happened in the thread that executed the job */ charon->bus->set_sa(charon->bus, NULL); } @@ -363,7 +371,8 @@ METHOD(job_t, terminate_child_execute, void, } METHOD(controller_t, terminate_child, status_t, - controller_t *this, u_int32_t reqid, controller_cb_t callback, void *param) + controller_t *this, u_int32_t reqid, + controller_cb_t callback, void *param, u_int timeout) { ike_sa_t *ike_sa; child_sa_t *child_sa; @@ -424,7 +433,11 @@ METHOD(controller_t, terminate_child, status_t, } else { - charon->bus->listen(charon->bus, &job.listener.public, &job.public); + if (charon->bus->listen(charon->bus, &job.listener.public, &job.public, + timeout)) + { + job.listener.status = OUT_OF_RES; + } /* checkin of the ike_sa happened in the thread that executed the job */ charon->bus->set_sa(charon->bus, NULL); } diff --git a/src/libcharon/control/controller.h b/src/libcharon/control/controller.h index 81c83d9a2..6adaef109 100644 --- a/src/libcharon/control/controller.h +++ b/src/libcharon/control/controller.h @@ -83,14 +83,16 @@ struct controller_t { * @param child_cfg child_cfg to set up CHILD_SA from * @param cb logging callback * @param param parameter to include in each call of cb + * @param timeout timeout in ms to wait for callbacks, 0 to disable * @return * - SUCCESS, if CHILD_SA established * - FAILED, if setup failed * - NEED_MORE, if callback returned FALSE + * - OUT_OF_RES if timed out */ status_t (*initiate)(controller_t *this, peer_cfg_t *peer_cfg, child_cfg_t *child_cfg, - controller_cb_t callback, void *param); + controller_cb_t callback, void *param, u_int timeout); /** * Terminate an IKE_SA and all of its CHILD_SAs. @@ -102,13 +104,16 @@ struct controller_t { * @param unique_id unique id of the IKE_SA to terminate. * @param cb logging callback * @param param parameter to include in each call of cb + * @param timeout timeout in ms to wait for callbacks, 0 to disable * @return * - SUCCESS, if CHILD_SA terminated * - NOT_FOUND, if no such CHILD_SA found * - NEED_MORE, if callback returned FALSE + * - OUT_OF_RES if timed out */ status_t (*terminate_ike)(controller_t *this, u_int32_t unique_id, - controller_cb_t callback, void *param); + controller_cb_t callback, void *param, + u_int timeout); /** * Terminate a CHILD_SA. @@ -116,13 +121,16 @@ struct controller_t { * @param reqid reqid of the CHILD_SA to terminate * @param cb logging callback * @param param parameter to include in each call of cb + * @param timeout timeout in ms to wait for callbacks, 0 to disable * @return * - SUCCESS, if CHILD_SA terminated * - NOT_FOUND, if no such CHILD_SA found * - NEED_MORE, if callback returned FALSE + * - OUT_OF_RES if timed out */ status_t (*terminate_child)(controller_t *this, u_int32_t reqid, - controller_cb_t callback, void *param); + controller_cb_t callback, void *param, + u_int timeout); /** * Destroy a controller_t instance. |