65f3ff73542ba38f5c24919abb95b3581e948acb
10 int __plugin_api_version
= 1;
11 struct pluginfuncs
*p
;
13 #define THROTTLE_KEY "lcp:interface-config"
15 int plugin_radius_response(struct param_radius_response
*data
)
21 if (strncmp(data
->key
, THROTTLE_KEY
, strlen(THROTTLE_KEY
)) == 0)
23 char *pt
= strdup(data
->value
);
24 while ((t
= strsep(&pt
, " ")) != NULL
)
26 if (strcmp(t
, "serv") == 0)
28 else if (strcmp(t
, "o") && i
== 1)
30 else if (strcmp(t
, "i") && i
== 1)
32 else if (i
> 1 && (rate
= atoi(t
)) > 0)
37 data
->s
->throttle_out
= rate
;
39 p
->log(3, 0, p
->get_id_by_session(data
->s
), data
->s
->tunnel
, " Set output throttle rate %dkb/s\n", rate
);
43 data
->s
->throttle_in
= rate
;
45 p
->log(3, 0, p
->get_id_by_session(data
->s
), data
->s
->tunnel
, " Set input throttle rate %dkb/s\n", rate
);
49 p
->log(1, 0, p
->get_id_by_session(data
->s
), data
->s
->tunnel
, "Syntax error in rate limit AV pair: %s=%s\n", data
->key
, data
->value
);
57 p
->log(1, 0, p
->get_id_by_session(data
->s
), data
->s
->tunnel
, "Syntax error in rate limit AV pair: %s=%s\n",
58 data
->key
, data
->value
);
64 else if (strcmp(data
->key
, "throttle") == 0)
66 if (strcmp(data
->value
, "yes") == 0)
68 p
->log(3, 0, p
->get_id_by_session(data
->s
), data
->s
->tunnel
, " Throttling user\n");
69 data
->s
->throttle_in
= data
->s
->throttle_out
= config
->rl_rate
;
71 else if (strcmp(data
->value
, "no") == 0)
73 p
->log(3, 0, p
->get_id_by_session(data
->s
), data
->s
->tunnel
, " Not throttling user\n");
74 data
->s
->throttle_in
= data
->s
->throttle_out
= 0;
78 p
->log(4, 0, p
->get_id_by_session(data
->s
), data
->s
->tunnel
, "autothrottle module ignoring AV pair %s=%s\n",
79 data
->key
, data
->value
);
84 int plugin_init(struct pluginfuncs
*funcs
)
86 return ((p
= funcs
)) ? 1 : 0;