From: Tobias Brunner Date: Wed, 2 Jun 2021 12:46:03 +0000 (+0200) Subject: swanctl: Add options to filter CHILD_SAs in --list-sas X-Git-Tag: 5.9.6rc1~3^2~1 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=955b526be806dc384cbb16ce82e042532d4ed9fe;p=thirdparty%2Fstrongswan.git swanctl: Add options to filter CHILD_SAs in --list-sas --- diff --git a/src/swanctl/commands/list_sas.c b/src/swanctl/commands/list_sas.c index 48c06fd613..0a7005ce22 100644 --- a/src/swanctl/commands/list_sas.c +++ b/src/swanctl/commands/list_sas.c @@ -373,8 +373,8 @@ static int list_sas(vici_conn_t *conn) vici_res_t *res; bool noblock = FALSE; command_format_options_t format = COMMAND_FORMAT_NONE; - char *arg, *ike = NULL; - int ike_id = 0, ret; + char *arg, *ike = NULL, *child = NULL; + int ike_id = 0, child_id = 0, ret; while (TRUE) { @@ -388,6 +388,12 @@ static int list_sas(vici_conn_t *conn) case 'I': ike_id = atoi(arg); continue; + case 'c': + child = arg; + continue; + case 'C': + child_id = atoi(arg); + continue; case 'n': noblock = TRUE; continue; @@ -419,6 +425,14 @@ static int list_sas(vici_conn_t *conn) { vici_add_key_valuef(req, "ike-id", "%d", ike_id); } + if (child) + { + vici_add_key_valuef(req, "child", "%s", child); + } + if (child_id) + { + vici_add_key_valuef(req, "child-id", "%d", child_id); + } if (noblock) { vici_add_key_valuef(req, "noblock", "yes"); @@ -490,11 +504,14 @@ static void __attribute__ ((constructor))reg() { command_register((command_t) { list_sas, 'l', "list-sas", "list currently active IKE_SAs", - {"[--raw|--pretty]"}, + {"[--ike |--ike-id ] [--child |--child-id ]", + "[--raw|--pretty]"}, { {"help", 'h', 0, "show usage information"}, {"ike", 'i', 1, "filter IKE_SAs by name"}, {"ike-id", 'I', 1, "filter IKE_SAs by unique identifier"}, + {"child", 'c', 1, "filter CHILD_SAs by name"}, + {"child-id", 'C', 1, "filter CHILD_SAs by unique identifier"}, {"noblock", 'n', 0, "don't wait for IKE_SAs in use"}, {"raw", 'r', 0, "dump raw response message"}, {"pretty", 'P', 0, "dump raw response message in pretty print"}, diff --git a/src/swanctl/commands/terminate.c b/src/swanctl/commands/terminate.c index 2309843b25..21ec1c8fe3 100644 --- a/src/swanctl/commands/terminate.c +++ b/src/swanctl/commands/terminate.c @@ -156,7 +156,7 @@ static void __attribute__ ((constructor))reg() {"help", 'h', 0, "show usage information"}, {"child", 'c', 1, "terminate by CHILD_SA name"}, {"ike", 'i', 1, "terminate by IKE_SA name"}, - {"child-id", 'C', 1, "terminate by CHILD_SA reqid"}, + {"child-id", 'C', 1, "terminate by CHILD_SA unique identifier"}, {"ike-id", 'I', 1, "terminate by IKE_SA unique identifier"}, {"force", 'f', 0, "terminate IKE_SA without waiting, unless timeout is set"}, {"timeout", 't', 1, "timeout in seconds before detaching"},