]> git.puffer.fish Git - mirror/frr.git/commitdiff
eigrpd: Create enum for states and string name for display
authorDonald Sharp <sharpd@cumulusnetworks.com>
Sat, 28 Oct 2017 22:04:19 +0000 (18:04 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Sat, 28 Oct 2017 22:06:28 +0000 (18:06 -0400)
Create an enum for the different states and create
a string name display handler.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
eigrpd/eigrp_const.h
eigrpd/eigrp_fsm.c

index 3fa59756b714470bd4f7f540ed6197008e55b39e..c5f6e64d0b4546a47b2b71d179187df86ea12070 100644 (file)
@@ -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
index 86914316b86f512fd70b99cf6fa769dfc95b574e..84f21013e4079b959f7b4d3c871b13fc3cc543f2 100644 (file)
@@ -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;