1 From 26b77b7cdc70beddc68507f74372a4e2815720f0 Mon Sep 17 00:00:00 2001
2 From: Yousong Zhou <yszhou4tech@gmail.com>
3 Date: Sun, 17 May 2015 10:53:44 +0800
4 Subject: [PATCH 210/210] xl2tpd-control: show all available commands in
8 xl2tpd-control.c | 63 ++++++++++++++++++++++++++++++++++++++----------------
9 1 file changed, 44 insertions(+), 19 deletions(-)
11 diff --git a/xl2tpd-control.c b/xl2tpd-control.c
12 index 6b08850..b98ff24 100644
13 --- a/xl2tpd-control.c
14 +++ b/xl2tpd-control.c
15 @@ -51,6 +51,7 @@ struct command_t
17 int (*handler) (FILE*, char* tunnel, int optc, char *optv[]);
22 int command_add_lac (FILE*, char* tunnel, int optc, char *optv[]);
23 @@ -65,13 +66,29 @@ int command_available (FILE*, char* tunnel, int optc, char *optv[]);
25 struct command_t commands[] = {
26 /* Keep this command mapping for backwards compat */
27 - {"add", &command_add_lac, TUNNEL_REQUIRED},
28 - {"connect", &command_connect_lac, TUNNEL_REQUIRED},
29 - {"disconnect", &command_disconnect_lac, TUNNEL_REQUIRED},
30 - {"remove", &command_remove_lac, TUNNEL_REQUIRED},
31 + {"add", &command_add_lac, TUNNEL_REQUIRED,
32 + "\tadd\tadds new or modify existing lac configuration.\n"
33 + "\t\tConfiguration must be specified as command options in\n"
34 + "\t\t<key>=<value> pairs format.\n"
35 + "\t\tSee available options in xl2tpd.conf(5)\n"
37 + {"connect", &command_connect_lac, TUNNEL_REQUIRED,
38 + "\tconnect\ttries to activate the tunnel.\n"
39 + "\t\tUsername and secret for the tunnel can be passed as\n"
40 + "\t\tcommand options.\n"
42 + {"disconnect", &command_disconnect_lac, TUNNEL_REQUIRED,
43 + "\tdisconnect\tdisconnects the tunnel.\n"
45 + {"remove", &command_remove_lac, TUNNEL_REQUIRED,
46 + "\tremove\tremoves lac configuration from xl2tpd.\n"
47 + "\t\txl2tpd disconnects the tunnel before removing.\n"
51 - {"add-lac", &command_add_lac, TUNNEL_REQUIRED},
52 + {"add-lac", &command_add_lac, TUNNEL_REQUIRED,
53 + "\tadd-lns\tadds new or modify existing lns configuration.\n"
55 {"connect-lac", &command_connect_lac, TUNNEL_REQUIRED},
56 {"disconnect-lac", &command_disconnect_lac, TUNNEL_REQUIRED},
57 {"remove-lac", &command_remove_lac, TUNNEL_REQUIRED},
58 @@ -89,36 +106,44 @@ struct command_t commands[] = {
64 printf ("\nxl2tpd server version %s\n", SERVER_VERSION);
65 printf ("Usage: xl2tpd-control [-c <PATH>] <command> <tunnel name> [<COMMAND OPTIONS>]\n"
67 " -c\tspecifies xl2tpd control file\n"
68 " -d\tspecify xl2tpd-control to run in debug mode\n"
69 "--help\tshows extended help\n"
70 - "Available commands: add, connect, disconnect, remove, add-lns\n"
73 + printf ("Available commands: ");
74 + for (i = 0; commands[i].name; i++) {
75 + struct command_t *command = &commands[i];
76 + int last = command[1].name == NULL;
78 + printf ("%s%s", command->name, !last ? ", " : "\n");
90 - "\tadd\tadds new or modify existing lac configuration.\n"
91 - "\t\tConfiguration must be specified as command options in\n"
92 - "\t\t<key>=<value> pairs format.\n"
93 - "\t\tSee available options in xl2tpd.conf(5)\n"
94 - "\tconnect\ttries to activate the tunnel.\n"
95 - "\t\tUsername and secret for the tunnel can be passed as\n"
96 - "\t\tcommand options.\n"
97 - "\tdisconnect\tdisconnects the tunnel.\n"
98 - "\tremove\tremoves lac configuration from xl2tpd.\n"
99 - "\t\txl2tpd disconnects the tunnel before removing.\n"
101 - "\tadd-lns\tadds new or modify existing lns configuration.\n"
102 - "See xl2tpd-control man page for more help\n"
105 + for (i = 0; commands[i].name; i++) {
106 + struct command_t *command = &commands[i];
108 + if (!command->help)
110 + printf ("%s", command->help);
112 + /*FIXME Ha! there is currently no manpage for xl2tpd-control */
113 + printf ("See xl2tpd-control man page for more help\n");