support in smp for terminate-by-name
authorMartin Willi <martin@strongswan.org>
Fri, 20 Jun 2008 07:14:35 +0000 (07:14 -0000)
committerMartin Willi <martin@strongswan.org>
Fri, 20 Jun 2008 07:14:35 +0000 (07:14 -0000)
src/charon/plugins/smp/smp.c

index 1d93d1d..063eee4 100644 (file)
@@ -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);
                
                /* <log> */