summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/ppp')
-rw-r--r--usr.sbin/ppp/ccp.c11
-rw-r--r--usr.sbin/ppp/command.c11
-rw-r--r--usr.sbin/ppp/fsm.c37
-rw-r--r--usr.sbin/ppp/fsm.h6
-rw-r--r--usr.sbin/ppp/ipcp.c9
-rw-r--r--usr.sbin/ppp/lcp.c16
-rw-r--r--usr.sbin/ppp/main.c22
-rw-r--r--usr.sbin/ppp/main.h4
-rw-r--r--usr.sbin/ppp/modem.c4
-rw-r--r--usr.sbin/ppp/ppp.821
-rw-r--r--usr.sbin/ppp/ppp.8.m421
-rw-r--r--usr.sbin/ppp/vars.c6
-rw-r--r--usr.sbin/ppp/vars.h4
13 files changed, 110 insertions, 62 deletions
diff --git a/usr.sbin/ppp/ccp.c b/usr.sbin/ppp/ccp.c
index 16e86b2..248da3f 100644
--- a/usr.sbin/ppp/ccp.c
+++ b/usr.sbin/ppp/ccp.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: ccp.c,v 1.27 1998/01/04 20:25:39 brian Exp $
+ * $Id: ccp.c,v 1.28 1998/01/10 01:55:08 brian Exp $
*
* TODO:
* o Support other compression protocols
@@ -59,12 +59,13 @@ struct fsm CcpFsm = {
"CCP",
PROTO_CCP,
CCP_MAXCODE,
- OPEN_ACTIVE,
+ 0,
ST_INITIAL,
0, 0, 0,
0,
- {0, 0, 0, NULL, NULL, NULL},
- {0, 0, 0, NULL, NULL, NULL},
+ {0, 0, 0, NULL, NULL, NULL}, /* FSM timer */
+ {0, 0, 0, NULL, NULL, NULL}, /* Open timer */
+ {0, 0, 0, NULL, NULL, NULL}, /* Stopped timer */
LogCCP,
CcpLayerUp,
@@ -270,7 +271,7 @@ CcpOpen()
for (f = 0; f < NALGORITHMS; f++)
if (Enabled(algorithm[f]->Conf)) {
- CcpFsm.open_mode = OPEN_ACTIVE;
+ CcpFsm.open_mode = 0;
FsmOpen(&CcpFsm);
break;
}
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c
index d410640..7a9a526 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.127 1998/01/11 17:50:31 brian Exp $
+ * $Id: command.c,v 1.128 1998/01/18 20:49:15 brian Exp $
*
*/
#include <sys/param.h>
@@ -190,9 +190,8 @@ DialCommand(struct cmdargs const *arg)
break;
}
if ((res = DialModem()) == EX_DONE) {
- nointr_sleep(1);
ModemTimeout(NULL);
- PacketMode();
+ PacketMode(VarOpenMode);
break;
} else if (res == EX_SIG)
return 1;
@@ -1400,9 +1399,9 @@ static int
SetOpenMode(struct cmdargs const *arg)
{
if (arg->argc > 0) {
- if (strcmp(*arg->argv, "active") == 0)
- VarOpenMode = OPEN_ACTIVE;
- else if (strcmp(*arg->argv, "passive") == 0)
+ if (strcasecmp(*arg->argv, "active") == 0)
+ VarOpenMode = arg->argc > 1 ? atoi(arg->argv[1]) : 1;
+ else if (strcasecmp(*arg->argv, "passive") == 0)
VarOpenMode = OPEN_PASSIVE;
else
return -1;
diff --git a/usr.sbin/ppp/fsm.c b/usr.sbin/ppp/fsm.c
index 1dd5bef..a3a50d2 100644
--- a/usr.sbin/ppp/fsm.c
+++ b/usr.sbin/ppp/fsm.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: fsm.c,v 1.25 1997/12/24 09:28:58 brian Exp $
+ * $Id: fsm.c,v 1.26 1998/01/10 01:55:09 brian Exp $
*
* TODO:
* o Refer loglevel for log output
@@ -68,6 +68,11 @@ StoppedTimeout(void *v)
struct fsm *fp = (struct fsm *)v;
LogPrintf(fp->LogLevel, "Stopped timer expired\n");
+ if (fp->OpenTimer.state == TIMER_RUNNING) {
+ LogPrintf(LogWARN, "%s: aborting open delay due to stopped timer\n",
+ fp->name);
+ StopTimer(&fp->OpenTimer);
+ }
if (modem != -1)
DownConnection();
else
@@ -122,6 +127,19 @@ FsmOutput(struct fsm * fp, u_int code, u_int id, u_char * ptr, int count)
HdlcOutput(PRI_LINK, fp->proto, bp);
}
+static void
+FsmOpenNow(void *v)
+{
+ struct fsm *fp = (struct fsm *)v;
+
+ StopTimer(&fp->OpenTimer);
+ if (fp->state <= ST_STOPPED) {
+ FsmInitRestartCounter(fp);
+ FsmSendConfigReq(fp);
+ NewState(fp, ST_REQSENT);
+ }
+}
+
void
FsmOpen(struct fsm * fp)
{
@@ -135,11 +153,18 @@ FsmOpen(struct fsm * fp)
case ST_CLOSED:
if (fp->open_mode == OPEN_PASSIVE) {
NewState(fp, ST_STOPPED);
- } else {
- FsmInitRestartCounter(fp);
- FsmSendConfigReq(fp);
- NewState(fp, ST_REQSENT);
- }
+ } else if (fp->open_mode > 0) {
+ if (fp->open_mode > 1)
+ LogPrintf(LogPHASE, "Entering STOPPED state for %d seconds\n",
+ fp->open_mode);
+ NewState(fp, ST_STOPPED);
+ fp->OpenTimer.state = TIMER_STOPPED;
+ fp->OpenTimer.load = fp->open_mode * SECTICKS;
+ fp->OpenTimer.func = FsmOpenNow;
+ fp->OpenTimer.arg = (void *)fp;
+ StartTimer(&fp->OpenTimer);
+ } else
+ FsmOpenNow(fp);
break;
case ST_STOPPED: /* XXX: restart option */
case ST_REQSENT:
diff --git a/usr.sbin/ppp/fsm.h b/usr.sbin/ppp/fsm.h
index 07ddb3b..42f1184 100644
--- a/usr.sbin/ppp/fsm.h
+++ b/usr.sbin/ppp/fsm.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: fsm.h,v 1.13 1997/12/03 10:23:47 brian Exp $
+ * $Id: fsm.h,v 1.14 1998/01/10 01:55:10 brian Exp $
*
* TODO:
*/
@@ -43,8 +43,7 @@
#define MODE_NOP 3
#define MODE_ACK 4 /* pseudo mode for ccp negotiations */
-#define OPEN_ACTIVE 0
-#define OPEN_PASSIVE 1
+#define OPEN_PASSIVE -1
struct fsm {
const char *name; /* Name of protocol */
@@ -58,6 +57,7 @@ struct fsm {
int reqcode; /* Request code sent */
struct pppTimer FsmTimer; /* Restart Timer */
+ struct pppTimer OpenTimer; /* Delay before opening */
/*
* This timer times the ST_STOPPED state out after the given value
diff --git a/usr.sbin/ppp/ipcp.c b/usr.sbin/ppp/ipcp.c
index ec8ea29..2677cd5 100644
--- a/usr.sbin/ppp/ipcp.c
+++ b/usr.sbin/ppp/ipcp.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: ipcp.c,v 1.47 1998/01/05 01:35:18 brian Exp $
+ * $Id: ipcp.c,v 1.48 1998/01/18 20:49:18 brian Exp $
*
* TODO:
* o More RFC1772 backwoard compatibility
@@ -84,13 +84,14 @@ struct fsm IpcpFsm = {
"IPCP",
PROTO_IPCP,
IPCP_MAXCODE,
- OPEN_ACTIVE,
+ 0,
ST_INITIAL,
0, 0, 0,
0,
- {0, 0, 0, NULL, NULL, NULL},
- {0, 0, 0, NULL, NULL, NULL},
+ {0, 0, 0, NULL, NULL, NULL}, /* FSM timer */
+ {0, 0, 0, NULL, NULL, NULL}, /* Open timer */
+ {0, 0, 0, NULL, NULL, NULL}, /* Stopped timer */
LogIPCP,
IpcpLayerUp,
diff --git a/usr.sbin/ppp/lcp.c b/usr.sbin/ppp/lcp.c
index 0d6a664..bc7b518 100644
--- a/usr.sbin/ppp/lcp.c
+++ b/usr.sbin/ppp/lcp.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: lcp.c,v 1.52 1998/01/11 17:50:35 brian Exp $
+ * $Id: lcp.c,v 1.53 1998/01/11 17:53:19 brian Exp $
*
* TODO:
* o Validate magic number received from peer.
@@ -120,12 +120,13 @@ struct fsm LcpFsm = {
"LCP", /* Name of protocol */
PROTO_LCP, /* Protocol Number */
LCP_MAXCODE,
- OPEN_ACTIVE,
+ 1, /* Open mode delay */
ST_INITIAL, /* State of machine */
0, 0, 0,
0,
- {0, 0, 0, NULL, NULL, NULL},
- {0, 0, 0, NULL, NULL, NULL},
+ {0, 0, 0, NULL, NULL, NULL}, /* FSM timer */
+ {0, 0, 0, NULL, NULL, NULL}, /* Open timer */
+ {0, 0, 0, NULL, NULL, NULL}, /* Stopped timer */
LogLCP,
LcpLayerUp,
@@ -179,8 +180,11 @@ ReportLcpStatus(struct cmdargs const *arg)
lcp->want_acfcomp, (u_long)lcp->want_magic, lcp->my_reject);
fprintf(VarTerm, "\nDefaults: MRU = %d, ACCMAP = %08lx\t",
VarMRU, (u_long)VarAccmap);
- fprintf(VarTerm, "Open Mode: %s\n",
- (VarOpenMode == OPEN_ACTIVE) ? "active" : "passive");
+ fprintf(VarTerm, "Open Mode: %s",
+ (VarOpenMode == OPEN_PASSIVE) ? "passive" : "active");
+ if (VarOpenMode > 0)
+ fprintf(VarTerm, " (delay %d)", VarOpenMode);
+ fputc('\n', VarTerm);
return 0;
}
diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c
index c1df109..b526658 100644
--- a/usr.sbin/ppp/main.c
+++ b/usr.sbin/ppp/main.c
@@ -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.116 1998/01/08 23:47:52 brian Exp $
+ * $Id: main.c,v 1.117 1998/01/11 17:53:21 brian Exp $
*
* TODO:
* o Add commands for traffic summary, version display, etc.
@@ -573,7 +573,7 @@ main(int argc, char **argv)
* Turn into packet mode, where we speak PPP.
*/
void
-PacketMode()
+PacketMode(int delay)
{
if (RawModem() < 0) {
LogPrintf(LogWARN, "PacketMode: Not connected.\n");
@@ -586,7 +586,7 @@ PacketMode()
CcpInit();
LcpUp();
- LcpOpen(VarOpenMode);
+ LcpOpen(delay);
if (mode & MODE_INTER)
TtyCommandMode(1);
if (VarTerm) {
@@ -660,10 +660,8 @@ ReadTty(void)
/*
* XXX: Should check carrier.
*/
- if (LcpFsm.state <= ST_CLOSED) {
- VarOpenMode = OPEN_ACTIVE;
- PacketMode();
- }
+ if (LcpFsm.state <= ST_CLOSED)
+ PacketMode(0);
break;
case '.':
TermMode = 1;
@@ -779,7 +777,7 @@ DoLoop(void)
if (OpenModem() < 0)
return;
LogPrintf(LogPHASE, "Packet mode enabled\n");
- PacketMode();
+ PacketMode(VarOpenMode);
} else if (mode & MODE_DEDICATED) {
if (modem < 0)
while (OpenModem() < 0)
@@ -829,8 +827,7 @@ DoLoop(void)
}
reconnectState = RECON_ENVOKED;
} else if (mode & MODE_DEDICATED)
- if (VarOpenMode == OPEN_ACTIVE)
- PacketMode();
+ PacketMode(VarOpenMode);
}
/*
@@ -864,9 +861,8 @@ DoLoop(void)
LogPrintf(LogCHAT, "Dial attempt %u\n", tries);
if ((res = DialModem()) == EX_DONE) {
- nointr_sleep(1); /* little pause to allow peer starts */
ModemTimeout(NULL);
- PacketMode();
+ PacketMode(VarOpenMode);
dial_up = 0;
reconnectState = RECON_UNKNOWN;
tries = 0;
@@ -1047,7 +1043,7 @@ DoLoop(void)
write(modem, rbuff, cp - rbuff);
write(modem, "\r\n", 2);
}
- PacketMode();
+ PacketMode(0);
} else
write(fileno(VarTerm), rbuff, n);
}
diff --git a/usr.sbin/ppp/main.h b/usr.sbin/ppp/main.h
index 87512a6..8e151dd 100644
--- a/usr.sbin/ppp/main.h
+++ b/usr.sbin/ppp/main.h
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: main.h,v 1.7 1997/10/26 01:03:15 brian Exp $
+ * $Id: main.h,v 1.8 1997/11/22 03:37:39 brian Exp $
*
*/
@@ -26,6 +26,6 @@ extern int tunno;
extern void Cleanup(int);
extern void TtyTermMode(void);
-extern void PacketMode(void);
+extern void PacketMode(int);
extern void TtyOldMode(void);
extern void TtyCommandMode(int);
diff --git a/usr.sbin/ppp/modem.c b/usr.sbin/ppp/modem.c
index 40183a1..54ce7fb 100644
--- a/usr.sbin/ppp/modem.c
+++ b/usr.sbin/ppp/modem.c
@@ -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.73 1997/12/30 23:22:31 brian Exp $
+ * $Id: modem.c,v 1.74 1998/01/10 01:55:10 brian Exp $
*
* TODO:
*/
@@ -266,7 +266,7 @@ ModemTimeout(void *data)
* carrier.
*/
if (mode & MODE_DEDICATED)
- PacketMode();
+ PacketMode(VarOpenMode);
} else {
LogPrintf(LogDEBUG, "ModemTimeout: online -> offline\n");
reconnect(RECON_TRUE);
diff --git a/usr.sbin/ppp/ppp.8 b/usr.sbin/ppp/ppp.8
index 2422242..1ecd5d6 100644
--- a/usr.sbin/ppp/ppp.8
+++ b/usr.sbin/ppp/ppp.8
@@ -1,4 +1,4 @@
-.\" $Id: ppp.8,v 1.94 1998/01/05 01:35:20 brian Exp $
+.\" $Id: ppp.8,v 1.95 1998/01/18 20:49:22 brian Exp $
.Dd 20 September 1995
.Os FreeBSD
.Dt PPP 8
@@ -2254,16 +2254,23 @@ will be negotiated.
.It set nbns x.x.x.x y.y.y.y
This option allows the setting of the Microsoft NetBIOS DNS servers that
will be negotiated.
-.It set openmode active|passive
+.It set openmode active|passive Op delay
By default,
.Ar openmode
is always
-.Ar active .
+.Ar active
+with a one second
+.Ar delay .
That is,
.Nm
-will always initiate LCP/IPCP/CCP negotiation. If you want to wait
-for the peer to initiate negotiations, you may use the value
+will always initiate LCP/IPCP/CCP negotiation one second after the line
+comes up. If you want to wait for the peer to initiate negotiations, you
+can use the value
.Ar passive .
+If you want to initiate negotiations immediately or after more than one
+second, the appropriate
+.Ar delay
+may be specified here in seconds.
.It set parity odd|even|none|mark
This allows the line parity to be set. The default value is
.Ar none .
@@ -2328,6 +2335,10 @@ log all state transitions.
The default value is zero, where
.Nm
doesn't time out in the stopped state.
+.Pp
+This value should not be set to less than the openmode delay (see
+.Dq set openmode
+above).
.It set server|socket TcpPort|LocalName|none [password] [mask]
This command tells
.Nm
diff --git a/usr.sbin/ppp/ppp.8.m4 b/usr.sbin/ppp/ppp.8.m4
index 2422242..1ecd5d6 100644
--- a/usr.sbin/ppp/ppp.8.m4
+++ b/usr.sbin/ppp/ppp.8.m4
@@ -1,4 +1,4 @@
-.\" $Id: ppp.8,v 1.94 1998/01/05 01:35:20 brian Exp $
+.\" $Id: ppp.8,v 1.95 1998/01/18 20:49:22 brian Exp $
.Dd 20 September 1995
.Os FreeBSD
.Dt PPP 8
@@ -2254,16 +2254,23 @@ will be negotiated.
.It set nbns x.x.x.x y.y.y.y
This option allows the setting of the Microsoft NetBIOS DNS servers that
will be negotiated.
-.It set openmode active|passive
+.It set openmode active|passive Op delay
By default,
.Ar openmode
is always
-.Ar active .
+.Ar active
+with a one second
+.Ar delay .
That is,
.Nm
-will always initiate LCP/IPCP/CCP negotiation. If you want to wait
-for the peer to initiate negotiations, you may use the value
+will always initiate LCP/IPCP/CCP negotiation one second after the line
+comes up. If you want to wait for the peer to initiate negotiations, you
+can use the value
.Ar passive .
+If you want to initiate negotiations immediately or after more than one
+second, the appropriate
+.Ar delay
+may be specified here in seconds.
.It set parity odd|even|none|mark
This allows the line parity to be set. The default value is
.Ar none .
@@ -2328,6 +2335,10 @@ log all state transitions.
The default value is zero, where
.Nm
doesn't time out in the stopped state.
+.Pp
+This value should not be set to less than the openmode delay (see
+.Dq set openmode
+above).
.It set server|socket TcpPort|LocalName|none [password] [mask]
This command tells
.Nm
diff --git a/usr.sbin/ppp/vars.c b/usr.sbin/ppp/vars.c
index 5781749..c0e3257 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.42 1997/12/29 22:23:12 brian Exp $
+ * $Id: vars.c,v 1.43 1998/01/10 01:55:11 brian Exp $
*
*/
#include <sys/param.h>
@@ -39,7 +39,7 @@
#include "auth.h"
char VarVersion[] = "PPP Version 1.65";
-char VarLocalVersion[] = "$Date: 1997/12/29 22:23:12 $";
+char VarLocalVersion[] = "$Date: 1998/01/10 01:55:11 $";
int Utmp = 0;
int ipInOctets = 0;
int ipOutOctets = 0;
@@ -73,7 +73,7 @@ struct pppvars pppVars = {
DEF_MRU, DEF_MTU, 0, MODEM_SPEED, CS8, MODEM_CTSRTS, 180, 30, 3,
RECONNECT_TIMER, RECONNECT_TRIES, REDIAL_PERIOD,
NEXT_REDIAL_PERIOD, 1, 1, MODEM_DEV, "", BASE_MODEM_DEV,
- OPEN_ACTIVE, LOCAL_NO_AUTH, 0
+ 1, LOCAL_NO_AUTH, 0
};
int
diff --git a/usr.sbin/ppp/vars.h b/usr.sbin/ppp/vars.h
index 59cc363..43c1000 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.39 1997/12/29 22:23:13 brian Exp $
+ * $Id: vars.h,v 1.40 1998/01/11 17:50:44 brian Exp $
*
* TODO:
*/
@@ -73,7 +73,7 @@ struct pppvars {
char modem_devlist[LINE_LEN]; /* Comma-separated list of devices */
char modem_dev[40]; /* Name of device / host:port */
const char *base_modem_dev; /* Pointer to base of modem_dev */
- int open_mode; /* LCP open mode */
+ int open_mode; /* Delay before first LCP REQ (-1 = passive) */
#define LOCAL_AUTH 0x01
#define LOCAL_NO_AUTH 0x02
#define LOCAL_DENY 0x03
OpenPOWER on IntegriCloud