From cb6bccf1dc60c955024134903445d05945bc35ed Mon Sep 17 00:00:00 2001 From: brian Date: Sat, 24 Oct 1998 01:08:45 +0000 Subject: Loosen our restrictions on setting enddisc, mrru, shortseq, authname and authkey. o Auth{name,key} may additionally be set in PHASE_ESTABLISH. o The others may be set in PHASE_ESTABLISH as long as no links have yet reached DATALINK_LCP. --- usr.sbin/ppp/bundle.c | 15 +++++++++- usr.sbin/ppp/bundle.h | 3 +- usr.sbin/ppp/command.c | 78 ++++++++++++++++++++++++++++++++++---------------- usr.sbin/ppp/mp.c | 19 +++++++++--- 4 files changed, 85 insertions(+), 30 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c index 28da452..8bc26e4 100644 --- a/usr.sbin/ppp/bundle.c +++ b/usr.sbin/ppp/bundle.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bundle.c,v 1.35 1998/09/17 00:45:25 brian Exp $ + * $Id: bundle.c,v 1.36 1998/10/22 02:32:48 brian Exp $ */ #include @@ -1695,3 +1695,16 @@ bundle_setsid(struct bundle *bundle, int holdsession) break; } } + +int +bundle_HighestState(struct bundle *bundle) +{ + struct datalink *dl; + int result = DATALINK_CLOSED; + + for (dl = bundle->links; dl; dl = dl->next) + if (result < dl->state) + result = dl->state; + + return result; +} diff --git a/usr.sbin/ppp/bundle.h b/usr.sbin/ppp/bundle.h index 2f24b18..5096ae1 100644 --- a/usr.sbin/ppp/bundle.h +++ b/usr.sbin/ppp/bundle.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bundle.h,v 1.13 1998/08/25 17:48:42 brian Exp $ + * $Id: bundle.h,v 1.14 1998/10/22 02:32:48 brian Exp $ */ #define PHASE_DEAD 0 /* Link is dead */ @@ -187,3 +187,4 @@ extern int bundle_RenameDatalink(struct bundle *, struct datalink *, const char *); extern void bundle_setsid(struct bundle *, int); extern void bundle_LockTun(struct bundle *); +extern int bundle_HighestState(struct bundle *); diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index ced6a8a..a1b1789 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.167 1998/10/17 12:28:05 brian Exp $ + * $Id: command.c,v 1.168 1998/10/22 02:32:48 brian Exp $ * */ #include @@ -132,7 +132,7 @@ #define NEG_DNS 50 const char Version[] = "2.0"; -const char VersionDate[] = "$Date: 1998/10/17 12:28:05 $"; +const char VersionDate[] = "$Date: 1998/10/22 02:32:48 $"; static int ShowCommand(struct cmdargs const *); static int TerminalCommand(struct cmdargs const *); @@ -1339,24 +1339,32 @@ SetVariable(struct cmdargs const *arg) switch (param) { case VAR_AUTHKEY: - if (bundle_Phase(arg->bundle) == PHASE_DEAD) { - strncpy(arg->bundle->cfg.auth.key, argp, - sizeof arg->bundle->cfg.auth.key - 1); - arg->bundle->cfg.auth.key[sizeof arg->bundle->cfg.auth.key - 1] = '\0'; - } else { - err = "set authkey: Only available at phase DEAD\n"; - log_Printf(LogWARN, err); + switch (bundle_Phase(arg->bundle)) { + case PHASE_DEAD: + case PHASE_ESTABLISH: + strncpy(arg->bundle->cfg.auth.key, argp, + sizeof arg->bundle->cfg.auth.key - 1); + arg->bundle->cfg.auth.key[sizeof arg->bundle->cfg.auth.key - 1] = '\0'; + break; + default: + err = "set authkey: Only available at phase DEAD/ESTABLISH\n"; + log_Printf(LogWARN, err); + break; } break; case VAR_AUTHNAME: - if (bundle_Phase(arg->bundle) == PHASE_DEAD) { - strncpy(arg->bundle->cfg.auth.name, argp, - sizeof arg->bundle->cfg.auth.name - 1); - arg->bundle->cfg.auth.name[sizeof arg->bundle->cfg.auth.name - 1] = '\0'; - } else { - err = "set authname: Only available at phase DEAD\n"; - log_Printf(LogWARN, err); + switch (bundle_Phase(arg->bundle)) { + case PHASE_DEAD: + case PHASE_ESTABLISH: + strncpy(arg->bundle->cfg.auth.name, argp, + sizeof arg->bundle->cfg.auth.name - 1); + arg->bundle->cfg.auth.name[sizeof arg->bundle->cfg.auth.name-1] = '\0'; + break; + default: + err = "set authname: Only available at phase DEAD/ESTABLISH\n"; + log_Printf(LogWARN, err); + break; } break; @@ -1439,9 +1447,19 @@ SetVariable(struct cmdargs const *arg) break; case VAR_MRRU: - if (bundle_Phase(arg->bundle) != PHASE_DEAD) { - log_Printf(LogWARN, "mrru: Only changable at phase DEAD\n"); - return 1; + switch (bundle_Phase(arg->bundle)) { + case PHASE_DEAD: + break; + case PHASE_ESTABLISH: + /* Make sure none of our links are DATALINK_LCP or greater */ + if (bundle_HighestState(arg->bundle) >= DATALINK_LCP) { + log_Printf(LogWARN, "mrru: Only changable before LCP negotiations\n"); + return 1; + } + break; + default: + log_Printf(LogWARN, "mrru: Only changable at phase DEAD/ESTABLISH\n"); + return 1; } long_val = atol(argp); if (long_val && long_val < MIN_MRU) { @@ -2113,12 +2131,24 @@ NegotiateSet(struct cmdargs const *arg) cx->physical->link.lcp.cfg.protocomp |= add; break; case NEG_SHORTSEQ: - if (bundle_Phase(arg->bundle) != PHASE_DEAD) - log_Printf(LogWARN, "shortseq: Only changable at phase DEAD\n"); - else { - arg->bundle->ncp.mp.cfg.shortseq &= keep; - arg->bundle->ncp.mp.cfg.shortseq |= add; + switch (bundle_Phase(arg->bundle)) { + case PHASE_DEAD: + break; + case PHASE_ESTABLISH: + /* Make sure none of our links are DATALINK_LCP or greater */ + if (bundle_HighestState(arg->bundle) >= DATALINK_LCP) { + log_Printf(LogWARN, "shortseq: Only changable before" + " LCP negotiations\n"); + return 1; + } + break; + default: + log_Printf(LogWARN, "shortseq: Only changable at phase" + " DEAD/ESTABLISH\n"); + return 1; } + arg->bundle->ncp.mp.cfg.shortseq &= keep; + arg->bundle->ncp.mp.cfg.shortseq |= add; break; case NEG_VJCOMP: arg->bundle->ncp.ipcp.cfg.vj.neg &= keep; diff --git a/usr.sbin/ppp/mp.c b/usr.sbin/ppp/mp.c index e9d38ba..201ce66 100644 --- a/usr.sbin/ppp/mp.c +++ b/usr.sbin/ppp/mp.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: mp.c,v 1.15 1998/08/26 17:39:37 brian Exp $ + * $Id: mp.c,v 1.16 1998/09/04 18:25:59 brian Exp $ */ #include @@ -774,9 +774,20 @@ mp_SetEnddisc(struct cmdargs const *arg) struct mp *mp = &arg->bundle->ncp.mp; struct in_addr addr; - if (bundle_Phase(arg->bundle) != PHASE_DEAD) { - log_Printf(LogWARN, "set enddisc: Only available at phase DEAD\n"); - return 1; + switch (bundle_Phase(arg->bundle)) { + case PHASE_DEAD: + break; + case PHASE_ESTABLISH: + /* Make sure none of our links are DATALINK_LCP or greater */ + if (bundle_HighestState(arg->bundle) >= DATALINK_LCP) { + log_Printf(LogWARN, "enddisc: Only changable before" + " LCP negotiations\n"); + return 1; + } + break; + default: + log_Printf(LogWARN, "enddisc: Only changable at phase DEAD/ESTABLISH\n"); + return 1; } if (arg->argc == arg->argn) { -- cgit v1.1