diff options
author | brian <brian@cvs.openbsd.org> | 1999-05-14 09:35:28 +0000 |
---|---|---|
committer | brian <brian@cvs.openbsd.org> | 1999-05-14 09:35:28 +0000 |
commit | b5bd1cf0aa74304f66246a7d314ae157308d7a47 (patch) | |
tree | 077cacc727b5adc326a268568927ffa4fa990ada /usr.sbin | |
parent | 64ebbf30bcc5a34d194bb6cf4297e3f4bcd7ee8b (diff) |
Handle LCP echo reqs properly again (broken with the
layering changes).
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ppp/ppp/fsm.c | 20 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/lqr.c | 29 |
2 files changed, 24 insertions, 25 deletions
diff --git a/usr.sbin/ppp/ppp/fsm.c b/usr.sbin/ppp/ppp/fsm.c index 61bd3363c02..96f9530eb1f 100644 --- a/usr.sbin/ppp/ppp/fsm.c +++ b/usr.sbin/ppp/ppp/fsm.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: fsm.c,v 1.8 1999/05/09 20:03:59 brian Exp $ + * $Id: fsm.c,v 1.9 1999/05/14 09:35:27 brian Exp $ * * TODO: */ @@ -900,23 +900,9 @@ FsmRecvEchoReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp) static void FsmRecvEchoRep(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp) { - struct lcp *lcp = fsm2lcp(fp); - u_int32_t magic; - - if (lcp && mbuf_Length(bp) >= 4) { - mbuf_Read(bp, &magic, 4); - magic = ntohl(magic); - /* Tolerate echo replies with either magic number */ - if (magic != 0 && magic != lcp->his_magic && magic != lcp->want_magic) { - log_Printf(LogWARN, "%s: RecvEchoRep: Bad magic: expected 0x%08x," - " got 0x%08x\n", fp->link->name, lcp->his_magic, magic); - /* - * XXX: We should send terminate request. But poor implementations may - * die as a result. - */ - } + if (fsm2lcp(fp)) bp = lqr_RecvEcho(fp, bp); - } + mbuf_Free(bp); } diff --git a/usr.sbin/ppp/ppp/lqr.c b/usr.sbin/ppp/ppp/lqr.c index e16d11b4fb3..6815c35dd09 100644 --- a/usr.sbin/ppp/ppp/lqr.c +++ b/usr.sbin/ppp/ppp/lqr.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: lqr.c,v 1.5 1999/05/09 20:04:02 brian Exp $ + * $Id: lqr.c,v 1.6 1999/05/14 09:35:27 brian Exp $ * * o LQR based on RFC1333 * @@ -82,18 +82,31 @@ struct mbuf * lqr_RecvEcho(struct fsm *fp, struct mbuf *bp) { struct hdlc *hdlc = &link2physical(fp->link)->hdlc; + struct lcp *lcp = fsm2lcp(fp); struct echolqr lqr; - u_int32_t seq; if (mbuf_Length(bp) == sizeof lqr) { - mbuf_Read(bp, &lqr, sizeof lqr); - if (ntohl(lqr.signature) == SIGNATURE) { - seq = ntohl(lqr.sequence); + bp = mbuf_Read(bp, &lqr, sizeof lqr); + lqr.magic = ntohl(lqr.magic); + lqr.signature = ntohl(lqr.signature); + lqr.sequence = ntohl(lqr.sequence); + + /* Tolerate echo replies with either magic number */ + if (lqr.magic != 0 && lqr.magic != lcp->his_magic && + lqr.magic != lcp->want_magic) { + log_Printf(LogWARN, "%s: lqr_RecvEcho: Bad magic: expected 0x%08x," + " got 0x%08x\n", fp->link->name, lcp->his_magic, lqr.magic); + /* + * XXX: We should send a terminate request. But poor implementations may + * die as a result. + */ + } + if (lqr.signature == SIGNATURE) { /* careful not to update lqm.echo.seq_recv with older values */ - if ((hdlc->lqm.echo.seq_recv > (u_int32_t)0 - 5 && seq < 5) || + if ((hdlc->lqm.echo.seq_recv > (u_int32_t)0 - 5 && lqr.sequence < 5) || (hdlc->lqm.echo.seq_recv <= (u_int32_t)0 - 5 && - seq > hdlc->lqm.echo.seq_recv)) - hdlc->lqm.echo.seq_recv = seq; + lqr.sequence > hdlc->lqm.echo.seq_recv)) + hdlc->lqm.echo.seq_recv = lqr.sequence; } else log_Printf(LogWARN, "lqr_RecvEcho: Got sig 0x%08lx, not 0x%08lx !\n", (u_long)ntohl(lqr.signature), (u_long)SIGNATURE); |