1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-17 15:27:36 +00:00

Allow multiple (comma seperated) devices on the "set device" line.

Submitted by: Derek Inksetter <derek@saidev.com>
This commit is contained in:
Brian Somers 1997-12-21 03:16:19 +00:00
parent 25ee22f573
commit 8fe71e0656
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=31917
6 changed files with 83 additions and 53 deletions

View File

@ -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.114 1997/12/18 01:10:13 brian Exp $
* $Id: command.c,v 1.115 1997/12/19 18:11:05 brian Exp $
*
*/
#include <sys/param.h>
@ -1349,10 +1349,8 @@ SetVariable(struct cmdargs const *arg)
LogPrintf(LogWARN, "Cannot change device to \"%s\" when \"%s\" is open\n",
argp, VarDevice);
else {
strncpy(VarDevice, argp, sizeof(VarDevice) - 1);
VarDevice[sizeof(VarDevice) - 1] = '\0';
VarBaseDevice = strrchr(VarDevice, '/');
VarBaseDevice = VarBaseDevice ? VarBaseDevice + 1 : "";
strncpy(VarDeviceList, argp, sizeof(VarDeviceList) - 1);
VarDeviceList[sizeof(VarDeviceList) - 1] = '\0';
}
break;
case VAR_ACCMAP:
@ -1423,7 +1421,7 @@ static struct cmdtab const SetCommands[] = {
{"ctsrts", NULL, SetCtsRts, LOCAL_AUTH,
"Use CTS/RTS modem signalling", "set ctsrts [on|off]"},
{"device", "line", SetVariable, LOCAL_AUTH, "Set modem device name",
"set device|line device-name", (const void *) VAR_DEVICE},
"set device|line device-name[,device-name]", (const void *) VAR_DEVICE},
{"dfilter", NULL, SetDfilter, LOCAL_AUTH,
"Set demand filter", "set dfilter ..."},
{"dial", NULL, SetVariable, LOCAL_AUTH,

View File

@ -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.67 1997/11/22 03:37:41 brian Exp $
* $Id: modem.c,v 1.68 1997/12/18 01:10:13 brian Exp $
*
* TODO:
*/
@ -434,6 +434,8 @@ OpenModem()
int oldflag;
char *host, *port;
char *cp;
char tmpDeviceList[sizeof(VarDeviceList)];
char *tmpDevice;
if (modem >= 0)
LogPrintf(LogDEBUG, "OpenModem: Modem is already open!\n");
@ -464,44 +466,62 @@ OpenModem()
return modem = 0;
}
} else {
if (strncmp(VarDevice, "/dev/", 5) == 0) {
if (LockModem() == -1)
return (-1);
modem = ID0open(VarDevice, O_RDWR | O_NONBLOCK);
if (modem < 0) {
LogPrintf(LogERROR, "OpenModem failed: %s: %s\n", VarDevice,
strerror(errno));
UnlockModem();
return (-1);
}
HaveModem();
LogPrintf(LogDEBUG, "OpenModem: Modem is %s\n", VarDevice);
} else {
/* PPP over TCP */
cp = strchr(VarDevice, ':');
if (cp) {
*cp = '\0';
host = VarDevice;
port = cp + 1;
if (*host && *port) {
modem = OpenConnection(host, port);
*cp = ':'; /* Don't destroy VarDevice */
if (modem < 0)
return (-1);
HaveModem();
LogPrintf(LogDEBUG, "OpenModem: Modem is socket %s\n", VarDevice);
} else {
*cp = ':'; /* Don't destroy VarDevice */
LogPrintf(LogERROR, "Invalid host:port: \"%s\"\n", VarDevice);
return (-1);
strncpy(tmpDeviceList, VarDeviceList, sizeof(tmpDeviceList));
tmpDeviceList[sizeof(tmpDeviceList)-1] = '\0';
for(tmpDevice=strtok(tmpDeviceList, ","); tmpDevice && (modem < 0);
tmpDevice=strtok(NULL,",")) {
strncpy(VarDevice, tmpDevice, sizeof(VarDevice));
VarDevice[sizeof(VarDevice)-1]= '\0';
VarBaseDevice = strrchr(VarDevice, '/');
VarBaseDevice = VarBaseDevice ? VarBaseDevice + 1 : "";
if (strncmp(VarDevice, "/dev/", 5) == 0) {
if (LockModem() == -1) {
modem = -1;
}
else {
modem = ID0open(VarDevice, O_RDWR | O_NONBLOCK);
if (modem < 0) {
LogPrintf(LogERROR, "OpenModem failed: %s: %s\n", VarDevice,
strerror(errno));
UnlockModem();
modem = -1;
}
else {
HaveModem();
LogPrintf(LogDEBUG, "OpenModem: Modem is %s\n", VarDevice);
}
}
} else {
LogPrintf(LogERROR,
"Device (%s) must be in /dev or be a host:port pair\n",
VarDevice);
return (-1);
/* PPP over TCP */
cp = strchr(VarDevice, ':');
if (cp) {
*cp = '\0';
host = VarDevice;
port = cp + 1;
if (*host && *port) {
modem = OpenConnection(host, port);
*cp = ':'; /* Don't destroy VarDevice */
if (modem < 0)
return (-1);
HaveModem();
LogPrintf(LogDEBUG, "OpenModem: Modem is socket %s\n", VarDevice);
} else {
*cp = ':'; /* Don't destroy VarDevice */
LogPrintf(LogERROR, "Invalid host:port: \"%s\"\n", VarDevice);
return (-1);
}
} else {
LogPrintf(LogERROR,
"Device (%s) must be in /dev or be a host:port pair\n",
VarDevice);
return (-1);
}
}
}
if (modem < 0) return modem;
}
/*

View File

@ -1,4 +1,4 @@
.\" $Id: ppp.8,v 1.88 1997/12/21 01:07:13 brian Exp $
.\" $Id: ppp.8,v 1.89 1997/12/21 02:34:27 brian Exp $
.Dd 20 September 1995
.Os FreeBSD
.Dt PPP 8
@ -1847,8 +1847,8 @@ for security reasons.
This sets the authentication id used in client mode PAP or CHAP negotiation.
.It set ctsrts
This sets hardware flow control and is the default.
.It set device|line value
This sets the device to which
.It set device|line value[,value...]
This sets the device(s) to which
.Nm
will talk to the given
.Dq value .
@ -1868,7 +1868,12 @@ on the given
.Dq port .
Refer to the section on
.Em PPP OVER TCP
above for further details.
above for further details. If multiple
.Dq values
are specified,
.Nm
will attempt to open each one in turn until it succeeds or runs out of
devices.
.It set dial chat-script
This specifies the chat script that will be used to dial the other
side. See also the

View File

@ -1,4 +1,4 @@
.\" $Id: ppp.8,v 1.88 1997/12/21 01:07:13 brian Exp $
.\" $Id: ppp.8,v 1.89 1997/12/21 02:34:27 brian Exp $
.Dd 20 September 1995
.Os FreeBSD
.Dt PPP 8
@ -1847,8 +1847,8 @@ for security reasons.
This sets the authentication id used in client mode PAP or CHAP negotiation.
.It set ctsrts
This sets hardware flow control and is the default.
.It set device|line value
This sets the device to which
.It set device|line value[,value...]
This sets the device(s) to which
.Nm
will talk to the given
.Dq value .
@ -1868,7 +1868,12 @@ on the given
.Dq port .
Refer to the section on
.Em PPP OVER TCP
above for further details.
above for further details. If multiple
.Dq values
are specified,
.Nm
will attempt to open each one in turn until it succeeds or runs out of
devices.
.It set dial chat-script
This specifies the chat script that will be used to dial the other
side. See also the

View File

@ -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.39 1997/12/03 23:28:01 brian Exp $
* $Id: vars.c,v 1.40 1997/12/13 02:37:33 brian Exp $
*
*/
#include <sys/param.h>
@ -39,7 +39,7 @@
#include "auth.h"
char VarVersion[] = "PPP Version 1.6";
char VarLocalVersion[] = "$Date: 1997/12/03 23:28:01 $";
char VarLocalVersion[] = "$Date: 1997/12/13 02:37:33 $";
int Utmp = 0;
int ipInOctets = 0;
int ipOutOctets = 0;
@ -73,7 +73,7 @@ struct confdesc pppConfs[] = {
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,
NEXT_REDIAL_PERIOD, 1, 1, MODEM_DEV, "", BASE_MODEM_DEV,
OPEN_ACTIVE, LOCAL_NO_AUTH, 0
};

View File

@ -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.36 1997/12/03 10:23:54 brian Exp $
* $Id: vars.h,v 1.37 1997/12/03 23:28:02 brian Exp $
*
* TODO:
*/
@ -70,6 +70,7 @@ struct pppvars {
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 */
const char *base_modem_dev; /* Pointer to base of modem_dev */
int open_mode; /* LCP open mode */
@ -102,6 +103,7 @@ struct pppvars {
#define VarMRU pppVars.var_mru
#define VarPrefMTU pppVars.pref_mtu
#define VarDevice pppVars.modem_dev
#define VarDeviceList pppVars.modem_devlist
#define VarBaseDevice pppVars.base_modem_dev
#define VarSpeed pppVars.modem_speed
#define VarParity pppVars.modem_parity