controller: Add option to force destruction of an IKE_SA
[strongswan.git] / src / conftest / actions.c
index 92b523f..66e41f7 100644 (file)
@@ -47,7 +47,7 @@ static job_requeue_t initiate(char *config)
        peer_cfg = charon->backends->get_peer_cfg_by_name(charon->backends, config);
        if (!peer_cfg)
        {
-               DBG1(DBG_CFG, "initiating '%s' failed, config not found");
+               DBG1(DBG_CFG, "initiating '%s' failed, config not found", config);
                return JOB_REQUEUE_NONE;
        }
        enumerator = peer_cfg->create_child_cfg_enumerator(peer_cfg);
@@ -65,7 +65,7 @@ static job_requeue_t initiate(char *config)
        {
                DBG1(DBG_CFG, "initiating IKE_SA for CHILD_SA config '%s'", config);
                charon->controller->initiate(charon->controller, peer_cfg, child_cfg,
-                                                                        NULL, NULL);
+                                                                        NULL, NULL, 0, FALSE);
        }
        else
        {
@@ -85,7 +85,8 @@ static job_requeue_t rekey_ike(char *config)
        job_t *job = NULL;
        ike_sa_t *ike_sa;
 
-       enumerator = charon->controller->create_ike_sa_enumerator(charon->controller);
+       enumerator = charon->controller->create_ike_sa_enumerator(
+                                                                                                       charon->controller, TRUE);
        while (enumerator->enumerate(enumerator, &ike_sa))
        {
                if (strcaseeq(config, ike_sa->get_name(ike_sa)))
@@ -113,22 +114,23 @@ static job_requeue_t rekey_ike(char *config)
  */
 static job_requeue_t rekey_child(char *config)
 {
-       enumerator_t *enumerator;
-       iterator_t *children;
+       enumerator_t *enumerator, *children;
        ike_sa_t *ike_sa;
        child_sa_t *child_sa;
-       u_int32_t reqid = 0, spi = 0;
-       protocol_id_t proto = PROTO_ESP;
+       uint32_t spi, proto;
+       host_t *dst = NULL;
 
-       enumerator = charon->controller->create_ike_sa_enumerator(charon->controller);
+       enumerator = charon->controller->create_ike_sa_enumerator(
+                                                                                                       charon->controller, TRUE);
        while (enumerator->enumerate(enumerator, &ike_sa))
        {
-               children = ike_sa->create_child_sa_iterator(ike_sa);
-               while (children->iterate(children, (void**)&child_sa))
+               children = ike_sa->create_child_sa_enumerator(ike_sa);
+               while (children->enumerate(children, &child_sa))
                {
                        if (streq(config, child_sa->get_name(child_sa)))
                        {
-                               reqid = child_sa->get_reqid(child_sa);
+                               dst = ike_sa->get_my_host(ike_sa);
+                               dst = dst->clone(dst);
                                proto = child_sa->get_protocol(child_sa);
                                spi = child_sa->get_spi(child_sa, TRUE);
                                break;
@@ -137,11 +139,12 @@ static job_requeue_t rekey_child(char *config)
                children->destroy(children);
        }
        enumerator->destroy(enumerator);
-       if (reqid)
+       if (dst)
        {
                DBG1(DBG_CFG, "starting rekey of CHILD_SA '%s'", config);
                lib->processor->queue_job(lib->processor,
-                                               (job_t*)rekey_child_sa_job_create(reqid, proto, spi));
+                                               (job_t*)rekey_child_sa_job_create(proto, spi, dst));
+               dst->destroy(dst);
        }
        else
        {
@@ -159,7 +162,8 @@ static job_requeue_t liveness(char *config)
        job_t *job = NULL;
        ike_sa_t *ike_sa;
 
-       enumerator = charon->controller->create_ike_sa_enumerator(charon->controller);
+       enumerator = charon->controller->create_ike_sa_enumerator(
+                                                                                                       charon->controller, TRUE);
        while (enumerator->enumerate(enumerator, &ike_sa))
        {
                if (strcaseeq(config, ike_sa->get_name(ike_sa)))
@@ -191,7 +195,8 @@ static job_requeue_t close_ike(char *config)
        ike_sa_t *ike_sa;
        int id = 0;
 
-       enumerator = charon->controller->create_ike_sa_enumerator(charon->controller);
+       enumerator = charon->controller->create_ike_sa_enumerator(
+                                                                                                       charon->controller, TRUE);
        while (enumerator->enumerate(enumerator, &ike_sa))
        {
                if (strcaseeq(config, ike_sa->get_name(ike_sa)))
@@ -204,7 +209,8 @@ static job_requeue_t close_ike(char *config)
        if (id)
        {
                DBG1(DBG_CFG, "closing IKE_SA '%s'", config);
-               charon->controller->terminate_ike(charon->controller, id, NULL, NULL);
+               charon->controller->terminate_ike(charon->controller, id, FALSE, NULL,
+                                                                                 NULL, 0);
        }
        else
        {
@@ -218,22 +224,22 @@ static job_requeue_t close_ike(char *config)
  */
 static job_requeue_t close_child(char *config)
 {
-       enumerator_t *enumerator;
-       iterator_t *children;
+       enumerator_t *enumerator, *children;
        ike_sa_t *ike_sa;
        child_sa_t *child_sa;
        int id = 0;
 
-       enumerator = charon->controller->create_ike_sa_enumerator(charon->controller);
+       enumerator = charon->controller->create_ike_sa_enumerator(
+                                                                                                       charon->controller, TRUE);
        while (enumerator->enumerate(enumerator, &ike_sa))
        {
 
-               children = ike_sa->create_child_sa_iterator(ike_sa);
-               while (children->iterate(children, (void**)&child_sa))
+               children = ike_sa->create_child_sa_enumerator(ike_sa);
+               while (children->enumerate(children, (void**)&child_sa))
                {
                        if (streq(config, child_sa->get_name(child_sa)))
                        {
-                               id = child_sa->get_reqid(child_sa);
+                               id = child_sa->get_unique_id(child_sa);
                                break;
                        }
                }
@@ -243,7 +249,8 @@ static job_requeue_t close_child(char *config)
        if (id)
        {
                DBG1(DBG_CFG, "closing CHILD_SA '%s'", config);
-               charon->controller->terminate_child(charon->controller, id, NULL, NULL);
+               charon->controller->terminate_child(charon->controller, id,
+                                                                                       NULL, NULL, 0);
        }
        else
        {
@@ -273,7 +280,7 @@ static void load_action(settings_t *settings, char *action)
 
        for (i = 0; i < countof(actions); i++)
        {
-               if (strcaseeq(actions[i].name, action))
+               if (strncaseeq(actions[i].name, action, strlen(actions[i].name)))
                {
                        int delay;
                        char *config;