From bb1383183cf48d48559b7f2250cc8c1dc3b08237 Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Fri, 20 Jun 2008 07:14:35 +0000 Subject: [PATCH] support in smp for terminate-by-name --- src/charon/plugins/smp/smp.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/charon/plugins/smp/smp.c b/src/charon/plugins/smp/smp.c index 1d93d1df8..063eee48c 100644 --- a/src/charon/plugins/smp/smp.c +++ b/src/charon/plugins/smp/smp.c @@ -390,11 +390,35 @@ static void request_control_terminate(xmlTextReaderPtr reader, status_t status; str = xmlTextReaderConstValue(reader); - if (str == NULL || !(id = atoi(str))) + if (str == NULL) { DBG1(DBG_CFG, "error parsing XML id string"); return; } + id = atoi(str); + if (!id) + { + enumerator_t *enumerator; + ike_sa_t *ike_sa; + + enumerator = charon->controller->create_ike_sa_enumerator(charon->controller); + while (enumerator->enumerate(enumerator, &ike_sa)) + { + if (streq(str, ike_sa->get_name(ike_sa))) + { + ike = TRUE; + id = ike_sa->get_unique_id(ike_sa); + break; + } + } + enumerator->destroy(enumerator); + } + if (!id) + { + DBG1(DBG_CFG, "error parsing XML id string"); + return; + } + DBG1(DBG_CFG, "terminating %s_SA %d", ike ? "IKE" : "CHILD", id); /* */