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.
This commit is contained in:
Brian Somers 1998-10-24 01:08:45 +00:00
parent b6542d2e4f
commit 9b5f8ffdc6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=40622
4 changed files with 85 additions and 30 deletions

View File

@ -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 <sys/param.h>
@ -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;
}

View File

@ -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 *);

View File

@ -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 <sys/types.h>
@ -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;

View File

@ -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 <sys/types.h>
@ -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) {