From f7a76abf3078bac6251d4e27f0143a9c0b14dde7 Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Tue, 4 Jul 2006 13:57:49 +0000 Subject: [ospfd] Apply some simplifications to ospf_nsm, from Andrew's suggestions 2006-07-04 Paul Jakma * ospf_nsm.c: (general) Various small cleanups from Andrew's review of last set of patches. (nsm_timer_set) Loading, Full and default can share same code too. (nsm_should_adj) Can just be one big OR. (nsm_twoway_received) Collapse into return statement. --- ospfd/ospf_nsm.c | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) (limited to 'ospfd/ospf_nsm.c') diff --git a/ospfd/ospf_nsm.c b/ospfd/ospf_nsm.c index 149ff7cb..11da503e 100644 --- a/ospfd/ospf_nsm.c +++ b/ospfd/ospf_nsm.c @@ -125,11 +125,7 @@ nsm_timer_set (struct ospf_neighbor *nbr) OSPF_NSM_TIMER_OFF (nbr->t_db_desc); break; case NSM_Loading: - OSPF_NSM_TIMER_OFF (nbr->t_db_desc); - break; case NSM_Full: - OSPF_NSM_TIMER_OFF (nbr->t_db_desc); - break; default: OSPF_NSM_TIMER_OFF (nbr->t_db_desc); break; @@ -142,23 +138,17 @@ nsm_timer_set (struct ospf_neighbor *nbr) static int nsm_should_adj (struct ospf_neighbor *nbr) { - struct ospf_interface *oi; - - oi = nbr->oi; + struct ospf_interface *oi = nbr->oi; - /* These network types must always form adjacencies. */ + /* These network types must always form adjacencies. */ if (oi->type == OSPF_IFTYPE_POINTOPOINT || oi->type == OSPF_IFTYPE_POINTOMULTIPOINT - || oi->type == OSPF_IFTYPE_VIRTUALLINK) - return 1; - - /* Router itself is the DRouter or the BDRouter. */ - if (IPV4_ADDR_SAME (&oi->address->u.prefix4, &DR (oi)) - || IPV4_ADDR_SAME (&oi->address->u.prefix4, &BDR (oi))) - return 1; - - /* Neighboring Router is the DRouter or the BDRouter. */ - if (IPV4_ADDR_SAME (&nbr->address.u.prefix4, &DR (oi)) + || oi->type == OSPF_IFTYPE_VIRTUALLINK + /* Router itself is the DRouter or the BDRouter. */ + || IPV4_ADDR_SAME (&oi->address->u.prefix4, &DR (oi)) + || IPV4_ADDR_SAME (&oi->address->u.prefix4, &BDR (oi)) + /* Neighboring Router is the DRouter or the BDRouter. */ + || IPV4_ADDR_SAME (&nbr->address.u.prefix4, &DR (oi)) || IPV4_ADDR_SAME (&nbr->address.u.prefix4, &BDR (oi))) return 1; @@ -211,12 +201,7 @@ nsm_start (struct ospf_neighbor *nbr) static int nsm_twoway_received (struct ospf_neighbor *nbr) { - int next_state = NSM_TwoWay; - - if (nsm_should_adj (nbr)) - next_state = NSM_ExStart; - - return next_state; + return (nsm_should_adj (nbr) ? NSM_ExStart : NSM_TwoWay); } int -- cgit v1.2.1