]> git.ozlabs.org Git - ppp.git/blob - pppd/plugins/minconn.c
Make the example plugins here export the version number that they
[ppp.git] / pppd / plugins / minconn.c
1 /*
2  * minconn.c - pppd plugin to implement a `minconnect' option.
3  *
4  * Copyright 1999 Paul Mackerras.
5  *
6  *  This program is free software; you can redistribute it and/or
7  *  modify it under the terms of the GNU General Public License
8  *  as published by the Free Software Foundation; either version
9  *  2 of the License, or (at your option) any later version.
10  */
11 #include <stddef.h>
12 #include <time.h>
13 #include "pppd.h"
14
15 char pppd_version[] = VERSION;
16
17 static int minconnect = 0;
18
19 static option_t my_options[] = {
20         { "minconnect", o_int, &minconnect,
21           "Set minimum connect time before idle timeout applies" },
22         { NULL }
23 };
24
25 static int my_get_idle(struct ppp_idle *idle)
26 {
27         time_t t;
28
29         if (idle == NULL)
30                 return minconnect? minconnect: idle_time_limit;
31         t = idle->xmit_idle;
32         if (idle->recv_idle < t)
33                 t = idle->recv_idle;
34         return idle_time_limit - t;
35 }
36
37 void plugin_init(void)
38 {
39         info("plugin_init");
40         add_options(my_options);
41         idle_time_hook = my_get_idle;
42 }