]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
list supported protocols in --version or --help output, using API functions
authorDaniel Lenski <dlenski@gmail.com>
Wed, 19 Apr 2017 20:12:49 +0000 (13:12 -0700)
committerDavid Woodhouse <dwmw2@infradead.org>
Sun, 14 May 2017 23:15:58 +0000 (16:15 -0700)
Signed-off-by: Daniel Lenski <dlenski@gmail.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
main.c

diff --git a/main.c b/main.c
index fd0fb708b9aab43c9a553169abc589b527ae0cdc..7869f721767f358efa981372621cbcd300f2b980 100644 (file)
--- a/main.c
+++ b/main.c
@@ -631,12 +631,47 @@ static void print_build_opts(void)
        }
 
 #ifdef HAVE_DTLS
-       printf("%sDTLS\n", sep);
-#else
-       printf(_("\nWARNING: No DTLS support in this binary. Performance will be impaired.\n"));
+       printf("%sDTLS", sep);
+#endif
+#ifdef HAVE_ESP
+       printf("%sESP", sep);
+#endif
+       printf("\n");
+
+#if !defined(HAVE_DTLS) || !defined(HAVE_ESP)
+       printf(_("WARNING: This binary lacks DTLS and/or ESP support. Performance will be impaired.\n"));
 #endif
 }
 
+static void print_supported_protocols(void)
+{
+       const char *comma = ", ", *sep = comma + 1;
+       struct oc_vpn_proto *protos, *p;
+
+       if (openconnect_get_supported_protocols(&protos)>=0) {
+               printf(_("Supported protocols:"));
+               for (p=protos; p->name; p++) {
+                       printf("%s%s%s", sep, p->name, p==protos ? _(" (default)") : "");
+                       sep = comma;
+               }
+               printf("\n");
+               free(protos);
+       }
+}
+
+static void print_supported_protocols_usage(void)
+{
+       struct oc_vpn_proto *protos, *p;
+
+       if (openconnect_get_supported_protocols(&protos)>=0) {
+               printf(_("\n    Set VPN protocol:\n"));
+               for (p=protos; p->name; p++)
+                       printf("      --protocol=%-16s %s%s\n",
+                                  p->name, p->description, p==protos ? _(" (default)") : "");
+               openconnect_free_supported_protocols(protos);
+       }
+}
+
 #ifndef _WIN32
 static const char default_vpncscript[] = DEFAULT_VPNCSCRIPT;
 static void read_stdin(char **string, int hidden, int allow_fail)
@@ -750,7 +785,7 @@ static int gai_override_cb(void *cbdata, const char *node,
 static void usage(void)
 {
        printf(_("Usage:  openconnect [options] <server>\n"));
-       printf(_("Open client for Cisco AnyConnect VPN, version %s\n\n"), openconnect_version_str);
+       printf(_("Open client for multiple VPN protocols, version %s\n\n"), openconnect_version_str);
        print_build_opts();
        printf("      --config=CONFIGFILE         %s\n", _("Read options from config file"));
 #ifndef _WIN32
@@ -832,6 +867,8 @@ static void usage(void)
        printf("      --resolve=HOST:IP           %s\n", _("Use IP when connecting to HOST"));
        printf("      --os=STRING                 %s\n", _("OS type (linux,linux-64,win,...) to report"));
        printf("      --dtls-local-port=PORT      %s\n", _("Set local port for DTLS datagrams"));
+       print_supported_protocols_usage();
+
        printf("\n");
 
        helpmessage();
@@ -1334,6 +1371,7 @@ int main(int argc, char **argv)
                case 'V':
                        printf(_("OpenConnect version %s\n"), openconnect_version_str);
                        print_build_opts();
+                       print_supported_protocols();
                        exit(0);
                case 'x':
                        vpninfo->xmlconfig = keep_config_arg();