*/
#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>
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 **));
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();
{"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 */
/*
* 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.
*/
}
/*
- * 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;
char *str;
int *valp;
{
- long v;
+ u_int32_t v;
if (!number_option(str, &v, 0))
return 0;
setmru(argv)
char **argv;
{
- long mru;
+ u_int32_t mru;
if (!number_option(*argv, &mru, 0))
return 0;
setmtu(argv)
char **argv;
{
- long mtu;
+ u_int32_t mtu;
if (!number_option(*argv, &mtu, 0))
return 0;
setasyncmap(argv)
char **argv;
{
- long asyncmap;
+ u_int32_t asyncmap;
if (!number_option(*argv, &asyncmap, 16))
return 0;
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;
.\" 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
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).
*/
#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
/*
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));
u->us_id = 0;
u->us_timeouttime = UPAP_DEFTIMEOUT;
u->us_maxtransmits = 10;
+ u->us_reqtimeout = UPAP_DEFREQTIME;
}
}
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)
}
+/*
+ * 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.
*
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);
+ }
}
{
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;
u->us_serverstate = UPAPSS_BADAUTH;
auth_peer_fail(u->us_unit, PPP_PAP);
}
+
+ if (u->us_reqtimeout > 0)
+ UNTIMEOUT(upap_reqtimeout, (caddr_t) u);
}
* 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 $
*/
/*
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;
/*
* 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[];