summaryrefslogtreecommitdiff
path: root/accel-pppd/ctrl/pppoe/cli.c
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2017-08-08 18:39:58 +0300
committerDmitry Kozlov <xeb@mail.ru>2017-08-08 18:39:58 +0300
commit4b7c9dea22afa4ab598b1b6fae2c0d470aa32d9f (patch)
treeee1ad9ef1de38763ccab699fc43804ae27447fc4 /accel-pppd/ctrl/pppoe/cli.c
parent945a132a7af2862d89fa1fb86c175fe595419eef (diff)
parent685a8b314121dbdde3bdcfe6308497123a878420 (diff)
downloadaccel-ppp-4b7c9dea22afa4ab598b1b6fae2c0d470aa32d9f.tar.gz
accel-ppp-4b7c9dea22afa4ab598b1b6fae2c0d470aa32d9f.zip
Merge branch 'master' of github.com:xebd/accel-ppp
Diffstat (limited to 'accel-pppd/ctrl/pppoe/cli.c')
-rw-r--r--accel-pppd/ctrl/pppoe/cli.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/accel-pppd/ctrl/pppoe/cli.c b/accel-pppd/ctrl/pppoe/cli.c
index c79a5f1..d839954 100644
--- a/accel-pppd/ctrl/pppoe/cli.c
+++ b/accel-pppd/ctrl/pppoe/cli.c
@@ -170,9 +170,15 @@ static int show_service_name_exec(const char *cmd, char * const *f, int f_cnt, v
if (f_cnt != 3)
return CLI_CMD_SYNTAX;
- if (conf_service_name)
- cli_sendv(cli, "%s\r\n", conf_service_name);
- else
+ if (conf_service_name[0]) {
+ int i = 0;
+ do {
+ cli_sendv(cli, "%s", conf_service_name[i]);
+ i++;
+ if (conf_service_name[i]) { cli_sendv(cli, ","); }
+ } while(conf_service_name[i]);
+ cli_sendv(cli, "\r\n");
+ } else
cli_sendv(cli, "*\r\n");
return CLI_CMD_OK;
@@ -219,13 +225,27 @@ static int set_service_name_exec(const char *cmd, char * const *f, int f_cnt, vo
if (f_cnt != 4)
return CLI_CMD_SYNTAX;
- if (conf_service_name)
- _free(conf_service_name);
-
+ if (conf_service_name[0]) {
+ int i = 0;
+ do {
+ _free(conf_service_name[i]);
+ i++;
+ } while(conf_service_name[i]);
+ conf_service_name[0] = NULL;
+ }
if (!strcmp(f[3], "*"))
- conf_service_name = NULL;
- else
- conf_service_name = _strdup(f[3]);
+ conf_service_name[0] = NULL;
+ else {
+ char *conf_service_name_string = _strdup(f[3]);
+ char *p = strtok (conf_service_name_string, ",");
+ int i = 0;
+ while (p != NULL && i<255) {
+ conf_service_name[i++] = _strdup(p);
+ p = strtok(NULL, ",");
+ }
+ conf_service_name[i] = NULL;
+ _free(conf_service_name_string);
+ }
return CLI_CMD_OK;
}