controller: Add option to force destruction of an IKE_SA
[strongswan.git] / src / libcharon / plugins / uci / uci_control.c
index af4a6a7..22fd3c2 100644 (file)
@@ -42,11 +42,6 @@ struct private_uci_control_t {
         * Public part
         */
        uci_control_t public;
-
-       /**
-        * Job
-        */
-       callback_job_t *job;
 };
 
 /**
@@ -77,6 +72,7 @@ static void write_fifo(private_uci_control_t *this, char *format, ...)
 static void status(private_uci_control_t *this, char *name)
 {
        enumerator_t *configs, *sas, *children;
+       linked_list_t *list;
        ike_sa_t *ike_sa;
        child_sa_t *child_sa;
        peer_cfg_t *peer_cfg;
@@ -84,7 +80,7 @@ static void status(private_uci_control_t *this, char *name)
        FILE *out = NULL;
 
        configs = charon->backends->create_peer_cfg_enumerator(charon->backends,
-                                                                                                               NULL, NULL, NULL, NULL);
+                                                                                       NULL, NULL, NULL, NULL, IKE_ANY);
        while (configs->enumerate(configs, &peer_cfg))
        {
                if (name && !streq(name, peer_cfg->get_name(peer_cfg)))
@@ -113,8 +109,10 @@ static void status(private_uci_control_t *this, char *name)
                        children = ike_sa->create_child_sa_enumerator(ike_sa);
                        while (children->enumerate(children, (void**)&child_sa))
                        {
-                               fprintf(out, "%#R",
-                                               child_sa->get_traffic_selectors(child_sa, FALSE));
+                               list = linked_list_create_from_enumerator(
+                                                       child_sa->create_ts_enumerator(child_sa, FALSE));
+                               fprintf(out, "%#R", list);
+                               list->destroy(list);
                        }
                        children->destroy(children);
                        fprintf(out, "\n");
@@ -149,7 +147,7 @@ static void initiate(private_uci_control_t *this, char *name)
                if (enumerator->enumerate(enumerator, &child_cfg) &&
                        charon->controller->initiate(charon->controller, peer_cfg,
                                                                child_cfg->get_ref(child_cfg),
-                                                               controller_cb_empty, NULL, 0) == SUCCESS)
+                                                               controller_cb_empty, NULL, 0, FALSE) == SUCCESS)
                {
                        write_fifo(this, "connection '%s' established\n", name);
                }
@@ -182,7 +180,7 @@ static void terminate(private_uci_control_t *this, char *name)
                {
                        id = ike_sa->get_unique_id(ike_sa);
                        enumerator->destroy(enumerator);
-                       charon->controller->terminate_ike(charon->controller, id,
+                       charon->controller->terminate_ike(charon->controller, id, FALSE,
                                                                                          controller_cb_empty, NULL, 0);
                        write_fifo(this, "connection '%s' terminated\n", name);
                        return;
@@ -269,7 +267,6 @@ static job_requeue_t receive(private_uci_control_t *this)
 METHOD(uci_control_t, destroy, void,
        private_uci_control_t *this)
 {
-       this->job->cancel(this->job);
        unlink(FIFO_FILE);
        free(this);
 }
@@ -295,10 +292,10 @@ uci_control_t *uci_control_create()
        }
        else
        {
-               this->job = callback_job_create_with_prio((callback_job_cb_t)receive,
-                                                                               this, NULL, NULL, JOB_PRIO_CRITICAL);
-               lib->processor->queue_job(lib->processor, (job_t*)this->job);
+               lib->processor->queue_job(lib->processor,
+                       (job_t*)callback_job_create_with_prio((callback_job_cb_t)receive,
+                                                       this, NULL, (callback_job_cancel_t)return_false,
+                                                       JOB_PRIO_CRITICAL));
        }
        return &this->public;
 }
-