From: Paul Mackerras Date: Sat, 11 Sep 1999 12:13:11 +0000 (+0000) Subject: add an example plugin X-Git-Tag: ppp-2.4.7~637 X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=commitdiff_plain;h=97c99cb3b52be24977c72445766efdec1464b8f5;ds=sidebyside add an example plugin --- diff --git a/pppd/plugins/Makefile b/pppd/plugins/Makefile new file mode 100644 index 0000000..b33ab27 --- /dev/null +++ b/pppd/plugins/Makefile @@ -0,0 +1,8 @@ +CC = gcc +CFLAGS = -g -O2 -I.. -I../../include +LDFLAGS = -shared + +all: minconn.so + +minconn.so: minconn.c + $(CC) -o $@ $(LDFLAGS) $(CFLAGS) minconn.c diff --git a/pppd/plugins/minconn.c b/pppd/plugins/minconn.c new file mode 100644 index 0000000..8c9354e --- /dev/null +++ b/pppd/plugins/minconn.c @@ -0,0 +1,40 @@ +/* + * minconn.c - pppd plugin to implement a `minconnect' option. + * + * Copyright 1999 Paul Mackerras. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ +#include +#include +#include "pppd.h" + +static int minconnect = 0; + +static option_t my_options[] = { + { "minconnect", o_int, &minconnect, + "Set minimum connect time before idle timeout applies" }, + { NULL } +}; + +static int my_get_idle(struct ppp_idle *idle) +{ + time_t t; + + if (idle == NULL) + return minconnect? minconnect: idle_time_limit; + t = idle->xmit_idle; + if (idle->recv_idle < t) + t = idle->recv_idle; + return idle_time_limit - t; +} + +void plugin_init(void) +{ + info("plugin_init"); + add_options(my_options); + idle_time_hook = my_get_idle; +}