swanctl: Add options to filter CHILD_SAs in --list-sas
This commit is contained in:
@@ -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 <name>|--ike-id <id>] [--child <name>|--child-id <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"},
|
||||
|
||||
@@ -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"},
|
||||
|
||||
Reference in New Issue
Block a user