summaryrefslogtreecommitdiff
path: root/eigrpd
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2017-08-22 16:19:23 -0400
committerDonald Sharp <sharpd@cumulusnetworks.com>2017-08-24 08:04:20 -0400
commit7cfa4322558c56b5a0801b17e60598c5a49779dd (patch)
tree3f1a3167603a4cfccedc39f8274c741a9295f866 /eigrpd
parent6118272f14f91ad4b315c6cd1ad13f4aa8e77a2d (diff)
eigrpd: make fsm msg data_type an enum
We need to eventually be able to handle multiple data types to figure out if the distance is better worse. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'eigrpd')
-rw-r--r--eigrpd/eigrp_query.c2
-rw-r--r--eigrpd/eigrp_reply.c2
-rw-r--r--eigrpd/eigrp_siaquery.c2
-rw-r--r--eigrpd/eigrp_siareply.c2
-rw-r--r--eigrpd/eigrp_structs.h7
-rw-r--r--eigrpd/eigrp_topology.c57
-rw-r--r--eigrpd/eigrp_update.c6
7 files changed, 48 insertions, 30 deletions
diff --git a/eigrpd/eigrp_query.c b/eigrpd/eigrp_query.c
index b9351ed896..92aa7f9855 100644
--- a/eigrpd/eigrp_query.c
+++ b/eigrpd/eigrp_query.c
@@ -131,7 +131,7 @@ void eigrp_query_receive(struct eigrp *eigrp, struct ip *iph,
nbr);
msg.packet_type = EIGRP_OPC_QUERY;
msg.eigrp = eigrp;
- msg.data_type = EIGRP_TLV_IPv4_INT;
+ msg.data_type = EIGRP_INT;
msg.adv_router = nbr;
msg.data.ipv4_int_type = tlv;
msg.entry = entry;
diff --git a/eigrpd/eigrp_reply.c b/eigrpd/eigrp_reply.c
index 7015413f56..92cea77305 100644
--- a/eigrpd/eigrp_reply.c
+++ b/eigrpd/eigrp_reply.c
@@ -237,7 +237,7 @@ void eigrp_reply_receive(struct eigrp *eigrp, struct ip *iph,
msg.packet_type = EIGRP_OPC_REPLY;
msg.eigrp = eigrp;
- msg.data_type = EIGRP_TLV_IPv4_INT;
+ msg.data_type = EIGRP_INT;
msg.adv_router = nbr;
msg.data.ipv4_int_type = tlv;
msg.entry = entry;
diff --git a/eigrpd/eigrp_siaquery.c b/eigrpd/eigrp_siaquery.c
index 9447efb2e2..60decc5bef 100644
--- a/eigrpd/eigrp_siaquery.c
+++ b/eigrpd/eigrp_siaquery.c
@@ -100,7 +100,7 @@ void eigrp_siaquery_receive(struct eigrp *eigrp, struct ip *iph,
nbr);
msg.packet_type = EIGRP_OPC_SIAQUERY;
msg.eigrp = eigrp;
- msg.data_type = EIGRP_TLV_IPv4_INT;
+ msg.data_type = EIGRP_INT;
msg.adv_router = nbr;
msg.data.ipv4_int_type = tlv;
msg.entry = entry;
diff --git a/eigrpd/eigrp_siareply.c b/eigrpd/eigrp_siareply.c
index 2cf7520a96..e960940200 100644
--- a/eigrpd/eigrp_siareply.c
+++ b/eigrpd/eigrp_siareply.c
@@ -99,7 +99,7 @@ void eigrp_siareply_receive(struct eigrp *eigrp, struct ip *iph,
nbr);
msg.packet_type = EIGRP_OPC_SIAQUERY;
msg.eigrp = eigrp;
- msg.data_type = EIGRP_TLV_IPv4_INT;
+ msg.data_type = EIGRP_INT;
msg.adv_router = nbr;
msg.data.ipv4_int_type = tlv;
msg.entry = entry;
diff --git a/eigrpd/eigrp_structs.h b/eigrpd/eigrp_structs.h
index 0c15436d4f..c81dfebb46 100644
--- a/eigrpd/eigrp_structs.h
+++ b/eigrpd/eigrp_structs.h
@@ -499,6 +499,11 @@ struct eigrp_neighbor_entry {
};
//---------------------------------------------------------------------------------------------------------------------------------------------
+typedef enum {
+ EIGRP_CONNECTED,
+ EIGRP_INT,
+ EIGRP_EXT,
+} msg_data_t;
/* EIGRP Finite State Machine */
@@ -508,7 +513,7 @@ struct eigrp_fsm_action_message {
struct eigrp_neighbor *adv_router; // advertising neighbor
struct eigrp_neighbor_entry *entry;
struct eigrp_prefix_entry *prefix;
- int data_type; // internal or external tlv type
+ msg_data_t data_type; // internal or external tlv type
union {
struct TLV_IPv4_External_type *ipv4_ext_data;
struct TLV_IPv4_Internal_type *ipv4_int_type;
diff --git a/eigrpd/eigrp_topology.c b/eigrpd/eigrp_topology.c
index d4d55393a8..d1c09d6612 100644
--- a/eigrpd/eigrp_topology.c
+++ b/eigrpd/eigrp_topology.c
@@ -384,32 +384,45 @@ enum metric_change eigrp_topology_update_distance(struct eigrp_fsm_action_messag
struct TLV_IPv4_External_type *ext_data = NULL;
struct TLV_IPv4_Internal_type *int_data = NULL;
- if (msg->data_type == EIGRP_TLV_IPv4_INT) {
- u_int32_t new_reported_distance;
+ switch(msg->data_type) {
+ case EIGRP_CONNECTED:
+ break;
+ case EIGRP_INT:
+ {
+ u_int32_t new_reported_distance;
- int_data = msg->data.ipv4_int_type;
- if (eigrp_metrics_is_same(int_data->metric,
- entry->reported_metric)) {
- return change; // No change
- }
+ int_data = msg->data.ipv4_int_type;
+ if (eigrp_metrics_is_same(int_data->metric,
+ entry->reported_metric)) {
+ return change; // No change
+ }
- new_reported_distance = eigrp_calculate_metrics(eigrp,
- int_data->metric);
+ new_reported_distance = eigrp_calculate_metrics(eigrp,
+ int_data->metric);
- if (entry->reported_distance < new_reported_distance)
- change = METRIC_INCREASE;
- else
- change = METRIC_DECREASE;
+ if (entry->reported_distance < new_reported_distance)
+ change = METRIC_INCREASE;
+ else
+ change = METRIC_DECREASE;
- entry->reported_metric = int_data->metric;
- entry->reported_distance = new_reported_distance;
+ entry->reported_metric = int_data->metric;
+ entry->reported_distance = new_reported_distance;
eigrp_calculate_metrics(eigrp, int_data->metric);
- entry->distance = eigrp_calculate_total_metrics(eigrp, entry);
- } else {
- ext_data = msg->data.ipv4_ext_data;
- if (eigrp_metrics_is_same(ext_data->metric,
- entry->reported_metric))
- return change;
+ entry->distance = eigrp_calculate_total_metrics(eigrp, entry);
+ break;
+ }
+ case EIGRP_EXT:
+ {
+ ext_data = msg->data.ipv4_ext_data;
+ if (eigrp_metrics_is_same(ext_data->metric,
+ entry->reported_metric))
+ return change;
+
+ break;
+ }
+ default:
+ zlog_err("%s: Please implement handler", __PRETTY_FUNCTION__);
+ break;
}
/*
* Move to correct position in list according to new distance
@@ -492,7 +505,7 @@ void eigrp_topology_neighbor_down(struct eigrp *eigrp,
tlv->metric.delay = EIGRP_MAX_METRIC;
msg.packet_type = EIGRP_OPC_UPDATE;
msg.eigrp = eigrp;
- msg.data_type = EIGRP_TLV_IPv4_INT;
+ msg.data_type = EIGRP_INT;
msg.adv_router = nbr;
msg.data.ipv4_int_type = tlv;
msg.entry = entry;
diff --git a/eigrpd/eigrp_update.c b/eigrpd/eigrp_update.c
index 89b8ecd928..ba54fa5727 100644
--- a/eigrpd/eigrp_update.c
+++ b/eigrpd/eigrp_update.c
@@ -139,7 +139,7 @@ static void eigrp_update_receive_GR_ask(struct eigrp *eigrp,
fsm_msg.packet_type = EIGRP_OPC_UPDATE;
fsm_msg.eigrp = eigrp;
- fsm_msg.data_type = EIGRP_TLV_IPv4_INT;
+ fsm_msg.data_type = EIGRP_INT;
fsm_msg.adv_router = nbr;
fsm_msg.data.ipv4_int_type = tlv_max;
fsm_msg.entry = entry;
@@ -315,7 +315,7 @@ void eigrp_update_receive(struct eigrp *eigrp, struct ip *iph,
msg.packet_type = EIGRP_OPC_UPDATE;
msg.eigrp = eigrp;
- msg.data_type = EIGRP_TLV_IPv4_INT;
+ msg.data_type = EIGRP_INT;
msg.adv_router = nbr;
msg.data.ipv4_int_type = tlv;
msg.entry = entry;
@@ -978,7 +978,7 @@ static void eigrp_update_send_GR_part(struct eigrp_neighbor *nbr)
fsm_msg.packet_type = EIGRP_OPC_UPDATE;
fsm_msg.eigrp = e;
- fsm_msg.data_type = EIGRP_TLV_IPv4_INT;
+ fsm_msg.data_type = EIGRP_INT;
fsm_msg.adv_router = nbr;
fsm_msg.data.ipv4_int_type = tlv_max;
fsm_msg.entry = entry;