add sessionctl
This commit is contained in:
parent
092cd4db4e
commit
f0aa42be04
6 changed files with 93 additions and 11 deletions
3
Changes
3
Changes
|
|
@ -1,4 +1,4 @@
|
|||
* Mon May 9 2005 Brendan O'Dea <bod@optusnet.com.au> 2.1.0
|
||||
* Tue May 10 2005 Brendan O'Dea <bod@optusnet.com.au> 2.1.0
|
||||
- Add IPv6 support from Jonathan McDowell.
|
||||
- Add CHAP support from Jordan Hrycaj.
|
||||
- Add interim accounting support from Vladislav Bjelic.
|
||||
|
|
@ -60,6 +60,7 @@
|
|||
master kills all slaves once restarted).
|
||||
- Make "show running-config" a privileged command (contains clear text
|
||||
shared secrets).
|
||||
- Add sessionctl plugin to provide drop/kill via nsctl.
|
||||
|
||||
* Fri Dec 17 2004 Brendan O'Dea <bod@optusnet.com.au> 2.0.13
|
||||
- Better cluster master collision resolution: keep a counter of state
|
||||
|
|
|
|||
15
Makefile
15
Makefile
|
|
@ -29,8 +29,8 @@ OBJS = arp.o cli.o cluster.o constants.o control.o icmp.o l2tpns.o \
|
|||
ll.o md5.o ppp.o radius.o tbf.o util.o
|
||||
|
||||
PROGRAMS = l2tpns nsctl
|
||||
PLUGINS = garden.so throttlectl.so autothrottle.so snoopctl.so \
|
||||
autosnoop.so stripdomain.so setrxspeed.so
|
||||
PLUGINS = autosnoop.so autothrottle.so garden.so sessionctl.so \
|
||||
setrxspeed.so snoopctl.so stripdomain.so throttlectl.so
|
||||
|
||||
TESTS = generateload bounce
|
||||
|
||||
|
|
@ -127,10 +127,11 @@ radius.o: radius.c md5.h constants.h l2tpns.h plugin.h util.h
|
|||
tbf.o: tbf.c l2tpns.h util.h tbf.h
|
||||
util.o: util.c l2tpns.h bgp.h
|
||||
bgp.o: bgp.c l2tpns.h bgp.h util.h
|
||||
garden.so: garden.c l2tpns.h plugin.h control.h
|
||||
throttlectl.so: throttlectl.c l2tpns.h plugin.h control.h
|
||||
autothrottle.so: autothrottle.c l2tpns.h plugin.h
|
||||
snoopctl.so: snoopctl.c l2tpns.h plugin.h control.h
|
||||
autosnoop.so: autosnoop.c l2tpns.h plugin.h
|
||||
stripdomain.so: stripdomain.c l2tpns.h plugin.h
|
||||
autothrottle.so: autothrottle.c l2tpns.h plugin.h
|
||||
garden.so: garden.c l2tpns.h plugin.h control.h
|
||||
sessionctl.so: sessionctl.c l2tpns.h plugin.h control.h
|
||||
setrxspeed.so: setrxspeed.c l2tpns.h plugin.h
|
||||
snoopctl.so: snoopctl.c l2tpns.h plugin.h control.h
|
||||
stripdomain.so: stripdomain.c l2tpns.h plugin.h
|
||||
throttlectl.so: throttlectl.c l2tpns.h plugin.h control.h
|
||||
|
|
|
|||
|
|
@ -13,8 +13,9 @@ set throttle_speed 64
|
|||
set accounting_dir "/var/run/l2tpns/acct"
|
||||
set setuid 0
|
||||
set dump_speed no
|
||||
load plugin "garden"
|
||||
load plugin "sessionctl"
|
||||
load plugin "throttlectl"
|
||||
load plugin "autothrottle"
|
||||
load plugin "snoopctl"
|
||||
load plugin "autosnoop"
|
||||
load plugin "garden"
|
||||
|
|
|
|||
|
|
@ -43,5 +43,5 @@ rm -rf %{buildroot}
|
|||
%attr(644,root,root) /usr/share/man/man[58]/*
|
||||
|
||||
%changelog
|
||||
* Mon May 9 2005 Brendan O'Dea <bod@optusnet.com.au> 2.1.0-1
|
||||
* Tue May 10 2005 Brendan O'Dea <bod@optusnet.com.au> 2.1.0-1
|
||||
- 2.1.0 release, see /usr/share/doc/l2tpns-2.1.0/Changes
|
||||
|
|
|
|||
3
plugin.h
3
plugin.h
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef __PLUGIN_H__
|
||||
#define __PLUGIN_H__
|
||||
|
||||
#define PLUGIN_API_VERSION 4
|
||||
#define PLUGIN_API_VERSION 5
|
||||
#define MAX_PLUGIN_TYPES 30
|
||||
|
||||
enum
|
||||
|
|
@ -35,6 +35,7 @@ struct pluginfuncs
|
|||
uint16_t (*radiusnew)(sessionidt s);
|
||||
void (*radiussend)(uint16_t r, uint8_t state);
|
||||
void *(*getconfig)(char *key, enum config_typet type);
|
||||
void (*sessionshutdown)(sessionidt s, char *reason, int result, int error);
|
||||
void (*sessionkill)(sessionidt s, char *reason);
|
||||
void (*throttle)(sessionidt s, int rate_in, int rate_out);
|
||||
int (*session_changed)(int sid);
|
||||
|
|
|
|||
78
sessionctl.c
Normal file
78
sessionctl.c
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
#include <string.h>
|
||||
#include "l2tpns.h"
|
||||
#include "plugin.h"
|
||||
#include "control.h"
|
||||
|
||||
/* session control */
|
||||
|
||||
char const *cvs_id = "$Id: sessionctl.c,v 1.1 2005-05-10 06:44:11 bodea Exp $";
|
||||
|
||||
int plugin_api_version = PLUGIN_API_VERSION;
|
||||
static struct pluginfuncs *p = 0;
|
||||
|
||||
char *plugin_control_help[] = {
|
||||
" drop USER|SID [REASON] Shutdown user session",
|
||||
" kill USER|SID [REASON] Kill user session",
|
||||
0
|
||||
};
|
||||
|
||||
int plugin_init(struct pluginfuncs *funcs)
|
||||
{
|
||||
if (!funcs)
|
||||
return 0;
|
||||
|
||||
p = funcs;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int plugin_control(struct param_control *data)
|
||||
{
|
||||
sessionidt session;
|
||||
sessiont *s = 0;
|
||||
char *end;
|
||||
char *reason;
|
||||
|
||||
if (data->argc < 1)
|
||||
return PLUGIN_RET_OK;
|
||||
|
||||
if (strcmp(data->argv[0], "drop") && strcmp(data->argv[0], "kill"))
|
||||
return PLUGIN_RET_OK; // not for us
|
||||
|
||||
if (!data->iam_master)
|
||||
return PLUGIN_RET_NOTMASTER;
|
||||
|
||||
if (data->argc < 2 || data->argc > 3)
|
||||
{
|
||||
data->response = NSCTL_RES_ERR;
|
||||
data->additional = "requires username or session id and optional reason";
|
||||
return PLUGIN_RET_STOP;
|
||||
}
|
||||
|
||||
if (!(session = strtol(data->argv[1], &end, 10)) || *end)
|
||||
session = p->get_session_by_username(data->argv[1]);
|
||||
|
||||
if (session)
|
||||
s = p->get_session_by_id(session);
|
||||
|
||||
if (!s || !s->ip)
|
||||
{
|
||||
data->response = NSCTL_RES_ERR;
|
||||
data->additional = "session not found";
|
||||
return PLUGIN_RET_STOP;
|
||||
}
|
||||
|
||||
if (data->argc > 2)
|
||||
reason = data->argv[2];
|
||||
else
|
||||
reaons = "Requested by administrator.";
|
||||
|
||||
if (data->argv[0][0] == 'd')
|
||||
p->sessionshutdown(session, reason, 3, 0);
|
||||
else
|
||||
p->sessionkill(session, reason);
|
||||
|
||||
data->response = NSCTL_RES_OK;
|
||||
data->additional = 0;
|
||||
|
||||
return PLUGIN_RET_STOP;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue