diff --git a/usr.sbin/ppp/ccp.c b/usr.sbin/ppp/ccp.c index bee71312c0f5..0bd6ea709a22 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.12 1997/05/26 00:43:56 brian Exp $ + * $Id: ccp.c,v 1.13 1997/06/09 03:27:14 brian Exp $ * * TODO: * o Support other compression protocols @@ -52,9 +52,10 @@ struct fsm CcpFsm = { OPEN_ACTIVE, ST_INITIAL, 0, 0, 0, - 0, { 0, 0, 0, NULL, NULL, NULL }, + { 0, 0, 0, NULL, NULL, NULL }, + LogCCP, CcpLayerUp, CcpLayerDown, @@ -120,7 +121,7 @@ struct fsm *fp; struct ccpstate *icp = &CcpInfo; cp = ReqBuff; - LogPrintf(LogLCP, "CcpSendConfigReq\n"); + LogPrintf(LogCCP, "CcpSendConfigReq\n"); if (icp->want_proto && !REJECTED(icp, TY_PRED1)) { *cp++ = TY_PRED1; *cp++ = 2; } @@ -132,7 +133,7 @@ CcpSendResetReq(fp) struct fsm *fp; { Pred1Init(1); /* Initialize Input part */ - LogPrintf(LogLCP, "CcpSendResetReq\n"); + LogPrintf(LogCCP, "CcpSendResetReq\n"); FsmOutput(fp, CODE_RESETREQ, fp->reqid, NULL, 0); } @@ -147,7 +148,7 @@ static void CcpSendTerminateAck(fp) struct fsm *fp; { - LogPrintf(LogLCP, "CcpSendTerminateAck\n"); + LogPrintf(LogCCP, "CcpSendTerminateAck\n"); FsmOutput(fp, CODE_TERMACK, fp->reqid++, NULL, 0); } @@ -162,21 +163,21 @@ static void CcpLayerStart(fp) struct fsm *fp; { - LogPrintf(LogLCP, "CcpLayerStart.\n"); + LogPrintf(LogCCP, "CcpLayerStart.\n"); } static void CcpLayerFinish(fp) struct fsm *fp; { - LogPrintf(LogLCP, "CcpLayerFinish.\n"); + LogPrintf(LogCCP, "CcpLayerFinish.\n"); } static void CcpLayerDown(fp) struct fsm *fp; { - LogPrintf(LogLCP, "CcpLayerDown.\n"); + LogPrintf(LogCCP, "CcpLayerDown.\n"); } /* @@ -186,8 +187,8 @@ static void CcpLayerUp(fp) struct fsm *fp; { - LogPrintf(LogLCP, "CcpLayerUp(%d).\n", fp->state); - LogPrintf(LogLCP, "myproto = %d, hisproto = %d\n", + LogPrintf(LogCCP, "CcpLayerUp(%d).\n", fp->state); + LogPrintf(LogCCP, "myproto = %d, hisproto = %d\n", CcpInfo.want_proto, CcpInfo.his_proto); Pred1Init(3); /* Initialize Input and Output */ } @@ -196,7 +197,7 @@ void CcpUp() { FsmUp(&CcpFsm); - LogPrintf(LogLCP, "CCP Up event!!\n"); + LogPrintf(LogCCP, "CCP Up event!!\n"); } void @@ -229,7 +230,7 @@ int mode; else snprintf(tbuff, sizeof(tbuff), " "); - LogPrintf(LogLCP, "%s\n", tbuff); + LogPrintf(LogCCP, "%s\n", tbuff); switch (type) { case TY_PRED1: diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index 5896abfe71ce..bfb0b8edf8f3 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.69 1997/08/18 20:15:09 brian Exp $ + * $Id: command.c,v 1.70 1997/08/19 01:10:19 brian Exp $ * */ #include @@ -415,10 +415,27 @@ static int ShowStopped() { if (!VarTerm) return 0; - if (!VarStoppedTimeout) - fprintf(VarTerm, " Stopped Timer: Disabled\n"); + + fprintf(VarTerm, " Stopped Timer: LCP: "); + if (!LcpFsm.StoppedTimer.load) + fprintf(VarTerm, "Disabled"); else - fprintf(VarTerm, " Stopped Timer: %d secs\n", VarStoppedTimeout); + fprintf(VarTerm, "%ld secs", LcpFsm.StoppedTimer.load / SECTICKS); + + fprintf(VarTerm, ", IPCP: "); + if (!IpcpFsm.StoppedTimer.load) + fprintf(VarTerm, "Disabled"); + else + fprintf(VarTerm, "%ld secs", IpcpFsm.StoppedTimer.load / SECTICKS); + + fprintf(VarTerm, ", CCP: "); + if (!CcpFsm.StoppedTimer.load) + fprintf(VarTerm, "Disabled"); + else + fprintf(VarTerm, "%ld secs", CcpFsm.StoppedTimer.load / SECTICKS); + + fprintf(VarTerm, "\n"); + return 1; } @@ -887,8 +904,18 @@ struct cmdtab *list; int argc; char **argv; { - if (argc == 1) { - VarStoppedTimeout = atoi(argv[0]); + LcpFsm.StoppedTimer.load = 0; + IpcpFsm.StoppedTimer.load = 0; + CcpFsm.StoppedTimer.load = 0; + if (argc <= 3) { + if (argc > 0) { + LcpFsm.StoppedTimer.load = atoi(argv[0]) * SECTICKS; + if (argc > 1) { + IpcpFsm.StoppedTimer.load = atoi(argv[1]) * SECTICKS; + if (argc > 2) + CcpFsm.StoppedTimer.load = atoi(argv[2]) * SECTICKS; + } + } return 0; } return -1; diff --git a/usr.sbin/ppp/fsm.c b/usr.sbin/ppp/fsm.c index a881c465dca5..eabbfccbb5f9 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.13 1997/06/09 03:27:21 brian Exp $ + * $Id: fsm.c,v 1.14 1997/08/17 20:45:46 brian Exp $ * * TODO: * o Refer loglevel for log output @@ -43,23 +43,11 @@ char const *StateNames[] = { "Req-Sent", "Ack-Rcvd", "Ack-Sent", "Opened", }; -/* - * This timer times the ST_STOPPED state out after the given value - * (specified via "set stopped ..."). Although this isn't - * specified in the rfc, the rfc *does* say that "the application - * may use higher level timers to avoid deadlock". - * The StoppedTimer takes effect when the other side ABENDs rather - * than going into ST_ACKSENT (and sending the ACK), causing ppp to - * time out and drop into ST_STOPPED. At this point, nothing will - * change this state :-( - */ -struct pppTimer StoppedTimer; - static void StoppedTimeout(fp) struct fsm *fp; { - LogPrintf(LogLCP, "Stopped timer expired\n"); + LogPrintf(fp->LogLevel, "Stopped timer expired\n"); if (modem != -1) DownConnection(); else @@ -82,19 +70,18 @@ NewState(fp, new) struct fsm *fp; int new; { - LogPrintf(LogLCP, "State change %s --> %s\n", + LogPrintf(fp->LogLevel, "State change %s --> %s\n", StateNames[fp->state], StateNames[new]); - if (fp->state == ST_STOPPED && StoppedTimer.state == TIMER_RUNNING) - StopTimer(&StoppedTimer); + if (fp->state == ST_STOPPED && fp->StoppedTimer.state == TIMER_RUNNING) + StopTimer(&fp->StoppedTimer); fp->state = new; if ((new >= ST_INITIAL && new <= ST_STOPPED) || (new == ST_OPENED)) { StopTimer(&fp->FsmTimer); - if (new == ST_STOPPED && VarStoppedTimeout) { - StoppedTimer.state = TIMER_STOPPED; - StoppedTimer.func = StoppedTimeout; - StoppedTimer.arg = (void *)fp; - StoppedTimer.load = VarStoppedTimeout * SECTICKS; - StartTimer(&StoppedTimer); + if (new == ST_STOPPED && fp->StoppedTimer.load) { + fp->StoppedTimer.state = TIMER_STOPPED; + fp->StoppedTimer.func = StoppedTimeout; + fp->StoppedTimer.arg = (void *)fp; + StartTimer(&fp->StoppedTimer); } } } @@ -169,7 +156,7 @@ struct fsm *fp; NewState(fp, ST_REQSENT); break; default: - LogPrintf(LogLCP, "Oops, Up at %s\n", StateNames[fp->state]); + LogPrintf(fp->LogLevel, "Oops, Up at %s\n", StateNames[fp->state]); break; } } @@ -246,7 +233,7 @@ void FsmSendTerminateReq(fp) struct fsm *fp; { - LogPrintf(LogLCP, "SendTerminateReq.\n"); + LogPrintf(fp->LogLevel, "SendTerminateReq.\n"); FsmOutput(fp, CODE_TERMREQ, fp->reqid++, NULL, 0); (fp->SendTerminateReq)(fp); StartTimer(&fp->FsmTimer); /* Start restart timer */ @@ -260,7 +247,7 @@ struct fsmheader *lhp; u_char *option; int count; { - LogPrintf(LogLCP, "SendConfigAck(%s)\n", StateNames[fp->state]); + LogPrintf(fp->LogLevel, "SendConfigAck(%s)\n", StateNames[fp->state]); (fp->DecodeConfig)(option, count, MODE_NOP); FsmOutput(fp, CODE_CONFIGACK, lhp->id, option, count); } @@ -272,7 +259,7 @@ struct fsmheader *lhp; u_char *option; int count; { - LogPrintf(LogLCP, "SendConfigRej(%s)\n", StateNames[fp->state]); + LogPrintf(fp->LogLevel, "SendConfigRej(%s)\n", StateNames[fp->state]); (fp->DecodeConfig)(option, count, MODE_NOP); FsmOutput(fp, CODE_CONFIGREJ, lhp->id, option, count); } @@ -284,7 +271,7 @@ struct fsmheader *lhp; u_char *option; int count; { - LogPrintf(LogLCP, "SendConfigNak(%s)\n", StateNames[fp->state]); + LogPrintf(fp->LogLevel, "SendConfigNak(%s)\n", StateNames[fp->state]); (fp->DecodeConfig)(option, count, MODE_NOP); FsmOutput(fp, CODE_CONFIGNAK, lhp->id, option, count); } @@ -370,7 +357,7 @@ struct mbuf *bp; switch (fp->state) { case ST_INITIAL: case ST_STARTING: - LogPrintf(LogLCP, "Oops, RCR in %s.\n", StateNames[fp->state]); + LogPrintf(fp->LogLevel, "Oops, RCR in %s.\n", StateNames[fp->state]); pfree(bp); return; case ST_CLOSED: @@ -490,7 +477,7 @@ struct mbuf *bp; switch (fp->state) { case ST_INITIAL: case ST_STARTING: - LogPrintf(LogLCP, "Oops, RCN in %s.\n", StateNames[fp->state]); + LogPrintf(fp->LogLevel, "Oops, RCN in %s.\n", StateNames[fp->state]); pfree(bp); return; case ST_CLOSED: @@ -533,7 +520,7 @@ struct mbuf *bp; switch (fp->state) { case ST_INITIAL: case ST_STARTING: - LogPrintf(LogLCP, "Oops, RTR in %s\n", StateNames[fp->state]); + LogPrintf(fp->LogLevel, "Oops, RTR in %s\n", StateNames[fp->state]); break; case ST_CLOSED: case ST_STOPPED: @@ -599,7 +586,7 @@ struct mbuf *bp; pfree(bp); return; } - LogPrintf(LogLCP, "RecvConfigRej.\n"); + LogPrintf(fp->LogLevel, "RecvConfigRej.\n"); /* * Check and process easy case @@ -607,7 +594,7 @@ struct mbuf *bp; switch (fp->state) { case ST_INITIAL: case ST_STARTING: - LogPrintf(LogLCP, "Oops, RCJ in %s.\n", StateNames[fp->state]); + LogPrintf(fp->LogLevel, "Oops, RCJ in %s.\n", StateNames[fp->state]); pfree(bp); return; case ST_CLOSED: @@ -646,7 +633,7 @@ struct fsm *fp; struct fsmheader *lhp; struct mbuf *bp; { - LogPrintf(LogLCP, "RecvCodeRej\n"); + LogPrintf(fp->LogLevel, "RecvCodeRej\n"); pfree(bp); } @@ -660,7 +647,7 @@ struct mbuf *bp; sp = (u_short *)MBUF_CTOP(bp); proto = ntohs(*sp); - LogPrintf(LogLCP, "-- Protocol (%04x) was rejected.\n", proto); + LogPrintf(fp->LogLevel, "-- Protocol (%04x) was rejected.\n", proto); switch (proto) { case PROTO_LQR: @@ -701,7 +688,7 @@ struct mbuf *bp; if (fp->state == ST_OPENED) { *lp = htonl(LcpInfo.want_magic); /* Insert local magic number */ - LogPrintf(LogLCP, "SendEchoRep(%s)\n", StateNames[fp->state]); + LogPrintf(fp->LogLevel, "SendEchoRep(%s)\n", StateNames[fp->state]); FsmOutput(fp, CODE_ECHOREP, lhp->id, cp, plength(bp)); } pfree(bp); @@ -738,7 +725,7 @@ struct fsm *fp; struct fsmheader *lhp; struct mbuf *bp; { - LogPrintf(LogLCP, "RecvDiscReq\n"); + LogPrintf(fp->LogLevel, "RecvDiscReq\n"); pfree(bp); } @@ -748,7 +735,7 @@ struct fsm *fp; struct fsmheader *lhp; struct mbuf *bp; { - LogPrintf(LogLCP, "RecvIdent\n"); + LogPrintf(fp->LogLevel, "RecvIdent\n"); pfree(bp); } @@ -758,7 +745,7 @@ struct fsm *fp; struct fsmheader *lhp; struct mbuf *bp; { - LogPrintf(LogLCP, "RecvTimeRemain\n"); + LogPrintf(fp->LogLevel, "RecvTimeRemain\n"); pfree(bp); } @@ -768,9 +755,9 @@ struct fsm *fp; struct fsmheader *lhp; struct mbuf *bp; { - LogPrintf(LogLCP, "RecvResetReq\n"); + LogPrintf(fp->LogLevel, "RecvResetReq\n"); CcpRecvResetReq(fp); - LogPrintf(LogLCP, "SendResetAck\n"); + LogPrintf(fp->LogLevel, "SendResetAck\n"); FsmOutput(fp, CODE_RESETACK, fp->reqid, NULL, 0); pfree(bp); } @@ -781,7 +768,7 @@ struct fsm *fp; struct fsmheader *lhp; struct mbuf *bp; { - LogPrintf(LogLCP, "RecvResetAck\n"); + LogPrintf(fp->LogLevel, "RecvResetAck\n"); fp->reqid++; pfree(bp); } @@ -828,7 +815,7 @@ struct mbuf *bp; bp->cnt -= sizeof(struct fsmheader); codep = FsmCodes + lhp->code - 1; - LogPrintf(LogLCP, "Received %s (%d) state = %s (%d)\n", + LogPrintf(fp->LogLevel, "Received %s (%d) state = %s (%d)\n", codep->name, lhp->id, StateNames[fp->state], fp->state); if (LogIsKept(LogDEBUG)) LogMemory(); diff --git a/usr.sbin/ppp/fsm.h b/usr.sbin/ppp/fsm.h index 0b55a8940e97..6fd4e4837c51 100644 --- a/usr.sbin/ppp/fsm.h +++ b/usr.sbin/ppp/fsm.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: fsm.h,v 1.7 1997/02/22 16:10:14 peter Exp $ + * $Id: fsm.h,v 1.8 1997/06/09 03:27:21 brian Exp $ * * TODO: */ @@ -65,6 +65,19 @@ struct fsm { int reqcode; /* Request code sent */ struct pppTimer FsmTimer; /* Restart Timer */ + /* + * This timer times the ST_STOPPED state out after the given value + * (specified via "set stopped ..."). Although this isn't + * specified in the rfc, the rfc *does* say that "the application + * may use higher level timers to avoid deadlock". + * The StoppedTimer takes effect when the other side ABENDs rather + * than going into ST_ACKSENT (and sending the ACK), causing ppp to + * time out and drop into ST_STOPPED. At this point, nothing will + * change this state :-( + */ + struct pppTimer StoppedTimer; + int LogLevel; + void (*LayerUp)(struct fsm *); void (*LayerDown)(struct fsm *); void (*LayerStart)(struct fsm *); diff --git a/usr.sbin/ppp/ipcp.c b/usr.sbin/ppp/ipcp.c index 90c6f364246c..4480a204a3ac 100644 --- a/usr.sbin/ppp/ipcp.c +++ b/usr.sbin/ppp/ipcp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ipcp.c,v 1.23 1997/07/29 22:37:04 brian Exp $ + * $Id: ipcp.c,v 1.24 1997/08/19 01:10:20 brian Exp $ * * TODO: * o More RFC1772 backwoard compatibility @@ -76,6 +76,8 @@ struct fsm IpcpFsm = { 0, { 0, 0, 0, NULL, NULL, NULL }, + { 0, 0, 0, NULL, NULL, NULL }, + LogIPCP, IpcpLayerUp, IpcpLayerDown, @@ -187,7 +189,7 @@ IpcpInit() */ if (HaveTriggerAddress) { icp->want_ipaddr.s_addr = TriggerAddress.s_addr; - LogPrintf(LogLCP, "Using trigger address %s\n", inet_ntoa(TriggerAddress)); + LogPrintf(LogIPCP, "Using trigger address %s\n", inet_ntoa(TriggerAddress)); } if (Enabled(ConfVjcomp)) @@ -214,7 +216,7 @@ struct fsm *fp; struct ipcpstate *icp = &IpcpInfo; cp = ReqBuff; - LogPrintf(LogLCP, "IpcpSendConfigReq\n"); + LogPrintf(LogIPCP, "IpcpSendConfigReq\n"); if (!DEV_IS_SYNC || !REJECTED(icp, TY_IPADDR)) PutConfValue(&cp, cftypes, TY_IPADDR, 6, ntohl(icp->want_ipaddr.s_addr)); if (icp->want_compproto && !REJECTED(icp, TY_COMPPROTO)) { @@ -237,7 +239,7 @@ static void IpcpSendTerminateAck(fp) struct fsm *fp; { - LogPrintf(LogLCP, "IpcpSendTerminateAck\n"); + LogPrintf(LogIPCP, "IpcpSendTerminateAck\n"); FsmOutput(fp, CODE_TERMACK, fp->reqid++, NULL, 0); } @@ -245,14 +247,14 @@ static void IpcpLayerStart(fp) struct fsm *fp; { - LogPrintf(LogLCP, "IpcpLayerStart.\n"); + LogPrintf(LogIPCP, "IpcpLayerStart.\n"); } static void IpcpLayerFinish(fp) struct fsm *fp; { - LogPrintf(LogLCP, "IpcpLayerFinish.\n"); + LogPrintf(LogIPCP, "IpcpLayerFinish.\n"); reconnect(RECON_FALSE); LcpClose(); NewPhase(PHASE_TERMINATE); @@ -262,7 +264,7 @@ static void IpcpLayerDown(fp) struct fsm *fp; { - LogPrintf(LogLCP, "IpcpLayerDown.\n"); + LogPrintf(LogIPCP, "IpcpLayerDown.\n"); StopTimer(&IpcpReportTimer); } @@ -276,10 +278,10 @@ struct fsm *fp; char tbuff[100]; Prompt(); - LogPrintf(LogLCP, "IpcpLayerUp(%d).\n", fp->state); + LogPrintf(LogIPCP, "IpcpLayerUp(%d).\n", fp->state); snprintf(tbuff, sizeof(tbuff), "myaddr = %s ", inet_ntoa(IpcpInfo.want_ipaddr)); - LogPrintf(LogIsKept(LogLCP) ? LogLCP : LogLINK, " %s hisaddr = %s\n", + LogPrintf(LogIsKept(LogIPCP) ? LogIPCP : LogLINK, " %s hisaddr = %s\n", tbuff, inet_ntoa(IpcpInfo.his_ipaddr)); if (OsSetIpaddress(IpcpInfo.want_ipaddr, IpcpInfo.his_ipaddr, ifnetmask) < 0) { if (VarTerm) @@ -297,7 +299,7 @@ void IpcpUp() { FsmUp(&IpcpFsm); - LogPrintf(LogLCP, "IPCP Up event!!\n"); + LogPrintf(LogIPCP, "IPCP Up event!!\n"); } void @@ -351,7 +353,7 @@ int mode; case TY_IPADDR: /* RFC1332 */ lp = (u_long *)(cp + 2); ipaddr.s_addr = *lp; - LogPrintf(LogLCP, "%s %s\n", tbuff, inet_ntoa(ipaddr)); + LogPrintf(LogIPCP, "%s %s\n", tbuff, inet_ntoa(ipaddr)); switch (mode) { case MODE_REQ: @@ -376,7 +378,7 @@ int mode; * Use address suggested by peer. */ snprintf(tbuff2, sizeof(tbuff2), "%s changing address: %s ", tbuff, inet_ntoa(IpcpInfo.want_ipaddr)); - LogPrintf(LogLCP, "%s --> %s\n", tbuff2, inet_ntoa(ipaddr)); + LogPrintf(LogIPCP, "%s --> %s\n", tbuff2, inet_ntoa(ipaddr)); IpcpInfo.want_ipaddr = ipaddr; } break; @@ -388,7 +390,7 @@ int mode; case TY_COMPPROTO: lp = (u_long *)(cp + 2); compproto = htonl(*lp); - LogPrintf(LogLCP, "%s %08x\n", tbuff, compproto); + LogPrintf(LogIPCP, "%s %08x\n", tbuff, compproto); switch (mode) { case MODE_REQ: @@ -436,7 +438,7 @@ int mode; } break; case MODE_NAK: - LogPrintf(LogLCP, "%s changing compproto: %08x --> %08x\n", + LogPrintf(LogIPCP, "%s changing compproto: %08x --> %08x\n", tbuff, IpcpInfo.want_compproto, compproto); IpcpInfo.want_compproto = compproto; break; @@ -450,8 +452,8 @@ int mode; ipaddr.s_addr = *lp; lp = (u_long *)(cp + 6); dstipaddr.s_addr = *lp; - LogPrintf(LogLCP, "%s %s, ", tbuff, inet_ntoa(ipaddr)); - LogPrintf(LogLCP, "%s\n", inet_ntoa(dstipaddr)); + LogPrintf(LogIPCP, "%s %s, ", tbuff, inet_ntoa(ipaddr)); + LogPrintf(LogIPCP, "%s\n", inet_ntoa(dstipaddr)); switch (mode) { case MODE_REQ: @@ -461,9 +463,9 @@ int mode; ackp += length; break; case MODE_NAK: - LogPrintf(LogLCP, "%s changing address: %s ", + LogPrintf(LogIPCP, "%s changing address: %s ", tbuff, inet_ntoa(IpcpInfo.want_ipaddr)); - LogPrintf(LogLCP, "--> %s\n", inet_ntoa(ipaddr)); + LogPrintf(LogIPCP, "--> %s\n", inet_ntoa(ipaddr)); IpcpInfo.want_ipaddr = ipaddr; IpcpInfo.his_ipaddr = dstipaddr; break; @@ -481,7 +483,7 @@ int mode; case TY_PRIMARY_DNS: /* MS PPP DNS negotiation hack */ case TY_SECONDARY_DNS: if( !Enabled( ConfMSExt ) ) { - LogPrintf(LogLCP, "MS NS req - rejected - msext disabled\n"); + LogPrintf(LogIPCP, "MS NS req - rejected - msext disabled\n"); IpcpInfo.my_reject |= ( 1 << type ); bcopy(cp, rejp, length); rejp += length; @@ -499,7 +501,7 @@ int mode; so well tell 'em how it is */ bcopy( cp, nakp, 2 ); /* copy first two (type/length) */ - LogPrintf( LogLCP, "MS NS req %d:%s->%s - nak\n", + LogPrintf( LogIPCP, "MS NS req %d:%s->%s - nak\n", type, inet_ntoa( dnsstuff ), inet_ntoa( ms_info_req )); @@ -511,17 +513,17 @@ int mode; Otherwise they have it right (this time) so we send a ack packet back confirming it... end of story */ - LogPrintf( LogLCP, "MS NS req %d:%s ok - ack\n", + LogPrintf( LogIPCP, "MS NS req %d:%s ok - ack\n", type, inet_ntoa( ms_info_req )); bcopy( cp, ackp, length ); ackp += length; break; case MODE_NAK: /* what does this mean?? */ - LogPrintf(LogLCP, "MS NS req %d - NAK??\n", type ); + LogPrintf(LogIPCP, "MS NS req %d - NAK??\n", type ); break; case MODE_REJ: /* confused?? me to :) */ - LogPrintf(LogLCP, "MS NS req %d - REJ??\n", type ); + LogPrintf(LogIPCP, "MS NS req %d - REJ??\n", type ); break; } break; @@ -529,7 +531,7 @@ int mode; case TY_PRIMARY_NBNS: /* MS PPP NetBIOS nameserver hack */ case TY_SECONDARY_NBNS: if( !Enabled( ConfMSExt ) ) { - LogPrintf( LogLCP, "MS NBNS req - rejected - msext disabled\n" ); + LogPrintf( LogIPCP, "MS NBNS req - rejected - msext disabled\n" ); IpcpInfo.my_reject |= ( 1 << type ); bcopy( cp, rejp, length ); rejp += length; @@ -544,24 +546,24 @@ int mode; { bcopy( cp, nakp, 2 ); bcopy( &ms_info_req.s_addr , nakp+2, length ); - LogPrintf( LogLCP, "MS NBNS req %d:%s->%s - nak\n", + LogPrintf(LogIPCP, "MS NBNS req %d:%s->%s - nak\n", type, inet_ntoa( dnsstuff ), inet_ntoa( ms_info_req )); nakp += length; break; } - LogPrintf( LogLCP, "MS NBNS req %d:%s ok - ack\n", + LogPrintf(LogIPCP, "MS NBNS req %d:%s ok - ack\n", type, inet_ntoa( ms_info_req )); bcopy( cp, ackp, length ); ackp += length; break; case MODE_NAK: - LogPrintf( LogLCP, "MS NBNS req %d - NAK??\n", type ); + LogPrintf(LogIPCP, "MS NBNS req %d - NAK??\n", type ); break; case MODE_REJ: - LogPrintf( LogLCP, "MS NBNS req %d - REJ??\n", type ); + LogPrintf(LogIPCP, "MS NBNS req %d - REJ??\n", type ); break; } break; diff --git a/usr.sbin/ppp/lcp.c b/usr.sbin/ppp/lcp.c index 01047ad3e727..56c4867a547f 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.24 1997/06/14 00:21:23 ache Exp $ + * $Id: lcp.c,v 1.25 1997/08/01 02:02:28 brian Exp $ * * TODO: * o Validate magic number received from peer. @@ -76,9 +76,10 @@ struct fsm LcpFsm = { OPEN_ACTIVE, ST_INITIAL, /* State of machine */ 0, 0, 0, - 0, { 0, 0, 0, NULL, NULL, NULL }, + { 0, 0, 0, NULL, NULL, NULL }, + LogLCP, LcpLayerUp, LcpLayerDown, diff --git a/usr.sbin/ppp/log.c b/usr.sbin/ppp/log.c index a9ec54a7e913..a91248bc211f 100644 --- a/usr.sbin/ppp/log.c +++ b/usr.sbin/ppp/log.c @@ -13,11 +13,13 @@ static char *LogNames[] = { "Async", "Carrier", + "CCP", "Chat", "Command", "Connect", "Debug", "HDLC", + "IPCP", "LCP", "Link", "LQM", diff --git a/usr.sbin/ppp/log.h b/usr.sbin/ppp/log.h index 3a68cbfa61cd..0b5287668b72 100644 --- a/usr.sbin/ppp/log.h +++ b/usr.sbin/ppp/log.h @@ -1,22 +1,24 @@ #define LogMIN (1) #define LogASYNC (1) /* syslog(LOG_INFO, ....) */ #define LogCARRIER (2) -#define LogCHAT (3) -#define LogCOMMAND (4) -#define LogCONNECT (5) -#define LogDEBUG (6) /* syslog(LOG_DEBUG, ....) */ -#define LogHDLC (7) -#define LogLCP (8) -#define LogLINK (9) -#define LogLQM (10) -#define LogPHASE (11) -#define LogTCPIP (12) -#define LogTUN (13) /* If set, tun%d is output with each message */ -#define LogMAXCONF (13) -#define LogWARN (14) /* Sent to VarTerm else syslog(LOG_WARNING, ) */ -#define LogERROR (15) /* syslog(LOG_ERR, ....), + sent to VarTerm */ -#define LogALERT (16) /* syslog(LOG_ALERT, ....) */ -#define LogMAX (16) +#define LogCCP (3) +#define LogCHAT (4) +#define LogCOMMAND (5) +#define LogCONNECT (6) +#define LogDEBUG (7) /* syslog(LOG_DEBUG, ....) */ +#define LogHDLC (8) +#define LogIPCP (9) +#define LogLCP (10) +#define LogLINK (11) +#define LogLQM (12) +#define LogPHASE (13) +#define LogTCPIP (14) +#define LogTUN (15) /* If set, tun%d is output with each message */ +#define LogMAXCONF (15) +#define LogWARN (16) /* Sent to VarTerm else syslog(LOG_WARNING, ) */ +#define LogERROR (17) /* syslog(LOG_ERR, ....), + sent to VarTerm */ +#define LogALERT (18) /* syslog(LOG_ALERT, ....) */ +#define LogMAX (18) /* The first int arg for all of the following is one of the above values */ extern const char *LogName(int); diff --git a/usr.sbin/ppp/ppp.8 b/usr.sbin/ppp/ppp.8 index 91b4a2fb2e4b..f88e90532d6d 100644 --- a/usr.sbin/ppp/ppp.8 +++ b/usr.sbin/ppp/ppp.8 @@ -1,4 +1,4 @@ -.\" $Id: ppp.8,v 1.52 1997/08/19 11:18:34 danny Exp $ +.\" $Id: ppp.8,v 1.53 1997/08/19 11:27:00 danny Exp $ .Dd 20 September 1995 .Os FreeBSD .Dt PPP 8 @@ -758,7 +758,7 @@ ui-gate: set device ui-gate:ppp-in set dial set timeout 30 5 4 - set log Phase Chat Connect Carrier hdlc LCP tun + set log Phase Chat Connect Carrier hdlc LCP IPCP CCP tun set ifaddr 10.0.4.2 10.0.4.1 add 10.0.4.2 255.255.255.255 127.0.0.1 add 10.0.2.0 255.255.255.0 10.0.4.2 @@ -1214,7 +1214,7 @@ add 0 0 HISADDR .Ed HISADDR is a macro meaning the "other side"s IP number, and is -available once an IP number has been agreed (using LCP). +available once an IP number has been agreed (using IPCP). Now, once a connection is established, .Nm will delete all non-direct interface routes, and add a default route @@ -1260,12 +1260,14 @@ is able to generate the following log info via .Bl -column SMMMMMM -offset indent .It Li Async Dump async level packet in hex .It Li Carrier Log Chat lines with 'CARRIER' +.It Li CCP Generate a CPP packet trace .It Li Chat Generate Chat script trace log .It Li Command Log commands executed .It Li Connect Generate complete Chat log .It Li Debug Log (very verbose) debug information .It Li HDLC Dump HDLC packet in hex -.It Li LCP Generate LCP/IPCP packet trace +.It Li IPCP Generate an IPCP packet trace +.It Li LCP Generate an LCP packet trace .It Li Link Log address assignments and link up/down events .It Li LQM Generate LQR report .It Li Phase Phase transition log output @@ -1666,8 +1668,8 @@ receive the increased packet size. .It set openmode active|passive By default, openmode is always active. That is, .Nm -will always initiate LCP negotiation. If you want to wait for the -peer to initiate LCP negotiation, you may use the value +will always initiate LCP/IPCP/CCP negotiation. If you want to wait for the +peer to initiate negotiations, you may use the value .Dq passive . .It set parity odd|even|none|mark @@ -1717,17 +1719,18 @@ is taken before starting at the first number again. A value of .Dq random may be used here too. -.It set stopped seconds +.It set stopped [LCPseconds [IPCPseconds [CCPseconds]]] If this option is set, .Nm -will time out after being in the stopped state for the given number of +will time out after the given FSM (Finite State Machine) has been in +the stopped state for the given number of .Dq seconds . This option may be useful if you see ppp failing to respond in the stopped state. Use -.Dq set log +lcp +.Dq set log +lcp +ipcp +ccp to make .Nm -log state transitions. +log all state transitions. .Pp The default value is zero, where ppp doesn't time out in the stopped state. @@ -1844,7 +1847,7 @@ Show the current reconnect values. Show the current redial values. .It show stopped -Show the current stopped timeout. +Show the current stopped timeouts. .It show route Show the current routing tables. diff --git a/usr.sbin/ppp/ppp.8.m4 b/usr.sbin/ppp/ppp.8.m4 index 91b4a2fb2e4b..f88e90532d6d 100644 --- a/usr.sbin/ppp/ppp.8.m4 +++ b/usr.sbin/ppp/ppp.8.m4 @@ -1,4 +1,4 @@ -.\" $Id: ppp.8,v 1.52 1997/08/19 11:18:34 danny Exp $ +.\" $Id: ppp.8,v 1.53 1997/08/19 11:27:00 danny Exp $ .Dd 20 September 1995 .Os FreeBSD .Dt PPP 8 @@ -758,7 +758,7 @@ ui-gate: set device ui-gate:ppp-in set dial set timeout 30 5 4 - set log Phase Chat Connect Carrier hdlc LCP tun + set log Phase Chat Connect Carrier hdlc LCP IPCP CCP tun set ifaddr 10.0.4.2 10.0.4.1 add 10.0.4.2 255.255.255.255 127.0.0.1 add 10.0.2.0 255.255.255.0 10.0.4.2 @@ -1214,7 +1214,7 @@ add 0 0 HISADDR .Ed HISADDR is a macro meaning the "other side"s IP number, and is -available once an IP number has been agreed (using LCP). +available once an IP number has been agreed (using IPCP). Now, once a connection is established, .Nm will delete all non-direct interface routes, and add a default route @@ -1260,12 +1260,14 @@ is able to generate the following log info via .Bl -column SMMMMMM -offset indent .It Li Async Dump async level packet in hex .It Li Carrier Log Chat lines with 'CARRIER' +.It Li CCP Generate a CPP packet trace .It Li Chat Generate Chat script trace log .It Li Command Log commands executed .It Li Connect Generate complete Chat log .It Li Debug Log (very verbose) debug information .It Li HDLC Dump HDLC packet in hex -.It Li LCP Generate LCP/IPCP packet trace +.It Li IPCP Generate an IPCP packet trace +.It Li LCP Generate an LCP packet trace .It Li Link Log address assignments and link up/down events .It Li LQM Generate LQR report .It Li Phase Phase transition log output @@ -1666,8 +1668,8 @@ receive the increased packet size. .It set openmode active|passive By default, openmode is always active. That is, .Nm -will always initiate LCP negotiation. If you want to wait for the -peer to initiate LCP negotiation, you may use the value +will always initiate LCP/IPCP/CCP negotiation. If you want to wait for the +peer to initiate negotiations, you may use the value .Dq passive . .It set parity odd|even|none|mark @@ -1717,17 +1719,18 @@ is taken before starting at the first number again. A value of .Dq random may be used here too. -.It set stopped seconds +.It set stopped [LCPseconds [IPCPseconds [CCPseconds]]] If this option is set, .Nm -will time out after being in the stopped state for the given number of +will time out after the given FSM (Finite State Machine) has been in +the stopped state for the given number of .Dq seconds . This option may be useful if you see ppp failing to respond in the stopped state. Use -.Dq set log +lcp +.Dq set log +lcp +ipcp +ccp to make .Nm -log state transitions. +log all state transitions. .Pp The default value is zero, where ppp doesn't time out in the stopped state. @@ -1844,7 +1847,7 @@ Show the current reconnect values. Show the current redial values. .It show stopped -Show the current stopped timeout. +Show the current stopped timeouts. .It show route Show the current routing tables. diff --git a/usr.sbin/ppp/vars.c b/usr.sbin/ppp/vars.c index 9aba5459dc63..4b0b37594ff5 100644 --- a/usr.sbin/ppp/vars.c +++ b/usr.sbin/ppp/vars.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: vars.c,v 1.20 1997/06/09 23:38:38 brian Exp $ + * $Id: vars.c,v 1.21 1997/08/17 20:45:49 brian Exp $ * */ #include "fsm.h" @@ -30,7 +30,7 @@ #include "defs.h" char VarVersion[] = "PPP Version 1.00"; -char VarLocalVersion[] = "$Date: 1997/06/09 23:38:38 $"; +char VarLocalVersion[] = "$Date: 1997/08/17 20:45:49 $"; /* * Order of conf option is important. See vars.h. @@ -52,7 +52,7 @@ struct confdesc pppConfs[] = { struct pppvars pppVars = { DEF_MRU, DEF_MTU, 0, MODEM_SPEED, CS8, MODEM_CTSRTS, 180, 30, 3, RECONNECT_TIMER, RECONNECT_TRIES, REDIAL_PERIOD, - NEXT_REDIAL_PERIOD, 1, 0, MODEM_DEV, BASE_MODEM_DEV, + NEXT_REDIAL_PERIOD, 1, MODEM_DEV, BASE_MODEM_DEV, OPEN_ACTIVE, LOCAL_NO_AUTH,0 }; diff --git a/usr.sbin/ppp/vars.h b/usr.sbin/ppp/vars.h index ae1a392bf3b3..ae124955a180 100644 --- a/usr.sbin/ppp/vars.h +++ b/usr.sbin/ppp/vars.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: vars.h,v 1.21 1997/08/17 20:38:45 brian Exp $ + * $Id: vars.h,v 1.22 1997/08/17 20:45:50 brian Exp $ * * TODO: */ @@ -68,7 +68,6 @@ struct pppvars { int redial_timeout; /* Redial timeout value */ int redial_next_timeout; /* Redial next timeout value */ int dial_tries; /* Dial attempts before giving up, 0 == inf */ - int stopped_timeout; /* Timeout in ST_STOPPED */ char modem_dev[40]; /* Name of device / host:port */ char *base_modem_dev; /* Pointer to base of modem_dev */ int open_mode; /* LCP open mode */ @@ -119,7 +118,6 @@ struct pppvars { #define VarRedialTimeout pppVars.redial_timeout #define VarRedialNextTimeout pppVars.redial_next_timeout #define VarDialTries pppVars.dial_tries -#define VarStoppedTimeout pppVars.stopped_timeout #define VarTerm pppVars.termfp #define VarAliasHandlers pppVars.handler