From b1076bc8fd9fe41156afd832c8b1ec65e9cfcf8c Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Tue, 6 May 2014 10:56:07 +0200 Subject: [PATCH] swanctl: By default print local swanctl version with --version But add a --daemon option to query the IKE daemon for its version. --- src/swanctl/commands/version.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/swanctl/commands/version.c b/src/swanctl/commands/version.c index 36b7a6db4e..c44004dee2 100644 --- a/src/swanctl/commands/version.c +++ b/src/swanctl/commands/version.c @@ -22,7 +22,7 @@ static int version(vici_conn_t *conn) vici_req_t *req; vici_res_t *res; char *arg; - bool raw = FALSE; + bool raw = FALSE, daemon = FALSE;; while (TRUE) { @@ -33,6 +33,9 @@ static int version(vici_conn_t *conn) case 'r': raw = TRUE; continue; + case 'd': + daemon = TRUE; + continue; case EOF: break; default: @@ -41,6 +44,12 @@ static int version(vici_conn_t *conn) break; } + if (!daemon) + { + printf("strongSwan swanctl %s\n", VERSION); + return 0; + } + req = vici_begin("version"); res = vici_submit(req, conn); if (!res) @@ -71,10 +80,11 @@ static int version(vici_conn_t *conn) static void __attribute__ ((constructor))reg() { command_register((command_t) { - version, 'v', "version", "show daemon version information", + version, 'v', "version", "show version information", {"[--raw]"}, { {"help", 'h', 0, "show usage information"}, + {"daemon", 'd', 0, "query daemon version"}, {"raw", 'r', 0, "dump raw response message"}, } }); -- 2.47.2