5 /* set up intercept based on RADIUS reply */
7 int plugin_api_version
= PLUGIN_API_VERSION
;
8 static struct pluginfuncs
*f
= 0;
10 int plugin_radius_response(struct param_radius_response
*data
)
12 if (!strcmp(data
->key
, "intercept"))
15 data
->s
->snoop_ip
= 0;
16 data
->s
->snoop_port
= 0;
17 if ((p
= strchr(data
->value
, ':')))
21 data
->s
->snoop_ip
= inet_addr(data
->value
);
23 if (data
->s
->snoop_ip
== INADDR_NONE
)
24 data
->s
->snoop_ip
= 0;
27 data
->s
->snoop_port
= atoi(p
);
29 f
->log(3, f
->get_id_by_session(data
->s
), data
->s
->tunnel
,
30 " Intercepting user to %s:%d\n",
31 f
->fmtaddr(data
->s
->snoop_ip
, 0), data
->s
->snoop_port
);
35 f
->log(3, f
->get_id_by_session(data
->s
), data
->s
->tunnel
,
36 " Not Intercepting user (reply string should"
37 " be intercept=ip:port)\n");
44 int plugin_radius_reset(struct param_radius_reset
*data
)
46 data
->s
->snoop_ip
= 0;
47 data
->s
->snoop_port
= 0;
51 int plugin_radius_account(struct param_radius_account
*data
)
53 if (data
->s
->snoop_ip
&& data
->s
->snoop_port
)
55 uint8_t *p
= *data
->packet
;
57 *p
= 26; // vendor-specific
58 *(uint32_t *) (p
+ 2) = htonl(9); // Cisco
59 p
[6] = 1; // Cisco-AVPair
60 p
[7] = 2 + sprintf((char *) p
+ 8, "intercept=%s:%d",
61 f
->fmtaddr(data
->s
->snoop_ip
, 0), data
->s
->snoop_port
);
64 *data
->packet
+= p
[1];
70 int plugin_init(struct pluginfuncs
*funcs
)
72 return ((f
= funcs
)) ? 1 : 0;