summaryrefslogtreecommitdiff
path: root/src/swanctl/commands/load_pools.c
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@corsac.net>2018-02-19 18:17:21 +0100
committerYves-Alexis Perez <corsac@corsac.net>2018-02-20 11:09:03 +0100
commit94218f4dc079e5fcf76b3468b9e40072181246f2 (patch)
tree05db24c85038c8ab49a30c98bd93dc7ff126390b /src/swanctl/commands/load_pools.c
parentfd2deca589bc3d067f1cbfe59a25d3a90625e02b (diff)
downloadvyos-strongswan-94218f4dc079e5fcf76b3468b9e40072181246f2.tar.gz
vyos-strongswan-94218f4dc079e5fcf76b3468b9e40072181246f2.zip
New upstream version 5.6.2
Diffstat (limited to 'src/swanctl/commands/load_pools.c')
-rw-r--r--src/swanctl/commands/load_pools.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/swanctl/commands/load_pools.c b/src/swanctl/commands/load_pools.c
index 2b9fa2d42..feb8d3a52 100644
--- a/src/swanctl/commands/load_pools.c
+++ b/src/swanctl/commands/load_pools.c
@@ -41,14 +41,13 @@ static void add_list_key(vici_req_t *req, char *key, char *value)
}
/**
- * Translate setting key/values from a section into vici key-values/lists
+ * Translate setting key/values from a section enumerator into vici
+ * key-values/lists. Destroys the enumerator.
*/
-static void add_key_values(vici_req_t *req, settings_t *cfg, char *section)
+static void add_key_values(vici_req_t *req, enumerator_t *enumerator)
{
- enumerator_t *enumerator;
char *key, *value;
- enumerator = cfg->create_key_value_enumerator(cfg, section);
while (enumerator->enumerate(enumerator, &key, &value))
{
/* pool subnet is encoded as key/value, all other attributes as list */
@@ -70,17 +69,16 @@ static void add_key_values(vici_req_t *req, settings_t *cfg, char *section)
static bool load_pool(vici_conn_t *conn, settings_t *cfg,
char *section, command_format_options_t format)
{
+ enumerator_t *enumerator;
vici_req_t *req;
vici_res_t *res;
bool ret = TRUE;
- char buf[128];
-
- snprintf(buf, sizeof(buf), "%s.%s", "pools", section);
req = vici_begin("load-pool");
vici_begin_section(req, section);
- add_key_values(req, cfg, buf);
+ enumerator = cfg->create_key_value_enumerator(cfg, "pools.%s", section);
+ add_key_values(req, enumerator);
vici_end_section(req);
res = vici_submit(req, conn);