X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=pppd%2Flcp.c;h=f9d6c1cc9b9c2fd91bae5f623ae987085a4d5313;hp=af48e9c58a628961042928da73df28f70aef9694;hb=45ce13154222739ab53c94b5dbbe650bef20db8d;hpb=78357d9d00ef7f3bb10ac98ac818916d481a3a0d diff --git a/pppd/lcp.c b/pppd/lcp.c index af48e9c..f9d6c1c 100644 --- a/pppd/lcp.c +++ b/pppd/lcp.c @@ -18,7 +18,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: lcp.c,v 1.19 1995/05/19 03:25:16 paulus Exp $"; +static char rcsid[] = "$Id: lcp.c,v 1.21 1995/08/10 06:51:06 paulus Exp $"; #endif /* @@ -232,32 +232,25 @@ RestartIdleTimer (f) fsm *f; { u_long delta; - struct ppp_ddinfo ddinfo; - u_long latest; + struct ppp_idle ddinfo; /* * Read the time since the last packet was received. */ - if (ioctl (fd, PPPIOCGTIME, &ddinfo) < 0) { - syslog (LOG_ERR, "ioctl(PPPIOCGTIME): %m"); + if (ioctl (fd, PPPIOCGIDLE, &ddinfo) < 0) { + syslog (LOG_ERR, "ioctl(PPPIOCGIDLE): %m"); die (1); } -/* - * Choose the most recient IP activity. It may be a read or write frame - */ - latest = ddinfo.ip_sjiffies < ddinfo.ip_rjiffies ? ddinfo.ip_sjiffies - : ddinfo.ip_rjiffies; /* * Compute the time since the last packet was received. If the timer - * has expired then send the echo request and reset the timer to maximum. + * has expired then disconnect the line. */ - delta = (idle_time_limit * HZ) - latest; - if (((int) delta < HZ || (int) latest < 0L) && f->state == OPENED) { - syslog (LOG_NOTICE, "No IP frames exchanged within idle time limit"); + delta = idle_time_limit - (u_long) ddinfo.recv_idle; + if (((int) delta <= 0L) && (f->state == OPENED)) { + syslog (LOG_NOTICE, "No IP frames received within idle time limit"); lcp_close(f->unit); /* Reset connection */ phase = PHASE_TERMINATE; /* Mark it down */ } else { - delta = (delta + HZ - 1) / HZ; - if (delta == 0) + if ((int) delta <= 0L) delta = (u_long) idle_time_limit; assert (idle_timer_running==0); TIMEOUT (IdleTimeCheck, (caddr_t) f, delta); @@ -885,11 +878,13 @@ lcp_nakci(f, p, len) * `let me authenticate myself with you' which is a bit pointless. * For the quality protocol, the Nak means `ask me to send you quality * reports', but if we didn't ask for them, we don't want them. + * An option we don't recognize represents the peer asking to + * negotiate some option we don't support, so ignore it. */ while (len > CILEN_VOID) { GETCHAR(citype, p); GETCHAR(cilen, p); - if( (len -= cilen) < 0 ) + if ((len -= cilen) < 0) goto bad; next = p + cilen - 2; @@ -925,8 +920,6 @@ lcp_nakci(f, p, len) if (go->neg_lqr || no.neg_lqr || cilen != CILEN_LQR) goto bad; break; - default: - goto bad; } p = next; } @@ -1671,43 +1664,36 @@ static void LcpEchoCheck (f) fsm *f; { - u_int32_t delta; + long int delta; #ifdef __linux__ - struct ppp_ddinfo ddinfo; - u_int32_t latest; + struct ppp_idle ddinfo; /* * Read the time since the last packet was received. */ - if (ioctl (fd, PPPIOCGTIME, &ddinfo) < 0) { - syslog (LOG_ERR, "ioctl(PPPIOCGTIME): %m"); + if (ioctl (fd, PPPIOCGIDLE, &ddinfo) < 0) { + syslog (LOG_ERR, "ioctl(PPPIOCGIDLE): %m"); die (1); } -/* - * Choose the most recient frame received. It may be an IP or NON-IP frame. - */ - latest = ddinfo.nip_rjiffies < ddinfo.ip_rjiffies ? ddinfo.nip_rjiffies - : ddinfo.ip_rjiffies; /* * Compute the time since the last packet was received. If the timer * has expired then send the echo request and reset the timer to maximum. */ - delta = (lcp_echo_interval * HZ) - latest; - if (delta < HZ || latest < 0L) { + delta = (long int) lcp_echo_interval - (long int) ddinfo.recv_idle; + if (delta < 0L) { LcpSendEchoRequest (f); - delta = lcp_echo_interval * HZ; + delta = (int) lcp_echo_interval; } - delta /= HZ; #else /* Other implementations do not have ability to find delta */ LcpSendEchoRequest (f); - delta = lcp_echo_interval; + delta = (int) lcp_echo_interval; #endif /* * Start the timer for the next interval. */ assert (lcp_echo_timer_running==0); - TIMEOUT (LcpEchoTimeout, (caddr_t) f, delta); + TIMEOUT (LcpEchoTimeout, (caddr_t) f, (u_int32_t) delta); lcp_echo_timer_running = 1; }