diff options
-rw-r--r-- | usr.sbin/ppp/bundle.c | 22 | ||||
-rw-r--r-- | usr.sbin/ppp/command.c | 7 | ||||
-rw-r--r-- | usr.sbin/ppp/datalink.c | 23 | ||||
-rw-r--r-- | usr.sbin/ppp/fsm.c | 20 | ||||
-rw-r--r-- | usr.sbin/ppp/fsm.h | 7 | ||||
-rw-r--r-- | usr.sbin/ppp/mp.c | 5 |
6 files changed, 35 insertions, 49 deletions
diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c index fbd9969..d020db0 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.19 1998/06/16 19:40:34 brian Exp $ + * $Id: bundle.c,v 1.20 1998/06/18 23:38:04 brian Exp $ */ #include <sys/param.h> @@ -427,8 +427,7 @@ bundle_LayerFinish(void *v, struct fsm *fp) bundle_NewPhase(bundle, PHASE_TERMINATE); for (dl = bundle->links; dl; dl = dl->next) datalink_Close(dl, CLOSE_NORMAL); - fsm_Down(fp); - fsm_Close(fp); + fsm2initial(fp); } else if (fp->proto == PROTO_LCP) { int others_active; @@ -438,10 +437,8 @@ bundle_LayerFinish(void *v, struct fsm *fp) dl->state != DATALINK_CLOSED && dl->state != DATALINK_HANGUP) others_active++; - if (!others_active) { - fsm_Down(&bundle->ncp.ipcp.fsm); - fsm_Close(&bundle->ncp.ipcp.fsm); /* ST_INITIAL please */ - } + if (!others_active) + fsm2initial(&bundle->ncp.ipcp.fsm); } } @@ -498,10 +495,7 @@ bundle_Close(struct bundle *bundle, const char *name, int how) bundle->ncp.ipcp.fsm.state == ST_STARTING) fsm_Close(&bundle->ncp.ipcp.fsm); else { - if (bundle->ncp.ipcp.fsm.state > ST_INITIAL) { - fsm_Close(&bundle->ncp.ipcp.fsm); - fsm_Down(&bundle->ncp.ipcp.fsm); - } + fsm2initial(&bundle->ncp.ipcp.fsm); for (dl = bundle->links; dl; dl = dl->next) datalink_Close(dl, how); } @@ -1091,11 +1085,7 @@ bundle_LinkClosed(struct bundle *bundle, struct datalink *dl) if (!other_links) { if (dl->physical->type != PHYS_AUTO) /* Not in -auto mode */ bundle_DownInterface(bundle); - if (bundle->ncp.ipcp.fsm.state > ST_CLOSED || - bundle->ncp.ipcp.fsm.state == ST_STARTING) { - fsm_Down(&bundle->ncp.ipcp.fsm); - fsm_Close(&bundle->ncp.ipcp.fsm); /* ST_INITIAL please */ - } + fsm2initial(&bundle->ncp.ipcp.fsm); bundle_NewPhase(bundle, PHASE_DEAD); bundle_StopIdleTimer(bundle); bundle_StopAutoLoadTimer(bundle); diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index 542c90c..11a06bc 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.146 1998/06/16 19:40:35 brian Exp $ + * $Id: command.c,v 1.147 1998/06/16 23:23:54 brian Exp $ * */ #include <sys/types.h> @@ -124,7 +124,7 @@ #define NEG_DNS 50 const char Version[] = "2.0-beta"; -const char VersionDate[] = "$Date: 1998/06/16 19:40:35 $"; +const char VersionDate[] = "$Date: 1998/06/16 23:23:54 $"; static int ShowCommand(struct cmdargs const *); static int TerminalCommand(struct cmdargs const *); @@ -916,8 +916,7 @@ DownCommand(struct cmdargs const *arg) } else if (!strcasecmp(arg->argv[arg->argn], "ccp")) { struct fsm *fp = arg->cx ? &arg->cx->physical->link.ccp.fsm : &arg->bundle->ncp.mp.link.ccp.fsm; - fsm_Down(fp); - fsm_Close(fp); + fsm2initial(fp); } else return -1; } else diff --git a/usr.sbin/ppp/datalink.c b/usr.sbin/ppp/datalink.c index b266c9e..9923ec5 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.9 1998/06/15 19:05:15 brian Exp $ + * $Id: datalink.c,v 1.10 1998/06/16 07:15:16 brian Exp $ */ #include <sys/types.h> @@ -512,8 +512,7 @@ datalink_LayerDown(void *v, struct fsm *fp) switch (dl->state) { case DATALINK_OPEN: peerid_Init(&dl->peer); - fsm_Down(&dl->physical->link.ccp.fsm); - fsm_Close(&dl->physical->link.ccp.fsm); + fsm2initial(&dl->physical->link.ccp.fsm); datalink_NewState(dl, DATALINK_LCP); /* before parent TLD */ (*dl->parent->LayerDown)(dl->parent->object, fp); /* fall through */ @@ -533,9 +532,7 @@ datalink_LayerFinish(void *v, struct fsm *fp) struct datalink *dl = (struct datalink *)v; if (fp->proto == PROTO_LCP) { - if (fp->state == ST_STOPPED) - fsm_Close(fp); /* back to CLOSED */ - fsm_Down(fp); /* Bring us to INITIAL or STARTING */ + fsm2initial(fp); (*dl->parent->LayerFinish)(dl->parent->object, fp); datalink_ComeDown(dl, CLOSE_NORMAL); } else if (fp->state == ST_CLOSED && fp->open_mode == OPEN_PASSIVE) @@ -740,8 +737,7 @@ datalink_Close(struct datalink *dl, int how) switch (dl->state) { case DATALINK_OPEN: peerid_Init(&dl->peer); - fsm_Down(&dl->physical->link.ccp.fsm); - fsm_Close(&dl->physical->link.ccp.fsm); + fsm2initial(&dl->physical->link.ccp.fsm); /* fall through */ case DATALINK_AUTH: @@ -767,19 +763,12 @@ datalink_Down(struct datalink *dl, int how) switch (dl->state) { case DATALINK_OPEN: peerid_Init(&dl->peer); - fsm_Down(&dl->physical->link.ccp.fsm); - fsm_Close(&dl->physical->link.ccp.fsm); + fsm2initial(&dl->physical->link.ccp.fsm); /* fall through */ case DATALINK_AUTH: case DATALINK_LCP: - if (dl->physical->link.lcp.fsm.state == ST_STOPPED) - fsm_Close(&dl->physical->link.lcp.fsm); /* back to CLOSED */ - fsm_Down(&dl->physical->link.lcp.fsm); - if (how != CLOSE_NORMAL) - fsm_Close(&dl->physical->link.lcp.fsm); - else - fsm_Open(&dl->physical->link.ccp.fsm); + fsm2initial(&dl->physical->link.lcp.fsm); /* fall through */ default: diff --git a/usr.sbin/ppp/fsm.c b/usr.sbin/ppp/fsm.c index a25caf1..498077b 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.29 1998/06/15 19:06:42 brian Exp $ + * $Id: fsm.c,v 1.30 1998/06/16 19:40:36 brian Exp $ * * TODO: */ @@ -119,11 +119,8 @@ StoppedTimeout(void *v) fp->link->name, fp->name); timer_Stop(&fp->OpenTimer); } - if (fp->state == ST_STOPPED) { - /* Force ourselves back to initial */ - fsm_Down(fp); - fsm_Close(fp); - } + if (fp->state == ST_STOPPED) + fsm2initial(fp); } void @@ -959,3 +956,14 @@ fsm_NullRecvResetAck(struct fsm *fp, u_char id) log_Printf(fp->LogLevel, "%s: Oops - received unexpected reset ack\n", fp->link->name); } + +void +fsm2initial(struct fsm *fp) +{ + if (fp->state == ST_STOPPED) + fsm_Close(fp); + if (fp->state > ST_INITIAL) + fsm_Down(fp); + if (fp->state > ST_INITIAL) + fsm_Close(fp); +} diff --git a/usr.sbin/ppp/fsm.h b/usr.sbin/ppp/fsm.h index 8f033fc..c77fa8a 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.16.2.16 1998/05/01 19:24:35 brian Exp $ + * $Id: fsm.h,v 1.17 1998/05/21 21:45:26 brian Exp $ * * TODO: */ @@ -152,6 +152,7 @@ extern void fsm_Up(struct fsm *); extern void fsm_Down(struct fsm *); extern void fsm_Input(struct fsm *, struct mbuf *); extern void fsm_Close(struct fsm *); -extern void fsm_NullRecvResetReq(struct fsm *fp); -extern void fsm_NullRecvResetAck(struct fsm *fp, u_char); +extern void fsm_NullRecvResetReq(struct fsm *); +extern void fsm_NullRecvResetAck(struct fsm *, u_char); +extern void fsm2initial(struct fsm *); extern const char *State2Nam(u_int); diff --git a/usr.sbin/ppp/mp.c b/usr.sbin/ppp/mp.c index b1539ac..642d535 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.8 1998/06/15 19:06:53 brian Exp $ + * $Id: mp.c,v 1.9 1998/06/16 19:40:40 brian Exp $ */ #include <sys/types.h> @@ -294,8 +294,7 @@ mp_Down(struct mp *mp) mpserver_Close(&mp->server); /* CCP goes down with a bang */ - fsm_Down(&mp->link.ccp.fsm); - fsm_Close(&mp->link.ccp.fsm); + fsm2initial(&mp->link.ccp.fsm); /* Received fragments go in the bit-bucket */ while (mp->inbufs) { |