summaryrefslogtreecommitdiff
path: root/usr.sbin/ppp
diff options
context:
space:
mode:
authorBrian Somers <brian@FreeBSD.org>1998-05-15 23:58:30 +0000
committerBrian Somers <brian@FreeBSD.org>1998-05-15 23:58:30 +0000
commitdd0645c5b76252f6c673406039f384ba2cdeea74 (patch)
tree684801d060a212758ea54068162a61bfd1d7c05b /usr.sbin/ppp
parentea7229694b5a94840ef14aa0bb71bb338f02bbe9 (diff)
downloadsrc-test2-dd0645c5b76252f6c673406039f384ba2cdeea74.tar.gz
src-test2-dd0645c5b76252f6c673406039f384ba2cdeea74.zip
Notes
Diffstat (limited to 'usr.sbin/ppp')
-rw-r--r--usr.sbin/ppp/bundle.c34
-rw-r--r--usr.sbin/ppp/bundle.h3
-rw-r--r--usr.sbin/ppp/ccp.c10
-rw-r--r--usr.sbin/ppp/command.c48
-rw-r--r--usr.sbin/ppp/datalink.c16
-rw-r--r--usr.sbin/ppp/datalink.h3
-rw-r--r--usr.sbin/ppp/defs.c48
-rw-r--r--usr.sbin/ppp/defs.h5
-rw-r--r--usr.sbin/ppp/ipcp.c27
-rw-r--r--usr.sbin/ppp/ipcp.h3
-rw-r--r--usr.sbin/ppp/lcp.c10
-rw-r--r--usr.sbin/ppp/physical.c15
-rw-r--r--usr.sbin/ppp/physical.h3
-rw-r--r--usr.sbin/ppp/ppp.812
-rw-r--r--usr.sbin/ppp/systems.c42
-rw-r--r--usr.sbin/ppp/systems.h3
16 files changed, 207 insertions, 75 deletions
diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c
index e57e29f8f11d..ebf119387ff2 100644
--- a/usr.sbin/ppp/bundle.c
+++ b/usr.sbin/ppp/bundle.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: bundle.c,v 1.1.2.82 1998/05/11 23:39:27 brian Exp $
+ * $Id: bundle.c,v 1.1.2.83 1998/05/15 18:21:32 brian Exp $
*/
#include <sys/types.h>
@@ -1375,3 +1375,35 @@ bundle_SendDatalink(struct datalink *dl, int s, struct sockaddr_un *sun)
while (niov--)
free(iov[niov].iov_base);
}
+
+int
+bundle_SetMode(struct bundle *bundle, struct datalink *dl, int mode)
+{
+ int omode;
+
+ omode = dl->physical->type;
+ if (omode == mode)
+ return 1;
+
+ if (mode == PHYS_DEMAND && !(bundle->phys_type & PHYS_DEMAND))
+ /* Changing to demand-dial mode */
+ if (bundle->ncp.ipcp.peer_ip.s_addr == INADDR_ANY) {
+ log_Printf(LogWARN, "You must `set ifaddr' before changing mode to %s\n",
+ mode2Nam(mode));
+ return 0;
+ }
+
+ if (!datalink_SetMode(dl, mode))
+ return 0;
+
+ if (mode == PHYS_DEMAND && !(bundle->phys_type & PHYS_DEMAND))
+ ipcp_InterfaceUp(&bundle->ncp.ipcp);
+
+ bundle_GenPhysType(bundle);
+
+ if (omode == PHYS_DEMAND && !(bundle->phys_type & PHYS_DEMAND))
+ /* Changing from demand-dial mode */
+ ipcp_CleanInterface(&bundle->ncp.ipcp);
+
+ return 1;
+}
diff --git a/usr.sbin/ppp/bundle.h b/usr.sbin/ppp/bundle.h
index bb181b48d642..f387fed5488e 100644
--- a/usr.sbin/ppp/bundle.h
+++ b/usr.sbin/ppp/bundle.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: bundle.h,v 1.1.2.38 1998/05/06 23:50:02 brian Exp $
+ * $Id: bundle.h,v 1.1.2.39 1998/05/10 10:21:11 brian Exp $
*/
#define PHASE_DEAD 0 /* Link is dead */
@@ -152,3 +152,4 @@ extern void bundle_SetLabel(struct bundle *, const char *);
extern const char *bundle_GetLabel(struct bundle *);
extern void bundle_SendDatalink(struct datalink *, int, struct sockaddr_un *);
extern void bundle_ReceiveDatalink(struct bundle *, int, struct sockaddr_un *);
+extern int bundle_SetMode(struct bundle *, struct datalink *, int);
diff --git a/usr.sbin/ppp/ccp.c b/usr.sbin/ppp/ccp.c
index 9abdf826bf02..8c3d23838373 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.30.2.42 1998/05/01 19:23:57 brian Exp $
+ * $Id: ccp.c,v 1.30.2.43 1998/05/15 18:20:55 brian Exp $
*
* TODO:
* o Support other compression protocols
@@ -132,8 +132,12 @@ static const struct ccp_algorithm *algorithm[] = {
int
ccp_ReportStatus(struct cmdargs const *arg)
{
- struct link *l = command_ChooseLink(arg);
- struct ccp *ccp = &l->ccp;
+ struct link *l;
+ struct ccp *ccp;
+
+ if (!(l = command_ChooseLink(arg)))
+ return -1;
+ ccp = &l->ccp;
prompt_Printf(arg->prompt, "%s: %s [%s]\n", l->name, ccp->fsm.name,
State2Nam(ccp->fsm.state));
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c
index 2cfb9312a443..6f259e6e047d 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.82 1998/05/10 09:26:17 brian Exp $
+ * $Id: command.c,v 1.131.2.83 1998/05/15 18:20:58 brian Exp $
*
*/
#include <sys/types.h>
@@ -104,6 +104,7 @@
#define VAR_IPCPRETRY 20
#define VAR_DNS 21
#define VAR_NBNS 22
+#define VAR_MODE 23
/* ``accept|deny|disable|enable'' masks */
#define NEG_HISMASK (1)
@@ -123,7 +124,7 @@
#define NEG_DNS 50
const char Version[] = "2.0-beta";
-const char VersionDate[] = "$Date: 1998/05/10 09:26:17 $";
+const char VersionDate[] = "$Date: 1998/05/15 18:20:58 $";
static int ShowCommand(struct cmdargs const *);
static int TerminalCommand(struct cmdargs const *);
@@ -199,11 +200,6 @@ CloneCommand(struct cmdargs const *arg)
if (arg->argc == arg->argn)
return -1;
- if (!arg->bundle->ncp.mp.cfg.mrru) {
- log_Printf(LogWARN, "clone: Only available in multilink mode\n");
- return 1;
- }
-
namelist[sizeof namelist - 1] = '\0';
for (f = arg->argn; f < arg->argc; f++) {
strncpy(namelist, arg->argv[f], sizeof namelist - 1);
@@ -522,6 +518,8 @@ ShowProtocolStats(struct cmdargs const *arg)
{
struct link *l = command_ChooseLink(arg);
+ if (!l)
+ return -1;
prompt_Printf(arg->prompt, "%s:\n", l->name);
link_ReportProtocolStatus(l, arg->prompt);
return 0;
@@ -805,7 +803,12 @@ OpenCommand(struct cmdargs const *arg)
bundle_Open(arg->bundle, arg->cx ? arg->cx->name : NULL, PHYS_ALL);
else if (arg->argc == arg->argn+1 &&
!strcasecmp(arg->argv[arg->argn], "ccp")) {
- struct fsm *fp = &command_ChooseLink(arg)->ccp.fsm;
+ struct link *l;
+ struct fsm *fp;
+
+ if (!(l = command_ChooseLink(arg)))
+ return -1;
+ fp = &l->ccp.fsm;
if (fp->link->lcp.fsm.state != ST_OPENED)
log_Printf(LogWARN, "open: LCP must be open before opening CCP\n");
@@ -834,7 +837,12 @@ CloseCommand(struct cmdargs const *arg)
else if (arg->argc == arg->argn+1 &&
(!strcasecmp(arg->argv[arg->argn], "ccp") ||
!strcasecmp(arg->argv[arg->argn], "ccp!"))) {
- struct fsm *fp = &command_ChooseLink(arg)->ccp.fsm;
+ struct link *l;
+ struct fsm *fp;
+
+ if (!(l = command_ChooseLink(arg)))
+ return -1;
+ fp = &l->ccp.fsm;
if (fp->state == ST_OPENED) {
fsm_Close(fp);
@@ -1094,8 +1102,8 @@ SetInterfaceAddr(struct cmdargs const *arg)
ipcp->cfg.peer_range.width = 0;
}
- if (hisaddr &&
- !ipcp_UseHisaddr(arg->bundle, hisaddr, arg->bundle->phys_type & PHYS_DEMAND))
+ if (hisaddr && !ipcp_UseHisaddr(arg->bundle, hisaddr,
+ arg->bundle->phys_type & PHYS_DEMAND))
return 4;
return 0;
@@ -1106,13 +1114,16 @@ SetVariable(struct cmdargs const *arg)
{
u_long ulong_val;
const char *argp;
- int param = (int)arg->cmd->args;
+ int param = (int)arg->cmd->args, mode;
struct datalink *cx = arg->cx; /* AUTH_CX uses this */
const char *err = NULL;
struct link *l = command_ChooseLink(arg); /* AUTH_CX_OPT uses this */
int dummyint;
struct in_addr dummyaddr, *addr;
+ if (!l)
+ return -1;
+
if (arg->argc > arg->argn)
argp = arg->argv[arg->argn];
else
@@ -1194,6 +1205,14 @@ SetVariable(struct cmdargs const *arg)
log_Printf(LogWARN, err);
}
break;
+ case VAR_MODE:
+ mode = Nam2mode(argp);
+ if (mode == PHYS_NONE || mode == PHYS_ALL) {
+ log_Printf(LogWARN, "%s: Invalid mode\n", argp);
+ return -1;
+ }
+ bundle_SetMode(arg->bundle, cx, mode);
+ break;
case VAR_MRRU:
if (bundle_Phase(arg->bundle) != PHASE_DEAD)
log_Printf(LogWARN, "mrru: Only changable at phase DEAD\n");
@@ -1398,6 +1417,8 @@ static struct cmdtab const SetCommands[] = {
"Set login script", "set login chat-script", (const void *) VAR_LOGIN},
{"lqrperiod", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX_OPT,
"Set LQR period", "set lqrperiod value", (const void *)VAR_LQRPERIOD},
+ {"mode", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "Set mode value",
+ "set mode interactive|auto|ddial|background", (const void *)VAR_MODE},
{"mrru", NULL, SetVariable, LOCAL_AUTH, "Set MRRU value",
"set mrru value", (const void *)VAR_MRRU},
{"mru", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX_OPT,
@@ -1790,6 +1811,9 @@ NegotiateSet(struct cmdargs const *arg)
unsigned keep; /* Keep these bits */
unsigned add; /* Add these bits */
+ if (!l)
+ return -1;
+
if ((cmd = ident_cmd(arg->argv[arg->argn-2], &keep, &add)) == NULL)
return 1;
diff --git a/usr.sbin/ppp/datalink.c b/usr.sbin/ppp/datalink.c
index e946465c18f3..f89557bbbbbb 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.60 1998/05/15 18:21:02 brian Exp $
+ * $Id: datalink.c,v 1.1.2.61 1998/05/15 18:21:34 brian Exp $
*/
#include <sys/types.h>
@@ -1073,3 +1073,17 @@ datalink_NextName(struct datalink *dl)
dl->physical->link.name = dl->name = name;
return oname;
}
+
+int
+datalink_SetMode(struct datalink *dl, int mode)
+{
+ if (!physical_SetMode(dl->physical, mode))
+ return 0;
+ if (dl->physical->type & (PHYS_DIRECT|PHYS_DEDICATED))
+ dl->script.run = 0;
+ if (dl->physical->type == PHYS_DIRECT)
+ dl->reconnect_tries = 0;
+ if (mode & (PHYS_PERM|PHYS_1OFF) && dl->state <= DATALINK_READY)
+ datalink_Up(dl, 1, 1);
+ return 1;
+}
diff --git a/usr.sbin/ppp/datalink.h b/usr.sbin/ppp/datalink.h
index 7634a01c3a48..24073fbaa18d 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.23 1998/05/06 23:49:33 brian Exp $
+ * $Id: datalink.h,v 1.1.2.24 1998/05/15 18:21:35 brian Exp $
*/
#define DATALINK_CLOSED (0)
@@ -126,3 +126,4 @@ extern const char *datalink_State(struct datalink *);
extern char *datalink_NextName(struct datalink *);
extern int datalink_RemoveFromSet(struct datalink *, fd_set *, fd_set *,
fd_set *);
+extern int datalink_SetMode(struct datalink *, int);
diff --git a/usr.sbin/ppp/defs.c b/usr.sbin/ppp/defs.c
index 6a6a361ca7e2..e7ee32190d83 100644
--- a/usr.sbin/ppp/defs.c
+++ b/usr.sbin/ppp/defs.c
@@ -23,11 +23,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: defs.c,v 1.11.4.10 1998/04/30 23:53:35 brian Exp $
+ * $Id: defs.c,v 1.11.4.11 1998/05/06 18:50:06 brian Exp $
*/
#include <stdlib.h>
+#include <string.h>
#include <sys/errno.h>
#include <time.h>
#include <unistd.h>
@@ -66,3 +67,48 @@ fullread(int fd, void *v, size_t n)
}
return total;
}
+
+static struct {
+ int mode;
+ const char *name;
+} modes[] = {
+ { PHYS_MANUAL, "interactive" },
+ { PHYS_DEMAND, "auto" },
+ { PHYS_DIRECT, "direct" },
+ { PHYS_DEDICATED, "dedicated" },
+ { PHYS_PERM, "ddial" },
+ { PHYS_1OFF, "background" },
+ { PHYS_ALL, "*" },
+ { 0, 0 }
+};
+
+const char *
+mode2Nam(int mode)
+{
+ int m;
+
+ for (m = 0; modes[m].mode; m++)
+ if (modes[m].mode == mode)
+ return modes[m].name;
+
+ return "unknown";
+}
+
+int
+Nam2mode(const char *name)
+{
+ int m, got, len;
+
+ len = strlen(name);
+ got = -1;
+ for (m = 0; modes[m].mode; m++)
+ if (!strncasecmp(name, modes[m].name, len)) {
+ if (modes[m].name[len] == '\0')
+ return modes[m].mode;
+ if (got != -1)
+ return 0;
+ got = m;
+ }
+
+ return got == -1 ? 0 : modes[got].mode;
+}
diff --git a/usr.sbin/ppp/defs.h b/usr.sbin/ppp/defs.h
index bc6b751d0132..1d05f640fda8 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.16 1998/05/01 19:20:03 brian Exp $
+ * $Id: defs.h,v 1.29.2.17 1998/05/01 19:24:26 brian Exp $
*
* TODO:
*/
@@ -72,6 +72,7 @@
#define EX_NOLOGIN 13
/* physical::type values (OR'd in bundle::phys_type) */
+#define PHYS_NONE 0
#define PHYS_MANUAL 1 /* Manual link */
#define PHYS_DEMAND 2 /* Dial-on-demand link (-auto) */
#define PHYS_DIRECT 4 /* Incoming link (-direct) */
@@ -82,3 +83,5 @@
extern void randinit(void);
extern ssize_t fullread(int, void *, size_t);
+extern const char *mode2Nam(int);
+extern int Nam2mode(const char *);
diff --git a/usr.sbin/ppp/ipcp.c b/usr.sbin/ppp/ipcp.c
index 4b3982a832fe..dd3c1680b43b 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.50.2.50 1998/05/05 23:30:03 brian Exp $
+ * $Id: ipcp.c,v 1.50.2.51 1998/05/06 23:50:14 brian Exp $
*
* TODO:
* o More RFC1772 backwoard compatibility
@@ -691,6 +691,22 @@ IpcpLayerDown(struct fsm *fp)
ipcp_CleanInterface(ipcp);
}
+int
+ipcp_InterfaceUp(struct ipcp *ipcp)
+{
+ if (ipcp_SetIPaddress(ipcp->fsm.bundle, ipcp->my_ip, ipcp->peer_ip, 0) < 0) {
+ log_Printf(LogERROR, "IpcpLayerUp: unable to set ip address\n");
+ return 0;
+ }
+
+#ifndef NOALIAS
+ if (alias_IsEnabled())
+ (*PacketAlias.SetAddress)(ipcp->my_ip);
+#endif
+
+ return 1;
+}
+
static int
IpcpLayerUp(struct fsm *fp)
{
@@ -705,15 +721,8 @@ IpcpLayerUp(struct fsm *fp)
if (ipcp->peer_compproto >> 16 == PROTO_VJCOMP)
sl_compress_init(&ipcp->vj.cslc, (ipcp->peer_compproto >> 8) & 255);
- if (ipcp_SetIPaddress(fp->bundle, ipcp->my_ip, ipcp->peer_ip, 0) < 0) {
- log_Printf(LogERROR, "IpcpLayerUp: unable to set ip address\n");
+ if (!ipcp_InterfaceUp(ipcp))
return 0;
- }
-
-#ifndef NOALIAS
- if (alias_IsEnabled())
- (*PacketAlias.SetAddress)(ipcp->my_ip);
-#endif
/*
* XXX this stuff should really live in the FSM. Our config should
diff --git a/usr.sbin/ppp/ipcp.h b/usr.sbin/ppp/ipcp.h
index 110bb5db7810..2cc40a555e31 100644
--- a/usr.sbin/ppp/ipcp.h
+++ b/usr.sbin/ppp/ipcp.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: ipcp.h,v 1.18.2.25 1998/05/01 19:24:53 brian Exp $
+ * $Id: ipcp.h,v 1.18.2.26 1998/05/05 23:30:05 brian Exp $
*
* TODO:
*/
@@ -111,3 +111,4 @@ extern void ipcp_AddOutOctets(struct ipcp *, int);
extern int ipcp_UseHisaddr(struct bundle *, const char *, int);
extern int ipcp_vjset(struct cmdargs const *);
extern void ipcp_CleanInterface(struct ipcp *);
+extern int ipcp_InterfaceUp(struct ipcp *);
diff --git a/usr.sbin/ppp/lcp.c b/usr.sbin/ppp/lcp.c
index 91cde27fda3c..4da2d555eb6e 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.55.2.52 1998/05/01 19:24:55 brian Exp $
+ * $Id: lcp.c,v 1.55.2.53 1998/05/06 23:49:45 brian Exp $
*
* TODO:
* o Limit data field length by MRU
@@ -132,8 +132,12 @@ static const char *cftypes[] = {
int
lcp_ReportStatus(struct cmdargs const *arg)
{
- struct link *l = command_ChooseLink(arg);
- struct lcp *lcp = &l->lcp;
+ struct link *l;
+ struct lcp *lcp;
+
+ if (!(l = command_ChooseLink(arg)))
+ return -1;
+ lcp = &l->lcp;
prompt_Printf(arg->prompt, "%s: %s [%s]\n", l->name, lcp->fsm.name,
State2Nam(lcp->fsm.state));
diff --git a/usr.sbin/ppp/physical.c b/usr.sbin/ppp/physical.c
index 4f9dff32f874..2a36d094ed6d 100644
--- a/usr.sbin/ppp/physical.c
+++ b/usr.sbin/ppp/physical.c
@@ -16,7 +16,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: physical.c,v 1.1.2.31 1998/05/10 22:20:14 brian Exp $
+ * $Id: physical.c,v 1.1.2.32 1998/05/15 18:21:43 brian Exp $
*
*/
@@ -211,3 +211,16 @@ physical_Logout(struct physical *phys)
phys->Utmp = 0;
}
}
+
+int
+physical_SetMode(struct physical *p, int mode)
+{
+ if (p->type & (PHYS_DIRECT|PHYS_DEDICATED)
+ || mode & (PHYS_DIRECT|PHYS_DEDICATED)) {
+ log_Printf(LogWARN, "%s: Cannot change mode %s to %s\n", p->link.name,
+ mode2Nam(p->type), mode2Nam(mode));
+ return 0;
+ }
+ p->type = mode;
+ return 1;
+}
diff --git a/usr.sbin/ppp/physical.h b/usr.sbin/ppp/physical.h
index abb43729205b..45b0c581f431 100644
--- a/usr.sbin/ppp/physical.h
+++ b/usr.sbin/ppp/physical.h
@@ -16,7 +16,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: physical.h,v 1.1.2.24 1998/05/01 19:25:37 brian Exp $
+ * $Id: physical.h,v 1.1.2.25 1998/05/15 18:21:45 brian Exp $
*
*/
@@ -98,3 +98,4 @@ extern void physical_Login(struct physical *, const char *);
extern void physical_Logout(struct physical *);
extern int physical_RemoveFromSet(struct physical *, fd_set *, fd_set *,
fd_set *);
+extern int physical_SetMode(struct physical *, int);
diff --git a/usr.sbin/ppp/ppp.8 b/usr.sbin/ppp/ppp.8
index 493211f7423f..3ec65632aa80 100644
--- a/usr.sbin/ppp/ppp.8
+++ b/usr.sbin/ppp/ppp.8
@@ -1,4 +1,4 @@
-.\" $Id: ppp.8,v 1.97.2.32 1998/05/13 19:06:27 brian Exp $
+.\" $Id: ppp.8,v 1.97.2.33 1998/05/15 18:21:12 brian Exp $
.Dd 20 September 1995
.Os FreeBSD
.Dt PPP 8
@@ -2682,6 +2682,16 @@ or
packets are sent. The default is 30 seconds. You must also use the
.Dq enable lqr
command if you wish to send LQR requests to the peer.
+.It set mode Ar interactive|auto|ddial|background
+This command allows you to change the
+.Sq mode
+of the specified link. This is normally only useful in multilink mode,
+but may also be used in unilink mode.
+.Pp
+It is not possible to change a link that is
+.Sq direct
+or
+.Sq dedicated .
.It set mrru Ar value
Setting this option enables Multilink PPP negotiations, also known as
Multilink Protocol or MP. There is no default MRRU (Maximum
diff --git a/usr.sbin/ppp/systems.c b/usr.sbin/ppp/systems.c
index 26b709a7e4eb..ab95428206cd 100644
--- a/usr.sbin/ppp/systems.c
+++ b/usr.sbin/ppp/systems.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: systems.c,v 1.35.2.8 1998/04/30 23:53:56 brian Exp $
+ * $Id: systems.c,v 1.35.2.9 1998/05/01 19:26:01 brian Exp $
*
* TODO:
*/
@@ -180,49 +180,19 @@ AllowUsers(struct cmdargs const *arg)
return 0;
}
-static struct {
- int mode;
- const char *name;
-} modes[] = {
- { PHYS_MANUAL, "interactive" },
- { PHYS_DEMAND, "auto" },
- { PHYS_DIRECT, "direct" },
- { PHYS_DEDICATED, "dedicated" },
- { PHYS_PERM, "ddial" },
- { PHYS_1OFF, "background" },
- { PHYS_ALL, "*" },
- { 0, 0 }
-};
-
-const char *
-mode2Nam(int mode)
-{
- int m;
-
- for (m = 0; modes[m].mode; m++)
- if (modes[m].mode == mode)
- return modes[m].name;
-
- return "unknown";
-}
-
int
AllowModes(struct cmdargs const *arg)
{
/* arg->bundle may be NULL (see system_IsValid()) ! */
- int f;
- int m;
- int allowed;
+ int f, mode, allowed;
allowed = 0;
for (f = arg->argn; f < arg->argc; f++) {
- for (m = 0; modes[m].mode; m++)
- if (!strcasecmp(modes[m].name, arg->argv[f])) {
- allowed |= modes[m].mode;
- break;
- }
- if (modes[m].mode == 0)
+ mode = Nam2mode(arg->argv[f]);
+ if (mode == PHYS_NONE || mode == PHYS_ALL)
log_Printf(LogWARN, "allow modes: %s: Invalid mode\n", arg->argv[f]);
+ else
+ allowed |= mode;
}
modeok = modereq & allowed ? 1 : 0;
diff --git a/usr.sbin/ppp/systems.h b/usr.sbin/ppp/systems.h
index b03a141a2342..7fd4f5c2a781 100644
--- a/usr.sbin/ppp/systems.h
+++ b/usr.sbin/ppp/systems.h
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: systems.h,v 1.10.2.4 1998/04/10 13:19:22 brian Exp $
+ * $Id: systems.h,v 1.10.2.5 1998/05/01 19:26:02 brian Exp $
*
*/
@@ -34,4 +34,3 @@ extern int AllowUsers(struct cmdargs const *);
extern int AllowModes(struct cmdargs const *);
extern int LoadCommand(struct cmdargs const *);
extern int SaveCommand(struct cmdargs const *);
-extern const char *mode2Nam(int);