4d985a2f0639bf380ed03b78f8ef62a4c2b98cee
[l2tpns.git] / autothrottle.c
1 #include <string.h>
2 #include <malloc.h>
3 #include <stdlib.h>
4 #include <sys/wait.h>
5 #include <sys/types.h>
6 #include "l2tpns.h"
7 #include "plugin.h"
8 #include "control.h"
9
10 int __plugin_api_version = 1;
11 struct pluginfuncs p;
12
13 int plugin_radius_response(struct param_radius_response *data)
14 {
15 if (strcmp(data->key, "throttle") == 0)
16 {
17 if (strcmp(data->value, "yes") == 0)
18 {
19 p.log(3, 0, 0, 0, " Throttling user\n");
20 data->s->throttle = 1;
21 }
22 else if (strcmp(data->value, "no") == 0)
23 {
24 p.log(3, 0, 0, 0, " Not throttling user\n");
25 data->s->throttle = 0;
26 }
27 }
28 return PLUGIN_RET_OK;
29 }
30
31 int plugin_init(struct pluginfuncs *funcs)
32 {
33 if (!funcs) return 0;
34 memcpy(&p, funcs, sizeof(p));
35
36 return 1;
37 }
38
39 void plugin_done()
40 {
41 }
42