1N/A/*
1N/A * minconn.c - pppd plugin to implement a `minconnect' option.
1N/A *
1N/A * Copyright 1999 Paul Mackerras.
1N/A *
1N/A * This program is free software; you can redistribute it and/or
1N/A * modify it under the terms of the GNU General Public License
1N/A * as published by the Free Software Foundation; either version
1N/A * 2 of the License, or (at your option) any later version.
1N/A */
1N/A#include <stddef.h>
1N/A#include <time.h>
1N/A#include "pppd.h"
1N/A
1N/Astatic int minconnect = 0;
1N/A
1N/Astatic option_t my_options[] = {
1N/A { "minconnect", o_int, &minconnect,
1N/A "Set minimum connect time before idle timeout applies" },
1N/A { NULL }
1N/A};
1N/A
1N/Astatic int my_get_idle(struct ppp_idle *idle)
1N/A{
1N/A time_t t;
1N/A
1N/A if (idle == NULL)
1N/A return minconnect? minconnect: idle_time_limit;
1N/A t = idle->xmit_idle;
1N/A if (idle->recv_idle < t)
1N/A t = idle->recv_idle;
1N/A return idle_time_limit - t;
1N/A}
1N/A
1N/Avoid plugin_init(void)
1N/A{
1N/A info("plugin_init");
1N/A add_options(my_options);
1N/A idle_time_hook = my_get_idle;
1N/A}