From 814514a6402a4a3d6bf10c54ac9d4892be30769d Mon Sep 17 00:00:00 2001 From: brian Date: Sun, 26 Sep 1999 23:02:18 +0000 Subject: Support ``set cd off'' to tell ppp not to even look for carrier on the device. --- usr.sbin/ppp/command.c | 16 ++++++++++------ usr.sbin/ppp/physical.c | 18 +++++++++++------- usr.sbin/ppp/physical.h | 7 ++++++- usr.sbin/ppp/ppp.8 | 18 +++++++++++++----- usr.sbin/ppp/ppp.8.m4 | 18 +++++++++++++----- usr.sbin/ppp/tty.c | 7 ++++--- 6 files changed, 57 insertions(+), 27 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index 45e0bcc..599e91c 100644 --- a/usr.sbin/ppp/command.c +++ b/usr.sbin/ppp/command.c @@ -1757,14 +1757,18 @@ SetVariable(struct cmdargs const *arg) 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] == '!'; + if (strcasecmp(argp, "off")) { + long_val = atol(argp); + if (long_val < 0) + long_val = 0; + cx->physical->cfg.cd.delay = long_val; + cx->physical->cfg.cd.necessity = argp[strlen(argp)-1] == '!' ? + CD_REQUIRED : CD_VARIABLE; + } else + cx->physical->cfg.cd.necessity = CD_NOTREQUIRED; } else { cx->physical->cfg.cd.delay = DEF_CDDELAY; - cx->physical->cfg.cd.required = 0; + cx->physical->cfg.cd.necessity = CD_VARIABLE; } break; diff --git a/usr.sbin/ppp/physical.c b/usr.sbin/ppp/physical.c index 2ee96eb..89ccad8 100644 --- a/usr.sbin/ppp/physical.c +++ b/usr.sbin/ppp/physical.c @@ -175,7 +175,7 @@ physical_Create(struct datalink *dl, int type) p->cfg.parity = CS8; memcpy(p->cfg.devlist, MODEM_LIST, sizeof MODEM_LIST); p->cfg.ndev = NMODEMS; - p->cfg.cd.required = 0; + p->cfg.cd.necessity = CD_VARIABLE; p->cfg.cd.delay = DEF_CDDELAY; lcp_Init(&p->link.lcp, dl->bundle, &p->link, &dl->fsmp); @@ -457,12 +457,16 @@ physical_ShowStatus(struct cmdargs const *arg) prompt_Printf(arg->prompt, ", CTS/RTS %s\n", (p->cfg.rts_cts ? "on" : "off")); - prompt_Printf(arg->prompt, " CD check delay: %d second%s", - p->cfg.cd.delay, p->cfg.cd.delay == 1 ? "" : "s"); - if (p->cfg.cd.required) - prompt_Printf(arg->prompt, " (required!)\n\n"); - else - prompt_Printf(arg->prompt, "\n\n"); + prompt_Printf(arg->prompt, " CD check delay: "); + if (p->cfg.cd.necessity == CD_NOTREQUIRED) + prompt_Printf(arg->prompt, "no cd"); + else { + prompt_Printf(arg->prompt, "%d second%s", p->cfg.cd.delay, + p->cfg.cd.delay == 1 ? "" : "s"); + if (p->cfg.cd.necessity == CD_REQUIRED) + prompt_Printf(arg->prompt, " (required!)"); + } + prompt_Printf(arg->prompt, "\n\n"); throughput_disp(&p->link.throughput, arg->prompt); diff --git a/usr.sbin/ppp/physical.h b/usr.sbin/ppp/physical.h index f98ff10..887c449 100644 --- a/usr.sbin/ppp/physical.h +++ b/usr.sbin/ppp/physical.h @@ -40,6 +40,11 @@ struct cmdargs; #define CARRIER_OK 2 #define CARRIER_LOST 3 +/* A cd ``necessity'' value */ +#define CD_VARIABLE 1 +#define CD_REQUIRED 2 +#define CD_NOTREQUIRED 3 + struct device { int type; const char *name; @@ -91,7 +96,7 @@ struct physical { char devlist[LINE_LEN]; /* NUL separated list of devices */ int ndev; /* number of devices in list */ struct { - unsigned required : 1; /* Is cd *REQUIRED* on this device */ + unsigned necessity : 2; /* A CD_ value */ int delay; /* Wait this many seconds after login script */ } cd; } cfg; diff --git a/usr.sbin/ppp/ppp.8 b/usr.sbin/ppp/ppp.8 index 7544168..79f6802 100644 --- a/usr.sbin/ppp/ppp.8 +++ b/usr.sbin/ppp/ppp.8 @@ -3561,7 +3561,7 @@ 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 \&! +.It "set cd off|" Ns Ar seconds Ns Op \&! Normally, .Nm checks for the existence of carrier one second after the login script is @@ -3581,6 +3581,11 @@ specifies the number of seconds that should wait after the dial script has finished before deciding if carrier is available or not. .Pp +If +.Dq off +is specified, +.Nm +will not check for carrier on the device, otherwise .Nm will not proceed to the login script until either carrier is detected or until @@ -3600,15 +3605,18 @@ seconds, the link will be disconnected. .Pp For ISDN devices, .Nm -will always insist on carrier. Carrier is raised by the i4brbchX device -driver only after the call has connected. It is therefore wise to set -a reasonable value such as +will always insist on carrier (the value +.Dq off +is invalid). Carrier is raised by the i4brbchX device driver only after +the call has connected. It is therefore wise to set a reasonable value +such as .Ar 6 seconds. .Pp Carrier .Em require Ns No ment -is ignored for all other device types. +is ignored for all other device types - as if set to +.Dq off . .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 7544168..79f6802 100644 --- a/usr.sbin/ppp/ppp.8.m4 +++ b/usr.sbin/ppp/ppp.8.m4 @@ -3561,7 +3561,7 @@ 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 \&! +.It "set cd off|" Ns Ar seconds Ns Op \&! Normally, .Nm checks for the existence of carrier one second after the login script is @@ -3581,6 +3581,11 @@ specifies the number of seconds that should wait after the dial script has finished before deciding if carrier is available or not. .Pp +If +.Dq off +is specified, +.Nm +will not check for carrier on the device, otherwise .Nm will not proceed to the login script until either carrier is detected or until @@ -3600,15 +3605,18 @@ seconds, the link will be disconnected. .Pp For ISDN devices, .Nm -will always insist on carrier. Carrier is raised by the i4brbchX device -driver only after the call has connected. It is therefore wise to set -a reasonable value such as +will always insist on carrier (the value +.Dq off +is invalid). Carrier is raised by the i4brbchX device driver only after +the call has connected. It is therefore wise to set a reasonable value +such as .Ar 6 seconds. .Pp Carrier .Em require Ns No ment -is ignored for all other device types. +is ignored for all other device types - as if set to +.Dq off . .It set choked Op Ar timeout This sets the number of seconds that .Nm diff --git a/usr.sbin/ppp/tty.c b/usr.sbin/ppp/tty.c index 2ca27cc..6a4c1ac 100644 --- a/usr.sbin/ppp/tty.c +++ b/usr.sbin/ppp/tty.c @@ -115,7 +115,7 @@ tty_Timeout(void *data) if (Online(dev)) log_Printf(LogPHASE, "%s: %s: CD detected\n", p->link.name, p->name.full); else if (++dev->carrier_seconds >= p->cfg.cd.delay) { - if (p->cfg.cd.required) + if (p->cfg.cd.necessity == CD_REQUIRED) log_Printf(LogPHASE, "%s: %s: Required CD not detected\n", p->link.name, p->name.full); else { @@ -169,7 +169,7 @@ tty_AwaitCarrier(struct physical *p) { struct ttydevice *dev = device2tty(p->handler); - if (physical_IsSync(p)) + if (p->cfg.cd.necessity == CD_NOTREQUIRED || physical_IsSync(p)) return CARRIER_OK; if (dev->mbits == -1) { @@ -180,7 +180,8 @@ tty_AwaitCarrier(struct physical *p) return CARRIER_PENDING; /* Not yet ! */ } - return Online(dev) || !p->cfg.cd.required ? CARRIER_OK : CARRIER_LOST; + return Online(dev) || !p->cfg.cd.necessity == CD_REQUIRED ? + CARRIER_OK : CARRIER_LOST; } static int -- cgit v1.1