cmd-inet: link pppd plugins passprompt,pppoe with -lc
[unleashed.git] / usr / src / cmd / cmd-inet / usr.bin / pppd / plugins / minconn.c
blob8c9354ebd364ea98d2d558cbe3b857e3289b6915
1 /*
2 * minconn.c - pppd plugin to implement a `minconnect' option.
4 * Copyright 1999 Paul Mackerras.
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.
11 #include <stddef.h>
12 #include <time.h>
13 #include "pppd.h"
15 static int minconnect = 0;
17 static option_t my_options[] = {
18 { "minconnect", o_int, &minconnect,
19 "Set minimum connect time before idle timeout applies" },
20 { NULL }
23 static int my_get_idle(struct ppp_idle *idle)
25 time_t t;
27 if (idle == NULL)
28 return minconnect? minconnect: idle_time_limit;
29 t = idle->xmit_idle;
30 if (idle->recv_idle < t)
31 t = idle->recv_idle;
32 return idle_time_limit - t;
35 void plugin_init(void)
37 info("plugin_init");
38 add_options(my_options);
39 idle_time_hook = my_get_idle;