add Cisco-AVPairs to RADIUS accounting records via plugin_radius_account
This commit is contained in:
parent
5d659af7fd
commit
f6b56a0f4d
12 changed files with 668 additions and 584 deletions
1
Changes
1
Changes
|
|
@ -3,6 +3,7 @@
|
|||
- Fix RADIUS authentication on DAE responses.
|
||||
- Don't send tunnel HELLO when there are pending control messages.
|
||||
- Move plugin_radius_reset from *ctl to auto* plugins.
|
||||
- Add Cisco-AVPairs to RADIUS accounting records via plugin_radius_account.
|
||||
|
||||
* Mon Sep 19 2005 Brendan O'Dea <bod@optus.net> 2.1.8
|
||||
- Move code from signal handlers into mainloop, avoiding a race
|
||||
|
|
|
|||
52
autosnoop.c
52
autosnoop.c
|
|
@ -4,32 +4,39 @@
|
|||
|
||||
/* set up intercept based on RADIUS reply */
|
||||
|
||||
char const *cvs_id = "$Id: autosnoop.c,v 1.11 2005/10/11 07:59:09 bodea Exp $";
|
||||
char const *cvs_id = "$Id: autosnoop.c,v 1.12 2005/10/11 09:04:53 bodea Exp $";
|
||||
|
||||
int plugin_api_version = PLUGIN_API_VERSION;
|
||||
struct pluginfuncs *p;
|
||||
static struct pluginfuncs *f = 0;
|
||||
|
||||
int plugin_radius_response(struct param_radius_response *data)
|
||||
{
|
||||
if (!strcmp(data->key, "intercept"))
|
||||
{
|
||||
char *x;
|
||||
char *p;
|
||||
data->s->snoop_ip = 0;
|
||||
data->s->snoop_port = 0;
|
||||
if ((x = strchr(data->value, ':')))
|
||||
if ((p = strchr(data->value, ':')))
|
||||
{
|
||||
*x++ = 0;
|
||||
if (*data->value) data->s->snoop_ip = inet_addr(data->value);
|
||||
if (data->s->snoop_ip == INADDR_NONE) data->s->snoop_ip = 0;
|
||||
if (*x) data->s->snoop_port = atoi(x);
|
||||
p->log(3, p->get_id_by_session(data->s), data->s->tunnel,
|
||||
*p++ = 0;
|
||||
if (*data->value)
|
||||
data->s->snoop_ip = inet_addr(data->value);
|
||||
|
||||
if (data->s->snoop_ip == INADDR_NONE)
|
||||
data->s->snoop_ip = 0;
|
||||
|
||||
if (*p)
|
||||
data->s->snoop_port = atoi(p);
|
||||
|
||||
f->log(3, f->get_id_by_session(data->s), data->s->tunnel,
|
||||
" Intercepting user to %s:%d\n",
|
||||
p->fmtaddr(data->s->snoop_ip, 0), data->s->snoop_port);
|
||||
f->fmtaddr(data->s->snoop_ip, 0), data->s->snoop_port);
|
||||
}
|
||||
else
|
||||
{
|
||||
p->log(3, p->get_id_by_session(data->s), data->s->tunnel,
|
||||
" Not Intercepting user (reply string should be intercept=ip:port)\n");
|
||||
f->log(3, f->get_id_by_session(data->s), data->s->tunnel,
|
||||
" Not Intercepting user (reply string should"
|
||||
" be intercept=ip:port)\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -43,7 +50,26 @@ int plugin_radius_reset(struct param_radius_reset *data)
|
|||
return PLUGIN_RET_OK;
|
||||
}
|
||||
|
||||
int plugin_radius_account(struct param_radius_account *data)
|
||||
{
|
||||
if (data->s->snoop_ip && data->s->snoop_port)
|
||||
{
|
||||
uint8_t *p = *data->packet;
|
||||
|
||||
*p = 26; // vendor-specific
|
||||
*(uint32_t *) (p + 2) = htonl(9); // Cisco
|
||||
p[6] = 1; // Cisco-AVPair
|
||||
p[7] = 2 + sprintf((char *) p + 8, "intercept=%s:%d",
|
||||
f->fmtaddr(data->s->snoop_ip, 0), data->s->snoop_port);
|
||||
|
||||
p[1] = p[7] + 6;
|
||||
*data->packet += p[1];
|
||||
}
|
||||
|
||||
return PLUGIN_RET_OK;
|
||||
}
|
||||
|
||||
int plugin_init(struct pluginfuncs *funcs)
|
||||
{
|
||||
return ((p = funcs)) ? 1 : 0;
|
||||
return ((f = funcs)) ? 1 : 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@
|
|||
* throttle=no
|
||||
*/
|
||||
|
||||
char const *cvs_id = "$Id: autothrottle.c,v 1.15 2005/10/11 07:59:09 bodea Exp $";
|
||||
char const *cvs_id = "$Id: autothrottle.c,v 1.16 2005/10/11 09:04:53 bodea Exp $";
|
||||
|
||||
int plugin_api_version = PLUGIN_API_VERSION;
|
||||
struct pluginfuncs *p;
|
||||
static struct pluginfuncs *f = 0;
|
||||
|
||||
#define THROTTLE_KEY "lcp:interface-config"
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ int plugin_radius_response(struct param_radius_response *data)
|
|||
(strncmp("input", data->value, sp - data->value) &&
|
||||
strncmp("output", data->value, sp - data->value)))
|
||||
{
|
||||
p->log(3, p->get_id_by_session(data->s), data->s->tunnel,
|
||||
f->log(3, f->get_id_by_session(data->s), data->s->tunnel,
|
||||
" Not throttling user (invalid type %.*s)\n",
|
||||
sp - data->value, data->value);
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ int plugin_radius_response(struct param_radius_response *data)
|
|||
|
||||
if ((rate = strtol(data->value, &sp, 10)) < 0 || *sp)
|
||||
{
|
||||
p->log(3, p->get_id_by_session(data->s), data->s->tunnel,
|
||||
f->log(3, f->get_id_by_session(data->s), data->s->tunnel,
|
||||
" Not throttling user (invalid rate %s)\n",
|
||||
data->value);
|
||||
|
||||
|
|
@ -63,20 +63,17 @@ int plugin_radius_response(struct param_radius_response *data)
|
|||
if (type == 'i')
|
||||
{
|
||||
data->s->throttle_in = rate;
|
||||
p->log(3, p->get_id_by_session(data->s), data->s->tunnel,
|
||||
" Throttling user input to %dkb/s\n",
|
||||
rate);
|
||||
f->log(3, f->get_id_by_session(data->s), data->s->tunnel,
|
||||
" Throttling user input to %dkb/s\n", rate);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->s->throttle_out = rate;
|
||||
p->log(3, p->get_id_by_session(data->s), data->s->tunnel,
|
||||
" Throttling user output to %dkb/s\n",
|
||||
rate);
|
||||
f->log(3, f->get_id_by_session(data->s), data->s->tunnel,
|
||||
" Throttling user output to %dkb/s\n", rate);
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp(data->key, "throttle"))
|
||||
else if (!strcmp(data->key, "throttle"))
|
||||
{
|
||||
char *e;
|
||||
int rate;
|
||||
|
|
@ -86,7 +83,7 @@ int plugin_radius_response(struct param_radius_response *data)
|
|||
rate = -1;
|
||||
if (!strcmp(data->value, "yes"))
|
||||
{
|
||||
unsigned long *ts = p->getconfig("throttle_speed", UNSIGNED_LONG);
|
||||
unsigned long *ts = f->getconfig("throttle_speed", UNSIGNED_LONG);
|
||||
if (ts)
|
||||
rate = *ts;
|
||||
}
|
||||
|
|
@ -98,10 +95,10 @@ int plugin_radius_response(struct param_radius_response *data)
|
|||
return PLUGIN_RET_OK;
|
||||
|
||||
if (rate)
|
||||
p->log(3, p->get_id_by_session(data->s), data->s->tunnel,
|
||||
f->log(3, f->get_id_by_session(data->s), data->s->tunnel,
|
||||
" Throttling user to %dkb/s\n", rate);
|
||||
else
|
||||
p->log(3, p->get_id_by_session(data->s), data->s->tunnel,
|
||||
f->log(3, f->get_id_by_session(data->s), data->s->tunnel,
|
||||
" Not throttling user\n");
|
||||
|
||||
data->s->throttle_in = data->s->throttle_out = rate;
|
||||
|
|
@ -112,11 +109,50 @@ int plugin_radius_response(struct param_radius_response *data)
|
|||
|
||||
int plugin_radius_reset(struct param_radius_reset *data)
|
||||
{
|
||||
p->throttle(p->get_id_by_session(data->s), 0, 0);
|
||||
f->throttle(f->get_id_by_session(data->s), 0, 0);
|
||||
return PLUGIN_RET_OK;
|
||||
}
|
||||
|
||||
int plugin_radius_account(struct param_radius_account *data)
|
||||
{
|
||||
if (data->s->throttle_in || data->s->throttle_out)
|
||||
{
|
||||
uint8_t *p = *data->packet;
|
||||
int i = 1;
|
||||
|
||||
if (data->s->throttle_in)
|
||||
{
|
||||
*p = 26; // vendor-specific
|
||||
*(uint32_t *) (p + 2) = htonl(9); // Cisco
|
||||
p[6] = 1; // Cisco-AVPair
|
||||
p[7] = 2 + sprintf((char *) p + 8,
|
||||
"lcp:interface-config#%d=service-policy input %d", i++,
|
||||
data->s->throttle_in);
|
||||
|
||||
p[1] = p[7] + 6;
|
||||
p += p[1];
|
||||
}
|
||||
|
||||
if (data->s->throttle_out)
|
||||
{
|
||||
*p = 26; // vendor-specific
|
||||
*(uint32_t *) (p + 2) = htonl(9); // Cisco
|
||||
p[6] = 1; // Cisco-AVPair
|
||||
p[7] = 2 + sprintf((char *) p + 8,
|
||||
"lcp:interface-config#%d=service-policy output %d", i++,
|
||||
data->s->throttle_out);
|
||||
|
||||
p[1] = p[7] + 6;
|
||||
p += p[1];
|
||||
}
|
||||
|
||||
*data->packet = p;
|
||||
}
|
||||
|
||||
return PLUGIN_RET_OK;
|
||||
}
|
||||
|
||||
int plugin_init(struct pluginfuncs *funcs)
|
||||
{
|
||||
return ((p = funcs)) ? 1 : 0;
|
||||
return ((f = funcs)) ? 1 : 0;
|
||||
}
|
||||
|
|
|
|||
61
garden.c
61
garden.c
|
|
@ -9,10 +9,10 @@
|
|||
|
||||
/* walled garden */
|
||||
|
||||
char const *cvs_id = "$Id: garden.c,v 1.23 2005/06/02 11:32:30 bodea Exp $";
|
||||
char const *cvs_id = "$Id: garden.c,v 1.24 2005/10/11 09:04:53 bodea Exp $";
|
||||
|
||||
int plugin_api_version = PLUGIN_API_VERSION;
|
||||
static struct pluginfuncs *p = 0;
|
||||
static struct pluginfuncs *f = 0;
|
||||
|
||||
static int iam_master = 0; // We're all slaves! Slaves I tell you!
|
||||
|
||||
|
|
@ -49,9 +49,12 @@ int garden_session(sessiont *s, int flag, char *newuser);
|
|||
int plugin_post_auth(struct param_post_auth *data)
|
||||
{
|
||||
// Ignore if user authentication was successful
|
||||
if (data->auth_allowed) return PLUGIN_RET_OK;
|
||||
if (data->auth_allowed)
|
||||
return PLUGIN_RET_OK;
|
||||
|
||||
f->log(3, f->get_id_by_session(data->s), data->s->tunnel,
|
||||
"Walled Garden allowing login\n");
|
||||
|
||||
p->log(3, p->get_id_by_session(data->s), data->s->tunnel, "Walled Garden allowing login\n");
|
||||
data->auth_allowed = 1;
|
||||
data->s->walled_garden = 1;
|
||||
return PLUGIN_RET_OK;
|
||||
|
|
@ -116,13 +119,13 @@ int plugin_control(struct param_control *data)
|
|||
if (!(session = strtol(data->argv[1], &end, 10)) || *end)
|
||||
{
|
||||
if (flag)
|
||||
session = p->get_session_by_username(data->argv[1]);
|
||||
session = f->get_session_by_username(data->argv[1]);
|
||||
else
|
||||
session = 0; // can't ungarden by username
|
||||
}
|
||||
|
||||
if (session)
|
||||
s = p->get_session_by_id(session);
|
||||
s = f->get_session_by_id(session);
|
||||
|
||||
if (!s || !s->ip)
|
||||
{
|
||||
|
|
@ -139,7 +142,7 @@ int plugin_control(struct param_control *data)
|
|||
}
|
||||
|
||||
garden_session(s, flag, data->argc > 2 ? data->argv[2] : 0);
|
||||
p->session_changed(session);
|
||||
f->session_changed(session);
|
||||
|
||||
data->response = NSCTL_RES_OK;
|
||||
data->additional = 0;
|
||||
|
|
@ -154,7 +157,7 @@ int plugin_become_master(void)
|
|||
|
||||
for (i = 0; up_commands[i] && *up_commands[i]; i++)
|
||||
{
|
||||
p->log(3, 0, 0, "Running %s\n", up_commands[i]);
|
||||
f->log(3, 0, 0, "Running %s\n", up_commands[i]);
|
||||
system(up_commands[i]);
|
||||
}
|
||||
|
||||
|
|
@ -178,12 +181,17 @@ int garden_session(sessiont *s, int flag, char *newuser)
|
|||
if (!s) return 0;
|
||||
if (!s->opened) return 0;
|
||||
|
||||
sess = p->get_id_by_session(s);
|
||||
sess = f->get_id_by_session(s);
|
||||
if (flag == F_GARDEN)
|
||||
{
|
||||
p->log(2, sess, s->tunnel, "Garden user %s (%s)\n", s->user, p->fmtaddr(htonl(s->ip), 0));
|
||||
snprintf(cmd, sizeof(cmd), "iptables -t nat -A garden_users -s %s -j garden", p->fmtaddr(htonl(s->ip), 0));
|
||||
p->log(3, sess, s->tunnel, "%s\n", cmd);
|
||||
f->log(2, sess, s->tunnel, "Garden user %s (%s)\n", s->user,
|
||||
f->fmtaddr(htonl(s->ip), 0));
|
||||
|
||||
snprintf(cmd, sizeof(cmd),
|
||||
"iptables -t nat -A garden_users -s %s -j garden",
|
||||
f->fmtaddr(htonl(s->ip), 0));
|
||||
|
||||
f->log(3, sess, s->tunnel, "%s\n", cmd);
|
||||
system(cmd);
|
||||
s->walled_garden = 1;
|
||||
}
|
||||
|
|
@ -193,26 +201,33 @@ int garden_session(sessiont *s, int flag, char *newuser)
|
|||
int count = 40;
|
||||
|
||||
// Normal User
|
||||
p->log(2, sess, s->tunnel, "Un-Garden user %s (%s)\n", s->user, p->fmtaddr(htonl(s->ip), 0));
|
||||
f->log(2, sess, s->tunnel, "Un-Garden user %s (%s)\n", s->user, f->fmtaddr(htonl(s->ip), 0));
|
||||
if (newuser)
|
||||
{
|
||||
snprintf(s->user, MAXUSER, "%s", newuser);
|
||||
p->log(2, sess, s->tunnel, " Setting username to %s\n", s->user);
|
||||
f->log(2, sess, s->tunnel, " Setting username to %s\n", s->user);
|
||||
}
|
||||
|
||||
// Kick off any duplicate usernames
|
||||
// but make sure not to kick off ourself
|
||||
if (s->ip && !s->die && (other = p->get_session_by_username(s->user)) && s != p->get_session_by_id(other)) {
|
||||
p->sessionkill(other, "Duplicate session when user released from walled garden");
|
||||
if (s->ip && !s->die && (other = f->get_session_by_username(s->user)) &&
|
||||
s != f->get_session_by_id(other))
|
||||
{
|
||||
f->sessionkill(other,
|
||||
"Duplicate session when user released from walled garden");
|
||||
}
|
||||
|
||||
/* Clean up counters */
|
||||
s->pin = s->pout = 0;
|
||||
s->cin = s->cout = 0;
|
||||
s->cin_delta = s->cout_delta = 0;
|
||||
s->cin_wrap = s->cout_wrap = 0;
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "iptables -t nat -D garden_users -s %s -j garden", p->fmtaddr(htonl(s->ip), 0));
|
||||
p->log(3, sess, s->tunnel, "%s\n", cmd);
|
||||
snprintf(cmd, sizeof(cmd),
|
||||
"iptables -t nat -D garden_users -s %s -j garden",
|
||||
f->fmtaddr(htonl(s->ip), 0));
|
||||
|
||||
f->log(3, sess, s->tunnel, "%s\n", cmd);
|
||||
while (--count)
|
||||
{
|
||||
int status = system(cmd);
|
||||
|
|
@ -224,8 +239,8 @@ int garden_session(sessiont *s, int flag, char *newuser)
|
|||
if (flag != F_CLEANUP)
|
||||
{
|
||||
/* OK, we're up! */
|
||||
uint16_t r = p->radiusnew(p->get_id_by_session(s));
|
||||
if (r) p->radiussend(r, RADIUSSTART);
|
||||
uint16_t r = f->radiusnew(f->get_id_by_session(s));
|
||||
if (r) f->radiussend(r, RADIUSSTART);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -240,7 +255,7 @@ int plugin_init(struct pluginfuncs *funcs)
|
|||
if (!funcs)
|
||||
return 0;
|
||||
|
||||
p = funcs;
|
||||
f = funcs;
|
||||
|
||||
if ((tables = fopen("/proc/net/ip_tables_names", "r")))
|
||||
{
|
||||
|
|
@ -257,7 +272,7 @@ int plugin_init(struct pluginfuncs *funcs)
|
|||
int i;
|
||||
for (i = 0; down_commands[i] && *down_commands[i]; i++)
|
||||
{
|
||||
p->log(3, 0, 0, "Running %s\n", down_commands[i]);
|
||||
f->log(3, 0, 0, "Running %s\n", down_commands[i]);
|
||||
system(down_commands[i]);
|
||||
}
|
||||
}
|
||||
|
|
@ -274,7 +289,7 @@ void plugin_done()
|
|||
|
||||
for (i = 0; down_commands[i] && *down_commands[i]; i++)
|
||||
{
|
||||
p->log(3, 0, 0, "Running %s\n", down_commands[i]);
|
||||
f->log(3, 0, 0, "Running %s\n", down_commands[i]);
|
||||
system(down_commands[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
3
l2tpns.c
3
l2tpns.c
|
|
@ -4,7 +4,7 @@
|
|||
// Copyright (c) 2002 FireBrick (Andrews & Arnold Ltd / Watchfront Ltd) - GPL licenced
|
||||
// vim: sw=8 ts=8
|
||||
|
||||
char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.143 2005/10/11 07:06:56 bodea Exp $";
|
||||
char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.144 2005/10/11 09:04:53 bodea Exp $";
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <assert.h>
|
||||
|
|
@ -162,6 +162,7 @@ static char *plugin_functions[] = {
|
|||
"plugin_control",
|
||||
"plugin_radius_response",
|
||||
"plugin_radius_reset",
|
||||
"plugin_radius_account",
|
||||
"plugin_become_master",
|
||||
"plugin_new_session_master",
|
||||
};
|
||||
|
|
|
|||
8
plugin.h
8
plugin.h
|
|
@ -16,6 +16,7 @@ enum
|
|||
PLUGIN_CONTROL,
|
||||
PLUGIN_RADIUS_RESPONSE,
|
||||
PLUGIN_RADIUS_RESET,
|
||||
PLUGIN_RADIUS_ACCOUNT,
|
||||
PLUGIN_BECOME_MASTER,
|
||||
PLUGIN_NEW_SESSION_MASTER,
|
||||
};
|
||||
|
|
@ -118,4 +119,11 @@ struct param_radius_reset
|
|||
sessiont *s;
|
||||
};
|
||||
|
||||
struct param_radius_account
|
||||
{
|
||||
tunnelt *t;
|
||||
sessiont *s;
|
||||
uint8_t **packet;
|
||||
};
|
||||
|
||||
#endif /* __PLUGIN_H__ */
|
||||
|
|
|
|||
15
radius.c
15
radius.c
|
|
@ -1,6 +1,6 @@
|
|||
// L2TPNS Radius Stuff
|
||||
|
||||
char const *cvs_id_radius = "$Id: radius.c,v 1.43 2005/10/11 02:27:40 foonly Exp $";
|
||||
char const *cvs_id_radius = "$Id: radius.c,v 1.44 2005/10/11 09:04:53 bodea Exp $";
|
||||
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
|
|
@ -304,18 +304,11 @@ void radiussend(uint16_t r, uint8_t state)
|
|||
p[1] = 6;
|
||||
*(uint32_t *) (p + 2) = htonl(session[s].cout_wrap);
|
||||
p += p[1];
|
||||
}
|
||||
|
||||
if (session[s].snoop_ip && session[s].snoop_port)
|
||||
{
|
||||
*p = 26; // vendor-specific
|
||||
*(uint32_t *) (p + 2) = htonl(9); // Cisco
|
||||
p[6] = 1; // Cisco-AVPair
|
||||
p[7] = 2 + sprintf((char *) p + 8, "intercept=%s:%d",
|
||||
fmtaddr(session[s].snoop_ip, 0), session[s].snoop_port);
|
||||
|
||||
p[1] = p[7] + 6;
|
||||
p += p[1];
|
||||
struct param_radius_account acct = { &tunnel[session[s].tunnel], &session[s], &p };
|
||||
run_plugins(PLUGIN_RADIUS_ACCOUNT, &acct);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
14
sessionctl.c
14
sessionctl.c
|
|
@ -5,10 +5,10 @@
|
|||
|
||||
/* session control */
|
||||
|
||||
char const *cvs_id = "$Id: sessionctl.c,v 1.3 2005/06/28 14:48:28 bodea Exp $";
|
||||
char const *cvs_id = "$Id: sessionctl.c,v 1.4 2005/10/11 09:04:53 bodea Exp $";
|
||||
|
||||
int plugin_api_version = PLUGIN_API_VERSION;
|
||||
static struct pluginfuncs *p = 0;
|
||||
static struct pluginfuncs *f = 0;
|
||||
|
||||
char *plugin_control_help[] = {
|
||||
" drop USER|SID [REASON] Shutdown user session",
|
||||
|
|
@ -40,10 +40,10 @@ int plugin_control(struct param_control *data)
|
|||
}
|
||||
|
||||
if (!(session = strtol(data->argv[1], &end, 10)) || *end)
|
||||
session = p->get_session_by_username(data->argv[1]);
|
||||
session = f->get_session_by_username(data->argv[1]);
|
||||
|
||||
if (session)
|
||||
s = p->get_session_by_id(session);
|
||||
s = f->get_session_by_id(session);
|
||||
|
||||
if (!s || !s->ip)
|
||||
{
|
||||
|
|
@ -58,9 +58,9 @@ int plugin_control(struct param_control *data)
|
|||
reason = "Requested by administrator.";
|
||||
|
||||
if (data->argv[0][0] == 'd')
|
||||
p->sessionshutdown(session, reason, 3, 0);
|
||||
f->sessionshutdown(session, reason, 3, 0);
|
||||
else
|
||||
p->sessionkill(session, reason);
|
||||
f->sessionkill(session, reason);
|
||||
|
||||
data->response = NSCTL_RES_OK;
|
||||
data->additional = 0;
|
||||
|
|
@ -70,5 +70,5 @@ int plugin_control(struct param_control *data)
|
|||
|
||||
int plugin_init(struct pluginfuncs *funcs)
|
||||
{
|
||||
return ((p = funcs)) ? 1 : 0;
|
||||
return ((f = funcs)) ? 1 : 0;
|
||||
}
|
||||
|
|
|
|||
24
setrxspeed.c
24
setrxspeed.c
|
|
@ -4,34 +4,38 @@
|
|||
|
||||
/* fudge up session rx speed if not set */
|
||||
|
||||
char const *cvs_id = "$Id: setrxspeed.c,v 1.3 2004/11/17 08:23:35 bodea Exp $";
|
||||
char const *cvs_id = "$Id: setrxspeed.c,v 1.4 2005/10/11 09:04:53 bodea Exp $";
|
||||
|
||||
int plugin_api_version = PLUGIN_API_VERSION;
|
||||
static struct pluginfuncs *p = 0;
|
||||
static struct pluginfuncs *f = 0;
|
||||
|
||||
int plugin_post_auth(struct param_post_auth *data)
|
||||
{
|
||||
if (!data->auth_allowed) return PLUGIN_RET_OK;
|
||||
if (!data->auth_allowed)
|
||||
return PLUGIN_RET_OK;
|
||||
|
||||
if (data->s->rx_connect_speed)
|
||||
return PLUGIN_RET_OK;
|
||||
|
||||
if (!data->s->rx_connect_speed)
|
||||
{
|
||||
switch (data->s->tx_connect_speed)
|
||||
{
|
||||
case 256 :
|
||||
case 256:
|
||||
data->s->rx_connect_speed = 64;
|
||||
break;
|
||||
case 512 :
|
||||
|
||||
case 512:
|
||||
data->s->rx_connect_speed = 128;
|
||||
break;
|
||||
case 1500 :
|
||||
|
||||
case 1500:
|
||||
data->s->rx_connect_speed = 256;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return PLUGIN_RET_OK;
|
||||
}
|
||||
|
||||
int plugin_init(struct pluginfuncs *funcs)
|
||||
{
|
||||
return ((p = funcs)) ? 1 : 0;
|
||||
return ((f = funcs)) ? 1 : 0;
|
||||
}
|
||||
|
|
|
|||
12
snoopctl.c
12
snoopctl.c
|
|
@ -5,10 +5,10 @@
|
|||
|
||||
/* snoop control */
|
||||
|
||||
char const *cvs_id = "$Id: snoopctl.c,v 1.6 2005/10/11 07:59:09 bodea Exp $";
|
||||
char const *cvs_id = "$Id: snoopctl.c,v 1.7 2005/10/11 09:04:53 bodea Exp $";
|
||||
|
||||
int plugin_api_version = PLUGIN_API_VERSION;
|
||||
static struct pluginfuncs *p = 0;
|
||||
static struct pluginfuncs *f = 0;
|
||||
|
||||
char *plugin_control_help[] = {
|
||||
" snoop USER|SID IP PORT Intercept user traffic",
|
||||
|
|
@ -54,10 +54,10 @@ int plugin_control(struct param_control *data)
|
|||
}
|
||||
|
||||
if (!(session = strtol(data->argv[1], &end, 10)) || *end)
|
||||
session = p->get_session_by_username(data->argv[1]);
|
||||
session = f->get_session_by_username(data->argv[1]);
|
||||
|
||||
if (session)
|
||||
s = p->get_session_by_id(session);
|
||||
s = f->get_session_by_id(session);
|
||||
|
||||
if (!s || !s->ip)
|
||||
{
|
||||
|
|
@ -108,7 +108,7 @@ int plugin_control(struct param_control *data)
|
|||
s->snoop_port = 0;
|
||||
}
|
||||
|
||||
p->session_changed(session);
|
||||
f->session_changed(session);
|
||||
|
||||
data->response = NSCTL_RES_OK;
|
||||
data->additional = 0;
|
||||
|
|
@ -118,5 +118,5 @@ int plugin_control(struct param_control *data)
|
|||
|
||||
int plugin_init(struct pluginfuncs *funcs)
|
||||
{
|
||||
return ((p = funcs)) ? 1 : 0;
|
||||
return ((f = funcs)) ? 1 : 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,22 +4,22 @@
|
|||
|
||||
/* strip domain part of username before sending RADIUS requests */
|
||||
|
||||
char const *cvs_id = "$Id: stripdomain.c,v 1.7 2004/11/29 02:17:18 bodea Exp $";
|
||||
char const *cvs_id = "$Id: stripdomain.c,v 1.8 2005/10/11 09:04:53 bodea Exp $";
|
||||
|
||||
int plugin_api_version = PLUGIN_API_VERSION;
|
||||
static struct pluginfuncs *p = 0;
|
||||
static struct pluginfuncs *f = 0;
|
||||
|
||||
int plugin_pre_auth(struct param_pre_auth *data)
|
||||
{
|
||||
char *x;
|
||||
char *p;
|
||||
|
||||
if (!data->continue_auth) return PLUGIN_RET_STOP;
|
||||
|
||||
// Strip off @domain
|
||||
if ((x = strchr(data->username, '@')))
|
||||
if ((p = strchr(data->username, '@')))
|
||||
{
|
||||
p->log(3, 0, 0, "Stripping off trailing domain name \"%s\"\n", x);
|
||||
*x = 0;
|
||||
f->log(3, 0, 0, "Stripping off trailing domain name \"%s\"\n", p);
|
||||
*p = 0;
|
||||
}
|
||||
|
||||
return PLUGIN_RET_OK;
|
||||
|
|
@ -27,5 +27,5 @@ int plugin_pre_auth(struct param_pre_auth *data)
|
|||
|
||||
int plugin_init(struct pluginfuncs *funcs)
|
||||
{
|
||||
return ((p = funcs)) ? 1 : 0;
|
||||
return ((f = funcs)) ? 1 : 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@
|
|||
|
||||
/* throttle control */
|
||||
|
||||
char const *cvs_id = "$Id: throttlectl.c,v 1.8 2005/10/11 07:59:09 bodea Exp $";
|
||||
char const *cvs_id = "$Id: throttlectl.c,v 1.9 2005/10/11 09:04:53 bodea Exp $";
|
||||
|
||||
int plugin_api_version = PLUGIN_API_VERSION;
|
||||
static struct pluginfuncs *p = 0;
|
||||
static struct pluginfuncs *f = 0;
|
||||
|
||||
char *plugin_control_help[] = {
|
||||
" throttle USER|SID [RATE|[in|out] RATE ...] Throttle user traffic",
|
||||
|
|
@ -28,8 +28,8 @@ int plugin_control(struct param_control *data)
|
|||
if (data->argc < 1)
|
||||
return PLUGIN_RET_OK;
|
||||
|
||||
if (strcmp(data->argv[0], "throttle")
|
||||
&& strcmp(data->argv[0], "unthrottle"))
|
||||
if (strcmp(data->argv[0], "throttle") &&
|
||||
strcmp(data->argv[0], "unthrottle"))
|
||||
return PLUGIN_RET_OK; // not for us
|
||||
|
||||
if (!data->iam_master)
|
||||
|
|
@ -57,10 +57,10 @@ int plugin_control(struct param_control *data)
|
|||
}
|
||||
|
||||
if (!(session = strtol(data->argv[1], &end, 10)) || *end)
|
||||
session = p->get_session_by_username(data->argv[1]);
|
||||
session = f->get_session_by_username(data->argv[1]);
|
||||
|
||||
if (session)
|
||||
s = p->get_session_by_id(session);
|
||||
s = f->get_session_by_id(session);
|
||||
|
||||
if (!s || !s->ip)
|
||||
{
|
||||
|
|
@ -74,7 +74,7 @@ int plugin_control(struct param_control *data)
|
|||
rate_in = rate_out = -1;
|
||||
if (data->argc == 2)
|
||||
{
|
||||
unsigned long *rate = p->getconfig("throttle_speed", UNSIGNED_LONG);
|
||||
unsigned long *rate = f->getconfig("throttle_speed", UNSIGNED_LONG);
|
||||
rate_in = rate_out = *rate;
|
||||
}
|
||||
else if (data->argc == 3)
|
||||
|
|
@ -120,8 +120,8 @@ int plugin_control(struct param_control *data)
|
|||
return PLUGIN_RET_STOP;
|
||||
}
|
||||
|
||||
p->throttle(session, rate_in, rate_out);
|
||||
p->session_changed(session);
|
||||
f->throttle(session, rate_in, rate_out);
|
||||
f->session_changed(session);
|
||||
|
||||
data->response = NSCTL_RES_OK;
|
||||
data->additional = 0;
|
||||
|
|
@ -131,5 +131,5 @@ int plugin_control(struct param_control *data)
|
|||
|
||||
int plugin_init(struct pluginfuncs *funcs)
|
||||
{
|
||||
return ((p = funcs)) ? 1 : 0;
|
||||
return ((f = funcs)) ? 1 : 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue