summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrian <brian@cvs.openbsd.org>1999-02-25 12:07:24 +0000
committerbrian <brian@cvs.openbsd.org>1999-02-25 12:07:24 +0000
commitb76a3968db63ee2aa6f3deac343b10649c07cdb7 (patch)
treed8f217cf5d95d4c7f20916c0c246e970cf052881
parent28d50d56c5954a5671fadcae329909d0da83d6c4 (diff)
When our dial timeout is ``random'', display its value
correctly by invoking the timer to get the value before displaying the message. Don't assume that a value of 0 is ``random'' in ``show datalink''. Make the random value between 1 and DIAL_TIMEOUT rather than between 0 and DIAL_TIMEOUT-1
-rw-r--r--usr.sbin/ppp/ppp/README.changes2
-rw-r--r--usr.sbin/ppp/ppp/datalink.c23
-rw-r--r--usr.sbin/ppp/ppp/ppp.810
3 files changed, 21 insertions, 14 deletions
diff --git a/usr.sbin/ppp/ppp/README.changes b/usr.sbin/ppp/ppp/README.changes
index 0ee2b36d115..4642dfe0595 100644
--- a/usr.sbin/ppp/ppp/README.changes
+++ b/usr.sbin/ppp/ppp/README.changes
@@ -76,3 +76,5 @@ o If you don't like seeing additional interface aliases when running in
check the sample file.
o Ppp waits for 1 second before checking whether the device supports
carrier. This is controllable with ``set cd''.
+o Random dial timeouts are now between 1 and 30 seconds inclusive rather
+ than between 0 and 29.
diff --git a/usr.sbin/ppp/ppp/datalink.c b/usr.sbin/ppp/ppp/datalink.c
index dd0ddee201b..d3a69720974 100644
--- a/usr.sbin/ppp/ppp/datalink.c
+++ b/usr.sbin/ppp/ppp/datalink.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: datalink.c,v 1.13 1999/02/18 00:50:45 brian Exp $
+ * $Id: datalink.c,v 1.14 1999/02/25 12:07:23 brian Exp $
*/
#include <sys/param.h>
@@ -86,16 +86,19 @@ datalink_OpenTimeout(void *v)
log_Printf(LogPHASE, "%s: Redial timer expired.\n", dl->name);
}
-static void
+static int
datalink_StartDialTimer(struct datalink *dl, int Timeout)
{
+ int result = Timeout;
+
timer_Stop(&dl->dial_timer);
-
if (Timeout) {
if (Timeout > 0)
dl->dial_timer.load = Timeout * SECTICKS;
- else
- dl->dial_timer.load = (random() % DIAL_TIMEOUT) * SECTICKS;
+ else {
+ result = (random() % DIAL_TIMEOUT) + 1;
+ dl->dial_timer.load = result * SECTICKS;
+ }
dl->dial_timer.func = datalink_OpenTimeout;
dl->dial_timer.name = "dial";
dl->dial_timer.arg = dl;
@@ -104,6 +107,7 @@ datalink_StartDialTimer(struct datalink *dl, int Timeout)
log_Printf(LogPHASE, "%s: Enter pause (%d) for redialing.\n",
dl->name, Timeout);
}
+ return result;
}
static void
@@ -133,6 +137,7 @@ datalink_HangupDone(struct datalink *dl)
if (!physical_SetMode(dl->physical, PHYS_BACKGROUND))
log_Printf(LogERROR, "Oops - can't change mode to BACKGROUND (gulp) !\n");
bundle_LinksRemoved(dl->bundle);
+ /* if dial.timeout is < 0 (random), don't override fsm.delay */
if (dl->cbcp.fsm.delay < dl->cfg.dial.timeout)
dl->cbcp.fsm.delay = dl->cfg.dial.timeout;
datalink_StartDialTimer(dl, dl->cbcp.fsm.delay);
@@ -281,9 +286,9 @@ datalink_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
bundle_LinkClosed(dl->bundle, dl);
}
if (!dl->bundle->CleaningUp) {
+ int timeout = datalink_StartDialTimer(dl, dl->cfg.dial.timeout);
log_WritePrompts(dl, "Failed to open %s, pause %d seconds\n",
- dl->physical->name.full, dl->cfg.dial.timeout);
- datalink_StartDialTimer(dl, dl->cfg.dial.timeout);
+ dl->physical->name.full, timeout);
}
}
}
@@ -976,11 +981,11 @@ datalink_Show(struct cmdargs const *arg)
arg->cx->cfg.dial.max);
else
prompt_Printf(arg->prompt, " Dial tries: infinite, delay ");
- if (arg->cx->cfg.dial.next_timeout > 0)
+ if (arg->cx->cfg.dial.next_timeout >= 0)
prompt_Printf(arg->prompt, "%ds/", arg->cx->cfg.dial.next_timeout);
else
prompt_Printf(arg->prompt, "random/");
- if (arg->cx->cfg.dial.timeout > 0)
+ if (arg->cx->cfg.dial.timeout >= 0)
prompt_Printf(arg->prompt, "%ds\n", arg->cx->cfg.dial.timeout);
else
prompt_Printf(arg->prompt, "random\n");
diff --git a/usr.sbin/ppp/ppp/ppp.8 b/usr.sbin/ppp/ppp/ppp.8
index 3bcb91a872e..09e28d445db 100644
--- a/usr.sbin/ppp/ppp/ppp.8
+++ b/usr.sbin/ppp/ppp/ppp.8
@@ -1,4 +1,4 @@
-.\" $Id: ppp.8,v 1.21 1999/02/18 00:50:45 brian Exp $
+.\" $Id: ppp.8,v 1.22 1999/02/25 12:07:23 brian Exp $
.Dd 20 September 1995
.nr XX \w'\fC00'
.Os FreeBSD
@@ -844,14 +844,14 @@ set redial seconds|random[.nseconds|random] [dial_attempts]
is the number of seconds to wait before attempting
to connect again. If the argument is
.Sq random ,
-the delay period is a random value between 0 and 30 seconds.
+the delay period is a random value between 1 and 30 seconds inclusive.
.Sq Nseconds
is the number of seconds to wait before attempting
to dial the next number in a list of numbers (see the
.Dq set phone
command). The default is 3 seconds. Again, if the argument is
.Sq random ,
-the delay period is a random value between 0 and 30 seconds.
+the delay period is a random value between 1 and 30 seconds.
.Sq dial_attempts
is the number of times to try to connect for each outgoing packet
that is received. The previous value is unchanged if this parameter
@@ -3826,7 +3826,7 @@ defaults to zero. A value of
.Ar random
for
.Ar timeout
-will result in a variable pause, somewhere between 0 and 30 seconds.
+will result in a variable pause, somewhere between 1 and 30 seconds.
.It set recvpipe Op Ar value
This sets the routing table RECVPIPE value. The optimum value is
just over twice the MTU value. If
@@ -3848,7 +3848,7 @@ may be used here in place of
.Ar seconds
and
.Ar nseconds ,
-causing a random delay of between 0 and 30 seconds.
+causing a random delay of between 1 and 30 seconds.
.Pp
Note, this delay will be effective, even after
.Ar attempts