mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-11 17:04:19 +01:00
Add a reconnect capability directing ppp to re-establish
the connection after an unexpected loss of carrier: set reconnect timer ntries The man page warns against using this command when your timeout value is slightly more than the other sides :{} Suggested by: burton@bsampley.vip.best.com (Burton Sampley)
This commit is contained in:
parent
19a58fedca
commit
07030d97c1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=25067
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: command.c,v 1.37 1997/04/09 17:35:52 ache Exp $
|
||||
* $Id: command.c,v 1.38 1997/04/14 23:48:12 brian Exp $
|
||||
*
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
@ -365,6 +365,13 @@ static int ShowLogList()
|
||||
return(1);
|
||||
}
|
||||
|
||||
static int ShowReconnect()
|
||||
{
|
||||
printf(" Reconnect Timer: %d, %d tries\n",
|
||||
VarReconnectTimer, VarReconnectTries);
|
||||
return(1);
|
||||
}
|
||||
|
||||
static int ShowRedial()
|
||||
{
|
||||
printf(" Redial Timer: ");
|
||||
@ -441,12 +448,14 @@ struct cmdtab const ShowCommands[] = {
|
||||
"Show Output filters", StrOption},
|
||||
{ "proto", NULL, ReportProtStatus, LOCAL_AUTH,
|
||||
"Show protocol summary", StrNull},
|
||||
{ "reconnect",NULL, ShowReconnect, LOCAL_AUTH,
|
||||
"Show Reconnect timer ntries", StrNull},
|
||||
{ "redial", NULL, ShowRedial, LOCAL_AUTH,
|
||||
"Show Redial timeout value", StrNull},
|
||||
{ "route", NULL, ShowRoute, LOCAL_AUTH,
|
||||
"Show routing table", StrNull},
|
||||
{ "timeout", NULL, ShowTimeout, LOCAL_AUTH,
|
||||
"Show Idle timeout value", StrNull},
|
||||
{ "redial", NULL, ShowRedial, LOCAL_AUTH,
|
||||
"Show Redial timeout value", StrNull},
|
||||
#ifdef MSEXT
|
||||
{ "msext", NULL, ShowMSExt, LOCAL_AUTH,
|
||||
"Show MS PPP extentions", StrNull},
|
||||
@ -630,7 +639,8 @@ DownCommand()
|
||||
return(1);
|
||||
}
|
||||
|
||||
static int SetModemSpeed(list, argc, argv)
|
||||
static int
|
||||
SetModemSpeed(list, argc, argv)
|
||||
struct cmdtab *list;
|
||||
int argc;
|
||||
char **argv;
|
||||
@ -652,7 +662,22 @@ char **argv;
|
||||
return(1);
|
||||
}
|
||||
|
||||
static int SetRedialTimeout(list, argc, argv)
|
||||
static int
|
||||
SetReconnect(list, argc, argv)
|
||||
struct cmdtab *list;
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
if (argc == 2) {
|
||||
VarReconnectTimer = atoi(argv[0]);
|
||||
VarReconnectTries = atoi(argv[1]);
|
||||
} else
|
||||
printf("Usage: %s %s\n", list->name, list->syntax);
|
||||
return(1);
|
||||
}
|
||||
|
||||
static int
|
||||
SetRedialTimeout(list, argc, argv)
|
||||
struct cmdtab *list;
|
||||
int argc;
|
||||
char **argv;
|
||||
@ -727,7 +752,8 @@ char **argv;
|
||||
return(1);
|
||||
}
|
||||
|
||||
static int SetModemParity(list, argc, argv)
|
||||
static int
|
||||
SetModemParity(list, argc, argv)
|
||||
struct cmdtab *list;
|
||||
int argc;
|
||||
char **argv;
|
||||
@ -1075,12 +1101,14 @@ struct cmdtab const SetCommands[] = {
|
||||
"Set modem parity", "[odd|even|none]"},
|
||||
{ "phone", NULL, SetVariable, LOCAL_AUTH,
|
||||
"Set telephone number(s)", "phone1[:phone2[...]]", (void *)VAR_PHONE },
|
||||
{ "reconnect",NULL, SetReconnect, LOCAL_AUTH,
|
||||
"Set Reconnect timeout", "value ntries"},
|
||||
{ "redial", NULL, SetRedialTimeout, LOCAL_AUTH,
|
||||
"Set Redial timeout", "value|random[.value|random] [dial_attempts]"},
|
||||
{ "speed", NULL, SetModemSpeed, LOCAL_AUTH,
|
||||
"Set modem speed", "speed"},
|
||||
{ "timeout", NULL, SetIdleTimeout, LOCAL_AUTH,
|
||||
"Set Idle timeout", StrValue},
|
||||
{ "redial", NULL, SetRedialTimeout, LOCAL_AUTH,
|
||||
"Set Redial timeout", "value|random[.value|random] [dial_attempts]"},
|
||||
#ifdef MSEXT
|
||||
{ "ns", NULL, SetNS, LOCAL_AUTH,
|
||||
"Set NameServer", "pri-addr [sec-addr]"},
|
||||
|
@ -15,7 +15,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: defs.h,v 1.10 1997/02/22 16:10:10 peter Exp $
|
||||
* $Id: defs.h,v 1.11 1997/04/14 23:48:13 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -46,6 +46,8 @@
|
||||
#define SERVER_PORT 3000 /* Base server port no. */
|
||||
|
||||
#define MODEM_CTSRTS TRUE /* Default (true): use CTS/RTS signals */
|
||||
#define RECONNECT_TIMER 3 /* Default timer for carrier loss */
|
||||
#define RECONNECT_TRIES 0 /* Default retries on carrier loss */
|
||||
#define REDIAL_PERIOD 30 /* Default Hold time to redial */
|
||||
#define NEXT_REDIAL_PERIOD 3 /* Default Hold time to next number redial */
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: ip.c,v 1.14 1997/02/22 16:10:18 peter Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Return ICMP message for filterd packet
|
||||
@ -45,6 +45,7 @@ static void IdleTimeout()
|
||||
{
|
||||
LogPrintf(LOG_PHASE_BIT, "Idle timer expired.\n");
|
||||
LcpClose();
|
||||
lostCarrier = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: main.c,v 1.43 1997/04/13 00:54:43 brian Exp $
|
||||
* $Id: main.c,v 1.44 1997/04/14 23:48:15 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Add commands for traffic summary, version display, etc.
|
||||
@ -735,6 +735,7 @@ DoLoop()
|
||||
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 0;
|
||||
lostCarrier = 0;
|
||||
|
||||
if (mode & MODE_BACKGROUND)
|
||||
dial_up = TRUE; /* Bring the line up */
|
||||
@ -752,11 +753,24 @@ DoLoop()
|
||||
if (mode & MODE_DDIAL && LcpFsm.state <= ST_CLOSED)
|
||||
dial_up = TRUE;
|
||||
|
||||
/*
|
||||
* If we lost carrier and want to re-establish the connection
|
||||
* due to the "set reconnect" value, we'd better bring the line
|
||||
* back up now.
|
||||
*/
|
||||
if (LcpFsm.state <= ST_CLOSED && dial_up != TRUE
|
||||
&& lostCarrier && lostCarrier <= VarReconnectTries) {
|
||||
LogPrintf(LOG_PHASE_BIT, "Connection lost, re-establish (%d/%d)\n",
|
||||
lostCarrier, VarReconnectTries);
|
||||
StartRedialTimer(VarReconnectTimer);
|
||||
dial_up = TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* If Ip packet for output is enqueued and require dial up,
|
||||
* If Ip packet for output is enqueued and require dial up,
|
||||
* Just do it!
|
||||
*/
|
||||
if ( dial_up && RedialTimer.state != TIMER_RUNNING ) { /* XXX */
|
||||
if ( dial_up && RedialTimer.state != TIMER_RUNNING ) {
|
||||
#ifdef DEBUG
|
||||
logprintf("going to dial: modem = %d\n", modem);
|
||||
#endif
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: modem.c,v 1.32 1997/03/31 22:51:00 brian Exp $
|
||||
* $Id: modem.c,v 1.33 1997/04/13 00:54:44 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -218,6 +218,7 @@ DownConnection()
|
||||
CloseModem();
|
||||
LcpDown();
|
||||
}
|
||||
lostCarrier++;
|
||||
connect_time = 0;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" manual page [] for ppp 0.94 beta2 + alpha
|
||||
.\" $Id: ppp.8,v 1.28 1997/04/13 00:54:45 brian Exp $
|
||||
.\" $Id: ppp.8,v 1.29 1997/04/14 23:48:17 brian Exp $
|
||||
.Dd 20 September 1995
|
||||
.Os FreeBSD
|
||||
.Dt PPP 8
|
||||
@ -441,13 +441,44 @@ dial mode on both ends of the link. If each end has the same timeout,
|
||||
both ends wind up calling each other at the same time if the link
|
||||
drops and both ends have packets queued.
|
||||
|
||||
At some locations, the serial link may not be reliable, and carrier
|
||||
may be lost at inappropriate times. It is possible to have
|
||||
.Nm
|
||||
redial should carrier be unexpectedly lost during a session.
|
||||
.Bd -literal -offset indent
|
||||
set reconnect timeout ntries
|
||||
.Ed
|
||||
|
||||
This command tells ppp to re-establish the connection
|
||||
.Ar ntries
|
||||
times on loss of carrier with a pause of
|
||||
.Ar timeout
|
||||
seconds before each try. For example,
|
||||
.Bd -literal -offset indent
|
||||
set reconnect 3 5
|
||||
.Ed
|
||||
|
||||
tells
|
||||
.Nm
|
||||
that on an unexpected loss of carrier, it should wait
|
||||
.Ar 3
|
||||
seconds before attempting to reconnect. This may happen up to
|
||||
.Ar 5
|
||||
times before
|
||||
.Nm
|
||||
gives up. The default value of ntries is zero (no redial). Care
|
||||
should be taken with this option. If the local timeout is slightly
|
||||
longer than the remote timeout, the reconnect feature will always be
|
||||
triggered (up to the given number of times) after the remote side
|
||||
times out and hangs up.
|
||||
|
||||
If the
|
||||
.Fl background
|
||||
flag is specified, all phone numbers are dialed at most once until
|
||||
a connection is made. The next number redial period specified with
|
||||
the
|
||||
.Dq set redial
|
||||
command is honoured.
|
||||
command is honoured, as is the reconnect tries value.
|
||||
|
||||
To terminate the program, type
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" manual page [] for ppp 0.94 beta2 + alpha
|
||||
.\" $Id: ppp.8,v 1.28 1997/04/13 00:54:45 brian Exp $
|
||||
.\" $Id: ppp.8,v 1.29 1997/04/14 23:48:17 brian Exp $
|
||||
.Dd 20 September 1995
|
||||
.Os FreeBSD
|
||||
.Dt PPP 8
|
||||
@ -441,13 +441,44 @@ dial mode on both ends of the link. If each end has the same timeout,
|
||||
both ends wind up calling each other at the same time if the link
|
||||
drops and both ends have packets queued.
|
||||
|
||||
At some locations, the serial link may not be reliable, and carrier
|
||||
may be lost at inappropriate times. It is possible to have
|
||||
.Nm
|
||||
redial should carrier be unexpectedly lost during a session.
|
||||
.Bd -literal -offset indent
|
||||
set reconnect timeout ntries
|
||||
.Ed
|
||||
|
||||
This command tells ppp to re-establish the connection
|
||||
.Ar ntries
|
||||
times on loss of carrier with a pause of
|
||||
.Ar timeout
|
||||
seconds before each try. For example,
|
||||
.Bd -literal -offset indent
|
||||
set reconnect 3 5
|
||||
.Ed
|
||||
|
||||
tells
|
||||
.Nm
|
||||
that on an unexpected loss of carrier, it should wait
|
||||
.Ar 3
|
||||
seconds before attempting to reconnect. This may happen up to
|
||||
.Ar 5
|
||||
times before
|
||||
.Nm
|
||||
gives up. The default value of ntries is zero (no redial). Care
|
||||
should be taken with this option. If the local timeout is slightly
|
||||
longer than the remote timeout, the reconnect feature will always be
|
||||
triggered (up to the given number of times) after the remote side
|
||||
times out and hangs up.
|
||||
|
||||
If the
|
||||
.Fl background
|
||||
flag is specified, all phone numbers are dialed at most once until
|
||||
a connection is made. The next number redial period specified with
|
||||
the
|
||||
.Dq set redial
|
||||
command is honoured.
|
||||
command is honoured, as is the reconnect tries value.
|
||||
|
||||
To terminate the program, type
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: vars.c,v 1.12 1997/02/22 16:11:00 peter Exp $
|
||||
* $Id: vars.c,v 1.13 1997/04/14 23:48:19 brian Exp $
|
||||
*
|
||||
*/
|
||||
#include "fsm.h"
|
||||
@ -29,7 +29,7 @@
|
||||
#include "defs.h"
|
||||
|
||||
char VarVersion[] = "Version 0.94";
|
||||
char VarLocalVersion[] = "$Date: 1997/02/22 16:11:00 $";
|
||||
char VarLocalVersion[] = "$Date: 1997/04/14 23:48:19 $";
|
||||
|
||||
/*
|
||||
* Order of conf option is important. See vars.h.
|
||||
@ -50,7 +50,8 @@ struct confdesc pppConfs[] = {
|
||||
|
||||
struct pppvars pppVars = {
|
||||
DEF_MRU, 0, MODEM_SPEED, CS8, MODEM_CTSRTS, 180, 30, 3,
|
||||
REDIAL_PERIOD, NEXT_REDIAL_PERIOD, 1, MODEM_DEV, OPEN_PASSIVE, LOCAL_NO_AUTH,
|
||||
RECONNECT_TIMER, RECONNECT_TRIES, REDIAL_PERIOD,
|
||||
NEXT_REDIAL_PERIOD, 1, MODEM_DEV, OPEN_PASSIVE, LOCAL_NO_AUTH,
|
||||
};
|
||||
|
||||
int
|
||||
|
@ -15,7 +15,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: vars.h,v 1.10 1997/02/22 16:11:02 peter Exp $
|
||||
* $Id: vars.h,v 1.11 1997/04/14 23:48:20 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -62,6 +62,8 @@ struct pppvars {
|
||||
int idle_timeout; /* Idle timeout value */
|
||||
int lqr_timeout; /* LQR timeout value */
|
||||
int retry_timeout; /* Retry timeout value */
|
||||
int reconnect_timer; /* Timeout before reconnect on carrier loss */
|
||||
int reconnect_tries; /* Attempt reconnect on carrier loss */
|
||||
int redial_timeout; /* Redial timeout value */
|
||||
int redial_next_timeout; /* Redial next timeout value */
|
||||
int dial_tries; /* Dial attempts before giving up, 0 == forever */
|
||||
@ -101,6 +103,8 @@ struct pppvars {
|
||||
#define VarPhoneCopy pppVars.phone_copy
|
||||
#define VarNextPhone pppVars.next_phone
|
||||
#define VarShortHost pppVars.shostname
|
||||
#define VarReconnectTimer pppVars.reconnect_timer
|
||||
#define VarReconnectTries pppVars.reconnect_tries
|
||||
#define VarRedialTimeout pppVars.redial_timeout
|
||||
#define VarRedialNextTimeout pppVars.redial_next_timeout
|
||||
#define VarDialTries pppVars.dial_tries
|
||||
@ -111,4 +115,5 @@ extern struct pppvars pppVars;
|
||||
|
||||
int ipInOctets, ipOutOctets, ipKeepAlive;
|
||||
int ipConnectSecs, ipIdleSecs;
|
||||
int lostCarrier;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user