CPU: Wrong CPU Load %.
[tomato.git] / release / src / router / ppp / pppd / plugins / minconn.c
blob02ea34bf6a31159cd2ecf1eb6926fa104918bdaf
1 /*
2 * minconn.c - pppd plugin to implement a `minconnect' option.
4 * Copyright 1999 Paul Mackerras.
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.
15 #include <stddef.h>
16 #include <time.h>
17 #include "pppd.h"
19 char pppd_version[] = VERSION;
21 static int minconnect = 0;
23 static option_t my_options[] = {
24 { "minconnect", o_int, &minconnect,
25 "Set minimum connect time before idle timeout applies" },
26 { NULL }
29 static int my_get_idle(struct ppp_idle *idle)
31 time_t t;
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;
41 void plugin_init(void)
43 info("plugin_init");
44 add_options(my_options);
45 idle_time_hook = my_get_idle;