2 #include <sys/socket.h>
3 #include <linux/rtnetlink.h>
8 /* set up intercept based on RADIUS reply */
10 int plugin_api_version
= PLUGIN_API_VERSION
;
11 static struct pluginfuncs
*f
= 0;
13 int plugin_radius_response(struct param_radius_response
*data
)
15 if (!strcmp(data
->key
, "intercept"))
18 data
->s
->snoop_ip
= 0;
19 data
->s
->snoop_port
= 0;
20 if ((p
= strchr(data
->value
, ':')))
24 data
->s
->snoop_ip
= inet_addr(data
->value
);
26 if (data
->s
->snoop_ip
== INADDR_NONE
)
27 data
->s
->snoop_ip
= 0;
30 data
->s
->snoop_port
= atoi(p
);
32 f
->log(3, f
->get_id_by_session(data
->s
), data
->s
->tunnel
,
33 " Intercepting user to %s:%d\n",
34 f
->fmtaddr(data
->s
->snoop_ip
, 0), data
->s
->snoop_port
);
38 f
->log(3, f
->get_id_by_session(data
->s
), data
->s
->tunnel
,
39 " Not Intercepting user (reply string should"
40 " be intercept=ip:port)\n");
47 int plugin_radius_reset(struct param_radius_reset
*data
)
49 data
->s
->snoop_ip
= 0;
50 data
->s
->snoop_port
= 0;
54 int plugin_radius_account(struct param_radius_account
*data
)
56 if (data
->s
->snoop_ip
&& data
->s
->snoop_port
)
58 uint8_t *p
= *data
->packet
;
60 *p
= 26; // vendor-specific
61 *(uint32_t *) (p
+ 2) = htonl(9); // Cisco
62 p
[6] = 1; // Cisco-AVPair
63 p
[7] = 2 + sprintf((char *) p
+ 8, "intercept=%s:%d",
64 f
->fmtaddr(data
->s
->snoop_ip
, 0), data
->s
->snoop_port
);
67 *data
->packet
+= p
[1];
73 int plugin_init(struct pluginfuncs
*funcs
)
75 return ((f
= funcs
)) ? 1 : 0;