swanctl: By default print local swanctl version with --version
authorMartin Willi <martin@revosec.ch>
Tue, 6 May 2014 08:56:07 +0000 (10:56 +0200)
committerMartin Willi <martin@revosec.ch>
Wed, 7 May 2014 13:48:17 +0000 (15:48 +0200)
But add a --daemon option to query the IKE daemon for its version.

src/swanctl/commands/version.c

index 36b7a6d..c44004d 100644 (file)
@@ -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"},
                }
        });