Cosmetic: Group configuration items in struct datalink.
This commit is contained in:
parent
c7cc50305f
commit
73a13b5c4d
@ -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.23 1998/02/17 19:28:09 brian Exp $
|
||||
* $Id: command.c,v 1.131.2.24 1998/02/17 19:28:25 brian Exp $
|
||||
*
|
||||
*/
|
||||
#include <sys/param.h>
|
||||
@ -517,8 +517,8 @@ static int
|
||||
ShowReconnect(struct cmdargs const *arg)
|
||||
{
|
||||
prompt_Printf(&prompt, "%s: Reconnect Timer: %d, %d tries\n",
|
||||
arg->cx->name, arg->cx->reconnect_timeout,
|
||||
arg->cx->max_reconnect);
|
||||
arg->cx->name, arg->cx->cfg.reconnect_timeout,
|
||||
arg->cx->cfg.max_reconnect);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -527,20 +527,20 @@ ShowRedial(struct cmdargs const *arg)
|
||||
{
|
||||
prompt_Printf(&prompt, " Redial Timer: ");
|
||||
|
||||
if (arg->cx->dial_timeout >= 0)
|
||||
prompt_Printf(&prompt, " %d seconds, ", arg->cx->dial_timeout);
|
||||
if (arg->cx->cfg.dial_timeout >= 0)
|
||||
prompt_Printf(&prompt, " %d seconds, ", arg->cx->cfg.dial_timeout);
|
||||
else
|
||||
prompt_Printf(&prompt, " Random 0 - %d seconds, ", DIAL_TIMEOUT);
|
||||
|
||||
prompt_Printf(&prompt, " Redial Next Timer: ");
|
||||
|
||||
if (arg->cx->dial_next_timeout >= 0)
|
||||
prompt_Printf(&prompt, " %d seconds, ", arg->cx->dial_next_timeout);
|
||||
if (arg->cx->cfg.dial_next_timeout >= 0)
|
||||
prompt_Printf(&prompt, " %d seconds, ", arg->cx->cfg.dial_next_timeout);
|
||||
else
|
||||
prompt_Printf(&prompt, " Random 0 - %d seconds, ", DIAL_TIMEOUT);
|
||||
|
||||
if (arg->cx->max_dial)
|
||||
prompt_Printf(&prompt, "%d dial tries", arg->cx->max_dial);
|
||||
if (arg->cx->cfg.max_dial)
|
||||
prompt_Printf(&prompt, "%d dial tries", arg->cx->cfg.max_dial);
|
||||
|
||||
prompt_Printf(&prompt, "\n");
|
||||
|
||||
@ -874,8 +874,8 @@ static int
|
||||
SetReconnect(struct cmdargs const *arg)
|
||||
{
|
||||
if (arg->argc == 2) {
|
||||
arg->cx->reconnect_timeout = atoi(arg->argv[0]);
|
||||
arg->cx->max_reconnect = (mode & MODE_DIRECT) ? 0 : atoi(arg->argv[1]);
|
||||
arg->cx->cfg.reconnect_timeout = atoi(arg->argv[0]);
|
||||
arg->cx->cfg.max_reconnect = (mode & MODE_DIRECT) ? 0 : atoi(arg->argv[1]);
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
@ -891,13 +891,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] == '.')) {
|
||||
arg->cx->dial_timeout = -1;
|
||||
arg->cx->cfg.dial_timeout = -1;
|
||||
randinit();
|
||||
} else {
|
||||
timeout = atoi(arg->argv[0]);
|
||||
|
||||
if (timeout >= 0)
|
||||
arg->cx->dial_timeout = timeout;
|
||||
arg->cx->cfg.dial_timeout = timeout;
|
||||
else {
|
||||
LogPrintf(LogWARN, "Invalid redial timeout\n");
|
||||
return -1;
|
||||
@ -907,12 +907,12 @@ SetRedialTimeout(struct cmdargs const *arg)
|
||||
dot = strchr(arg->argv[0], '.');
|
||||
if (dot) {
|
||||
if (strcasecmp(++dot, "random") == 0) {
|
||||
arg->cx->dial_next_timeout = -1;
|
||||
arg->cx->cfg.dial_next_timeout = -1;
|
||||
randinit();
|
||||
} else {
|
||||
timeout = atoi(dot);
|
||||
if (timeout >= 0)
|
||||
arg->cx->dial_next_timeout = timeout;
|
||||
arg->cx->cfg.dial_next_timeout = timeout;
|
||||
else {
|
||||
LogPrintf(LogWARN, "Invalid next redial timeout\n");
|
||||
return -1;
|
||||
@ -920,13 +920,13 @@ SetRedialTimeout(struct cmdargs const *arg)
|
||||
}
|
||||
} else
|
||||
/* Default next timeout */
|
||||
arg->cx->dial_next_timeout = DIAL_NEXT_TIMEOUT;
|
||||
arg->cx->cfg.dial_next_timeout = DIAL_NEXT_TIMEOUT;
|
||||
|
||||
if (arg->argc == 2) {
|
||||
tries = atoi(arg->argv[1]);
|
||||
|
||||
if (tries >= 0) {
|
||||
arg->cx->max_dial = tries;
|
||||
arg->cx->cfg.max_dial = tries;
|
||||
} else {
|
||||
LogPrintf(LogWARN, "Invalid retry value\n");
|
||||
return 1;
|
||||
@ -1326,14 +1326,14 @@ SetVariable(struct cmdargs const *arg)
|
||||
break;
|
||||
case VAR_DIAL:
|
||||
if (!(mode & (MODE_DIRECT|MODE_DEDICATED))) {
|
||||
strncpy(cx->script.dial, argp, sizeof cx->script.dial - 1);
|
||||
cx->script.dial[sizeof cx->script.dial - 1] = '\0';
|
||||
strncpy(cx->cfg.script.dial, argp, sizeof cx->cfg.script.dial - 1);
|
||||
cx->cfg.script.dial[sizeof cx->cfg.script.dial - 1] = '\0';
|
||||
}
|
||||
break;
|
||||
case VAR_LOGIN:
|
||||
if (!(mode & (MODE_DIRECT|MODE_DEDICATED))) {
|
||||
strncpy(cx->script.login, argp, sizeof cx->script.login - 1);
|
||||
cx->script.login[sizeof cx->script.login - 1] = '\0';
|
||||
strncpy(cx->cfg.script.login, argp, sizeof cx->cfg.script.login - 1);
|
||||
cx->cfg.script.login[sizeof cx->cfg.script.login - 1] = '\0';
|
||||
}
|
||||
break;
|
||||
case VAR_DEVICE:
|
||||
@ -1353,8 +1353,8 @@ SetVariable(struct cmdargs const *arg)
|
||||
break;
|
||||
case VAR_HANGUP:
|
||||
if (!(mode & (MODE_DIRECT|MODE_DEDICATED))) {
|
||||
strncpy(cx->script.hangup, argp, sizeof cx->script.hangup - 1);
|
||||
cx->script.hangup[sizeof cx->script.hangup - 1] = '\0';
|
||||
strncpy(cx->cfg.script.hangup, argp, sizeof cx->cfg.script.hangup - 1);
|
||||
cx->cfg.script.hangup[sizeof cx->cfg.script.hangup - 1] = '\0';
|
||||
}
|
||||
break;
|
||||
#ifdef HAVE_DES
|
||||
|
@ -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.7 1998/02/17 19:27:55 brian Exp $
|
||||
* $Id: datalink.c,v 1.1.2.8 1998/02/17 19:28:27 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -103,20 +103,20 @@ datalink_HangupDone(struct datalink *dl)
|
||||
dl->dial_tries = -1;
|
||||
dl->reconnect_tries = 0;
|
||||
bundle_LinkClosed(dl->bundle, dl);
|
||||
datalink_StartDialTimer(dl, dl->dial_timeout);
|
||||
datalink_StartDialTimer(dl, dl->cfg.dial_timeout);
|
||||
} else {
|
||||
LogPrintf(LogPHASE, "%s: Re-entering OPENING state\n", dl->name);
|
||||
dl->state = DATALINK_OPENING;
|
||||
if (dl->dial_tries < 0) {
|
||||
datalink_StartDialTimer(dl, dl->reconnect_timeout);
|
||||
dl->dial_tries = dl->max_dial;
|
||||
datalink_StartDialTimer(dl, dl->cfg.reconnect_timeout);
|
||||
dl->dial_tries = dl->cfg.max_dial;
|
||||
dl->reconnect_tries--;
|
||||
} else {
|
||||
dl->dial_tries--;
|
||||
if (VarNextPhone == NULL)
|
||||
datalink_StartDialTimer(dl, dl->dial_timeout);
|
||||
datalink_StartDialTimer(dl, dl->cfg.dial_timeout);
|
||||
else
|
||||
datalink_StartDialTimer(dl, dl->dial_next_timeout);
|
||||
datalink_StartDialTimer(dl, dl->cfg.dial_next_timeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -131,7 +131,7 @@ datalink_LoginDone(struct datalink *dl)
|
||||
LogPrintf(LogPHASE, "%s: Entering HANGUP state\n", dl->name);
|
||||
dl->state = DATALINK_HANGUP;
|
||||
modem_Offline(dl->physical);
|
||||
chat_Init(&dl->chat, dl->physical, dl->script.hangup, 1);
|
||||
chat_Init(&dl->chat, dl->physical, dl->cfg.script.hangup, 1);
|
||||
} else
|
||||
datalink_HangupDone(dl);
|
||||
} else {
|
||||
@ -175,27 +175,28 @@ datalink_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
|
||||
if (dl->script.run) {
|
||||
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) && dl->max_dial)
|
||||
chat_Init(&dl->chat, dl->physical, dl->cfg.script.dial, 1);
|
||||
if (!(mode & MODE_DDIAL) && dl->cfg.max_dial)
|
||||
LogPrintf(LogCHAT, "%s: Dial attempt %u of %d\n",
|
||||
dl->name, dl->max_dial - dl->dial_tries, dl->max_dial);
|
||||
dl->name, dl->cfg.max_dial - dl->dial_tries,
|
||||
dl->cfg.max_dial);
|
||||
} else
|
||||
datalink_LoginDone(dl);
|
||||
} else {
|
||||
if (!(mode & MODE_DDIAL) && dl->max_dial)
|
||||
if (!(mode & MODE_DDIAL) && dl->cfg.max_dial)
|
||||
LogPrintf(LogCHAT, "Failed to open modem (attempt %u of %d)\n",
|
||||
dl->max_dial - dl->dial_tries, dl->max_dial);
|
||||
dl->cfg.max_dial - dl->dial_tries, dl->cfg.max_dial);
|
||||
else
|
||||
LogPrintf(LogCHAT, "Failed to open modem\n");
|
||||
|
||||
if (!(mode & MODE_DDIAL) && dl->max_dial && dl->dial_tries == 0) {
|
||||
if (!(mode & MODE_DDIAL) && dl->cfg.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);
|
||||
}
|
||||
datalink_StartDialTimer(dl, dl->dial_timeout);
|
||||
datalink_StartDialTimer(dl, dl->cfg.dial_timeout);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -214,7 +215,7 @@ datalink_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
|
||||
case DATALINK_DIAL:
|
||||
LogPrintf(LogPHASE, "%s: Entering LOGIN state\n", dl->name);
|
||||
dl->state = DATALINK_LOGIN;
|
||||
chat_Init(&dl->chat, dl->physical, dl->script.login, 0);
|
||||
chat_Init(&dl->chat, dl->physical, dl->cfg.script.login, 0);
|
||||
break;
|
||||
case DATALINK_LOGIN:
|
||||
datalink_LoginDone(dl);
|
||||
@ -233,7 +234,7 @@ datalink_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
|
||||
LogPrintf(LogPHASE, "%s: Entering HANGUP state\n", dl->name);
|
||||
dl->state = DATALINK_HANGUP;
|
||||
modem_Offline(dl->physical);
|
||||
chat_Init(&dl->chat, dl->physical, dl->script.hangup, 1);
|
||||
chat_Init(&dl->chat, dl->physical, dl->cfg.script.hangup, 1);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -334,9 +335,9 @@ datalink_Create(const char *name, struct bundle *bundle)
|
||||
|
||||
dl->state = DATALINK_CLOSED;
|
||||
|
||||
*dl->script.dial = '\0';
|
||||
*dl->script.login = '\0';
|
||||
*dl->script.hangup = '\0';
|
||||
*dl->cfg.script.dial = '\0';
|
||||
*dl->cfg.script.login = '\0';
|
||||
*dl->cfg.script.hangup = '\0';
|
||||
dl->script.run = 1;
|
||||
dl->script.packetmode = 1;
|
||||
|
||||
@ -346,13 +347,13 @@ datalink_Create(const char *name, struct bundle *bundle)
|
||||
memset(&dl->dial_timer, '\0', sizeof dl->dial_timer);
|
||||
|
||||
dl->dial_tries = 0;
|
||||
dl->max_dial = 1;
|
||||
dl->dial_timeout = DIAL_TIMEOUT;
|
||||
dl->dial_next_timeout = DIAL_NEXT_TIMEOUT;
|
||||
dl->cfg.max_dial = 1;
|
||||
dl->cfg.dial_timeout = DIAL_TIMEOUT;
|
||||
dl->cfg.dial_next_timeout = DIAL_NEXT_TIMEOUT;
|
||||
|
||||
dl->reconnect_tries = 0;
|
||||
dl->max_reconnect = 0;
|
||||
dl->reconnect_timeout = RECONNECT_TIMEOUT;
|
||||
dl->cfg.max_reconnect = 0;
|
||||
dl->cfg.reconnect_timeout = RECONNECT_TIMEOUT;
|
||||
|
||||
dl->name = strdup(name);
|
||||
if ((dl->physical = modem_Create(dl->name)) == NULL) {
|
||||
@ -396,8 +397,8 @@ datalink_Up(struct datalink *dl, int runscripts, int packetmode)
|
||||
case DATALINK_CLOSED:
|
||||
LogPrintf(LogPHASE, "%s: Entering OPENING state\n", dl->name);
|
||||
dl->state = DATALINK_OPENING;
|
||||
dl->reconnect_tries = dl->max_reconnect;
|
||||
dl->dial_tries = dl->max_dial;
|
||||
dl->reconnect_tries = dl->cfg.max_reconnect;
|
||||
dl->dial_tries = dl->cfg.max_dial;
|
||||
dl->script.run = runscripts;
|
||||
dl->script.packetmode = packetmode;
|
||||
break;
|
||||
@ -432,7 +433,7 @@ datalink_ComeDown(struct datalink *dl, int stay)
|
||||
if (dl->script.run) {
|
||||
LogPrintf(LogPHASE, "%s: Entering HANGUP state\n", dl->name);
|
||||
dl->state = DATALINK_HANGUP;
|
||||
chat_Init(&dl->chat, dl->physical, dl->script.hangup, 1);
|
||||
chat_Init(&dl->chat, dl->physical, dl->cfg.script.hangup, 1);
|
||||
} else
|
||||
datalink_HangupDone(dl);
|
||||
}
|
||||
|
@ -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.5 1998/02/17 01:05:38 brian Exp $
|
||||
* $Id: datalink.h,v 1.1.2.6 1998/02/17 19:28:28 brian Exp $
|
||||
*/
|
||||
|
||||
#define DATALINK_CLOSED (0)
|
||||
@ -40,24 +40,29 @@ struct datalink {
|
||||
struct physical *physical; /* Our link */
|
||||
|
||||
struct chat chat; /* For bringing the link up & down */
|
||||
|
||||
struct {
|
||||
char dial[SCRIPT_LEN]; /* dial */
|
||||
char login[SCRIPT_LEN]; /* login */
|
||||
char hangup[SCRIPT_LEN]; /* hangup */
|
||||
unsigned run : 1; /* run scripts ? */
|
||||
unsigned packetmode : 1; /* Go into packet mode after login ? */
|
||||
} script;
|
||||
|
||||
struct pppTimer dial_timer; /* For timing between opens & scripts */
|
||||
|
||||
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 */
|
||||
struct {
|
||||
struct {
|
||||
char dial[SCRIPT_LEN]; /* dial */
|
||||
char login[SCRIPT_LEN]; /* login */
|
||||
char hangup[SCRIPT_LEN]; /* hangup */
|
||||
} script;
|
||||
int max_dial; /* initially try again this number of times */
|
||||
int dial_timeout; /* Redial timeout value */
|
||||
int dial_next_timeout; /* Redial next timeout value */
|
||||
int max_reconnect; /* initially try again this number of times */
|
||||
int reconnect_timeout; /* Timeout before reconnect on carrier loss */
|
||||
} cfg; /* All our config data is in here */
|
||||
|
||||
int dial_tries; /* currently try again this number of times */
|
||||
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 */
|
||||
|
||||
|
@ -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.77.2.19 1998/02/17 19:27:57 brian Exp $
|
||||
* $Id: modem.c,v 1.77.2.20 1998/02/17 19:28:33 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -948,9 +948,9 @@ modem_ShowStatus(struct cmdargs const *arg)
|
||||
#endif
|
||||
prompt_Printf(&prompt, "outqlen: %d\n",
|
||||
link_QueueLen(&arg->cx->physical->link));
|
||||
prompt_Printf(&prompt, "DialScript = %s\n", arg->cx->script.dial);
|
||||
prompt_Printf(&prompt, "LoginScript = %s\n", arg->cx->script.login);
|
||||
prompt_Printf(&prompt, "PhoneNumber(s) = %s\n", arg->cx->script.hangup);
|
||||
prompt_Printf(&prompt, "DialScript = %s\n", arg->cx->cfg.script.dial);
|
||||
prompt_Printf(&prompt, "LoginScript = %s\n", arg->cx->cfg.script.login);
|
||||
prompt_Printf(&prompt, "PhoneNumber(s) = %s\n", arg->cx->cfg.script.hangup);
|
||||
|
||||
prompt_Printf(&prompt, "\n");
|
||||
throughput_disp(&arg->cx->physical->link.throughput);
|
||||
|
Loading…
x
Reference in New Issue
Block a user