diff options
| -rw-r--r-- | usr.sbin/ppp/README.changes | 2 | ||||
| -rw-r--r-- | usr.sbin/ppp/command.c | 22 | ||||
| -rw-r--r-- | usr.sbin/ppp/defs.h | 3 | ||||
| -rw-r--r-- | usr.sbin/ppp/modem.c | 80 | ||||
| -rw-r--r-- | usr.sbin/ppp/physical.h | 6 | ||||
| -rw-r--r-- | usr.sbin/ppp/ppp.8 | 33 | ||||
| -rw-r--r-- | usr.sbin/ppp/ppp.8.m4 | 33 |
7 files changed, 141 insertions, 38 deletions
diff --git a/usr.sbin/ppp/README.changes b/usr.sbin/ppp/README.changes index b26cbd3882b1..0ee2b36d1155 100644 --- a/usr.sbin/ppp/README.changes +++ b/usr.sbin/ppp/README.changes @@ -74,3 +74,5 @@ o Command line options only need enough characters to uniquely identify o If you don't like seeing additional interface aliases when running in -auto -alias mode, add ``iface clear'' to your ppp.linkdown file - check the sample file. +o Ppp waits for 1 second before checking whether the device supports + carrier. This is controllable with ``set cd''. diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index 00486af68625..e53ab98a1516 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.179 1999/01/28 09:40:15 brian Exp $ + * $Id: command.c,v 1.180 1999/02/11 10:14:07 brian Exp $ * */ #include <sys/param.h> @@ -119,6 +119,7 @@ #define VAR_SENDPIPE 27 #define VAR_RECVPIPE 28 #define VAR_RADIUS 29 +#define VAR_CD 30 /* ``accept|deny|disable|enable'' masks */ #define NEG_HISMASK (1) @@ -137,8 +138,8 @@ #define NEG_VJCOMP 49 #define NEG_DNS 50 -const char Version[] = "2.1"; -const char VersionDate[] = "$Date: 1999/01/28 09:40:15 $"; +const char Version[] = "2.11"; +const char VersionDate[] = "$Date: 1999/02/11 10:14:07 $"; static int ShowCommand(struct cmdargs const *); static int TerminalCommand(struct cmdargs const *); @@ -1711,6 +1712,19 @@ SetVariable(struct cmdargs const *arg) } break; #endif + + case VAR_CD: + if (*argp) { + long_val = atol(argp); + if (long_val < 0) + long_val = 0; + cx->physical->cfg.cd.delay = long_val; + cx->physical->cfg.cd.required = argp[strlen(argp)-1] == '!'; + } else { + cx->physical->cfg.cd.delay = DEF_CDDELAY; + cx->physical->cfg.cd.required = 0; + } + break; } return err ? 1 : 0; @@ -1749,6 +1763,8 @@ static struct cmdtab const SetCommands[] = { (const void *)VAR_CBCP}, {"ccpretry", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX_OPT, "FSM retry period", "set ccpretry value", (const void *)VAR_CCPRETRY}, + {"cd", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "Carrier delay requirement", + "set cd value[!]", (const void *)VAR_CD}, {"chapretry", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "CHAP retry period", "set chapretry value", (const void *)VAR_CHAPRETRY}, {"choked", NULL, SetVariable, LOCAL_AUTH, diff --git a/usr.sbin/ppp/defs.h b/usr.sbin/ppp/defs.h index 03b36de473a7..ea64cdff5c13 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.37 1999/01/28 01:56:31 brian Exp $ + * $Id: defs.h,v 1.38 1999/02/11 10:14:08 brian Exp $ * * TODO: */ @@ -57,6 +57,7 @@ #define MIN_FSMRETRY 3 /* Minimum FSM retry frequency */ #define DEF_FSMRETRY 3 /* FSM retry frequency */ #define DEF_REQs 5 /* This number of REQs in IRC */ +#define DEF_CDDELAY 1 /* Delay before checking for carrier */ #define CONFFILE "ppp.conf" #define LINKUPFILE "ppp.linkup" diff --git a/usr.sbin/ppp/modem.c b/usr.sbin/ppp/modem.c index 8879b254c2dd..3afd2a23d154 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.100 1999/01/10 01:26:28 brian Exp $ + * $Id: modem.c,v 1.101 1999/01/28 01:56:33 brian Exp $ * * TODO: */ @@ -134,6 +134,8 @@ modem_Create(struct datalink *dl, int type) p->cfg.parity = CS8; strncpy(p->cfg.devlist, MODEM_LIST, sizeof p->cfg.devlist - 1); p->cfg.devlist[sizeof p->cfg.devlist - 1] = '\0'; + p->cfg.cd.required = 0; + p->cfg.cd.delay = DEF_CDDELAY; lcp_Init(&p->link.lcp, dl->bundle, &p->link, &dl->fsmp); ccp_Init(&p->link.ccp, dl->bundle, &p->link, &dl->fsmp); @@ -277,9 +279,12 @@ modem_Timeout(void *data) int change; timer_Stop(&modem->Timer); + modem->Timer.load = SECTICKS; /* Once a second please */ timer_Start(&modem->Timer); if (modem->isatty || physical_IsSync(modem)) { + ombits = modem->mbits; + if (modem->fd >= 0) { if (ioctl(modem->fd, TIOCMGET, &modem->mbits) < 0) { log_Printf(LogPHASE, "%s: ioctl error (%s)!\n", modem->link.name, @@ -289,18 +294,36 @@ modem_Timeout(void *data) } } else modem->mbits = 0; - change = ombits ^ modem->mbits; - if (change & TIOCM_CD) { - if (modem->mbits & TIOCM_CD) - log_Printf(LogDEBUG, "%s: offline -> online\n", modem->link.name); - else { - log_Printf(LogDEBUG, "%s: online -> offline\n", modem->link.name); - log_Printf(LogPHASE, "%s: Carrier lost\n", modem->link.name); + + if (ombits == -1) { + /* First time looking for carrier */ + if (Online(modem)) + log_Printf(LogDEBUG, "%s: %s: CD detected\n", + modem->link.name, modem->name.full); + else if (modem->cfg.cd.required) { + log_Printf(LogPHASE, "%s: %s: Required CD not detected\n", + modem->link.name, modem->name.full); datalink_Down(modem->dl, CLOSE_NORMAL); + } else { + log_Printf(LogPHASE, "%s: %s doesn't support CD\n", + modem->link.name, modem->name.full); + timer_Stop(&modem->Timer); + modem->mbits = TIOCM_CD; } - } else - log_Printf(LogDEBUG, "%s: Still %sline\n", modem->link.name, - Online(modem) ? "on" : "off"); + } else { + change = ombits ^ modem->mbits; + if (change & TIOCM_CD) { + if (modem->mbits & TIOCM_CD) + log_Printf(LogDEBUG, "%s: offline -> online\n", modem->link.name); + else { + log_Printf(LogDEBUG, "%s: online -> offline\n", modem->link.name); + log_Printf(LogPHASE, "%s: Carrier lost\n", modem->link.name); + datalink_Down(modem->dl, CLOSE_NORMAL); + } + } else + log_Printf(LogDEBUG, "%s: Still %sline\n", modem->link.name, + Online(modem) ? "on" : "off"); + } } else if (!Online(modem)) { /* mbits was set to zero in modem_Open() */ modem->mbits = TIOCM_CD; @@ -310,18 +333,15 @@ modem_Timeout(void *data) static void modem_StartTimer(struct bundle *bundle, struct physical *modem) { - struct pppTimer *ModemTimer; - - ModemTimer = &modem->Timer; - - timer_Stop(ModemTimer); - ModemTimer->load = SECTICKS; - ModemTimer->func = modem_Timeout; - ModemTimer->name = "modem CD"; - ModemTimer->arg = modem; + timer_Stop(&modem->Timer); + modem->Timer.load = SECTICKS * modem->cfg.cd.delay; + modem->Timer.func = modem_Timeout; + modem->Timer.name = "modem CD"; + modem->Timer.arg = modem; log_Printf(LogDEBUG, "%s: Using modem_Timeout [%p]\n", modem->link.name, modem_Timeout); - timer_Start(ModemTimer); + modem->mbits = -1; /* So we know it's the first time */ + timer_Start(&modem->Timer); } static const struct parity { @@ -724,14 +744,7 @@ modem_Raw(struct physical *modem, struct bundle *bundle) return (-1); fcntl(modem->fd, F_SETFL, oldflag | O_NONBLOCK); - if ((modem->isatty || physical_IsSync(modem)) && - ioctl(modem->fd, TIOCMGET, &modem->mbits) == 0 && - (modem->mbits & TIOCM_CD)) { - modem_StartTimer(bundle, modem); - modem_Timeout(modem); - } else - log_Printf(LogDEBUG, "%s: %s doesn't support CD\n", - modem->link.name, modem->name.full); + modem_StartTimer(bundle, modem); return 0; } @@ -933,8 +946,13 @@ modem_ShowStatus(struct cmdargs const *arg) prompt_Printf(arg->prompt, ", CTS/RTS %s\n", (modem->cfg.rts_cts ? "on" : "off")); + prompt_Printf(arg->prompt, " CD check delay: %d second%s", + modem->cfg.cd.delay, modem->cfg.cd.delay == 1 ? "" : "s"); + if (modem->cfg.cd.required) + prompt_Printf(arg->prompt, " (required!)\n\n"); + else + prompt_Printf(arg->prompt, "\n\n"); - prompt_Printf(arg->prompt, "\n"); throughput_disp(&modem->link.throughput, arg->prompt); return 0; @@ -1046,7 +1064,7 @@ iov2modem(struct datalink *dl, struct iovec *iov, int *niov, int maxiov, int fd) Enabled(dl->bundle, OPT_THROUGHPUT)); if (p->Timer.state != TIMER_STOPPED) { p->Timer.state = TIMER_STOPPED; /* Special - see modem2iov() */ - modem_StartTimer(dl->bundle, p); + modem_StartTimer(dl->bundle, p); /* XXX: Should we set cd.required ? */ } return p; diff --git a/usr.sbin/ppp/physical.h b/usr.sbin/ppp/physical.h index bfd1c74aef33..b2ce016fe900 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.4 1998/08/25 17:48:43 brian Exp $ + * $Id: physical.h,v 1.5 1999/01/10 01:26:30 brian Exp $ * */ @@ -51,6 +51,10 @@ struct physical { unsigned parity; /* What parity is enabled? (TTY flags) */ unsigned speed; /* Modem speed */ char devlist[LINE_LEN]; /* Comma-separated list of devices */ + struct { + unsigned required : 1; /* Is cd *REQUIRED* on this device */ + int delay; /* Wait this many seconds after login script */ + } cd; } cfg; struct termios ios; /* To be able to reset from raw mode */ diff --git a/usr.sbin/ppp/ppp.8 b/usr.sbin/ppp/ppp.8 index 1abda72c2b12..285458d1e5ff 100644 --- a/usr.sbin/ppp/ppp.8 +++ b/usr.sbin/ppp/ppp.8 @@ -1,4 +1,4 @@ -.\" $Id: ppp.8,v 1.147 1999/02/12 00:52:30 brian Exp $ +.\" $Id: ppp.8,v 1.148 1999/02/14 12:16:41 brian Exp $ .Dd 20 September 1995 .nr XX \w'\fC00' .Os FreeBSD @@ -3117,6 +3117,37 @@ be agreeable with the peer), or if is specified, .Nm will expect the peer to specify the number. +.It set cd Ar seconds Ns Op \&! +Normally, +.Nm +checks for the existence of carrier one second after the login script is +complete. If it's not set, +.Nm +assumes that this is because the device doesn't support carrier (which +is true for most NULL-modem cables), logs the fact and stops checking +for carrier. However, some modems take some time to assert the carrier +signal, resulting in +.Nm ppp Ns No s +inability to detect when the link is dropped. +.Ar Seconds +specifies the number of seconds that +.Nm +should wait after the login script has finished before first checking for +carrier. +.Pp +If +.Ar seconds +is followed immediately by an exclaimation mark +.Pq Dq \&! , +.Nm +will +.Em require +carrier. If carrier is not detected at the first check, the link will +be considered disconnected. +.Pp +Carrier +.Em require Ns No ment +is ignored when the link is not a tty device. .It set choked Op Ar timeout This sets the number of seconds that .Nm diff --git a/usr.sbin/ppp/ppp.8.m4 b/usr.sbin/ppp/ppp.8.m4 index 1abda72c2b12..285458d1e5ff 100644 --- a/usr.sbin/ppp/ppp.8.m4 +++ b/usr.sbin/ppp/ppp.8.m4 @@ -1,4 +1,4 @@ -.\" $Id: ppp.8,v 1.147 1999/02/12 00:52:30 brian Exp $ +.\" $Id: ppp.8,v 1.148 1999/02/14 12:16:41 brian Exp $ .Dd 20 September 1995 .nr XX \w'\fC00' .Os FreeBSD @@ -3117,6 +3117,37 @@ be agreeable with the peer), or if is specified, .Nm will expect the peer to specify the number. +.It set cd Ar seconds Ns Op \&! +Normally, +.Nm +checks for the existence of carrier one second after the login script is +complete. If it's not set, +.Nm +assumes that this is because the device doesn't support carrier (which +is true for most NULL-modem cables), logs the fact and stops checking +for carrier. However, some modems take some time to assert the carrier +signal, resulting in +.Nm ppp Ns No s +inability to detect when the link is dropped. +.Ar Seconds +specifies the number of seconds that +.Nm +should wait after the login script has finished before first checking for +carrier. +.Pp +If +.Ar seconds +is followed immediately by an exclaimation mark +.Pq Dq \&! , +.Nm +will +.Em require +carrier. If carrier is not detected at the first check, the link will +be considered disconnected. +.Pp +Carrier +.Em require Ns No ment +is ignored when the link is not a tty device. .It set choked Op Ar timeout This sets the number of seconds that .Nm |
