diff options
author | brian <brian@cvs.openbsd.org> | 1997-12-21 03:15:59 +0000 |
---|---|---|
committer | brian <brian@cvs.openbsd.org> | 1997-12-21 03:15:59 +0000 |
commit | 4e1b60c3b8d6d1c82dcd78b145417ea7ab08045f (patch) | |
tree | dd8df97e2129f2659475d934d35022fe536dca12 /usr.sbin/ppp | |
parent | 9bf4119d083087ab2ef501e3082c00b6532ea7f4 (diff) |
Allow multiple (comma seperated) devices on the "set device" line.
Submitted by: Derek Inksetter <derek@saidev.com>
Diffstat (limited to 'usr.sbin/ppp')
-rw-r--r-- | usr.sbin/ppp/command.c | 10 | ||||
-rw-r--r-- | usr.sbin/ppp/modem.c | 86 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp.8 | 13 | ||||
-rw-r--r-- | usr.sbin/ppp/vars.c | 6 | ||||
-rw-r--r-- | usr.sbin/ppp/vars.h | 4 |
5 files changed, 72 insertions, 47 deletions
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index e5ee56d617c..be7150d1670 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.10 1997/12/19 18:12:08 brian Exp $ + * $Id: command.c,v 1.11 1997/12/21 03:15:53 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, diff --git a/usr.sbin/ppp/modem.c b/usr.sbin/ppp/modem.c index e92a3b719d0..fcdffe3bcbb 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.2 1997/12/18 01:10:26 brian Exp $ + * $Id: modem.c,v 1.3 1997/12/21 03:15:54 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) + 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 { + /* 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); - HaveModem(); - LogPrintf(LogDEBUG, "OpenModem: Modem is socket %s\n", VarDevice); + } } else { - *cp = ':'; /* Don't destroy VarDevice */ - LogPrintf(LogERROR, "Invalid host:port: \"%s\"\n", VarDevice); + LogPrintf(LogERROR, + "Device (%s) must be in /dev or be a host:port pair\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; } /* diff --git a/usr.sbin/ppp/ppp.8 b/usr.sbin/ppp/ppp.8 index 7641e7faab3..1f4c473052f 100644 --- a/usr.sbin/ppp/ppp.8 +++ b/usr.sbin/ppp/ppp.8 @@ -1,4 +1,4 @@ -.\" $Id: ppp.8,v 1.9 1997/12/21 02:34:21 brian Exp $ +.\" $Id: ppp.8,v 1.10 1997/12/21 03:15:55 brian Exp $ .Dd 20 September 1995 .Os OpenBSD .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 diff --git a/usr.sbin/ppp/vars.c b/usr.sbin/ppp/vars.c index 76eafd47da1..8abd309a6c7 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.2 1997/12/06 12:09:04 brian Exp $ + * $Id: vars.c,v 1.3 1997/12/21 03:15:56 brian Exp $ * */ #include <sys/param.h> @@ -39,7 +39,7 @@ #include "auth.h" char VarVersion[] = "PPP Version 1.5"; -char VarLocalVersion[] = "$Date: 1997/12/06 12:09:04 $"; +char VarLocalVersion[] = "$Date: 1997/12/21 03:15:56 $"; 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 }; diff --git a/usr.sbin/ppp/vars.h b/usr.sbin/ppp/vars.h index fb7ae6da7a8..d59ecea4c2f 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.2 1997/12/06 12:09:05 brian Exp $ + * $Id: vars.h,v 1.3 1997/12/21 03:15:58 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 |