merge
[l2tpns.git] / autosnoop.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, "intercept") == 0)
16 {
17 char *x;
18 data->s->snoop_ip = 0;
19 data->s->snoop_port = 0;
20 if ((x = strchr(data->value, ':')))
21 {
22 *x++ = 0;
23 if (*data->value) data->s->snoop_ip = inet_addr(data->value);
24 if (data->s->snoop_ip == INADDR_NONE) data->s->snoop_ip = 0;
25 if (*x) data->s->snoop_port = atoi(x);
26 p->log(3, 0, 0, 0, " Intercepting user to %s:%d\n",
27 p->inet_toa(data->s->snoop_ip), data->s->snoop_port);
28 }
29 else
30 {
31 p->log(3, 0, 0, 0, " Not Intercepting user (reply string should be snoop=ip:port)\n");
32 }
33 }
34 return PLUGIN_RET_OK;
35 }
36
37 int plugin_init(struct pluginfuncs *funcs)
38 {
39 return ((p = funcs)) ? 1 : 0;
40 }
41
42 void plugin_done()
43 {
44 }
45