diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2018-04-21 08:20:32 +0300 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2018-04-21 08:20:32 +0300 |
commit | fc6624493c6260f0b216aabd8e51944209b71bec (patch) | |
tree | d3ed78e18af6a868bf25c891bed46e4ba9aa45d5 /accel-pppd/shaper | |
parent | dd1418d6a0d4906c2fa1aaec07f1ea0569d62ad7 (diff) | |
download | accel-ppp-fc6624493c6260f0b216aabd8e51944209b71bec.tar.gz accel-ppp-fc6624493c6260f0b216aabd8e51944209b71bec.zip |
shaper: "change" command: consider value to be in simple format
Diffstat (limited to 'accel-pppd/shaper')
-rw-r--r-- | accel-pppd/shaper/shaper.c | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/accel-pppd/shaper/shaper.c b/accel-pppd/shaper/shaper.c index 5f557b3b..0a1e5f87 100644 --- a/accel-pppd/shaper/shaper.c +++ b/accel-pppd/shaper/shaper.c @@ -189,10 +189,36 @@ static struct shaper_pd_t *find_pd(struct ap_session *ses, int create) return NULL; } -static void parse_string(const char *str, int dir, int *speed, int *burst, int *tr_id) +static void parse_string_simple(const char *str, int dir, int *speed, int *burst, int *tr_id) { char *endptr; long int val; + + val = strtol(str, &endptr, 10); + if (*endptr == 0) { + *speed = conf_multiplier * val; + return; + } + if (*endptr == ',') { + *tr_id = val; + val = strtol(endptr + 1, &endptr, 10); + } + if (*endptr == 0) { + *speed = conf_multiplier * val; + return; + } else { + if (*endptr == '/' || *endptr == '\\' || *endptr == ':') { + if (dir == ATTR_DOWN) + *speed = conf_multiplier * val; + else + *speed = conf_multiplier * strtol(endptr + 1, &endptr, 10); + } + } +} + +static void parse_string(const char *str, int dir, int *speed, int *burst, int *tr_id) +{ + long int val; unsigned int n1, n2, n3; char *str1; @@ -243,26 +269,7 @@ static void parse_string(const char *str, int dir, int *speed, int *burst, int * return; #endif - val = strtol(str, &endptr, 10); - if (*endptr == 0) { - *speed = conf_multiplier * val; - return; - } - if (*endptr == ',') { - *tr_id = val; - val = strtol(endptr + 1, &endptr, 10); - } - if (*endptr == 0) { - *speed = conf_multiplier * val; - return; - } else { - if (*endptr == '/' || *endptr == '\\' || *endptr == ':') { - if (dir == ATTR_DOWN) - *speed = conf_multiplier * val; - else - *speed = conf_multiplier * strtol(endptr + 1, &endptr, 10); - } - } + parse_string_simple(str, dir, speed, burst, tr_id); } static struct time_range_pd_t *get_tr_pd(struct shaper_pd_t *pd, int id) @@ -563,8 +570,8 @@ static int shaper_change_exec(const char *cmd, char * const *f, int f_cnt, void if (f_cnt < 4) return CLI_CMD_SYNTAX; - parse_string(f[3], ATTR_DOWN, &down_speed, &down_burst, &tr_id); - parse_string(f[3], ATTR_UP, &up_speed, &up_burst, &tr_id); + parse_string_simple(f[3], ATTR_DOWN, &down_speed, &down_burst, &tr_id); + parse_string_simple(f[3], ATTR_UP, &up_speed, &up_burst, &tr_id); //if (down_speed == 0 || up_speed == 0) // return CLI_CMD_INVAL; |