switch (actual_state) {
case EIGRP_FSM_STATE_PASSIVE: {
struct eigrp_neighbor_entry *head =
- (struct eigrp_neighbor_entry *)
- entry->prefix->entries->head->data;
+ listnode_head(prefix->entries);
if (head->reported_distance < prefix->fdistance) {
return EIGRP_FSM_KEEP_STATE;
case EIGRP_FSM_STATE_ACTIVE_0: {
if (msg->packet_type == EIGRP_OPC_REPLY) {
struct eigrp_neighbor_entry *head =
- (struct eigrp_neighbor_entry *)
- entry->prefix->entries->head->data;
+ listnode_head(prefix->entries);
listnode_delete(prefix->rij, entry->adv_router);
if (prefix->rij->count)
case EIGRP_FSM_STATE_ACTIVE_2: {
if (msg->packet_type == EIGRP_OPC_REPLY) {
struct eigrp_neighbor_entry *head =
- (struct eigrp_neighbor_entry *)
- prefix->entries->head->data;
+ listnode_head(prefix->entries);
listnode_delete(prefix->rij, entry->adv_router);
if (prefix->rij->count) {
struct eigrp *eigrp = msg->eigrp;
struct eigrp_prefix_entry *prefix = msg->prefix;
struct list *successors = eigrp_topology_get_successor(prefix);
+ struct eigrp_neighbor_entry *ne;
assert(successors); // If this is NULL we have shit the bed, fun huh?
+ ne = listnode_head(successors);
prefix->state = EIGRP_FSM_STATE_ACTIVE_1;
prefix->rdistance = prefix->distance = prefix->fdistance =
- ((struct eigrp_neighbor_entry *)successors->head->data)
- ->distance;
- prefix->reported_metric =
- ((struct eigrp_neighbor_entry *)successors->head->data)
- ->total_metric;
+ ne->distance;
+ prefix->reported_metric = ne->total_metric;
if (eigrp_nbr_count_get()) {
prefix->req_action |= EIGRP_FSM_NEED_QUERY;
struct eigrp *eigrp = msg->eigrp;
struct eigrp_prefix_entry *prefix = msg->prefix;
struct list *successors = eigrp_topology_get_successor(prefix);
+ struct eigrp_neighbor_entry *ne;
assert(successors); // If this is NULL somebody poked us in the eye.
+ ne = listnode_head(successors);
prefix->state = EIGRP_FSM_STATE_ACTIVE_3;
prefix->rdistance = prefix->distance = prefix->fdistance =
- ((struct eigrp_neighbor_entry *)successors->head->data)
- ->distance;
- prefix->reported_metric =
- ((struct eigrp_neighbor_entry *)successors->head->data)
- ->total_metric;
+ ne->distance;
+ prefix->reported_metric = ne->total_metric;
if (eigrp_nbr_count_get()) {
prefix->req_action |= EIGRP_FSM_NEED_QUERY;
listnode_add(eigrp->topology_changes_internalIPV4, prefix);
int eigrp_fsm_event_keep_state(struct eigrp_fsm_action_message *msg)
{
struct eigrp_prefix_entry *prefix = msg->prefix;
+ struct eigrp_neighbor_entry *ne = listnode_head(prefix->entries);
if (prefix->state == EIGRP_FSM_STATE_PASSIVE) {
if (!eigrp_metrics_is_same(prefix->reported_metric,
- ((struct eigrp_neighbor_entry *)
- prefix->entries->head->data)
- ->total_metric)) {
+ ne->total_metric)) {
prefix->rdistance = prefix->fdistance =
- prefix->distance =
- ((struct eigrp_neighbor_entry *)
- prefix->entries->head->data)
- ->distance;
+ prefix->distance = ne->distance;
prefix->reported_metric =
- ((struct eigrp_neighbor_entry *)
- prefix->entries->head->data)
- ->total_metric;
+ ne->total_metric;
if (msg->packet_type == EIGRP_OPC_QUERY)
eigrp_send_reply(msg->adv_router, prefix);
prefix->req_action |= EIGRP_FSM_NEED_UPDATE;
{
struct eigrp *eigrp = msg->eigrp;
struct eigrp_prefix_entry *prefix = msg->prefix;
+ struct eigrp_neighbor_entry *ne = listnode_head(prefix->entries);
+
prefix->fdistance = prefix->distance = prefix->rdistance =
- ((struct eigrp_neighbor_entry *)(prefix->entries->head->data))
- ->distance;
- prefix->reported_metric =
- ((struct eigrp_neighbor_entry *)(prefix->entries->head->data))
- ->total_metric;
+ ne->distance;
+ prefix->reported_metric = ne->total_metric;
if (prefix->state == EIGRP_FSM_STATE_ACTIVE_3) {
struct list *successors = eigrp_topology_get_successor(prefix);
assert(successors); // It's like Napolean and Waterloo
- eigrp_send_reply(
- ((struct eigrp_neighbor_entry *)successors->head->data)
- ->adv_router,
- prefix);
+ ne = listnode_head(successors);
+ eigrp_send_reply(ne->adv_router,
+ prefix);
list_delete(successors);
}
int eigrp_fsm_event_dinc(struct eigrp_fsm_action_message *msg)
{
struct list *successors = eigrp_topology_get_successor(msg->prefix);
+ struct eigrp_neighbor_entry *ne;
assert(successors); // Trump and his big hands
+ ne = listnode_head(successors);
msg->prefix->state = msg->prefix->state == EIGRP_FSM_STATE_ACTIVE_1
? EIGRP_FSM_STATE_ACTIVE_0
: EIGRP_FSM_STATE_ACTIVE_2;
- msg->prefix->distance =
- ((struct eigrp_neighbor_entry *)successors->head->data)
- ->distance;
+ msg->prefix->distance = ne->distance;
if (!msg->prefix->rij->count)
(*(NSM[msg->prefix->state][eigrp_get_fsm_event(msg)].func))(
msg);
{
struct eigrp *eigrp = msg->eigrp;
struct eigrp_prefix_entry *prefix = msg->prefix;
+ struct eigrp_neighbor_entry *ne = listnode_head(prefix->entries);
+
prefix->state = EIGRP_FSM_STATE_PASSIVE;
- prefix->distance = prefix->rdistance =
- ((struct eigrp_neighbor_entry *)(prefix->entries->head->data))
- ->distance;
- prefix->reported_metric =
- ((struct eigrp_neighbor_entry *)(prefix->entries->head->data))
- ->total_metric;
+ prefix->distance = prefix->rdistance = ne->distance;
+ prefix->reported_metric = ne->total_metric;
prefix->fdistance = prefix->fdistance > prefix->distance
? prefix->distance
: prefix->fdistance;
assert(successors); // Having a spoon and all you need is a
// knife
-
- eigrp_send_reply(
- ((struct eigrp_neighbor_entry *)successors->head->data)
- ->adv_router,
- prefix);
+ ne = listnode_head(successors);
+ eigrp_send_reply(ne->adv_router,
+ prefix);
list_delete(successors);
}
{
struct eigrp *eigrp = msg->eigrp;
struct eigrp_prefix_entry *prefix = msg->prefix;
+ struct eigrp_neighbor_entry *best_successor;
struct list *successors = eigrp_topology_get_successor(prefix);
assert(successors); // Routing without a stack
prefix->state = prefix->state == EIGRP_FSM_STATE_ACTIVE_0
? EIGRP_FSM_STATE_ACTIVE_1
: EIGRP_FSM_STATE_ACTIVE_3;
- struct eigrp_neighbor_entry *best_successor =
- ((struct eigrp_neighbor_entry *)(successors->head->data));
+
+ best_successor = listnode_head(successors);
prefix->rdistance = prefix->distance = best_successor->distance;
prefix->reported_metric = best_successor->total_metric;
int eigrp_fsm_event_qact(struct eigrp_fsm_action_message *msg)
{
struct list *successors = eigrp_topology_get_successor(msg->prefix);
+ struct eigrp_neighbor_entry *ne;
assert(successors); // Cats and no Dogs
+ ne = listnode_head(successors);
msg->prefix->state = EIGRP_FSM_STATE_ACTIVE_2;
- msg->prefix->distance =
- ((struct eigrp_neighbor_entry *)(successors->head->data))
- ->distance;
+ msg->prefix->distance = ne->distance;
list_delete(successors);
return 1;