1/*
2 * minconn.c - pppd plugin to implement a `minconnect' option.
3 *
4 * Copyright 1999 Paul Mackerras.
5 *
6 * Redistribution and use in source and binary forms are permitted
7 * provided that the above copyright notice and this paragraph are
8 * duplicated in all such forms.  The name of the author
9 * may not be used to endorse or promote products derived
10 * from this software without specific prior written permission.
11 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
12 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
13 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14 */
15#include <stddef.h>
16#include <time.h>
17#include "pppd.h"
18
19char pppd_version[] = VERSION;
20
21static int minconnect = 0;
22
23static option_t my_options[] = {
24	{ "minconnect", o_int, &minconnect,
25	  "Set minimum connect time before idle timeout applies" },
26	{ NULL }
27};
28
29static int my_get_idle(struct ppp_idle *idle)
30{
31	time_t t;
32
33	if (idle == NULL)
34		return minconnect? minconnect: idle_time_limit;
35	t = idle->xmit_idle;
36	if (idle->recv_idle < t)
37		t = idle->recv_idle;
38	return idle_time_limit - t;
39}
40
41void plugin_init(void)
42{
43	info("plugin_init");
44	add_options(my_options);
45	idle_time_hook = my_get_idle;
46}
47