diff options
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/ppp.8.m4 | 13 | ||||
-rw-r--r-- | usr.sbin/ppp/vars.c | 6 | ||||
-rw-r--r-- | usr.sbin/ppp/vars.h | 4 |
6 files changed, 81 insertions, 51 deletions
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index 020d518..6816936 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.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, diff --git a/usr.sbin/ppp/modem.c b/usr.sbin/ppp/modem.c index 014dd8a..bca7943 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.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) + 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 cc955ba..aeb4ec9 100644 --- a/usr.sbin/ppp/ppp.8 +++ b/usr.sbin/ppp/ppp.8 @@ -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 diff --git a/usr.sbin/ppp/ppp.8.m4 b/usr.sbin/ppp/ppp.8.m4 index cc955ba..aeb4ec9 100644 --- a/usr.sbin/ppp/ppp.8.m4 +++ b/usr.sbin/ppp/ppp.8.m4 @@ -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 diff --git a/usr.sbin/ppp/vars.c b/usr.sbin/ppp/vars.c index 281e168..015e7bb 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.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 }; diff --git a/usr.sbin/ppp/vars.h b/usr.sbin/ppp/vars.h index b5bc7ca..b9db977 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.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 |