fix bug with sending retransmission with id=-1 after seeing ack.
authorPaul Mackerras <paulus@samba.org>
Thu, 1 Sep 1994 00:14:03 +0000 (00:14 +0000)
committerPaul Mackerras <paulus@samba.org>
Thu, 1 Sep 1994 00:14:03 +0000 (00:14 +0000)
pppd/fsm.c
pppd/fsm.h

index 902ad64cbbc2733132ef69b3571fb3de20e441f6..ea8de821610a8cb2abc8a487333221dfeca1b7ba 100644 (file)
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static char rcsid[] = "$Id: fsm.c,v 1.3 1994/05/24 11:21:10 paulus Exp $";
+static char rcsid[] = "$Id: fsm.c,v 1.4 1994/09/01 00:14:03 paulus Exp $";
 #endif
 
 /*
@@ -446,15 +446,16 @@ fsm_rconfack(f, id, inp, len)
     FSMDEBUG((LOG_INFO, "fsm_rconfack(%s): Rcvd id %d.",
              PROTO_NAME(f), id));
 
-    if (id != f->reqid)                /* Expected id? */
-       return;                 /* Nope, toss... */
-    if( !(f->callbacks->ackci? (*f->callbacks->ackci)(f, inp, len): (len == 0)) ){
+    if (id != f->reqid || f->seen_ack)         /* Expected id? */
+       return;                                 /* Nope, toss... */
+    if( !(f->callbacks->ackci? (*f->callbacks->ackci)(f, inp, len):
+         (len == 0)) ){
        /* Ack is bad - ignore it */
        FSMDEBUG((LOG_INFO, "%s: received bad Ack (length %d)",
                  PROTO_NAME(f), len));
        return;
     }
-    f->reqid = -1;
+    f->seen_ack = 1;
 
     switch (f->state) {
     case CLOSED:
@@ -468,7 +469,7 @@ fsm_rconfack(f, id, inp, len)
        break;
 
     case ACKRCVD:
-       /* Huh? an extra Ack? oh well... */
+       /* Huh? an extra valid Ack? oh well... */
        fsm_sconfreq(f, 0);
        f->state = REQSENT;
        break;
@@ -507,16 +508,16 @@ fsm_rconfnakrej(f, code, id, inp, len)
     FSMDEBUG((LOG_INFO, "fsm_rconfnakrej(%s): Rcvd id %d.",
              PROTO_NAME(f), id));
 
-    if (id != f->reqid)                /* Expected id? */
-       return;                 /* Nope, toss... */
+    if (id != f->reqid || f->seen_ack) /* Expected id? */
+       return;                         /* Nope, toss... */
     proc = (code == CONFNAK)? f->callbacks->nakci: f->callbacks->rejci;
-    if( !proc || !proc(f, inp, len) ){
+    if (!proc || !proc(f, inp, len)) {
        /* Nak/reject is bad - ignore it */
        FSMDEBUG((LOG_INFO, "%s: received bad %s (length %d)",
                  PROTO_NAME(f), (code==CONFNAK? "Nak": "reject"), len));
        return;
     }
-    f->reqid = -1;
+    f->seen_ack = 1;
 
     switch (f->state) {
     case CLOSED:
@@ -715,6 +716,8 @@ fsm_sconfreq(f, retransmit)
        f->reqid = ++f->id;
     }
 
+    f->seen_ack = 0;
+
     /*
      * Make up the request packet
      */
index a12966bef48891ec4818b2c7d92115f8fa893784..22dbf651109d9d77118a79f89b376c56dcf99233 100644 (file)
@@ -16,7 +16,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * $Id: fsm.h,v 1.2 1994/04/11 07:18:35 paulus Exp $
+ * $Id: fsm.h,v 1.3 1994/09/01 00:14:03 paulus Exp $
  */
 
 /*
@@ -66,6 +66,7 @@ typedef struct fsm {
     int flags;                 /* Contains option bits */
     u_char id;                 /* Current id */
     u_char reqid;              /* Current request id */
+    u_char seen_ack;           /* Have received valid Ack/Nak/Rej to Req */
     int timeouttime;           /* Timeout time in milliseconds */
     int maxconfreqtransmits;   /* Maximum Configure-Request transmissions */
     int retransmits;           /* Number of retransmissions left */