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