diff --git a/usr.sbin/ppp/ccp.c b/usr.sbin/ppp/ccp.c index 62f4059ceca3..9141d774967f 100644 --- a/usr.sbin/ppp/ccp.c +++ b/usr.sbin/ppp/ccp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ccp.c,v 1.35 1998/06/25 22:33:12 brian Exp $ + * $Id: ccp.c,v 1.36 1998/06/27 23:48:40 brian Exp $ * * TODO: * o Support other compression protocols @@ -590,14 +590,22 @@ ccp_Proto(struct ccp *ccp) PROTO_COMPD : PROTO_ICOMPD; } -void +int ccp_SetOpenMode(struct ccp *ccp) { int f; for (f = 0; f < CCP_NEG_TOTAL; f++) - if (ccp->cfg.neg[f]) + if (IsEnabled(ccp->cfg.neg[f])) { ccp->fsm.open_mode = 0; + return 1; + } - ccp->fsm.open_mode = OPEN_PASSIVE; /* Go straight to ST_STOPPED */ + ccp->fsm.open_mode = OPEN_PASSIVE; /* Go straight to ST_STOPPED ? */ + + for (f = 0; f < CCP_NEG_TOTAL; f++) + if (IsAccepted(ccp->cfg.neg[f])) + return 1; + + return 0; /* No CCP at all */ } diff --git a/usr.sbin/ppp/ccp.h b/usr.sbin/ppp/ccp.h index ca4ac82f4810..b79fc272f850 100644 --- a/usr.sbin/ppp/ccp.h +++ b/usr.sbin/ppp/ccp.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ccp.h,v 1.17 1998/06/15 19:06:37 brian Exp $ + * $Id: ccp.h,v 1.18 1998/06/27 23:48:41 brian Exp $ * * TODO: */ @@ -125,4 +125,4 @@ extern int ccp_Compress(struct ccp *, struct link *, int, u_short, struct mbuf * extern struct mbuf *ccp_Decompress(struct ccp *, u_short *, struct mbuf *); extern u_short ccp_Proto(struct ccp *); extern void ccp_SetupCallbacks(struct ccp *); -extern void ccp_SetOpenMode(struct ccp *); +extern int ccp_SetOpenMode(struct ccp *); diff --git a/usr.sbin/ppp/datalink.c b/usr.sbin/ppp/datalink.c index d3d6a34e0a9b..fc2a84140fee 100644 --- a/usr.sbin/ppp/datalink.c +++ b/usr.sbin/ppp/datalink.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: datalink.c,v 1.13 1998/06/25 22:33:17 brian Exp $ + * $Id: datalink.c,v 1.14 1998/06/27 14:18:04 brian Exp $ */ #include @@ -460,7 +460,7 @@ datalink_GotAuthname(struct datalink *dl, const char *name, int len) void datalink_AuthOk(struct datalink *dl) { - ccp_SetOpenMode(&dl->physical->link.ccp); + int ccpok = ccp_SetOpenMode(&dl->physical->link.ccp); if (dl->physical->link.lcp.want_mrru && dl->physical->link.lcp.his_mrru) { /* we've authenticated in multilink mode ! */ @@ -491,8 +491,10 @@ datalink_AuthOk(struct datalink *dl) auth_Select(dl->bundle, dl->peer.authname, dl->physical); } - fsm_Up(&dl->physical->link.ccp.fsm); - fsm_Open(&dl->physical->link.ccp.fsm); + if (ccpok) { + fsm_Up(&dl->physical->link.ccp.fsm); + fsm_Open(&dl->physical->link.ccp.fsm); + } datalink_NewState(dl, DATALINK_OPEN); bundle_NewPhase(dl->bundle, PHASE_NETWORK); (*dl->parent->LayerUp)(dl->parent->object, &dl->physical->link.lcp.fsm); diff --git a/usr.sbin/ppp/fsm.c b/usr.sbin/ppp/fsm.c index 289670a1aef5..4888e090712a 100644 --- a/usr.sbin/ppp/fsm.c +++ b/usr.sbin/ppp/fsm.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: fsm.c,v 1.33 1998/06/25 22:33:20 brian Exp $ + * $Id: fsm.c,v 1.34 1998/06/27 23:48:43 brian Exp $ * * TODO: */ @@ -458,6 +458,21 @@ FsmRecvConfigReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp) */ switch (fp->state) { case ST_INITIAL: + if (fp->proto == PROTO_CCP && fp->link->lcp.fsm.state == ST_OPENED) { + /* + * ccp_SetOpenMode() leaves us in initial if we're disabling + * & denying everything. This is a bit smelly, we know that + * ``bp'' really has ``fsmheader'' in front of it, and CCP_PROTO + * in front of that. CCP_PROTO isn't compressed either 'cos it + * doesn't begin with 0x00.... + */ + bp->offset -= sizeof(struct fsmheader) + 2; + bp->cnt += sizeof(struct fsmheader) + 2; + lcp_SendProtoRej(&fp->link->lcp, MBUF_CTOP(bp), bp->cnt); + mbuf_Free(bp); + return; + } + /* Drop through */ case ST_STARTING: log_Printf(fp->LogLevel, "%s: Oops, RCR in %s.\n", fp->link->name, State2Nam(fp->state)); diff --git a/usr.sbin/ppp/mp.c b/usr.sbin/ppp/mp.c index 4c9ff8bc4d45..46a686e87fc7 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.10 1998/06/20 00:19:42 brian Exp $ + * $Id: mp.c,v 1.11 1998/06/24 19:33:34 brian Exp $ */ #include @@ -272,9 +272,10 @@ mp_Up(struct mp *mp, struct datalink *dl) ipcp_SetLink(&mp->bundle->ncp.ipcp, &mp->link); /* Our lcp's already up 'cos of the NULL parent */ - ccp_SetOpenMode(&mp->link.ccp); - fsm_Up(&mp->link.ccp.fsm); - fsm_Open(&mp->link.ccp.fsm); + if (ccp_SetOpenMode(&mp->link.ccp)) { + fsm_Up(&mp->link.ccp.fsm); + fsm_Open(&mp->link.ccp.fsm); + } mp->active = 1; break;