diff options
-rw-r--r-- | eigrpd/eigrp_const.h | 39 | ||||
-rw-r--r-- | eigrpd/eigrp_fsm.c | 34 |
2 files changed, 61 insertions, 12 deletions
diff --git a/eigrpd/eigrp_const.h b/eigrpd/eigrp_const.h index 3fa59756b..c5f6e64d0 100644 --- a/eigrpd/eigrp_const.h +++ b/eigrpd/eigrp_const.h @@ -153,14 +153,37 @@ enum eigrp_fsm_states { #define EIGRP_FSM_NEED_QUERY 2 /*EIGRP FSM events*/ -#define EIGRP_FSM_EVENT_NQ_FCN 0 /*input event other than query from succ, FC not satisfied*/ -#define EIGRP_FSM_EVENT_LR 1 /*last reply, FD is reset*/ -#define EIGRP_FSM_EVENT_Q_FCN 2 /*query from succ, FC not satisfied*/ -#define EIGRP_FSM_EVENT_LR_FCS 3 /*last reply, FC satisfied with current value of FDij*/ -#define EIGRP_FSM_EVENT_DINC 4 /*distance increase while in active state*/ -#define EIGRP_FSM_EVENT_QACT 5 /*query from succ while in active state*/ -#define EIGRP_FSM_EVENT_LR_FCN 6 /*last reply, FC not satisfied with current value of FDij*/ -#define EIGRP_FSM_KEEP_STATE 7 /*state not changed, usually by receiving not last reply */ +enum eigrp_fsm_events { + /* + * Input event other than query from succ, + * FC is not satisified + */ + EIGRP_FSM_EVENT_NQ_FCN, + + /* last reply, FD is reset */ + EIGRP_FSM_EVENT_LR, + + /* Query from succ, FC not satisfied */ + EIGRP_FSM_EVENT_Q_FCN, + + /* last reply, FC satisifed with current value of FDij */ + EIGRP_FSM_EVENT_LR_FCS, + + /* distance increase while in a active state */ + EIGRP_FSM_EVENT_DINC, + + /* Query from succ while in active state */ + EIGRP_FSM_EVENT_QACT, + + /* last reply, FC not satisified */ + EIGRP_FSM_EVENT_LR_FCN, + + /* + * state not changed + * usually by receiving not last reply + */ + EIGRP_FSM_KEEP_STATE, +}; /** * External routes originate from some other protocol - these are them diff --git a/eigrpd/eigrp_fsm.c b/eigrpd/eigrp_fsm.c index 86914316b..84f21013e 100644 --- a/eigrpd/eigrp_fsm.c +++ b/eigrpd/eigrp_fsm.c @@ -188,6 +188,29 @@ static const char *prefix_state2str(enum eigrp_fsm_states state) return "Unknown"; } +static const char *fsm_state2str(enum eigrp_fsm_events event) +{ + switch (event) { + case EIGRP_FSM_KEEP_STATE: + return "Keep State Event"; + case EIGRP_FSM_EVENT_NQ_FCN: + return "Non Query Event Feasability not satisfied"; + case EIGRP_FSM_EVENT_LR: + return "Last Reply Event"; + case EIGRP_FSM_EVENT_Q_FCN: + return "Query Event Feasability not satisified"; + case EIGRP_FSM_EVENT_LR_FCS: + return "Last Reply Event Feasability satisified"; + case EIGRP_FSM_EVENT_DINC: + return "Distance Increase Event"; + case EIGRP_FSM_EVENT_QACT: + return "Query from Successor while in active state"; + case EIGRP_FSM_EVENT_LR_FCN: + return "Last Reply Event, Feasibility not satisfied"; + }; + + return "Unknown"; +} /* * Main function in which are make decisions which event occurred. * msg - argument of type struct eigrp_fsm_action_message contain @@ -196,7 +219,8 @@ static const char *prefix_state2str(enum eigrp_fsm_states state) * Return number of occurred event (arrow in diagram). * */ -static int eigrp_get_fsm_event(struct eigrp_fsm_action_message *msg) +static enum eigrp_fsm_events eigrp_get_fsm_event( + struct eigrp_fsm_action_message *msg) { // Loading base information from message // struct eigrp *eigrp = msg->eigrp; @@ -348,10 +372,12 @@ static int eigrp_get_fsm_event(struct eigrp_fsm_action_message *msg) */ int eigrp_fsm_event(struct eigrp_fsm_action_message *msg) { - int event = eigrp_get_fsm_event(msg); - zlog_info("EIGRP AS: %d State: %s Event: %d Network: %s", + enum eigrp_fsm_events event = eigrp_get_fsm_event(msg); + + zlog_info("EIGRP AS: %d State: %s Event: %s Network: %s", msg->eigrp->AS, prefix_state2str(msg->prefix->state), - event, eigrp_topology_ip_string(msg->prefix)); + fsm_state2str(event), + eigrp_topology_ip_string(msg->prefix)); (*(NSM[msg->prefix->state][event].func))(msg); return 1; |