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
This commit is contained in:
brian 1999-02-25 12:00:04 +00:00
parent 9d6cca2d1c
commit 795fd6d8b3
4 changed files with 26 additions and 19 deletions

View File

@ -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.

View File

@ -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.31 1999/02/17 02:11:28 brian Exp $
* $Id: datalink.c,v 1.32 1999/02/18 00:52:13 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");

View File

@ -1,4 +1,4 @@
.\" $Id: ppp.8,v 1.149 1999/02/16 00:16:56 brian Exp $
.\" $Id: ppp.8,v 1.150 1999/02/18 00:52:15 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

View File

@ -1,4 +1,4 @@
.\" $Id: ppp.8,v 1.149 1999/02/16 00:16:56 brian Exp $
.\" $Id: ppp.8,v 1.150 1999/02/18 00:52:15 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