570c147ddc0c37de8d9958284608f2d28427484f
5 /* set up intercept based on RADIUS reply */
7 char const *cvs_id
= "$Id: autosnoop.c,v 1.12 2005-10-11 09:04:53 bodea Exp $";
9 int plugin_api_version
= PLUGIN_API_VERSION
;
10 static struct pluginfuncs
*f
= 0;
12 int plugin_radius_response(struct param_radius_response
*data
)
14 if (!strcmp(data
->key
, "intercept"))
17 data
->s
->snoop_ip
= 0;
18 data
->s
->snoop_port
= 0;
19 if ((p
= strchr(data
->value
, ':')))
23 data
->s
->snoop_ip
= inet_addr(data
->value
);
25 if (data
->s
->snoop_ip
== INADDR_NONE
)
26 data
->s
->snoop_ip
= 0;
29 data
->s
->snoop_port
= atoi(p
);
31 f
->log(3, f
->get_id_by_session(data
->s
), data
->s
->tunnel
,
32 " Intercepting user to %s:%d\n",
33 f
->fmtaddr(data
->s
->snoop_ip
, 0), data
->s
->snoop_port
);
37 f
->log(3, f
->get_id_by_session(data
->s
), data
->s
->tunnel
,
38 " Not Intercepting user (reply string should"
39 " be intercept=ip:port)\n");
46 int plugin_radius_reset(struct param_radius_reset
*data
)
48 data
->s
->snoop_ip
= 0;
49 data
->s
->snoop_port
= 0;
53 int plugin_radius_account(struct param_radius_account
*data
)
55 if (data
->s
->snoop_ip
&& data
->s
->snoop_port
)
57 uint8_t *p
= *data
->packet
;
59 *p
= 26; // vendor-specific
60 *(uint32_t *) (p
+ 2) = htonl(9); // Cisco
61 p
[6] = 1; // Cisco-AVPair
62 p
[7] = 2 + sprintf((char *) p
+ 8, "intercept=%s:%d",
63 f
->fmtaddr(data
->s
->snoop_ip
, 0), data
->s
->snoop_port
);
66 *data
->packet
+= p
[1];
72 int plugin_init(struct pluginfuncs
*funcs
)
74 return ((f
= funcs
)) ? 1 : 0;