0a971dee700814c90528d5f2674a25cee4fa8ee1
[l2tpns.git] / autosnoop.c
1 #include <string.h>
2 #include "l2tpns.h"
3 #include "plugin.h"
4
5 /* set up intercept based on RADIUS reply */
6
7 char const *cvs_id = "$Id: autosnoop.c,v 1.11 2005-10-11 07:59:09 bodea Exp $";
8
9 int plugin_api_version = PLUGIN_API_VERSION;
10 struct pluginfuncs *p;
11
12 int plugin_radius_response(struct param_radius_response *data)
13 {
14 if (!strcmp(data->key, "intercept"))
15 {
16 char *x;
17 data->s->snoop_ip = 0;
18 data->s->snoop_port = 0;
19 if ((x = strchr(data->value, ':')))
20 {
21 *x++ = 0;
22 if (*data->value) data->s->snoop_ip = inet_addr(data->value);
23 if (data->s->snoop_ip == INADDR_NONE) data->s->snoop_ip = 0;
24 if (*x) data->s->snoop_port = atoi(x);
25 p->log(3, p->get_id_by_session(data->s), data->s->tunnel,
26 " Intercepting user to %s:%d\n",
27 p->fmtaddr(data->s->snoop_ip, 0), data->s->snoop_port);
28 }
29 else
30 {
31 p->log(3, p->get_id_by_session(data->s), data->s->tunnel,
32 " Not Intercepting user (reply string should be intercept=ip:port)\n");
33 }
34 }
35
36 return PLUGIN_RET_OK;
37 }
38
39 int plugin_radius_reset(struct param_radius_reset *data)
40 {
41 data->s->snoop_ip = 0;
42 data->s->snoop_port = 0;
43 return PLUGIN_RET_OK;
44 }
45
46 int plugin_init(struct pluginfuncs *funcs)
47 {
48 return ((p = funcs)) ? 1 : 0;
49 }