Advertisement
Miguel-Brbyte

Accel-PPP MK Rate Limit

Jun 23rd, 2020
1,392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.78 KB | None | 0 0
  1. --- git a/accel-ppp/accel-pppd/shaper/shaper.c b/accel-ppp/accel-pppd/shaper/shaper.c
  2. --- a/accel-ppp/accel-pppd/shaper/shaper.c
  3. +++ b/accel-ppp/accel-pppd/shaper/shaper.c
  4. @@ -196,7 +196,9 @@ static struct shaper_pd_t *find_pd(struct ap_session *ses, int create)
  5.  static void parse_string_simple(const char *str, int dir, int *speed, int *burst, int *tr_id)
  6.  {
  7.     char *endptr;
  8. +   char *endstr;
  9.     long int val;
  10. +   long int bandw;
  11.  
  12.     val = strtol(str, &endptr, 10);
  13.     if (*endptr == 0) {
  14. @@ -211,15 +213,38 @@ static void parse_string_simple(const char *str, int dir, int *speed, int *burst
  15.         *speed = conf_multiplier * val;
  16.         return;
  17.     } else {
  18. -       if (*endptr == '/' || *endptr == '\\' || *endptr == ':') {
  19. -           if (dir == ATTR_DOWN)
  20. -               *speed = conf_multiplier * val;
  21. -           else
  22. -               *speed = conf_multiplier * strtol(endptr + 1, &endptr, 10);
  23. +       if (*endptr == 'k' || *endptr == 'K' || *endptr == 'm' || *endptr == 'M') {
  24. +           endstr = endptr;
  25. +           endptr++;
  26. +           if (*endptr == '/' || *endptr == '\\' || *endptr == ':') {
  27. +               if (dir == ATTR_UP) {
  28. +                   bandw = conf_multiplier * val;
  29. +                   if (*endstr == 'm' || *endstr == 'M') {
  30. +                       *speed = bandw * 1024;
  31. +                   } else {
  32. +                       *speed = bandw;
  33. +                   }
  34. +               } else {
  35. +                   bandw = conf_multiplier * strtol(endptr + 1, &endptr, 10);
  36. +                   if (*endptr == 'm' || *endptr == 'M') {
  37. +                       *speed = bandw * 1024;
  38. +                   } else {
  39. +                       *speed = bandw;
  40. +                   }
  41. +               }
  42. +           }
  43. +       } else {
  44. +           if (*endptr == '/' || *endptr == '\\' || *endptr == ':') {
  45. +               if (dir == ATTR_DOWN)
  46. +                   *speed = conf_multiplier * val;
  47. +               else
  48. +                   *speed = conf_multiplier * strtol(endptr + 1, &endptr, 10);
  49. +           }
  50.         }
  51.     }
  52.  }
  53.  
  54. +
  55.  static void parse_string(const char *str, int dir, int *speed, int *burst, int *tr_id)
  56.  {
  57.     long int val;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement