]> git.ozlabs.org Git - ppp.git/commitdiff
Give up waiting for a PAP auth-req from the peer after 30 seconds.
authorPaul Mackerras <paulus@samba.org>
Mon, 12 Jun 1995 12:02:25 +0000 (12:02 +0000)
committerPaul Mackerras <paulus@samba.org>
Mon, 12 Jun 1995 12:02:25 +0000 (12:02 +0000)
pppd/.cvsignore
pppd/options.c
pppd/pppd.8
pppd/upap.c
pppd/upap.h

index f3c7a7c5da68804a1bdf391127ba34aed33c3cca..7ee9db20da99af46555619a6e2ac54c43a408ea4 100644 (file)
@@ -1 +1,3 @@
 Makefile
+pppd
+pppd.0
index 2375cf50df33841b9a66ece47ef5e56e21b12545..b54f95a98cad3d3d89b287ca0c29be96a1148df0 100644 (file)
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static char rcsid[] = "$Id: options.c,v 1.20 1995/06/12 11:22:51 paulus Exp $";
+static char rcsid[] = "$Id: options.c,v 1.21 1995/06/12 12:02:20 paulus Exp $";
 #endif
 
 #include <stdio.h>
@@ -153,6 +153,7 @@ static int setipcpconf __P((char **));
 static int setipcpfails __P((char **));
 static int setpaptimeout __P((char **));
 static int setpapreqs __P((char **));
+static int setpapreqtime __P((char **));
 static int setchaptimeout __P((char **));
 static int setchapchal __P((char **));
 static int setchapintv __P((char **));
@@ -165,7 +166,7 @@ static int setnobsdcomp __P((void));
 static int setipparam __P((char **));
 static int setpapcrypt __P((void));
 
-static int number_option __P((char *, long *, int));
+static int number_option __P((char *, u_int32_t *, int));
 static int readable __P((int fd));
 
 void usage();
@@ -236,8 +237,9 @@ static struct cmd {
     {"ipcp-max-terminate", 1, setipcpterm}, /* Set max #xmits for term-reqs */
     {"ipcp-max-configure", 1, setipcpconf}, /* Set max #xmits for conf-reqs */
     {"ipcp-max-failure", 1, setipcpfails}, /* Set max #conf-naks for IPCP */
-    {"pap-restart", 1, setpaptimeout}, /* Set timeout for UPAP */
+    {"pap-restart", 1, setpaptimeout}, /* Set retransmit timeout for PAP */
     {"pap-max-authreq", 1, setpapreqs}, /* Set max #xmits for auth-reqs */
+    {"pap-timeout", 1, setpapreqtime}, /* Set time limit for peer PAP auth. */
     {"chap-restart", 1, setchaptimeout}, /* Set timeout for CHAP */
     {"chap-max-challenge", 1, setchapchal}, /* Set max #xmits for challenge */
     {"chap-interval", 1, setchapintv}, /* Set interval for rechallenge */
@@ -495,7 +497,7 @@ readable(fd)
 
 /*
  * Read a word from a file.
- * Words are delimited by white-space or by quotes (", or ').
+ * Words are delimited by white-space or by quotes (" or ').
  * Quotes, white-space and \ may be escaped with \.
  * \<newline> is ignored.
  */
@@ -741,17 +743,17 @@ getword(f, word, newlinep, filename)
 }
 
 /*
- * number_option - parse a numeric parameter for an option
+ * number_option - parse an unsigned numeric parameter for an option.
  */
 static int
 number_option(str, valp, base)
     char *str;
-    long *valp;
+    u_int32_t *valp;
     int base;
 {
     char *ptr;
 
-    *valp = strtol(str, &ptr, base);
+    *valp = strtoul(str, &ptr, base);
     if (ptr == str) {
        fprintf(stderr, "%s: invalid number: %s\n", progname, str);
        return 0;
@@ -770,7 +772,7 @@ int_option(str, valp)
     char *str;
     int *valp;
 {
-    long v;
+    u_int32_t v;
 
     if (!number_option(str, &v, 0))
        return 0;
@@ -893,7 +895,7 @@ static int
 setmru(argv)
     char **argv;
 {
-    long mru;
+    u_int32_t mru;
 
     if (!number_option(*argv, &mru, 0))
        return 0;
@@ -910,7 +912,7 @@ static int
 setmtu(argv)
     char **argv;
 {
-    long mtu;
+    u_int32_t mtu;
 
     if (!number_option(*argv, &mtu, 0))
        return 0;
@@ -1143,7 +1145,7 @@ static int
 setasyncmap(argv)
     char **argv;
 {
-    long asyncmap;
+    u_int32_t asyncmap;
 
     if (!number_option(*argv, &asyncmap, 16))
        return 0;
@@ -1598,6 +1600,13 @@ setpaptimeout(argv)
     return int_option(*argv, &upap[0].us_timeouttime);
 }
 
+static int
+setpapreqtime(argv)
+    char **argv;
+{
+    return int_option(*argv, &upap[0].us_reqtimeout);
+}
+
 static int
 setpapreqs(argv)
     char **argv;
index 2866f075895ba79b6519cf80a6317a4e42fd9766..c210d05d12a4df479d0748e57aa005ea5b6ada5c 100644 (file)
@@ -1,5 +1,5 @@
 .\" manual page [] for pppd 2.0
-.\" $Id: pppd.8,v 1.11 1995/05/01 01:46:40 paulus Exp $
+.\" $Id: pppd.8,v 1.12 1995/06/12 12:02:22 paulus Exp $
 .\" SH section heading
 .\" SS subsection heading
 .\" LP paragraph
@@ -395,6 +395,12 @@ Set the PAP restart interval (retransmission timeout) to <n> seconds
 Set the maximum number of PAP authenticate-request transmissions to
 <n> (default 10).
 .TP
+.B pap-timeout \fI<n>
+Set the maximum time that
+.I pppd
+will wait for the peer to authenticate itself with PAP to
+<n> seconds (0 means no limit).
+.TP
 .B chap-restart \fI<n>
 Set the CHAP restart interval (retransmission timeout for challenges)
 to <n> seconds (default 3).
index afbc180b56709c27434498536352e31cba85d07a..aed4a7b0e1a5643507af9267a0667368cec55555 100644 (file)
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static char rcsid[] = "$Id: upap.c,v 1.5 1994/10/24 04:31:11 paulus Exp $";
+static char rcsid[] = "$Id: upap.c,v 1.6 1995/06/12 12:02:24 paulus Exp $";
 #endif
 
 /*
@@ -39,6 +39,7 @@ upap_state upap[NUM_PPP];             /* UPAP state; one for each unit */
 
 
 static void upap_timeout __P((caddr_t));
+static void upap_reqtimeout __P((caddr_t));
 static void upap_rauthreq __P((upap_state *, u_char *, int, int));
 static void upap_rauthack __P((upap_state *, u_char *, int, int));
 static void upap_rauthnak __P((upap_state *, u_char *, int, int));
@@ -65,6 +66,7 @@ upap_init(unit)
     u->us_id = 0;
     u->us_timeouttime = UPAP_DEFTIMEOUT;
     u->us_maxtransmits = 10;
+    u->us_reqtimeout = UPAP_DEFREQTIME;
 }
 
 
@@ -117,11 +119,13 @@ upap_authpeer(unit)
     }
 
     u->us_serverstate = UPAPSS_LISTEN;
+    if (u->us_reqtimeout > 0)
+       TIMEOUT(upap_reqtimeout, (caddr_t) u, u->us_reqtimeout);
 }
 
 
 /*
- * upap_timeout - Timeout expired.
+ * upap_timeout - Retransmission timer for sending auth-reqs expired.
  */
 static void
 upap_timeout(arg)
@@ -144,6 +148,23 @@ upap_timeout(arg)
 }
 
 
+/*
+ * upap_reqtimeout - Give up waiting for the peer to send an auth-req.
+ */
+static void
+upap_reqtimeout(arg)
+    caddr_t arg;
+{
+    upap_state *u = (upap_state *) arg;
+
+    if (u->us_serverstate != UPAPSS_LISTEN)
+       return;                 /* huh?? */
+
+    auth_peer_fail(u->us_unit, PPP_PAP);
+    u->us_serverstate = UPAPSS_BADAUTH;
+}
+
+
 /*
  * upap_lowerup - The lower layer is up.
  *
@@ -163,8 +184,11 @@ upap_lowerup(unit)
 
     if (u->us_serverstate == UPAPSS_INITIAL)
        u->us_serverstate = UPAPSS_CLOSED;
-    else if (u->us_serverstate == UPAPSS_PENDING)
+    else if (u->us_serverstate == UPAPSS_PENDING) {
        u->us_serverstate = UPAPSS_LISTEN;
+       if (u->us_reqtimeout > 0)
+           TIMEOUT(upap_reqtimeout, (caddr_t) u, u->us_reqtimeout);
+    }
 }
 
 
@@ -179,8 +203,10 @@ upap_lowerdown(unit)
 {
     upap_state *u = &upap[unit];
 
-    if (u->us_clientstate == UPAPCS_AUTHREQ) /* Timeout pending? */
+    if (u->us_clientstate == UPAPCS_AUTHREQ)   /* Timeout pending? */
        UNTIMEOUT(upap_timeout, (caddr_t) u);   /* Cancel timeout */
+    if (u->us_serverstate == UPAPSS_LISTEN && u->us_reqtimeout > 0)
+       UNTIMEOUT(upap_reqtimeout, (caddr_t) u);
 
     u->us_clientstate = UPAPCS_INITIAL;
     u->us_serverstate = UPAPSS_INITIAL;
@@ -339,6 +365,9 @@ upap_rauthreq(u, inp, id, len)
        u->us_serverstate = UPAPSS_BADAUTH;
        auth_peer_fail(u->us_unit, PPP_PAP);
     }
+
+    if (u->us_reqtimeout > 0)
+       UNTIMEOUT(upap_reqtimeout, (caddr_t) u);
 }
 
 
index 4dfdeaf91996439e4dfc2376d5b63657af2299ba..8b1501964ad29114f5da478937d34047aa873e92 100644 (file)
@@ -16,7 +16,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * $Id: upap.h,v 1.3 1994/09/21 06:47:37 paulus Exp $
+ * $Id: upap.h,v 1.4 1995/06/12 12:02:25 paulus Exp $
  */
 
 /*
@@ -45,9 +45,10 @@ typedef struct upap_state {
     int us_clientstate;                /* Client state */
     int us_serverstate;                /* Server state */
     u_char us_id;              /* Current id */
-    int us_timeouttime;                /* Timeout time in milliseconds */
+    int us_timeouttime;                /* Timeout (seconds) for auth-req retrans. */
     int us_transmits;          /* Number of auth-reqs sent */
     int us_maxtransmits;       /* Maximum number of auth-reqs to send */
+    int us_reqtimeout;         /* Time to wait for auth-req from peer */
 } upap_state;
 
 
@@ -75,7 +76,8 @@ typedef struct upap_state {
 /*
  * Timeouts.
  */
-#define UPAP_DEFTIMEOUT        3       /* Timeout time in seconds */
+#define UPAP_DEFTIMEOUT        3       /* Timeout (seconds) for retransmitting req */
+#define UPAP_DEFREQTIME        30      /* Time to wait for auth-req from peer */
 
 
 extern upap_state upap[];