aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/ppp
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/ppp')
-rw-r--r--usr.sbin/ppp/command.c33
-rw-r--r--usr.sbin/ppp/datalink.c37
-rw-r--r--usr.sbin/ppp/datalink.h12
-rw-r--r--usr.sbin/ppp/defs.h6
-rw-r--r--usr.sbin/ppp/vars.c7
-rw-r--r--usr.sbin/ppp/vars.h8
6 files changed, 55 insertions, 48 deletions
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c
index 0c813dcd5d6e..7a91d37c10f2 100644
--- a/usr.sbin/ppp/command.c
+++ b/usr.sbin/ppp/command.c
@@ -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.131.2.18 1998/02/16 19:09:44 brian Exp $
+ * $Id: command.c,v 1.131.2.19 1998/02/16 19:10:30 brian Exp $
*
*/
#include <sys/param.h>
@@ -523,22 +523,24 @@ ShowReconnect(struct cmdargs const *arg)
static int
ShowRedial(struct cmdargs const *arg)
{
+ struct datalink *dl = bundle2datalink(arg->bundle, NULL);
+
prompt_Printf(&prompt, " Redial Timer: ");
- if (VarRedialTimeout >= 0)
- prompt_Printf(&prompt, " %d seconds, ", VarRedialTimeout);
+ if (dl->dial_timeout >= 0)
+ prompt_Printf(&prompt, " %d seconds, ", dl->dial_timeout);
else
- prompt_Printf(&prompt, " Random 0 - %d seconds, ", REDIAL_PERIOD);
+ prompt_Printf(&prompt, " Random 0 - %d seconds, ", DIAL_TIMEOUT);
prompt_Printf(&prompt, " Redial Next Timer: ");
- if (VarRedialNextTimeout >= 0)
- prompt_Printf(&prompt, " %d seconds, ", VarRedialNextTimeout);
+ if (dl->dial_next_timeout >= 0)
+ prompt_Printf(&prompt, " %d seconds, ", dl->dial_next_timeout);
else
- prompt_Printf(&prompt, " Random 0 - %d seconds, ", REDIAL_PERIOD);
+ prompt_Printf(&prompt, " Random 0 - %d seconds, ", DIAL_TIMEOUT);
- if (VarDialTries)
- prompt_Printf(&prompt, "%d dial tries", VarDialTries);
+ if (dl->max_dial)
+ prompt_Printf(&prompt, "%d dial tries", dl->max_dial);
prompt_Printf(&prompt, "\n");
@@ -868,6 +870,7 @@ SetReconnect(struct cmdargs const *arg)
static int
SetRedialTimeout(struct cmdargs const *arg)
{
+ struct datalink *dl = bundle2datalink(arg->bundle, NULL);
int timeout;
int tries;
char *dot;
@@ -875,13 +878,13 @@ SetRedialTimeout(struct cmdargs const *arg)
if (arg->argc == 1 || arg->argc == 2) {
if (strncasecmp(arg->argv[0], "random", 6) == 0 &&
(arg->argv[0][6] == '\0' || arg->argv[0][6] == '.')) {
- VarRedialTimeout = -1;
+ dl->dial_timeout = -1;
randinit();
} else {
timeout = atoi(arg->argv[0]);
if (timeout >= 0)
- VarRedialTimeout = timeout;
+ dl->dial_timeout = timeout;
else {
LogPrintf(LogWARN, "Invalid redial timeout\n");
return -1;
@@ -891,25 +894,25 @@ SetRedialTimeout(struct cmdargs const *arg)
dot = strchr(arg->argv[0], '.');
if (dot) {
if (strcasecmp(++dot, "random") == 0) {
- VarRedialNextTimeout = -1;
+ dl->dial_next_timeout = -1;
randinit();
} else {
timeout = atoi(dot);
if (timeout >= 0)
- VarRedialNextTimeout = timeout;
+ dl->dial_next_timeout = timeout;
else {
LogPrintf(LogWARN, "Invalid next redial timeout\n");
return -1;
}
}
} else
- VarRedialNextTimeout = NEXT_REDIAL_PERIOD; /* Default next timeout */
+ dl->dial_next_timeout = DIAL_NEXT_TIMEOUT; /* Default next timeout */
if (arg->argc == 2) {
tries = atoi(arg->argv[1]);
if (tries >= 0) {
- VarDialTries = tries;
+ dl->max_dial = tries;
} else {
LogPrintf(LogWARN, "Invalid retry value\n");
return 1;
diff --git a/usr.sbin/ppp/datalink.c b/usr.sbin/ppp/datalink.c
index 9310944af8ac..f803a32813d0 100644
--- a/usr.sbin/ppp/datalink.c
+++ b/usr.sbin/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.1.2.3 1998/02/16 19:09:48 brian Exp $
+ * $Id: datalink.c,v 1.1.2.4 1998/02/16 19:10:35 brian Exp $
*/
#include <sys/param.h>
@@ -78,7 +78,7 @@ datalink_StartDialTimer(struct datalink *dl, int Timeout)
if (Timeout > 0)
dl->dial_timer.load = Timeout * SECTICKS;
else
- dl->dial_timer.load = (random() % REDIAL_PERIOD) * SECTICKS;
+ dl->dial_timer.load = (random() % DIAL_TIMEOUT) * SECTICKS;
dl->dial_timer.func = datalink_OpenTimeout;
dl->dial_timer.arg = dl;
StartTimer(&dl->dial_timer);
@@ -98,21 +98,21 @@ datalink_HangupDone(struct datalink *dl)
dl->state = DATALINK_CLOSED;
dl->dial_tries = -1;
dl->reconnect_tries = 0;
- datalink_StartDialTimer(dl, VarRedialTimeout);
+ datalink_StartDialTimer(dl, dl->dial_timeout);
bundle_LinkClosed(dl->bundle, dl);
} else {
LogPrintf(LogPHASE, "%s: Entering OPENING state\n", dl->name);
dl->state = DATALINK_OPENING;
if (dl->dial_tries < 0) {
datalink_StartDialTimer(dl, dl->reconnect_timeout);
- dl->dial_tries = VarDialTries;
+ dl->dial_tries = dl->max_dial;
dl->reconnect_tries--;
} else {
dl->dial_tries--;
if (VarNextPhone == NULL)
- datalink_StartDialTimer(dl, VarRedialTimeout);
+ datalink_StartDialTimer(dl, dl->dial_timeout);
else
- datalink_StartDialTimer(dl, VarRedialNextTimeout);
+ datalink_StartDialTimer(dl, dl->dial_next_timeout);
}
}
}
@@ -137,24 +137,24 @@ datalink_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
LogPrintf(LogPHASE, "%s: Entering DIAL state\n", dl->name);
dl->state = DATALINK_DIAL;
chat_Init(&dl->chat, dl->physical, dl->script.dial, 1);
- if (!(mode & MODE_DDIAL) && VarDialTries)
+ if (!(mode & MODE_DDIAL) && dl->max_dial)
LogPrintf(LogCHAT, "%s: Dial attempt %u of %d\n",
- dl->name, VarDialTries - dl->dial_tries, VarDialTries);
+ dl->name, dl->max_dial - dl->dial_tries, dl->max_dial);
} else {
- if (!(mode & MODE_DDIAL) && VarDialTries)
+ if (!(mode & MODE_DDIAL) && dl->max_dial)
LogPrintf(LogCHAT, "Failed to open modem (attempt %u of %d)\n",
- VarDialTries - dl->dial_tries, VarDialTries);
+ dl->max_dial - dl->dial_tries, dl->max_dial);
else
LogPrintf(LogCHAT, "Failed to open modem\n");
- if (!(mode & MODE_DDIAL) && VarDialTries && dl->dial_tries == 0) {
+ if (!(mode & MODE_DDIAL) && dl->max_dial && dl->dial_tries == 0) {
LogPrintf(LogPHASE, "%s: Entering CLOSED state\n", dl->name);
dl->state = DATALINK_CLOSED;
dl->reconnect_tries = 0;
dl->dial_tries = -1;
bundle_LinkClosed(dl->bundle, dl);
} else
- datalink_StartDialTimer(dl, VarRedialTimeout);
+ datalink_StartDialTimer(dl, dl->dial_timeout);
}
}
break;
@@ -289,17 +289,24 @@ datalink_Create(const char *name, struct bundle *bundle)
dl->desc.Read = datalink_Read;
dl->desc.Write = datalink_Write;
+ dl->state = DATALINK_CLOSED;
+
*dl->script.dial = '\0';
*dl->script.login = '\0';
*dl->script.hangup = '\0';
- dl->state = DATALINK_CLOSED;
dl->bundle = bundle;
dl->next = NULL;
+
memset(&dl->dial_timer, '\0', sizeof dl->dial_timer);
+
dl->dial_tries = 0;
- dl->max_reconnect = 0;
+ dl->max_dial = 1;
+ dl->dial_timeout = DIAL_TIMEOUT;
+ dl->dial_next_timeout = DIAL_NEXT_TIMEOUT;
+
dl->reconnect_tries = 0;
+ dl->max_reconnect = 0;
dl->reconnect_timeout = RECONNECT_TIMEOUT;
dl->name = strdup(name);
@@ -342,7 +349,7 @@ datalink_Up(struct datalink *dl)
LogPrintf(LogPHASE, "%s: Entering OPENING state\n", dl->name);
dl->state = DATALINK_OPENING;
dl->reconnect_tries = dl->max_reconnect;
- dl->dial_tries = VarDialTries;
+ dl->dial_tries = dl->max_dial;
}
}
diff --git a/usr.sbin/ppp/datalink.h b/usr.sbin/ppp/datalink.h
index d5ba109976e2..9b213ce27b79 100644
--- a/usr.sbin/ppp/datalink.h
+++ b/usr.sbin/ppp/datalink.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: datalink.h,v 1.1.2.2 1998/02/16 19:09:51 brian Exp $
+ * $Id: datalink.h,v 1.1.2.3 1998/02/16 19:10:36 brian Exp $
*/
#define DATALINK_CLOSED (0)
@@ -46,12 +46,16 @@ struct datalink {
} script;
struct pppTimer dial_timer; /* For timing between opens & scripts */
- int dial_tries; /* try again this number of times */
- int max_reconnect; /* initially try again this number of times */
+
+ int dial_tries; /* currently try again this number of times */
+ int max_dial; /* initially try again this number of times */
+ int dial_timeout; /* Redial timeout value */
+ int dial_next_timeout; /* Redial next timeout value */
+
unsigned reconnect_tries; /* currently try again this number of times */
+ int max_reconnect; /* initially try again this number of times */
int reconnect_timeout; /* Timeout before reconnect on carrier loss */
-
char *name; /* Our name */
#ifdef soon
diff --git a/usr.sbin/ppp/defs.h b/usr.sbin/ppp/defs.h
index 7aaf3915da1c..bacb701234aa 100644
--- a/usr.sbin/ppp/defs.h
+++ b/usr.sbin/ppp/defs.h
@@ -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.29.2.1 1998/01/29 00:49:16 brian Exp $
+ * $Id: defs.h,v 1.29.2.2 1998/02/16 19:10:38 brian Exp $
*
* TODO:
*/
@@ -40,8 +40,8 @@
#define SERVER_PORT 3000 /* Base server port no. */
#define MODEM_CTSRTS 1 /* Default (true): use CTS/RTS signals */
#define RECONNECT_TIMEOUT 3 /* Default timer for carrier loss */
-#define REDIAL_PERIOD 30 /* Default Hold time to redial */
-#define NEXT_REDIAL_PERIOD 3 /* Default Hold time to next number redial */
+#define DIAL_TIMEOUT 30 /* Default and Max random time to redial */
+#define DIAL_NEXT_TIMEOUT 3 /* Default Hold time to next number redial */
#define SCRIPT_LEN 512 /* Size of login scripts */
#define LINE_LEN SCRIPT_LEN /* Size of login scripts */
#define MAXARGS 40 /* How many args per config line */
diff --git a/usr.sbin/ppp/vars.c b/usr.sbin/ppp/vars.c
index 102b01a806d3..5003a87034d5 100644
--- a/usr.sbin/ppp/vars.c
+++ b/usr.sbin/ppp/vars.c
@@ -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.45.2.8 1998/02/16 00:01:08 brian Exp $
+ * $Id: vars.c,v 1.45.2.9 1998/02/16 19:10:40 brian Exp $
*
*/
#include <sys/param.h>
@@ -46,7 +46,7 @@
#include "prompt.h"
char VarVersion[] = "PPP Version 2.0-beta";
-char VarLocalVersion[] = "$Date: 1998/02/16 00:01:08 $";
+char VarLocalVersion[] = "$Date: 1998/02/16 19:10:40 $";
int Utmp = 0;
int ipKeepAlive = 0;
@@ -73,8 +73,7 @@ struct confdesc pppConfs[] = {
struct pppvars pppVars = {
DEF_MRU, DEF_MTU, 0, MODEM_SPEED, CS8, MODEM_CTSRTS, 180, 30, 3,
- REDIAL_PERIOD, NEXT_REDIAL_PERIOD, 1, 1, MODEM_DEV, "", BASE_MODEM_DEV,
- 1, LOCAL_NO_AUTH
+ 1, MODEM_DEV, "", BASE_MODEM_DEV, 1, LOCAL_NO_AUTH
};
int
diff --git a/usr.sbin/ppp/vars.h b/usr.sbin/ppp/vars.h
index 4a74d543c264..ac1ef21d3f5b 100644
--- a/usr.sbin/ppp/vars.h
+++ b/usr.sbin/ppp/vars.h
@@ -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.42.2.5 1998/02/16 19:10:03 brian Exp $
+ * $Id: vars.h,v 1.42.2.6 1998/02/16 19:10:44 brian Exp $
*
* TODO:
*/
@@ -64,9 +64,6 @@ struct pppvars {
int idle_timeout; /* Idle timeout value */
int lqr_timeout; /* LQR timeout value */
int retry_timeout; /* Retry timeout value */
- int redial_timeout; /* Redial timeout value */
- int redial_next_timeout; /* Redial next timeout value */
- int dial_tries; /* Dial attempts before giving up, 0 == inf */
int loopback; /* Turn around packets addressed to me */
char modem_devlist[LINE_LEN]; /* Comma-separated list of devices */
char modem_dev[40]; /* Name of device / host:port */
@@ -123,9 +120,6 @@ struct pppvars {
#define VarNextPhone pppVars.next_phone
#define VarAltPhone pppVars.alt_phone
#define VarShortHost pppVars.shostname
-#define VarRedialTimeout pppVars.redial_timeout
-#define VarRedialNextTimeout pppVars.redial_next_timeout
-#define VarDialTries pppVars.dial_tries
#define VarLoopback pppVars.loopback
#define VarAliasHandlers pppVars.handler