diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c index 79efbdcb5d4a..104415860a9b 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.1.2.22 1998/03/13 00:44:32 brian Exp $ + * $Id: bundle.c,v 1.1.2.23 1998/03/13 00:44:38 brian Exp $ */ #include @@ -238,10 +238,7 @@ bundle_LayerFinish(void *v, struct fsm *fp) struct bundle *bundle = (struct bundle *)v; - if (fp->proto == PROTO_LCP) { - FsmDown(&IpcpInfo.fsm); /* You've lost your underlings */ - FsmClose(&IpcpInfo.fsm); /* ST_INITIAL please */ - } else if (fp == &IpcpInfo.fsm) { + if (fp->proto == PROTO_IPCP) { struct datalink *dl; bundle_NewPhase(bundle, PHASE_TERMINATE); @@ -249,6 +246,10 @@ bundle_LayerFinish(void *v, struct fsm *fp) for (dl = bundle->links; dl; dl = dl->next) datalink_Close(dl, 1); } + + /* when either the LCP or IPCP is down, drop IPCP */ + FsmDown(&IpcpInfo.fsm); + FsmClose(&IpcpInfo.fsm); /* ST_INITIAL please */ } int @@ -640,6 +641,8 @@ bundle_Open(struct bundle *bundle, const char *name) if (name != NULL) break; } + if (bundle->phase == PHASE_DEAD) + bundle_NewPhase(bundle, PHASE_ESTABLISH); } struct datalink * @@ -676,14 +679,10 @@ bundle2ccp(struct bundle *bundle, const char *name) struct lcp * bundle2lcp(struct bundle *bundle, const char *name) { -#ifdef realcode struct datalink *dl = bundle2datalink(bundle, name); if (dl) return &dl->lcp; return NULL; -#else - return &LcpInfo; -#endif } struct authinfo * diff --git a/usr.sbin/ppp/chap.c b/usr.sbin/ppp/chap.c index 6dc170ce21db..7a22aca60168 100644 --- a/usr.sbin/ppp/chap.c +++ b/usr.sbin/ppp/chap.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: chap.c,v 1.28.2.13 1998/03/10 03:05:39 brian Exp $ + * $Id: chap.c,v 1.28.2.14 1998/03/13 00:43:54 brian Exp $ * * TODO: */ @@ -236,7 +236,7 @@ RecvChapTalk(struct bundle *bundle, struct fsmheader *chp, struct mbuf *bp, ChapOutput(physical, CHAP_SUCCESS, chp->id, "Welcome!!", 10); Physical_Login(physical, name); - if (LcpInfo.auth_iwait == 0) + if (dl->lcp.auth_iwait == 0) /* * Either I didn't need to authenticate, or I've already been * told that I got the answer right. @@ -266,9 +266,9 @@ RecvChapResult(struct bundle *bundle, struct fsmheader *chp, struct mbuf *bp, len = ntohs(chp->length); LogPrintf(LogDEBUG, "RecvChapResult: length: %d\n", len); if (chp->code == CHAP_SUCCESS) { - if (LcpInfo.auth_iwait == PROTO_CHAP) { - LcpInfo.auth_iwait = 0; - if (LcpInfo.auth_ineed == 0) + if (dl->lcp.auth_iwait == PROTO_CHAP) { + dl->lcp.auth_iwait = 0; + if (dl->lcp.auth_ineed == 0) /* * We've succeeded in our ``login'' * If we're not expecting the peer to authenticate (or he already diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index 1fbf3df976f5..d5a46ba862d0 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.131.2.34 1998/03/13 00:43:58 brian Exp $ + * $Id: command.c,v 1.131.2.35 1998/03/13 00:44:41 brian Exp $ * */ #include @@ -452,11 +452,11 @@ static int ShowStopped(struct cmdargs const *arg) { prompt_Printf(&prompt, " Stopped Timer: LCP: "); - if (!LcpInfo.fsm.StoppedTimer.load) + if (!arg->cx->lcp.fsm.StoppedTimer.load) prompt_Printf(&prompt, "Disabled"); else prompt_Printf(&prompt, "%ld secs", - LcpInfo.fsm.StoppedTimer.load / SECTICKS); + arg->cx->lcp.fsm.StoppedTimer.load / SECTICKS); prompt_Printf(&prompt, ", CCP: "); if (!arg->cx->ccp.fsm.StoppedTimer.load) @@ -577,7 +577,7 @@ static struct cmdtab const ShowCommands[] = { "Show Input filters", "show ifilter option .."}, {"ipcp", NULL, ReportIpcpStatus, LOCAL_AUTH, "Show IPCP status", "show ipcp"}, - {"lcp", NULL, ReportLcpStatus, LOCAL_AUTH | LOCAL_CX, + {"lcp", NULL, lcp_ReportStatus, LOCAL_AUTH | LOCAL_CX, "Show LCP status", "show lcp"}, {"links", "link", bundle_ShowLinks, LOCAL_AUTH, "Show available link names", "show links"}, @@ -788,9 +788,9 @@ ShowCommand(struct cmdargs const *arg) static int TerminalCommand(struct cmdargs const *arg) { - if (LcpInfo.fsm.state > ST_CLOSED) { + if (arg->cx->lcp.fsm.state > ST_CLOSED) { prompt_Printf(&prompt, "LCP state is [%s]\n", - StateNames[LcpInfo.fsm.state]); + StateNames[arg->cx->lcp.fsm.state]); return 1; } @@ -932,11 +932,11 @@ SetRedialTimeout(struct cmdargs const *arg) static int SetStoppedTimeout(struct cmdargs const *arg) { - LcpInfo.fsm.StoppedTimer.load = 0; + arg->cx->lcp.fsm.StoppedTimer.load = 0; arg->cx->ccp.fsm.StoppedTimer.load = 0; if (arg->argc <= 2) { if (arg->argc > 0) { - LcpInfo.fsm.StoppedTimer.load = atoi(arg->argv[0]) * SECTICKS; + arg->cx->lcp.fsm.StoppedTimer.load = atoi(arg->argv[0]) * SECTICKS; if (arg->argc > 1) arg->cx->ccp.fsm.StoppedTimer.load = atoi(arg->argv[1]) * SECTICKS; } diff --git a/usr.sbin/ppp/datalink.c b/usr.sbin/ppp/datalink.c index eef54c495a86..e4cac79fa012 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.1.2.19 1998/03/13 00:44:33 brian Exp $ + * $Id: datalink.c,v 1.1.2.20 1998/03/13 00:44:42 brian Exp $ */ #include @@ -167,13 +167,13 @@ datalink_LoginDone(struct datalink *dl) } else { dl->dial_tries = -1; - lcp_Setup(&LcpInfo, dl->state == DATALINK_READY ? 0 : VarOpenMode); + lcp_Setup(&dl->lcp, dl->state == DATALINK_READY ? 0 : VarOpenMode); ccp_Setup(&dl->ccp); LogPrintf(LogPHASE, "%s: Entering LCP state\n", dl->name); dl->state = DATALINK_LCP; - FsmUp(&LcpInfo.fsm); - FsmOpen(&LcpInfo.fsm); + FsmUp(&dl->lcp.fsm); + FsmOpen(&dl->lcp.fsm); } } @@ -371,10 +371,10 @@ static void datalink_LayerStart(void *v, struct fsm *fp) { /* The given FSM is about to start up ! */ - if (fp == &LcpInfo.fsm) { - struct datalink *dl = (struct datalink *)v; + struct datalink *dl = (struct datalink *)v; + + if (fp == &dl->lcp.fsm) (*dl->parent->LayerStart)(dl->parent->object, fp); - } } static void @@ -383,18 +383,18 @@ datalink_LayerUp(void *v, struct fsm *fp) /* The given fsm is now up */ struct datalink *dl = (struct datalink *)v; - if (fp == &LcpInfo.fsm) { - LcpInfo.auth_ineed = LcpInfo.want_auth; - LcpInfo.auth_iwait = LcpInfo.his_auth; - if (LcpInfo.his_auth || LcpInfo.want_auth) { + if (fp == &dl->lcp.fsm) { + dl->lcp.auth_ineed = dl->lcp.want_auth; + dl->lcp.auth_iwait = dl->lcp.his_auth; + if (dl->lcp.his_auth || dl->lcp.want_auth) { if (dl->bundle->phase == PHASE_DEAD || dl->bundle->phase == PHASE_ESTABLISH) bundle_NewPhase(dl->bundle, PHASE_AUTHENTICATE); LogPrintf(LogPHASE, "%s: his = %s, mine = %s\n", dl->name, - Auth2Nam(LcpInfo.his_auth), Auth2Nam(LcpInfo.want_auth)); - if (LcpInfo.his_auth == PROTO_PAP) + Auth2Nam(dl->lcp.his_auth), Auth2Nam(dl->lcp.want_auth)); + if (dl->lcp.his_auth == PROTO_PAP) StartAuthChallenge(&dl->pap, dl->physical, SendPapChallenge); - if (LcpInfo.want_auth == PROTO_CHAP) + if (dl->lcp.want_auth == PROTO_CHAP) StartAuthChallenge(&dl->chap.auth, dl->physical, SendChapChallenge); } else datalink_AuthOk(dl); @@ -407,14 +407,14 @@ datalink_AuthOk(struct datalink *dl) FsmUp(&dl->ccp.fsm); FsmOpen(&dl->ccp.fsm); dl->state = DATALINK_OPEN; - (*dl->parent->LayerUp)(dl->parent->object, &LcpInfo.fsm); + (*dl->parent->LayerUp)(dl->parent->object, &dl->lcp.fsm); } void datalink_AuthNotOk(struct datalink *dl) { dl->state = DATALINK_LCP; - FsmClose(&LcpInfo.fsm); + FsmClose(&dl->lcp.fsm); } static void @@ -422,7 +422,8 @@ datalink_LayerDown(void *v, struct fsm *fp) { /* The given FSM has been told to come down */ struct datalink *dl = (struct datalink *)v; - if (fp == &LcpInfo.fsm) { + + if (fp == &dl->lcp.fsm) { switch (dl->state) { case DATALINK_OPEN: FsmDown(&dl->ccp.fsm); @@ -444,7 +445,7 @@ datalink_LayerFinish(void *v, struct fsm *fp) /* The given fsm is now down */ struct datalink *dl = (struct datalink *)v; - if (fp == &LcpInfo.fsm) { + if (fp == &dl->lcp.fsm) { (*dl->parent->LayerFinish)(dl->parent->object, fp); datalink_ComeDown(dl, 0); } @@ -509,7 +510,7 @@ datalink_Create(const char *name, struct bundle *bundle, dl->fsm.LayerFinish = datalink_LayerFinish; dl->fsm.object = dl; - lcp_Init(&LcpInfo, dl->bundle, dl->physical, &dl->fsm); + lcp_Init(&dl->lcp, dl->bundle, dl->physical, &dl->fsm); ccp_Init(&dl->ccp, dl->bundle, &dl->physical->link, &dl->fsm); authinfo_Init(&dl->pap); @@ -580,7 +581,7 @@ datalink_Close(struct datalink *dl, int stay) case DATALINK_AUTH: case DATALINK_LCP: - FsmClose(&LcpInfo.fsm); + FsmClose(&dl->lcp.fsm); if (stay) { dl->dial_tries = -1; dl->reconnect_tries = 0; @@ -604,9 +605,9 @@ datalink_Down(struct datalink *dl, int stay) case DATALINK_AUTH: case DATALINK_LCP: - FsmDown(&LcpInfo.fsm); + FsmDown(&dl->lcp.fsm); if (stay) - FsmClose(&LcpInfo.fsm); + FsmClose(&dl->lcp.fsm); else FsmOpen(&dl->ccp.fsm); /* fall through */ diff --git a/usr.sbin/ppp/datalink.h b/usr.sbin/ppp/datalink.h index 9ccddf624703..2c3dee395e60 100644 --- a/usr.sbin/ppp/datalink.h +++ b/usr.sbin/ppp/datalink.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: datalink.h,v 1.1.2.10 1998/03/01 01:07:43 brian Exp $ + * $Id: datalink.h,v 1.1.2.11 1998/03/09 19:24:56 brian Exp $ */ #define DATALINK_CLOSED (0) @@ -80,9 +80,7 @@ struct datalink { struct fsm_parent fsm; /* Our callback functions */ const struct fsm_parent *parent; /* Our parent */ -#ifdef soon struct lcp lcp; /* Our line control FSM */ -#endif struct ccp ccp; /* Our compression FSM */ struct authinfo pap; /* Authentication using pap */ diff --git a/usr.sbin/ppp/hdlc.c b/usr.sbin/ppp/hdlc.c index f10a1eb07298..f4cea0c539f9 100644 --- a/usr.sbin/ppp/hdlc.c +++ b/usr.sbin/ppp/hdlc.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: hdlc.c,v 1.28.2.16 1998/03/13 00:44:03 brian Exp $ + * $Id: hdlc.c,v 1.28.2.17 1998/03/13 00:44:44 brian Exp $ * * TODO: */ @@ -160,7 +160,7 @@ HdlcOutput(struct link *l, int pri, u_short proto, struct mbuf *bp) mhp = mballoc(4, MB_HDLCOUT); mhp->cnt = 0; cp = MBUF_CTOP(mhp); - if (proto == PROTO_LCP || LcpInfo.his_acfcomp == 0) { + if (proto == PROTO_LCP || p->dl->lcp.his_acfcomp == 0) { *cp++ = HDLC_ADDR; *cp++ = HDLC_UI; mhp->cnt += 2; @@ -169,7 +169,7 @@ HdlcOutput(struct link *l, int pri, u_short proto, struct mbuf *bp) /* * If possible, compress protocol field. */ - if (LcpInfo.his_protocomp && (proto & 0xff00) == 0) { + if (p->dl->lcp.his_protocomp && (proto & 0xff00) == 0) { *cp++ = proto; mhp->cnt++; } else { @@ -192,7 +192,7 @@ HdlcOutput(struct link *l, int pri, u_short proto, struct mbuf *bp) /* Overwrite the entire packet */ struct lqrdata lqr; - lqr.MagicNumber = LcpInfo.want_magic; + lqr.MagicNumber = p->dl->lcp.want_magic; lqr.LastOutLQRs = p->hdlc.lqm.lqr.peer.PeerOutLQRs; lqr.LastOutPackets = p->hdlc.lqm.lqr.peer.PeerOutPackets; lqr.LastOutOctets = p->hdlc.lqm.lqr.peer.PeerOutOctets; @@ -369,18 +369,18 @@ DecodePacket(struct bundle *bundle, u_short proto, struct mbuf * bp, struct link *l) { struct physical *p = link2physical(l); - struct ccp *ccp = bundle2ccp(bundle, l->name); + struct datalink *dl = bundle2datalink(bundle, l->name); u_char *cp; LogPrintf(LogDEBUG, "DecodePacket: proto = 0x%04x\n", proto); /* decompress everything. CCP needs uncompressed data too */ - if ((bp = ccp_Decompress(ccp, &proto, bp)) == NULL) + if ((bp = ccp_Decompress(&dl->ccp, &proto, bp)) == NULL) return; switch (proto) { case PROTO_LCP: - LcpInput(bp); + LcpInput(&dl->lcp, bp); break; case PROTO_PAP: if (p) @@ -420,7 +420,7 @@ DecodePacket(struct bundle *bundle, u_short proto, struct mbuf * bp, IpcpInput(bp); break; case PROTO_CCP: - CcpInput(ccp, bundle, bp); + CcpInput(&dl->ccp, bundle, bp); break; default: LogPrintf(LogPHASE, "Unknown protocol 0x%04x (%s)\n", @@ -428,7 +428,9 @@ DecodePacket(struct bundle *bundle, u_short proto, struct mbuf * bp, bp->offset -= 2; bp->cnt += 2; cp = MBUF_CTOP(bp); - LcpSendProtoRej(cp, bp->cnt); + if (p) + lcp_SendProtoRej(&dl->lcp, cp, bp->cnt); + /* XXX: Eeek - how to we proto-reject something at the bundle level ? */ p->hdlc.lqm.SaveInDiscards++; p->hdlc.stats.unknownproto++; pfree(bp); @@ -467,7 +469,7 @@ HdlcInput(struct bundle *bundle, struct mbuf * bp, struct physical *physical) } cp = MBUF_CTOP(bp); - if (!LcpInfo.want_acfcomp) { + if (!physical->dl->lcp.want_acfcomp) { /* * We expect that packet is not compressed. */ @@ -499,7 +501,7 @@ HdlcInput(struct bundle *bundle, struct mbuf * bp, struct physical *physical) bp->offset += 2; bp->cnt -= 2; } - if (LcpInfo.want_protocomp) { + if (physical->dl->lcp.want_protocomp) { proto = 0; cp--; do { diff --git a/usr.sbin/ppp/lcp.c b/usr.sbin/ppp/lcp.c index 504bfae8ea1c..dabc64f0ff4c 100644 --- a/usr.sbin/ppp/lcp.c +++ b/usr.sbin/ppp/lcp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: lcp.c,v 1.55.2.25 1998/03/09 19:26:39 brian Exp $ + * $Id: lcp.c,v 1.55.2.26 1998/03/13 00:44:08 brian Exp $ * * TODO: * o Limit data field length by MRU @@ -69,6 +69,8 @@ #include "descriptor.h" #include "physical.h" #include "prompt.h" +#include "chat.h" +#include "datalink.h" /* for received LQRs */ struct lqrreq { @@ -102,8 +104,6 @@ static struct fsm_callbacks lcp_Callbacks = { NullRecvResetAck }; -struct lcp LcpInfo; - static const char *cftypes[] = { /* Check out the latest ``Assigned numbers'' rfc (rfc1700.txt) */ "???", @@ -135,22 +135,22 @@ static const char *cftypes[] = { #define NCFTYPES (sizeof cftypes/sizeof cftypes[0]) int -ReportLcpStatus(struct cmdargs const *arg) +lcp_ReportStatus(struct cmdargs const *arg) { - prompt_Printf(&prompt, "%s [%s]\n", LcpInfo.fsm.name, - StateNames[LcpInfo.fsm.state]); + prompt_Printf(&prompt, "%s [%s]\n", arg->cx->lcp.fsm.name, + StateNames[arg->cx->lcp.fsm.state]); prompt_Printf(&prompt, " his side: MRU %d, ACCMAP %08lx, PROTOCOMP %d, ACFCOMP %d,\n" " MAGIC %08lx, REJECT %04x\n", - LcpInfo.his_mru, (u_long)LcpInfo.his_accmap, - LcpInfo.his_protocomp, LcpInfo.his_acfcomp, - (u_long)LcpInfo.his_magic, LcpInfo.his_reject); + arg->cx->lcp.his_mru, (u_long)arg->cx->lcp.his_accmap, + arg->cx->lcp.his_protocomp, arg->cx->lcp.his_acfcomp, + (u_long)arg->cx->lcp.his_magic, arg->cx->lcp.his_reject); prompt_Printf(&prompt, " my side: MRU %d, ACCMAP %08lx, PROTOCOMP %d, ACFCOMP %d,\n" " MAGIC %08lx, REJECT %04x\n", - LcpInfo.want_mru, (u_long)LcpInfo.want_accmap, - LcpInfo.want_protocomp, LcpInfo.want_acfcomp, - (u_long)LcpInfo.want_magic, LcpInfo.my_reject); + arg->cx->lcp.want_mru, (u_long)arg->cx->lcp.want_accmap, + arg->cx->lcp.want_protocomp, arg->cx->lcp.want_acfcomp, + (u_long)arg->cx->lcp.want_magic, arg->cx->lcp.my_reject); prompt_Printf(&prompt, "\nDefaults: MRU = %d, ACCMAP = %08lx\t", VarMRU, (u_long)VarAccmap); prompt_Printf(&prompt, "Open Mode: %s", @@ -351,11 +351,11 @@ LcpSendConfigReq(struct fsm *fp) } void -LcpSendProtoRej(u_char *option, int count) +lcp_SendProtoRej(struct lcp *lcp, u_char *option, int count) { /* Don't understand `option' */ - LogPrintf(LogLCP, "LcpSendProtoRej\n"); - FsmOutput(&LcpInfo.fsm, CODE_PROTOREJ, LcpInfo.fsm.reqid, option, count); + LogPrintf(LogLCP, "lcp_SendProtoRej\n"); + FsmOutput(&lcp->fsm, CODE_PROTOREJ, lcp->fsm.reqid, option, count); } static void @@ -376,8 +376,10 @@ static void LcpLayerStart(struct fsm *fp) { /* We're about to start up ! */ + struct lcp *lcp = fsm2lcp(fp); + LogPrintf(LogLCP, "LcpLayerStart\n"); - LcpInfo.LcpFailedMagic = 0; + lcp->LcpFailedMagic = 0; } static void @@ -773,8 +775,8 @@ reqreject: } void -LcpInput(struct mbuf * bp) +LcpInput(struct lcp *lcp, struct mbuf * bp) { /* Got PROTO_LCP from link */ - FsmInput(&LcpInfo.fsm, bp); + FsmInput(&lcp->fsm, bp); } diff --git a/usr.sbin/ppp/lcp.h b/usr.sbin/ppp/lcp.h index 7d75c2e4618d..125c8c517733 100644 --- a/usr.sbin/ppp/lcp.h +++ b/usr.sbin/ppp/lcp.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: lcp.h,v 1.16.2.12 1998/02/27 01:22:35 brian Exp $ + * $Id: lcp.h,v 1.16.2.13 1998/03/13 00:44:45 brian Exp $ * * TODO: */ @@ -71,8 +71,6 @@ struct lcp_opt { struct physical; -extern struct lcp LcpInfo; - #define fsm2lcp(fp) (fp->proto == PROTO_LCP ? (struct lcp *)fp : NULL) #define lcp2ccp(lcp) (&link2physical((lcp)->fsm.link)->dl->ccp) @@ -80,8 +78,8 @@ extern void lcp_Init(struct lcp *, struct bundle *, struct physical *, const struct fsm_parent *); extern void lcp_Setup(struct lcp *, int); -extern void LcpSendProtoRej(u_char *, int); +extern void lcp_SendProtoRej(struct lcp *, u_char *, int); extern int LcpPutConf(int, u_char *, const struct lcp_opt *, const char *, const char *, ...); -extern int ReportLcpStatus(struct cmdargs const *); -extern void LcpInput(struct mbuf *); +extern int lcp_ReportStatus(struct cmdargs const *); +extern void LcpInput(struct lcp *, struct mbuf *); diff --git a/usr.sbin/ppp/lqr.c b/usr.sbin/ppp/lqr.c index 10ef1aa2065b..94d6a35ed575 100644 --- a/usr.sbin/ppp/lqr.c +++ b/usr.sbin/ppp/lqr.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: lqr.c,v 1.22.2.9 1998/03/13 00:44:10 brian Exp $ + * $Id: lqr.c,v 1.22.2.10 1998/03/13 00:44:56 brian Exp $ * * o LQR based on RFC1333 * @@ -127,7 +127,7 @@ SendLqrReport(void *v) LogPrintf(LogPHASE, "** Too many LQR packets lost **\n"); LogPrintf(LogLQM, "LqrOutput: Too many LQR packets lost\n"); hdlc->lqm.method = 0; /* Prevent recursion via bundle_Close() */ - bundle_Close(LcpInfo.fsm.bundle, NULL, 1); + bundle_Close(lcp->fsm.bundle, NULL, 1); } else { bp = mballoc(sizeof(struct lqrdata), MB_LQR); HdlcOutput(lcp->fsm.link, PRI_LINK, PROTO_LQR, bp); @@ -141,7 +141,7 @@ SendLqrReport(void *v) LogPrintf(LogPHASE, "** Too many ECHO LQR packets lost **\n"); LogPrintf(LogLQM, "LqrOutput: Too many ECHO LQR packets lost\n"); hdlc->lqm.method = 0; /* Prevent recursion via bundle_Close() */ - bundle_Close(LcpInfo.fsm.bundle, NULL, 1); + bundle_Close(lcp->fsm.bundle, NULL, 1); } else SendEchoReq(lcp); } @@ -161,15 +161,17 @@ LqrInput(struct physical *physical, struct mbuf *bp) else if (!Acceptable(ConfLqr)) { bp->offset -= 2; bp->cnt += 2; - LcpSendProtoRej(MBUF_CTOP(bp), bp->cnt); + lcp_SendProtoRej(physical->hdlc.lqm.owner, MBUF_CTOP(bp), bp->cnt); } else { struct lqrdata *lqr; + struct lcp *lcp; u_int32_t lastLQR; lqr = (struct lqrdata *)MBUF_CTOP(bp); - if (ntohl(lqr->MagicNumber) != LcpInfo.his_magic) + lcp = physical->hdlc.lqm.owner; + if (ntohl(lqr->MagicNumber) != physical->hdlc.lqm.owner->his_magic) LogPrintf(LogERROR, "LqrInput: magic %x != expecting %x\n", - ntohl(lqr->MagicNumber), LcpInfo.his_magic); + ntohl(lqr->MagicNumber), physical->hdlc.lqm.owner->his_magic); else { /* * Remember our PeerInLQRs, then convert byte order and save @@ -188,7 +190,7 @@ LqrInput(struct physical *physical, struct mbuf *bp) * send our next one before the peers max timeout. */ if (physical->hdlc.lqm.timer.load == 0 || - lastLQR == physical->hdlc.lqm.lqr.peer.PeerInLQRs || + (lastLQR && lastLQR == physical->hdlc.lqm.lqr.peer.PeerInLQRs) || (physical->hdlc.lqm.lqr.peer_timeout && physical->hdlc.lqm.timer.rest * 100 / SECTICKS > physical->hdlc.lqm.lqr.peer_timeout)) diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c index 77549c50b938..b2d0ed2b15ff 100644 --- a/usr.sbin/ppp/main.c +++ b/usr.sbin/ppp/main.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: main.c,v 1.121.2.29 1998/03/01 01:07:46 brian Exp $ + * $Id: main.c,v 1.121.2.30 1998/03/13 00:44:13 brian Exp $ * * TODO: * o Add commands for traffic summary, version display, etc. @@ -610,7 +610,7 @@ DoLoop(struct bundle *bundle) * Process on-demand dialup. Output packets are queued within tunnel * device until IPCP is opened. */ - if (LcpInfo.fsm.state <= ST_CLOSED && (mode & MODE_AUTO) && + if (bundle->phase == PHASE_DEAD && (mode & MODE_AUTO) && (pri = PacketCheck(tun.data, n, FL_DIAL)) >= 0) bundle_Open(bundle, NULL); diff --git a/usr.sbin/ppp/modem.c b/usr.sbin/ppp/modem.c index 358be9e7dbde..982afcfcd3bf 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.77.2.32 1998/03/13 00:44:16 brian Exp $ + * $Id: modem.c,v 1.77.2.33 1998/03/13 00:44:46 brian Exp $ * * TODO: */ @@ -988,7 +988,7 @@ modem_DescriptorRead(struct descriptor *d, struct bundle *bundle, LogPrintf(LogDEBUG, "descriptor2physical; %p -> %p\n", d, p); /* something to read from modem */ - if (LcpInfo.fsm.state <= ST_CLOSED) + if (p->dl->lcp.fsm.state <= ST_CLOSED) nointr_usleep(10000); n = Physical_Read(p, rbuff, sizeof rbuff); @@ -997,7 +997,7 @@ modem_DescriptorRead(struct descriptor *d, struct bundle *bundle, else LogDumpBuff(LogASYNC, "ReadFromModem", rbuff, n); - if (LcpInfo.fsm.state <= ST_CLOSED) { + if (p->dl->lcp.fsm.state <= ST_CLOSED) { /* In dedicated mode, we just discard input until LCP is started */ if (!(mode & MODE_DEDICATED)) { cp = HdlcDetect(p, rbuff, n); diff --git a/usr.sbin/ppp/pap.c b/usr.sbin/ppp/pap.c index c633ebbfd616..db6930fc42f0 100644 --- a/usr.sbin/ppp/pap.c +++ b/usr.sbin/ppp/pap.c @@ -18,7 +18,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: pap.c,v 1.20.2.14 1998/03/10 03:05:50 brian Exp $ + * $Id: pap.c,v 1.20.2.15 1998/03/13 00:44:19 brian Exp $ * * TODO: */ @@ -157,10 +157,10 @@ PapInput(struct bundle *bundle, struct mbuf *bp, struct physical *physical) cp = (u_char *) (php + 1); if (PapValidate(bundle, cp, cp + *cp + 1, physical)) { SendPapCode(php->id, PAP_ACK, "Greetings!!", physical); - LcpInfo.auth_ineed = 0; + dl->lcp.auth_ineed = 0; Physical_Login(physical, cp + 1); - if (LcpInfo.auth_iwait == 0) + if (dl->lcp.auth_iwait == 0) /* * Either I didn't need to authenticate, or I've already been * told that I got the answer right. @@ -178,9 +178,9 @@ PapInput(struct bundle *bundle, struct mbuf *bp, struct physical *physical) len = *cp++; cp[len] = 0; LogPrintf(LogPHASE, "Received PAP_ACK (%s)\n", cp); - if (LcpInfo.auth_iwait == PROTO_PAP) { - LcpInfo.auth_iwait = 0; - if (LcpInfo.auth_ineed == 0) + if (dl->lcp.auth_iwait == PROTO_PAP) { + dl->lcp.auth_iwait = 0; + if (dl->lcp.auth_ineed == 0) /* * We've succeeded in our ``login'' * If we're not expecting the peer to authenticate (or he already