From 97b796f5a5ec6a4d14757c87885cd0f6bfdf6d5c Mon Sep 17 00:00:00 2001 From: bodea Date: Fri, 5 Nov 2004 02:38:59 +0000 Subject: [PATCH] add setrxspeed --- Makefile | 3 ++- setrxspeed.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 setrxspeed.c diff --git a/Makefile b/Makefile index d5c9a48..90432c9 100644 --- a/Makefile +++ b/Makefile @@ -44,7 +44,7 @@ OBJS = arp.o \ tbf.o \ util.o -PLUGINS = garden.so autothrottle.so autosnoop.so stripdomain.so +PLUGINS = garden.so autothrottle.so autosnoop.so stripdomain.so setrxspeed.so TARGETS = l2tpns nsctl generateload bounce $(PLUGINS) all: $(TARGETS) @@ -126,3 +126,4 @@ garden.so: garden.c l2tpns.h plugin.h control.h autothrottle.so: autothrottle.c l2tpns.h plugin.h control.h autosnoop.so: autosnoop.c l2tpns.h plugin.h control.h stripdomain.so: stripdomain.c l2tpns.h plugin.h +setrxspeed.so: setrxspeed.c l2tpns.h plugin.h diff --git a/setrxspeed.c b/setrxspeed.c new file mode 100644 index 0000000..2035ca4 --- /dev/null +++ b/setrxspeed.c @@ -0,0 +1,37 @@ +#include +#include "l2tpns.h" +#include "plugin.h" + +/* fudge up session rx speed if not set */ + +char const *cvs_id = "$Id: setrxspeed.c,v 1.1 2004/11/05 02:38:59 bodea Exp $"; + +int __plugin_api_version = 1; +static struct pluginfuncs *p = 0; + +int plugin_post_auth(struct param_post_auth *data) +{ + if (!data->auth_allowed) return PLUGIN_RET_OK; + + if (!data->s->rx_connect_speed) + { + switch (data->s->tx_connect_speed) + { + case 256 : + data->s->rx_connect_speed = 64; + break; + case 512 : + data->s->rx_connect_speed = 128; + break; + case 1500 : + data->s->rx_connect_speed = 256; + break; + } + } + return PLUGIN_RET_OK; +} + +int plugin_init(struct pluginfuncs *funcs) +{ + return ((p = funcs)) ? 1 : 0; +} -- 2.20.1