diff -ru ppp-2.4.2/pppd/auth.c ppp-2.4.2.sigalrm/pppd/auth.c --- ppp-2.4.2/pppd/auth.c 2003-06-11 18:56:26.000000000 -0500 +++ ppp-2.4.2.sigalrm/pppd/auth.c 2005-08-13 19:57:25.000000000 -0500 @@ -1053,6 +1053,10 @@ itime = MIN(idle.xmit_idle, idle.recv_idle); tlim = idle_time_limit - itime; } + if (extidle) { + itime = time() - reset_time; + tlim = idle_time_limit - itime; + } if (tlim <= 0) { /* link is idle: shut it down. */ notice("Terminating connection due to lack of activity."); diff -ru ppp-2.4.2/pppd/main.c ppp-2.4.2.sigalrm/pppd/main.c --- ppp-2.4.2/pppd/main.c 2004-01-12 22:00:34.000000000 -0600 +++ ppp-2.4.2.sigalrm/pppd/main.c 2005-08-13 20:23:04.000000000 -0500 @@ -149,6 +149,7 @@ int got_sigusr2; int got_sigterm; int got_sighup; +int got_sigalrm; static int waiting; static sigjmp_buf sigjmp; @@ -204,6 +205,7 @@ static void hup __P((int)); static void term __P((int)); static void chld __P((int)); +static void alrm __P((int)); static void toggle_debug __P((int)); static void open_ccp __P((int)); static void bad_signal __P((int)); @@ -721,13 +723,13 @@ SIGNAL(SIGUSR1, toggle_debug); /* Toggle debug flag */ SIGNAL(SIGUSR2, open_ccp); /* Reopen CCP */ + SIGNAL(SIGALRM, alrm); /* Reset activity timer */ /* * Install a handler for other signals which would otherwise * cause pppd to exit without cleaning up. */ SIGNAL(SIGABRT, bad_signal); - SIGNAL(SIGALRM, bad_signal); SIGNAL(SIGFPE, bad_signal); SIGNAL(SIGILL, bad_signal); SIGNAL(SIGPIPE, bad_signal); @@ -1402,6 +1404,18 @@ /* + * alrm - Catch SIGALRM signal. + * Resets external timeout timer. + */ +static void +alrm(sig) + int sig; +{ + got_sigalrm = 1; + reset_time = time(); +} + +/* * toggle_debug - Catch SIGUSR1 signal. * * Toggle debug flag. diff -ru ppp-2.4.2/pppd/options.c ppp-2.4.2.sigalrm/pppd/options.c --- ppp-2.4.2/pppd/options.c 2004-01-12 22:02:07.000000000 -0600 +++ ppp-2.4.2.sigalrm/pppd/options.c 2005-08-13 20:13:33.000000000 -0500 @@ -219,6 +219,8 @@ { "demand", o_bool, &demand, "Dial on demand", OPT_INITONLY | 1, &persist }, + { "external-filter", o_bool, &extidle, + "Use SIGALRM to wake up demand timer", OPT_INITONLY | 1}, { "--version", o_special_noarg, (void *)showversion, "Show version number" }, diff -ru ppp-2.4.2/pppd/pppd.h ppp-2.4.2.sigalrm/pppd/pppd.h --- ppp-2.4.2/pppd/pppd.h 2003-04-06 19:01:46.000000000 -0500 +++ ppp-2.4.2.sigalrm/pppd/pppd.h 2005-08-13 20:13:46.000000000 -0500 @@ -245,6 +245,7 @@ extern int ppp_session_number; /* Session number (eg PPPoE session) */ extern int listen_time; /* time to listen first (ms) */ +extern time_t reset_time; /* time of last SIGALRM */ extern struct notifier *pidchange; /* for notifications of pid changing */ extern struct notifier *phasechange; /* for notifications of phase changes */ extern struct notifier *exitnotify; /* for notification that we're exiting */ @@ -289,6 +290,7 @@ extern char remote_name[MAXNAMELEN]; /* Peer's name for authentication */ extern bool explicit_remote;/* remote_name specified with remotename opt */ extern bool demand; /* Do dial-on-demand */ +extern bool extidle; /* Use external idle/demand filter */ extern char *ipparam; /* Extra parameter for ip up/down scripts */ extern bool cryptpap; /* Others' PAP passwords are encrypted */ extern int idle_time_limit;/* Shut down link if idle for this long */