Move our Layer*() FSM callbacks into their own structure.

This commit is contained in:
Brian Somers 1998-02-24 03:36:50 +00:00
parent f4768038f0
commit 6eddf53ee8
5 changed files with 48 additions and 38 deletions

View File

@ -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.30.2.12 1998/02/21 01:45:00 brian Exp $
* $Id: ccp.c,v 1.30.2.13 1998/02/23 00:38:17 brian Exp $
*
* TODO:
* o Support other compression protocols
@ -64,10 +64,12 @@ static void CcpRecvResetReq(struct fsm *);
static void CcpRecvResetAck(struct fsm *, u_char);
static struct fsm_callbacks ccp_Callbacks = {
CcpLayerUp,
CcpLayerDown,
CcpLayerStart,
CcpLayerFinish,
{
CcpLayerUp,
CcpLayerDown,
CcpLayerStart,
CcpLayerFinish
},
CcpInitRestartCounter,
CcpSendConfigReq,
CcpSendTerminateReq,

View File

@ -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.27.2.13 1998/02/21 01:45:07 brian Exp $
* $Id: fsm.c,v 1.27.2.14 1998/02/23 00:38:29 brian Exp $
*
* TODO:
* o Refer loglevel for log output
@ -161,7 +161,7 @@ FsmOpen(struct fsm * fp)
switch (fp->state) {
case ST_INITIAL:
NewState(fp, ST_STARTING);
(*fp->fn->LayerStart)(fp);
(*fp->fn->notify.LayerStart)(fp);
bundle_LayerStart(fp->bundle, fp);
break;
case ST_CLOSED:
@ -219,13 +219,13 @@ FsmDown(struct fsm *fp)
NewState(fp, ST_INITIAL);
break;
case ST_CLOSING:
(*fp->fn->LayerFinish)(fp);
(*fp->fn->notify.LayerFinish)(fp);
NewState(fp, ST_INITIAL);
bundle_LayerFinish(fp->bundle, fp);
break;
case ST_STOPPED:
NewState(fp, ST_STARTING);
(*fp->fn->LayerStart)(fp);
(*fp->fn->notify.LayerStart)(fp);
bundle_LayerStart(fp->bundle, fp);
break;
case ST_STOPPING:
@ -235,7 +235,7 @@ FsmDown(struct fsm *fp)
NewState(fp, ST_STARTING);
break;
case ST_OPENED:
(*fp->fn->LayerDown)(fp);
(*fp->fn->notify.LayerDown)(fp);
NewState(fp, ST_STARTING);
bundle_LayerDown(fp->bundle, fp);
break;
@ -247,7 +247,7 @@ FsmClose(struct fsm *fp)
{
switch (fp->state) {
case ST_STARTING:
(*fp->fn->LayerFinish)(fp);
(*fp->fn->notify.LayerFinish)(fp);
NewState(fp, ST_INITIAL);
bundle_LayerFinish(fp->bundle, fp);
break;
@ -258,7 +258,7 @@ FsmClose(struct fsm *fp)
NewState(fp, ST_CLOSING);
break;
case ST_OPENED:
(*fp->fn->LayerDown)(fp);
(*fp->fn->notify.LayerDown)(fp);
FsmInitRestartCounter(fp);
FsmSendTerminateReq(fp);
NewState(fp, ST_CLOSING);
@ -353,19 +353,19 @@ FsmTimeout(void *v)
} else {
switch (fp->state) {
case ST_CLOSING:
(*fp->fn->LayerFinish)(fp);
(*fp->fn->notify.LayerFinish)(fp);
NewState(fp, ST_CLOSED);
bundle_LayerFinish(fp->bundle, fp);
break;
case ST_STOPPING:
(*fp->fn->LayerFinish)(fp);
(*fp->fn->notify.LayerFinish)(fp);
NewState(fp, ST_STOPPED);
bundle_LayerFinish(fp->bundle, fp);
break;
case ST_REQSENT: /* XXX: 3p */
case ST_ACKSENT:
case ST_ACKRCVD:
(*fp->fn->LayerFinish)(fp);
(*fp->fn->notify.LayerFinish)(fp);
NewState(fp, ST_STOPPED);
bundle_LayerFinish(fp->bundle, fp);
break;
@ -430,7 +430,7 @@ FsmRecvConfigReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
switch (fp->state) {
case ST_OPENED:
(*fp->fn->LayerDown)(fp);
(*fp->fn->notify.LayerDown)(fp);
FsmSendConfigReq(fp);
bundle_LayerDown(fp->bundle, fp);
break;
@ -462,7 +462,7 @@ FsmRecvConfigReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
case ST_ACKRCVD:
if (ackaction) {
NewState(fp, ST_OPENED);
(*fp->fn->LayerUp)(fp);
(*fp->fn->notify.LayerUp)(fp);
bundle_LayerUp(fp->bundle, fp);
}
break;
@ -497,11 +497,11 @@ FsmRecvConfigAck(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
case ST_ACKSENT:
FsmInitRestartCounter(fp);
NewState(fp, ST_OPENED);
(*fp->fn->LayerUp)(fp);
(*fp->fn->notify.LayerUp)(fp);
bundle_LayerUp(fp->bundle, fp);
break;
case ST_OPENED:
(*fp->fn->LayerDown)(fp);
(*fp->fn->notify.LayerDown)(fp);
FsmSendConfigReq(fp);
NewState(fp, ST_REQSENT);
bundle_LayerDown(fp->bundle, fp);
@ -552,7 +552,7 @@ FsmRecvConfigNak(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
FsmSendConfigReq(fp);
break;
case ST_OPENED:
(*fp->fn->LayerDown)(fp);
(*fp->fn->notify.LayerDown)(fp);
FsmSendConfigReq(fp);
NewState(fp, ST_REQSENT);
bundle_LayerDown(fp->bundle, fp);
@ -588,7 +588,7 @@ FsmRecvTermReq(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
NewState(fp, ST_REQSENT);
break;
case ST_OPENED:
(*fp->fn->LayerDown)(fp);
(*fp->fn->notify.LayerDown)(fp);
(*fp->fn->SendTerminateAck)(fp);
StartTimer(&fp->FsmTimer); /* Start restart timer */
fp->restart = 0;
@ -605,12 +605,12 @@ FsmRecvTermAck(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
{
switch (fp->state) {
case ST_CLOSING:
(*fp->fn->LayerFinish)(fp);
(*fp->fn->notify.LayerFinish)(fp);
NewState(fp, ST_CLOSED);
bundle_LayerFinish(fp->bundle, fp);
break;
case ST_STOPPING:
(*fp->fn->LayerFinish)(fp);
(*fp->fn->notify.LayerFinish)(fp);
NewState(fp, ST_STOPPED);
bundle_LayerFinish(fp->bundle, fp);
break;
@ -618,7 +618,7 @@ FsmRecvTermAck(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
NewState(fp, ST_REQSENT);
break;
case ST_OPENED:
(*fp->fn->LayerDown)(fp);
(*fp->fn->notify.LayerDown)(fp);
FsmSendConfigReq(fp);
NewState(fp, ST_REQSENT);
bundle_LayerDown(fp->bundle, fp);
@ -670,7 +670,7 @@ FsmRecvConfigRej(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
FsmSendConfigReq(fp);
break;
case ST_OPENED:
(*fp->fn->LayerDown)(fp);
(*fp->fn->notify.LayerDown)(fp);
FsmSendConfigReq(fp);
NewState(fp, ST_REQSENT);
bundle_LayerDown(fp->bundle, fp);
@ -710,7 +710,7 @@ FsmRecvProtoRej(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
break;
case PROTO_CCP:
fp = &bundle2ccp(fp->bundle, fp->link->name)->fsm;
(*fp->fn->LayerFinish)(fp);
(*fp->fn->notify.LayerFinish)(fp);
switch (fp->state) {
case ST_CLOSED:
case ST_CLOSING:

View File

@ -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.6 1998/02/19 19:56:57 brian Exp $
* $Id: fsm.h,v 1.16.2.7 1998/02/21 01:45:08 brian Exp $
*
* TODO:
*/
@ -47,11 +47,15 @@
struct fsm;
struct fsm_callbacks {
struct fsm_events {
void (*LayerUp) (struct fsm *); /* Layer is now up (tlu) */
void (*LayerDown) (struct fsm *); /* About to come down (tld) */
void (*LayerStart) (struct fsm *); /* Layer about to start up (tls) */
void (*LayerFinish) (struct fsm *); /* Layer now down (tlf) */
};
struct fsm_callbacks {
struct fsm_events notify;
void (*InitRestartCounter) (struct fsm *); /* Set fsm timer load */
void (*SendConfigReq) (struct fsm *); /* Send REQ please */
void (*SendTerminateReq) (struct fsm *); /* Term REQ just sent */

View File

@ -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.50.2.14 1998/02/19 19:56:59 brian Exp $
* $Id: ipcp.c,v 1.50.2.15 1998/02/21 01:45:11 brian Exp $
*
* TODO:
* o More RFC1772 backwoard compatibility
@ -89,10 +89,12 @@ static void IpcpSendTerminateAck(struct fsm *);
static void IpcpDecodeConfig(struct fsm *, u_char *, int, int);
static struct fsm_callbacks ipcp_Callbacks = {
IpcpLayerUp,
IpcpLayerDown,
IpcpLayerStart,
IpcpLayerFinish,
{
IpcpLayerUp,
IpcpLayerDown,
IpcpLayerStart,
IpcpLayerFinish
},
IpcpInitRestartCounter,
IpcpSendConfigReq,
IpcpSendTerminateReq,

View File

@ -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.18 1998/02/19 19:57:01 brian Exp $
* $Id: lcp.c,v 1.55.2.19 1998/02/21 01:45:14 brian Exp $
*
* TODO:
* o Limit data field length by MRU
@ -88,10 +88,12 @@ static void LcpSendTerminateAck(struct fsm *);
static void LcpDecodeConfig(struct fsm *, u_char *, int, int);
static struct fsm_callbacks lcp_Callbacks = {
LcpLayerUp,
LcpLayerDown,
LcpLayerStart,
LcpLayerFinish,
{
LcpLayerUp,
LcpLayerDown,
LcpLayerStart,
LcpLayerFinish
},
LcpInitRestartCounter,
LcpSendConfigReq,
LcpSendTerminateReq,