diff options
author | root <you@example.com> | 2016-11-13 22:20:45 +0000 |
---|---|---|
committer | root <you@example.com> | 2016-11-13 22:20:45 +0000 |
commit | e33a2b9c3fdfd7e89e1daa8c4407bec9dc02dc17 (patch) | |
tree | 6920324c3735b02c366fedcb661a384a032f288a /accel-pppd/ctrl/pppoe/cli.c | |
parent | 7de0d2d00be552dede15dfd02c9e423dda7eb6f5 (diff) | |
download | accel-ppp-e33a2b9c3fdfd7e89e1daa8c4407bec9dc02dc17.tar.gz accel-ppp-e33a2b9c3fdfd7e89e1daa8c4407bec9dc02dc17.zip |
Add possibility to specify multiple service names, add option accept-any-service to provide backward compatibility with old accel-ppp
Diffstat (limited to 'accel-pppd/ctrl/pppoe/cli.c')
-rw-r--r-- | accel-pppd/ctrl/pppoe/cli.c | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/accel-pppd/ctrl/pppoe/cli.c b/accel-pppd/ctrl/pppoe/cli.c index c79a5f1e..d8399543 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; } |