summaryrefslogtreecommitdiff
path: root/src/swanctl
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@debian.org>2015-11-18 14:49:27 +0100
committerYves-Alexis Perez <corsac@debian.org>2015-11-18 14:49:27 +0100
commit1e980d6be0ef0e243c6fe82b5e855454b97e24a4 (patch)
tree0d59eec2ce2ed332434ae80fc78a44db9ad293c5 /src/swanctl
parent5dca9ea0e2931f0e2a056c7964d311bcc30a01b8 (diff)
downloadvyos-strongswan-1e980d6be0ef0e243c6fe82b5e855454b97e24a4.tar.gz
vyos-strongswan-1e980d6be0ef0e243c6fe82b5e855454b97e24a4.zip
Imported Upstream version 5.3.4
Diffstat (limited to 'src/swanctl')
-rw-r--r--src/swanctl/commands/list_pools.c32
-rw-r--r--src/swanctl/commands/list_sas.c12
2 files changed, 40 insertions, 4 deletions
diff --git a/src/swanctl/commands/list_pools.c b/src/swanctl/commands/list_pools.c
index 155771657..429107e17 100644
--- a/src/swanctl/commands/list_pools.c
+++ b/src/swanctl/commands/list_pools.c
@@ -1,4 +1,7 @@
/*
+ * Copyright (C) 2015 Tobias Brunner
+ * Hochschule fuer Technik Rapperswil
+ *
* Copyright (C) 2014 Martin Willi
* Copyright (C) 2014 revosec AG
*
@@ -19,8 +22,22 @@
#include "command.h"
+CALLBACK(list_leases, int,
+ char *pool, vici_res_t *res, char *name)
+{
+ if (streq(name, "leases"))
+ {
+ return vici_parse_cb(res, list_leases, NULL, NULL, pool);
+ }
+ printf(" %-30s %-8s '%s'\n",
+ vici_find_str(res, "", "%s.leases.%s.address", pool, name),
+ vici_find_str(res, "", "%s.leases.%s.status", pool, name),
+ vici_find_str(res, "", "%s.leases.%s.identity", pool, name));
+ return 0;
+}
+
CALLBACK(list_pool, int,
- linked_list_t *list, vici_res_t *res, char *name)
+ void *not_used, vici_res_t *res, char *name)
{
char pool[64], leases[32];
@@ -33,7 +50,7 @@ CALLBACK(list_pool, int,
printf("%-20s %-30s %16s\n",
name, vici_find_str(res, "", "%s.base", name), leases);
- return 0;
+ return vici_parse_cb(res, list_leases, NULL, NULL, name);
}
static int list_pools(vici_conn_t *conn)
@@ -43,6 +60,7 @@ static int list_pools(vici_conn_t *conn)
command_format_options_t format = COMMAND_FORMAT_NONE;
char *arg;
int ret = 0;
+ bool leases = FALSE;
while (TRUE)
{
@@ -56,6 +74,9 @@ static int list_pools(vici_conn_t *conn)
case 'r':
format |= COMMAND_FORMAT_RAW;
continue;
+ case 'l':
+ leases = TRUE;
+ continue;
case EOF:
break;
default:
@@ -65,6 +86,10 @@ static int list_pools(vici_conn_t *conn)
}
req = vici_begin("get-pools");
+ if (leases)
+ {
+ vici_add_key_valuef(req, "leases", "yes");
+ }
res = vici_submit(req, conn);
if (!res)
{
@@ -92,11 +117,12 @@ static void __attribute__ ((constructor))reg()
{
command_register((command_t) {
list_pools, 'A', "list-pools", "list loaded pool configurations",
- {"[--raw|--pretty]"},
+ {"[--leases] [--raw|--pretty]"},
{
{"help", 'h', 0, "show usage information"},
{"raw", 'r', 0, "dump raw response message"},
{"pretty", 'P', 0, "dump raw response message in pretty print"},
+ {"leases", 'l', 0, "list leases of each pool"},
}
});
}
diff --git a/src/swanctl/commands/list_sas.c b/src/swanctl/commands/list_sas.c
index 1aca6d212..93dd7ed85 100644
--- a/src/swanctl/commands/list_sas.c
+++ b/src/swanctl/commands/list_sas.c
@@ -198,8 +198,14 @@ CALLBACK(ike_sa, int,
ike->get(ike, "state"), ike->get(ike, "version"),
ike->get(ike, "initiator-spi"), ike->get(ike, "responder-spi"));
- printf(" local '%s' @ %s\n",
+ printf(" local '%s' @ %s",
ike->get(ike, "local-id"), ike->get(ike, "local-host"));
+ if (ike->get(ike, "local-vips"))
+ {
+ printf(" [%s]", ike->get(ike, "local-vips"));
+ }
+ printf("\n");
+
printf(" remote '%s' @ %s",
ike->get(ike, "remote-id"), ike->get(ike, "remote-host"));
if (ike->get(ike, "remote-eap-id"))
@@ -210,6 +216,10 @@ CALLBACK(ike_sa, int,
{
printf(" XAuth: '%s'", ike->get(ike, "remote-xauth-id"));
}
+ if (ike->get(ike, "remote-vips"))
+ {
+ printf(" [%s]", ike->get(ike, "remote-vips"));
+ }
printf("\n");
if (ike->get(ike, "encr-alg"))