diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2014-11-17 19:37:28 +0300 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2014-11-17 19:37:28 +0300 |
commit | 731b6b13149ab333158aadfd3c7b841f5c1fc3b4 (patch) | |
tree | 745017146b54f9754373c0f8bceb25a516ec31e7 /accel-pppd/shaper | |
parent | ca13dfe2c774835c3aed9567747c9b8b989446ba (diff) | |
download | accel-ppp-731b6b13149ab333158aadfd3c7b841f5c1fc3b4.tar.gz accel-ppp-731b6b13149ab333158aadfd3c7b841f5c1fc3b4.zip |
shaper: simplified parsing Cisco-AVPair
Diffstat (limited to 'accel-pppd/shaper')
-rw-r--r-- | accel-pppd/shaper/shaper.c | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/accel-pppd/shaper/shaper.c b/accel-pppd/shaper/shaper.c index 85b0edd7..fa89e62b 100644 --- a/accel-pppd/shaper/shaper.c +++ b/accel-pppd/shaper/shaper.c @@ -143,37 +143,42 @@ static void parse_string(const char *str, int dir, int *speed, int *burst, int * char *endptr; long int val; unsigned int n1, n2, n3; + char *str1; - if (strstr(str, "lcp:interface-config#1=rate-limit output access-group") == str) { - if (dir == ATTR_DOWN) { - val = sscanf(str, "lcp:interface-config#1=rate-limit output access-group %i %u %u %u conform-action transmit exceed-action drop", tr_id, &n1, &n2, &n3); + if (dir == ATTR_DOWN) { + str1 = strstr(str, "rate-limit output access-group"); + if (str1) { + val = sscanf(str1, "rate-limit output access-group %i %u %u %u", tr_id, &n1, &n2, &n3); if (val == 4) { *speed = n1/1000; *burst = n2; } + return; } - return; - } else if (strstr(str, "lcp:interface-config#1=rate-limit input access-group") == str) { - if (dir == ATTR_UP) { - val = sscanf(str, "lcp:interface-config#1=rate-limit input access-group %i %u %u %u conform-action transmit exceed-action drop", tr_id, &n1, &n2, &n3); - if (val == 4) { + + str1 = strstr(str, "rate-limit output"); + if (str1) { + val = sscanf(str1, "rate-limit output %u %u %u", &n1, &n2, &n3); + if (val == 3) { *speed = n1/1000; *burst = n2; } + return; } - return; - } else if (strstr(str, "lcp:interface-config#1=rate-limit output") == str) { - if (dir == ATTR_DOWN) { - val = sscanf(str, "lcp:interface-config#1=rate-limit output %u %u %u conform-action transmit exceed-action drop", &n1, &n2, &n3); - if (val == 3) { + } else { + str1 = strstr(str, "rate-limit input access-group"); + if (str1) { + val = sscanf(str1, "rate-limit input access-group %i %u %u %u", tr_id, &n1, &n2, &n3); + if (val == 4) { *speed = n1/1000; *burst = n2; } + return; } - return; - } else if (strstr(str, "lcp:interface-config#1=rate-limit input") == str) { - if (dir == ATTR_UP) { - val = sscanf(str, "lcp:interface-config#1=rate-limit input %u %u %u conform-action transmit exceed-action drop", &n1, &n2, &n3); + + str1 = strstr(str, "rate-limit input"); + if (str1) { + val = sscanf(str1, "rate-limit input %u %u %u", &n1, &n2, &n3); if (val == 3) { *speed = n1/1000; *burst = n2; |