summaryrefslogtreecommitdiff
path: root/ospf6d
diff options
context:
space:
mode:
Diffstat (limited to 'ospf6d')
-rw-r--r--ospf6d/ChangeLog10
-rw-r--r--ospf6d/ospf6_abr.c49
-rw-r--r--ospf6d/ospf6_area.c48
-rw-r--r--ospf6d/ospf6_asbr.c18
-rw-r--r--ospf6d/ospf6_flood.c60
-rw-r--r--ospf6d/ospf6_interface.c90
-rw-r--r--ospf6d/ospf6_intra.c60
-rw-r--r--ospf6d/ospf6_message.c6
-rw-r--r--ospf6d/ospf6_neighbor.c47
-rw-r--r--ospf6d/ospf6_snmp.c7
-rw-r--r--ospf6d/ospf6_spf.c11
-rw-r--r--ospf6d/ospf6_top.c68
-rw-r--r--ospf6d/ospf6d.c134
-rw-r--r--ospf6d/ospf6d.h2
14 files changed, 219 insertions, 391 deletions
diff --git a/ospf6d/ChangeLog b/ospf6d/ChangeLog
index dc48ab7b..bc04cc94 100644
--- a/ospf6d/ChangeLog
+++ b/ospf6d/ChangeLog
@@ -1,3 +1,13 @@
+2005-04-07 Paul Jakma <paul@dishone.st>
+
+ * (global) Fix up list loops to match changes in lib/linklist,
+ and some basic auditing of usage.
+ * ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
+ scan of the area list, rather than scanning all areas first for
+ INTER_ROUTER and then again for INTER_NETWORK. According to
+ 16.2, the scan should be area specific anyway, and further
+ ospf6d does not seem to implement 16.3 anyway.
+
2005-04-02 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* ospf6_interface.[ch]: (ospf6_interface_lookup_by_name) Remove unused
diff --git a/ospf6d/ospf6_abr.c b/ospf6d/ospf6_abr.c
index 8bacfcd3..7eb8f09c 100644
--- a/ospf6d/ospf6_abr.c
+++ b/ospf6d/ospf6_abr.c
@@ -56,12 +56,9 @@ ospf6_is_router_abr (struct ospf6 *o)
struct ospf6_area *oa;
int area_count = 0;
- for (node = listhead (o->area_list); node; nextnode (node))
- {
- oa = OSPF6_AREA (getdata (node));
- if (IS_AREA_ENABLED (oa))
- area_count++;
- }
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, node, oa))
+ if (IS_AREA_ENABLED (oa))
+ area_count++;
if (area_count > 1)
return 1;
@@ -73,12 +70,10 @@ ospf6_abr_enable_area (struct ospf6_area *area)
{
struct ospf6_area *oa;
struct ospf6_route *ro;
- struct listnode *node;
+ struct listnode *node, *nnode;
- for (node = listhead (area->ospf6->area_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (area->ospf6->area_list, node, nnode, oa))
{
- oa = OSPF6_AREA (getdata (node));
-
/* update B bit for each area */
OSPF6_ROUTER_LSA_SCHEDULE (oa);
@@ -111,7 +106,7 @@ ospf6_abr_disable_area (struct ospf6_area *area)
struct ospf6_area *oa;
struct ospf6_route *ro;
struct ospf6_lsa *old;
- struct listnode *node;
+ struct listnode *node, *nnode;
/* Withdraw all summary prefixes previously originated */
for (ro = ospf6_route_head (area->summary_prefix); ro;
@@ -136,13 +131,9 @@ ospf6_abr_disable_area (struct ospf6_area *area)
}
/* Schedule Router-LSA for each area (ABR status may change) */
- for (node = listhead (area->ospf6->area_list); node; nextnode (node))
- {
- oa = OSPF6_AREA (getdata (node));
-
- /* update B bit for each area */
- OSPF6_ROUTER_LSA_SCHEDULE (oa);
- }
+ for (ALL_LIST_ELEMENTS (area->ospf6->area_list, node, nnode, oa))
+ /* update B bit for each area */
+ OSPF6_ROUTER_LSA_SCHEDULE (oa);
}
/* RFC 2328 12.4.3. Summary-LSAs */
@@ -470,7 +461,7 @@ ospf6_abr_range_update (struct ospf6_route *range)
void
ospf6_abr_originate_summary (struct ospf6_route *route)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_area *oa;
struct ospf6_route *range = NULL;
@@ -482,11 +473,8 @@ ospf6_abr_originate_summary (struct ospf6_route *route)
ospf6_abr_range_update (range);
}
- for (node = listhead (ospf6->area_list); node; nextnode (node))
- {
- oa = (struct ospf6_area *) getdata (node);
- ospf6_abr_originate_summary_to_area (route, oa);
- }
+ for (ALL_LIST_ELEMENTS (ospf6->area_list, node, nnode, oa))
+ ospf6_abr_originate_summary_to_area (route, oa);
}
/* RFC 2328 16.2. Calculating the inter-area routes */
@@ -656,22 +644,17 @@ ospf6_abr_examin_brouter (u_int32_t router_id)
{
struct ospf6_lsa *lsa;
struct ospf6_area *oa;
- struct listnode *node;
+ struct listnode *node, *nnode;
u_int16_t type;
- type = htons (OSPF6_LSTYPE_INTER_ROUTER);
- for (node = listhead (ospf6->area_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (ospf6->area_list, node, nnode, oa))
{
- oa = OSPF6_AREA (getdata (node));
+ type = htons (OSPF6_LSTYPE_INTER_ROUTER);
for (lsa = ospf6_lsdb_type_router_head (type, router_id, oa->lsdb); lsa;
lsa = ospf6_lsdb_type_router_next (type, router_id, lsa))
ospf6_abr_examin_summary (lsa, oa);
- }
- type = htons (OSPF6_LSTYPE_INTER_PREFIX);
- for (node = listhead (ospf6->area_list); node; nextnode (node))
- {
- oa = OSPF6_AREA (getdata (node));
+ type = htons (OSPF6_LSTYPE_INTER_PREFIX);
for (lsa = ospf6_lsdb_type_router_head (type, router_id, oa->lsdb); lsa;
lsa = ospf6_lsdb_type_router_next (type, router_id, lsa))
ospf6_abr_examin_summary (lsa, oa);
diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c
index 2a738cb6..57070e16 100644
--- a/ospf6d/ospf6_area.c
+++ b/ospf6d/ospf6_area.c
@@ -175,7 +175,7 @@ ospf6_area_create (u_int32_t area_id, struct ospf6 *o)
void
ospf6_area_delete (struct ospf6_area *oa)
{
- struct listnode *n;
+ struct listnode *n, *nnode;
struct ospf6_interface *oi;
ospf6_route_table_delete (oa->range_table);
@@ -183,9 +183,8 @@ ospf6_area_delete (struct ospf6_area *oa)
ospf6_route_table_delete (oa->summary_router);
/* ospf6 interface list */
- for (n = listhead (oa->if_list); n; nextnode (n))
+ for (ALL_LIST_ELEMENTS (oa->if_list, n, nnode, oi))
{
- oi = (struct ospf6_interface *) getdata (n);
ospf6_interface_delete (oi);
}
list_delete (oa->if_list);
@@ -217,12 +216,9 @@ ospf6_area_lookup (u_int32_t area_id, struct ospf6 *ospf6)
struct ospf6_area *oa;
struct listnode *n;
- for (n = listhead (ospf6->area_list); n; nextnode (n))
- {
- oa = (struct ospf6_area *) getdata (n);
- if (oa->area_id == area_id)
- return oa;
- }
+ for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, n, oa))
+ if (oa->area_id == area_id)
+ return oa;
return (struct ospf6_area *) NULL;
}
@@ -240,31 +236,25 @@ ospf6_area_get (u_int32_t area_id, struct ospf6 *o)
void
ospf6_area_enable (struct ospf6_area *oa)
{
- struct listnode *i;
+ struct listnode *node, *nnode;
struct ospf6_interface *oi;
SET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
- for (i = listhead (oa->if_list); i; nextnode (i))
- {
- oi = (struct ospf6_interface *) getdata (i);
- ospf6_interface_enable (oi);
- }
+ for (ALL_LIST_ELEMENTS (oa->if_list, node, nnode, oi))
+ ospf6_interface_enable (oi);
}
void
ospf6_area_disable (struct ospf6_area *oa)
{
- struct listnode *i;
+ struct listnode *node, *nnode;
struct ospf6_interface *oi;
UNSET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
- for (i = listhead (oa->if_list); i; nextnode (i))
- {
- oi = (struct ospf6_interface *) getdata (i);
- ospf6_interface_disable (oi);
- }
+ for (ALL_LIST_ELEMENTS (oa->if_list, node, nnode, oi))
+ ospf6_interface_disable (oi);
}
@@ -279,11 +269,9 @@ ospf6_area_show (struct vty *vty, struct ospf6_area *oa)
oa->lsdb->count, VNL);
vty_out (vty, " Interface attached to this area:");
- for (i = listhead (oa->if_list); i; nextnode (i))
- {
- oi = (struct ospf6_interface *) getdata (i);
- vty_out (vty, " %s", oi->interface->name);
- }
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, i, oi))
+ vty_out (vty, " %s", oi->interface->name);
+
vty_out (vty, "%s", VNL);
}
@@ -415,10 +403,8 @@ ospf6_area_config_write (struct vty *vty)
struct ospf6_route *range;
char buf[128];
- for (node = listhead (ospf6->area_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
{
- oa = OSPF6_AREA (getdata (node));
-
for (range = ospf6_route_head (oa->range_table); range;
range = ospf6_route_next (range))
{
@@ -444,9 +430,9 @@ DEFUN (show_ipv6_ospf6_spf_tree,
struct prefix prefix;
ospf6_linkstate_prefix (ospf6->router_id, htonl (0), &prefix);
- for (node = listhead (ospf6->area_list); node; nextnode (node))
+
+ for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
{
- oa = (struct ospf6_area *) getdata (node);
route = ospf6_route_lookup (&prefix, oa->spf_table);
if (route == NULL)
{
diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c
index c9fc5c1c..564efb22 100644
--- a/ospf6d/ospf6_asbr.c
+++ b/ospf6d/ospf6_asbr.c
@@ -444,7 +444,7 @@ ospf6_asbr_redistribute_add (int type, int ifindex, struct prefix *prefix,
struct prefix prefix_id;
struct route_node *node;
char pbuf[64], ibuf[16];
- struct listnode *lnode;
+ struct listnode *lnode, *lnnode;
struct ospf6_area *oa;
if (! ospf6_zebra_is_redistribute (type))
@@ -574,11 +574,8 @@ ospf6_asbr_redistribute_add (int type, int ifindex, struct prefix *prefix,
ospf6_as_external_lsa_originate (route);
/* Router-Bit (ASBR Flag) may have to be updated */
- for (lnode = listhead (ospf6->area_list); lnode; nextnode (lnode))
- {
- oa = (struct ospf6_area *) getdata (lnode);
- OSPF6_ROUTER_LSA_SCHEDULE (oa);
- }
+ for (ALL_LIST_ELEMENTS (ospf6->area_list, lnode, lnnode, oa))
+ OSPF6_ROUTER_LSA_SCHEDULE (oa);
}
void
@@ -590,7 +587,7 @@ ospf6_asbr_redistribute_remove (int type, int ifindex, struct prefix *prefix)
struct ospf6_lsa *lsa;
struct prefix prefix_id;
char pbuf[64], ibuf[16];
- struct listnode *lnode;
+ struct listnode *lnode, *lnnode;
struct ospf6_area *oa;
match = ospf6_route_lookup (prefix, ospf6->external_table);
@@ -642,11 +639,8 @@ ospf6_asbr_redistribute_remove (int type, int ifindex, struct prefix *prefix)
XFREE (MTYPE_OSPF6_EXTERNAL_INFO, info);
/* Router-Bit (ASBR Flag) may have to be updated */
- for (lnode = listhead (ospf6->area_list); lnode; nextnode (lnode))
- {
- oa = (struct ospf6_area *) getdata (lnode);
- OSPF6_ROUTER_LSA_SCHEDULE (oa);
- }
+ for (ALL_LIST_ELEMENTS (ospf6->area_list, lnode, lnnode, oa))
+ OSPF6_ROUTER_LSA_SCHEDULE (oa);
}
DEFUN (ospf6_redistribute,
diff --git a/ospf6d/ospf6_flood.c b/ospf6d/ospf6_flood.c
index 9971ef1c..39b7c1f3 100644
--- a/ospf6d/ospf6_flood.c
+++ b/ospf6d/ospf6_flood.c
@@ -245,7 +245,7 @@ void
ospf6_flood_interface (struct ospf6_neighbor *from,
struct ospf6_lsa *lsa, struct ospf6_interface *oi)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_neighbor *on;
struct ospf6_lsa *req;
int retrans_added = 0;
@@ -259,10 +259,8 @@ ospf6_flood_interface (struct ospf6_neighbor *from,
}
/* (1) For each neighbor */
- for (node = listhead (oi->neighbor_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
{
- on = (struct ospf6_neighbor *) getdata (node);
-
if (is_debug)
zlog_debug ("To neighbor %s", on->name);
@@ -380,9 +378,8 @@ ospf6_flood_interface (struct ospf6_neighbor *from,
else
{
/* reschedule retransmissions to all neighbors */
- for (node = listhead (oi->neighbor_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
{
- on = (struct ospf6_neighbor *) getdata (node);
THREAD_OFF (on->thread_send_lsupdate);
on->thread_send_lsupdate =
thread_add_event (master, ospf6_lsupdate_send_neighbor, on, 0);
@@ -394,13 +391,11 @@ void
ospf6_flood_area (struct ospf6_neighbor *from,
struct ospf6_lsa *lsa, struct ospf6_area *oa)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_interface *oi;
- for (node = listhead (oa->if_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (oa->if_list, node, nnode, oi))
{
- oi = OSPF6_INTERFACE (getdata (node));
-
if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_LINKLOCAL &&
oi != OSPF6_INTERFACE (lsa->lsdb->data))
continue;
@@ -419,13 +414,11 @@ void
ospf6_flood_process (struct ospf6_neighbor *from,
struct ospf6_lsa *lsa, struct ospf6 *process)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_area *oa;
- for (node = listhead (process->area_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (process->area_list, node, nnode, oa))
{
- oa = OSPF6_AREA (getdata (node));
-
if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_AREA &&
oa != OSPF6_AREA (lsa->lsdb->data))
continue;
@@ -450,13 +443,12 @@ ospf6_flood (struct ospf6_neighbor *from, struct ospf6_lsa *lsa)
void
ospf6_flood_clear_interface (struct ospf6_lsa *lsa, struct ospf6_interface *oi)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_neighbor *on;
struct ospf6_lsa *rem;
- for (node = listhead (oi->neighbor_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
{
- on = OSPF6_NEIGHBOR (getdata (node));
rem = ospf6_lsdb_lookup (lsa->header->type, lsa->header->id,
lsa->header->adv_router, on->retrans_list);
if (rem && ! ospf6_lsa_compare (rem, lsa))
@@ -474,13 +466,11 @@ ospf6_flood_clear_interface (struct ospf6_lsa *lsa, struct ospf6_interface *oi)
void
ospf6_flood_clear_area (struct ospf6_lsa *lsa, struct ospf6_area *oa)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_interface *oi;
- for (node = listhead (oa->if_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (oa->if_list, node, nnode, oi))
{
- oi = OSPF6_INTERFACE (getdata (node));
-
if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_LINKLOCAL &&
oi != OSPF6_INTERFACE (lsa->lsdb->data))
continue;
@@ -498,13 +488,11 @@ ospf6_flood_clear_area (struct ospf6_lsa *lsa, struct ospf6_area *oa)
void
ospf6_flood_clear_process (struct ospf6_lsa *lsa, struct ospf6 *process)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_area *oa;
- for (node = listhead (process->area_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (process->area_list, node, nnode, oa))
{
- oa = OSPF6_AREA (getdata (node));
-
if (OSPF6_LSA_SCOPE (lsa->header->type) == OSPF6_SCOPE_AREA &&
oa != OSPF6_AREA (lsa->lsdb->data))
continue;
@@ -725,21 +713,13 @@ ospf6_is_maxage_lsa_drop (struct ospf6_lsa *lsa, struct ospf6_neighbor *from)
return 0;
process = from->ospf6_if->area->ospf6;
- for (i = listhead (process->area_list); i; nextnode (i))
- {
- oa = OSPF6_AREA (getdata (i));
- for (j = listhead (oa->if_list); j; nextnode (j))
- {
- oi = OSPF6_INTERFACE (getdata (j));
- for (k = listhead (oi->neighbor_list); k; nextnode (k))
- {
- on = OSPF6_NEIGHBOR (getdata (k));
- if (on->state == OSPF6_NEIGHBOR_EXCHANGE ||
- on->state == OSPF6_NEIGHBOR_LOADING)
- count++;
- }
- }
- }
+
+ for (ALL_LIST_ELEMENTS_RO (process->area_list, i, oa))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
+ for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
+ if (on->state == OSPF6_NEIGHBOR_EXCHANGE ||
+ on->state == OSPF6_NEIGHBOR_LOADING)
+ count++;
if (count == 0)
return 1;
diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c
index d4180d92..0614e440 100644
--- a/ospf6d/ospf6_interface.c
+++ b/ospf6d/ospf6_interface.c
@@ -151,14 +151,12 @@ ospf6_interface_create (struct interface *ifp)
void
ospf6_interface_delete (struct ospf6_interface *oi)
{
- struct listnode *n;
+ struct listnode *node, *nnode;
struct ospf6_neighbor *on;
- for (n = listhead (oi->neighbor_list); n; nextnode (n))
- {
- on = (struct ospf6_neighbor *) getdata (n);
+ for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
ospf6_neighbor_delete (on);
- }
+
list_delete (oi->neighbor_list);
THREAD_OFF (oi->thread_send_hello);
@@ -199,16 +197,14 @@ ospf6_interface_enable (struct ospf6_interface *oi)
void
ospf6_interface_disable (struct ospf6_interface *oi)
{
- struct listnode *i;
+ struct listnode *node, *nnode;
struct ospf6_neighbor *on;
SET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE);
- for (i = listhead (oi->neighbor_list); i; nextnode (i))
- {
- on = (struct ospf6_neighbor *) getdata (i);
+ for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
ospf6_neighbor_delete (on);
- }
+
list_delete_all_node (oi->neighbor_list);
ospf6_lsdb_remove_all (oi->lsdb);
@@ -228,10 +224,8 @@ ospf6_interface_get_linklocal_address (struct interface *ifp)
struct in6_addr *l = (struct in6_addr *) NULL;
/* for each connected address */
- for (n = listhead (ifp->connected); n; nextnode (n))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, n, c))
{
- c = (struct connected *) getdata (n);
-
/* if family not AF_INET6, ignore */
if (c->address->family != AF_INET6)
continue;
@@ -318,7 +312,7 @@ ospf6_interface_connected_route_update (struct interface *ifp)
struct ospf6_interface *oi;
struct ospf6_route *route;
struct connected *c;
- struct listnode *i;
+ struct listnode *node, *nnode;
oi = (struct ospf6_interface *) ifp->info;
if (oi == NULL)
@@ -333,10 +327,9 @@ ospf6_interface_connected_route_update (struct interface *ifp)
/* update "route to advertise" interface route table */
ospf6_route_remove_all (oi->route_connected);
- for (i = listhead (oi->interface->connected); i; nextnode (i))
- {
- c = (struct connected *) getdata (i);
+ for (ALL_LIST_ELEMENTS (oi->interface->connected, node, nnode, c))
+ {
if (c->address->family != AF_INET6)
continue;
@@ -498,7 +491,7 @@ better_drouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b)
static u_char
dr_election (struct ospf6_interface *oi)
{
- struct listnode *i;
+ struct listnode *node, *nnode;
struct ospf6_neighbor *on, *drouter, *bdrouter, myself;
struct ospf6_neighbor *best_drouter, *best_bdrouter;
u_char next_state = 0;
@@ -517,20 +510,16 @@ dr_election (struct ospf6_interface *oi)
myself.router_id = oi->area->ospf6->router_id;
/* Electing BDR (2) */
- for (i = listhead (oi->neighbor_list); i; nextnode (i))
- {
- on = (struct ospf6_neighbor *) getdata (i);
- bdrouter = better_bdrouter (bdrouter, on);
- }
+ for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
+ bdrouter = better_bdrouter (bdrouter, on);
+
best_bdrouter = bdrouter;
bdrouter = better_bdrouter (best_bdrouter, &myself);
/* Electing DR (3) */
- for (i = listhead (oi->neighbor_list); i; nextnode (i))
- {
- on = (struct ospf6_neighbor *) getdata (i);
- drouter = better_drouter (drouter, on);
- }
+ for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
+ drouter = better_drouter (drouter, on);
+
best_drouter = drouter;
drouter = better_drouter (best_drouter, &myself);
if (drouter == NULL)
@@ -576,9 +565,8 @@ dr_election (struct ospf6_interface *oi)
(drouter ? drouter->name : "0.0.0.0"),
(bdrouter ? bdrouter->name : "0.0.0.0"));
- for (i = listhead (oi->neighbor_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, node, on))
{
- on = (struct ospf6_neighbor *) getdata (i);
if (on->state < OSPF6_NEIGHBOR_TWOWAY)
continue;
/* Schedule AdjOK. */
@@ -724,7 +712,7 @@ int
interface_down (struct thread *thread)
{
struct ospf6_interface *oi;
- struct listnode *n;
+ struct listnode *node, *nnode;
struct ospf6_neighbor *on;
oi = (struct ospf6_interface *) THREAD_ARG (thread);
@@ -740,11 +728,9 @@ interface_down (struct thread *thread)
ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi);
- for (n = listhead (oi->neighbor_list); n; nextnode (n))
- {
- on = (struct ospf6_neighbor *) getdata (n);
- ospf6_neighbor_delete (on);
- }
+ for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
+ ospf6_neighbor_delete (on);
+
list_delete_all_node (oi->neighbor_list);
return 0;
@@ -790,9 +776,9 @@ ospf6_interface_show (struct vty *vty, struct interface *ifp)
oi = (struct ospf6_interface *) ifp->info;
vty_out (vty, " Internet Address:%s", VNL);
- for (i = listhead (ifp->connected); i; nextnode (i))
+
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, i, c))
{
- c = (struct connected *)getdata (i);
p = c->address;
prefix2str (p, strbuf, sizeof (strbuf));
switch (p->family)
@@ -896,11 +882,8 @@ DEFUN (show_ipv6_ospf6_interface,
}
else
{
- for (i = listhead (iflist); i; nextnode (i))
- {
- ifp = (struct interface *) getdata (i);
- ospf6_interface_show (vty, ifp);
- }
+ for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
+ ospf6_interface_show (vty, ifp);
}
return CMD_SUCCESS;
@@ -992,9 +975,8 @@ DEFUN (show_ipv6_ospf6_interface_prefix,
struct ospf6_interface *oi;
struct interface *ifp;
- for (i = listhead (iflist); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
{
- ifp = (struct interface *) getdata (i);
oi = (struct ospf6_interface *) ifp->info;
if (oi == NULL)
continue;
@@ -1045,7 +1027,7 @@ DEFUN (ipv6_ospf6_ifmtu,
struct ospf6_interface *oi;
struct interface *ifp;
unsigned int ifmtu, iobuflen;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_neighbor *on;
ifp = (struct interface *) vty->index;
@@ -1084,9 +1066,8 @@ DEFUN (ipv6_ospf6_ifmtu,
oi->ifmtu = ifmtu;
/* re-establish adjacencies */
- for (node = listhead (oi->neighbor_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
{
- on = (struct ospf6_neighbor *) getdata (node);
THREAD_OFF (on->inactivity_timer);
thread_execute (master, inactivity_timer, on, 0);
}
@@ -1106,7 +1087,7 @@ DEFUN (no_ipv6_ospf6_ifmtu,
struct ospf6_interface *oi;
struct interface *ifp;
unsigned int iobuflen;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_neighbor *on;
ifp = (struct interface *) vty->index;
@@ -1133,9 +1114,8 @@ DEFUN (no_ipv6_ospf6_ifmtu,
oi->ifmtu = ifp->mtu;
/* re-establish adjacencies */
- for (node = listhead (oi->neighbor_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
{
- on = (struct ospf6_neighbor *) getdata (node);
THREAD_OFF (on->inactivity_timer);
thread_execute (master, inactivity_timer, on, 0);
}
@@ -1355,7 +1335,7 @@ DEFUN (ipv6_ospf6_passive,
{
struct ospf6_interface *oi;
struct interface *ifp;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_neighbor *on;
ifp = (struct interface *) vty->index;
@@ -1369,9 +1349,8 @@ DEFUN (ipv6_ospf6_passive,
SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE);
THREAD_OFF (oi->thread_send_hello);
- for (node = listhead (oi->neighbor_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
{
- on = (struct ospf6_neighbor *) getdata (node);
THREAD_OFF (on->inactivity_timer);
thread_execute (master, inactivity_timer, on, 0);
}
@@ -1490,9 +1469,8 @@ config_write_ospf6_interface (struct vty *vty)
struct ospf6_interface *oi;
struct interface *ifp;
- for (i = listhead (iflist); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp))
{
- ifp = (struct interface *) getdata (i);
oi = (struct ospf6_interface *) ifp->info;
if (oi == NULL)
continue;
diff --git a/ospf6d/ospf6_intra.c b/ospf6d/ospf6_intra.c
index e7844114..21693dbc 100644
--- a/ospf6d/ospf6_intra.c
+++ b/ospf6d/ospf6_intra.c
@@ -109,7 +109,8 @@ ospf6_router_lsa_originate (struct thread *thread)
struct ospf6_lsa *lsa;
u_int32_t link_state_id = 0;
- struct listnode *i, *j;
+ struct listnode *node, *nnode;
+ struct listnode *j;
struct ospf6_interface *oi;
struct ospf6_neighbor *on, *drouter = NULL;
struct ospf6_router_lsa *router_lsa;
@@ -151,10 +152,8 @@ ospf6_router_lsa_originate (struct thread *thread)
lsdesc = (struct ospf6_router_lsdesc *)
((caddr_t) router_lsa + sizeof (struct ospf6_router_lsa));
- for (i = listhead (oa->if_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS (oa->if_list, node, nnode, oi))
{
- oi = (struct ospf6_interface *) getdata (i);
-
/* Interfaces in state Down or Loopback are not described */
if (oi->state == OSPF6_INTERFACE_DOWN ||
oi->state == OSPF6_INTERFACE_LOOPBACK)
@@ -162,12 +161,10 @@ ospf6_router_lsa_originate (struct thread *thread)
/* Nor are interfaces without any full adjacencies described */
count = 0;
- for (j = listhead (oi->neighbor_list); j; nextnode (j))
- {
- on = (struct ospf6_neighbor *) getdata (j);
- if (on->state == OSPF6_NEIGHBOR_FULL)
- count++;
- }
+ for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, j, on))
+ if (on->state == OSPF6_NEIGHBOR_FULL)
+ count++;
+
if (count == 0)
continue;
@@ -215,9 +212,8 @@ ospf6_router_lsa_originate (struct thread *thread)
/* Point-to-Point interfaces */
if (if_is_pointopoint (oi->interface))
{
- for (j = listhead (oi->neighbor_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, j, on))
{
- on = (struct ospf6_neighbor *) getdata (j);
if (on->state != OSPF6_NEIGHBOR_FULL)
continue;
@@ -383,12 +379,11 @@ ospf6_network_lsa_originate (struct thread *thread)
/* If none of neighbor is adjacent to us */
count = 0;
- for (i = listhead (oi->neighbor_list); i; nextnode (i))
- {
- on = (struct ospf6_neighbor *) getdata (i);
- if (on->state == OSPF6_NEIGHBOR_FULL)
- count++;
- }
+
+ for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, i, on))
+ if (on->state == OSPF6_NEIGHBOR_FULL)
+ count++;
+
if (count == 0)
{
if (IS_OSPF6_DEBUG_ORIGINATE (NETWORK))
@@ -425,10 +420,8 @@ ospf6_network_lsa_originate (struct thread *thread)
lsdesc++;
/* Walk through the neighbors */
- for (i = listhead (oi->neighbor_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, i, on))
{
- on = (struct ospf6_neighbor *) getdata (i);
-
if (on->state != OSPF6_NEIGHBOR_FULL)
continue;
@@ -725,10 +718,8 @@ ospf6_intra_prefix_lsa_originate_stub (struct thread *thread)
route_advertise = ospf6_route_table_create ();
- for (i = listhead (oa->if_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, i, oi))
{
- oi = (struct ospf6_interface *) getdata (i);
-
if (oi->state == OSPF6_INTERFACE_DOWN)
{
if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
@@ -737,12 +728,11 @@ ospf6_intra_prefix_lsa_originate_stub (struct thread *thread)
}
full_count = 0;
- for (j = listhead (oi->neighbor_list); j; nextnode (j))
- {
- on = (struct ospf6_neighbor *) getdata (j);
- if (on->state == OSPF6_NEIGHBOR_FULL)
- full_count++;
- }
+
+ for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, j, on))
+ if (on->state == OSPF6_NEIGHBOR_FULL)
+ full_count++;
+
if (oi->state != OSPF6_INTERFACE_LOOPBACK &&
oi->state != OSPF6_INTERFACE_POINTTOPOINT &&
full_count != 0)
@@ -891,12 +881,10 @@ ospf6_intra_prefix_lsa_originate_transit (struct thread *thread)
}
full_count = 0;
- for (i = listhead (oi->neighbor_list); i; nextnode (i))
- {
- on = (struct ospf6_neighbor *) getdata (i);
- if (on->state == OSPF6_NEIGHBOR_FULL)
- full_count++;
- }
+ for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, i, on))
+ if (on->state == OSPF6_NEIGHBOR_FULL)
+ full_count++;
+
if (full_count == 0)
{
if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
diff --git a/ospf6d/ospf6_message.c b/ospf6d/ospf6_message.c
index 1486b693..a4e5d674 100644
--- a/ospf6d/ospf6_message.c
+++ b/ospf6d/ospf6_message.c
@@ -1388,7 +1388,7 @@ ospf6_hello_send (struct thread *thread)
struct ospf6_header *oh;
struct ospf6_hello *hello;
u_char *p;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_neighbor *on;
oi = (struct ospf6_interface *) THREAD_ARG (thread);
@@ -1422,10 +1422,8 @@ ospf6_hello_send (struct thread *thread)
p = (char *)((caddr_t) hello + sizeof (struct ospf6_hello));
- for (node = listhead (oi->neighbor_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on))
{
- on = (struct ospf6_neighbor *) getdata (node);
-
if (on->state < OSPF6_NEIGHBOR_INIT)
continue;
diff --git a/ospf6d/ospf6_neighbor.c b/ospf6d/ospf6_neighbor.c
index 5e71c7b4..dd46ebc7 100644
--- a/ospf6d/ospf6_neighbor.c
+++ b/ospf6d/ospf6_neighbor.c
@@ -61,12 +61,10 @@ ospf6_neighbor_lookup (u_int32_t router_id,
struct listnode *n;
struct ospf6_neighbor *on;
- for (n = listhead (oi->neighbor_list); n; nextnode (n))
- {
- on = (struct ospf6_neighbor *) getdata (n);
- if (on->router_id == router_id)
- return on;
- }
+ for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, n, on))
+ if (on->router_id == router_id)
+ return on;
+
return (struct ospf6_neighbor *) NULL;
}
@@ -795,19 +793,11 @@ DEFUN (show_ipv6_ospf6_neighbor,
"RouterID", "State", "Duration", "DR", "BDR", "I/F",
"State", VNL);
- for (i = listhead (ospf6->area_list); i; nextnode (i))
- {
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
- {
- oi = (struct ospf6_interface *) getdata (j);
- for (k = listhead (oi->neighbor_list); k; nextnode (k))
- {
- on = (struct ospf6_neighbor *) getdata (k);
- (*showfunc) (vty, on);
- }
- }
- }
+ for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, i, oa))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
+ for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
+ (*showfunc) (vty, on);
+
return CMD_SUCCESS;
}
@@ -849,20 +839,11 @@ DEFUN (show_ipv6_ospf6_neighbor_one,
return CMD_SUCCESS;
}
- for (i = listhead (ospf6->area_list); i; nextnode (i))
- {
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
- {
- oi = (struct ospf6_interface *) getdata (j);
- for (k = listhead (oi->neighbor_list); k; nextnode (k))
- {
- on = (struct ospf6_neighbor *) getdata (k);
- if (on->router_id == router_id)
- (*showfunc) (vty, on);
- }
- }
- }
+ for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, i, oa))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
+ for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
+ (*showfunc) (vty, on);
+
return CMD_SUCCESS;
}
diff --git a/ospf6d/ospf6_snmp.c b/ospf6d/ospf6_snmp.c
index 3cc4f2dd..09fa27ce 100644
--- a/ospf6d/ospf6_snmp.c
+++ b/ospf6d/ospf6_snmp.c
@@ -318,9 +318,8 @@ ospfv3AreaEntry (struct variable *v, oid *name, size_t *length,
inet_ntoa (* (struct in_addr *) &area_id),
exact, len, *length);
- for (node = listhead (ospf6->area_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
{
- oa = (struct ospf6_area *) getdata (node);
if (area == NULL)
{
if (len == 0) /* return first area entry */
@@ -435,10 +434,8 @@ ospfv3AreaLsdbEntry (struct variable *v, oid *name, size_t *length,
}
else
{
- for (node = listhead (ospf6->area_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
{
- oa = (struct ospf6_area *) getdata (node);
-
if (lsa)
continue;
if (ntohl (oa->area_id) < ntohl (area_id.s_addr))
diff --git a/ospf6d/ospf6_spf.c b/ospf6d/ospf6_spf.c
index d212c43a..08c1eb73 100644
--- a/ospf6d/ospf6_spf.c
+++ b/ospf6d/ospf6_spf.c
@@ -281,7 +281,7 @@ ospf6_spf_install (struct ospf6_vertex *v,
struct ospf6_route *route;
int i, j;
struct ospf6_vertex *prev, *w;
- struct listnode *node;
+ struct listnode *node, *nnode;
if (IS_OSPF6_DEBUG_SPF (PROCESS))
zlog_debug ("SPF install %s hops %d cost %d",
@@ -322,7 +322,7 @@ ospf6_spf_install (struct ospf6_vertex *v,
prev = (struct ospf6_vertex *) route->route_option;
if (prev->hops > v->hops)
{
- LIST_LOOP (prev->child_list, w, node)
+ for (ALL_LIST_ELEMENTS (prev->child_list, node, nnode, w))
{
assert (w->parent == prev);
w->parent = v;
@@ -502,9 +502,8 @@ ospf6_spf_log_database (struct ospf6_area *oa)
snprintf (p, end - p, " Area %s: %d", oa->name, oa->lsdb->count);
p = (buffer + strlen (buffer) < end ? buffer + strlen (buffer) : end);
- for (node = listhead (oa->if_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, node, oi))
{
- oi = (struct ospf6_interface *) getdata (node);
snprintf (p, end - p, " I/F %s: %d",
oi->interface->name, oi->lsdb->count);
p = (buffer + strlen (buffer) < end ? buffer + strlen (buffer) : end);
@@ -556,7 +555,7 @@ void
ospf6_spf_display_subtree (struct vty *vty, const char *prefix, int rest,
struct ospf6_vertex *v)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct ospf6_vertex *c;
char *next_prefix;
int len;
@@ -575,7 +574,7 @@ ospf6_spf_display_subtree (struct vty *vty, const char *prefix, int rest,
snprintf (next_prefix, len, "%s%s", prefix, (rest ? "| " : " "));
restnum = listcount (v->child_list);
- LIST_LOOP (v->child_list, c, node)
+ for (ALL_LIST_ELEMENTS (v->child_list, node, nnode, c))
{
restnum--;
ospf6_spf_display_subtree (vty, next_prefix, restnum, c);
diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c
index b0fe5ca7..b3d45167 100644
--- a/ospf6d/ospf6_top.c
+++ b/ospf6d/ospf6_top.c
@@ -143,14 +143,11 @@ ospf6_create ()
void
ospf6_delete (struct ospf6 *o)
{
- struct listnode *i;
+ struct listnode *node, *nnode;
struct ospf6_area *oa;
- for (i = listhead (o->area_list); i; nextnode (i))
- {
- oa = (struct ospf6_area *) getdata (i);
- ospf6_area_delete (oa);
- }
+ for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
+ ospf6_area_delete (oa);
ospf6_lsdb_delete (o->lsdb);
ospf6_lsdb_delete (o->lsdb_self);
@@ -167,34 +164,29 @@ ospf6_delete (struct ospf6 *o)
void
ospf6_enable (struct ospf6 *o)
{
- struct listnode *i;
+ struct listnode *node, *nnode;
struct ospf6_area *oa;
if (CHECK_FLAG (o->flag, OSPF6_DISABLED))
{
UNSET_FLAG (o->flag, OSPF6_DISABLED);
- for (i = listhead (o->area_list); i; nextnode (i))
- {
- oa = (struct ospf6_area *) getdata (i);
- ospf6_area_enable (oa);
- }
+ for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
+ ospf6_area_enable (oa);
}
}
void
ospf6_disable (struct ospf6 *o)
{
- struct listnode *i;
+ struct listnode *node, *nnode;
struct ospf6_area *oa;
if (! CHECK_FLAG (o->flag, OSPF6_DISABLED))
{
SET_FLAG (o->flag, OSPF6_DISABLED);
- for (i = listhead (o->area_list); i; nextnode (i))
- {
- oa = (struct ospf6_area *) getdata (i);
- ospf6_area_disable (oa);
- }
+
+ for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
+ ospf6_area_disable (oa);
ospf6_lsdb_remove_all (o->lsdb);
ospf6_route_remove_all (o->route_table);
@@ -213,15 +205,12 @@ ospf6_maxage_remover (struct thread *thread)
o->maxage_remover = (struct thread *) NULL;
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
- for (k = listhead (oi->neighbor_list); k; nextnode (k))
+ for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
{
- on = (struct ospf6_neighbor *) getdata (k);
if (on->state != OSPF6_NEIGHBOR_EXCHANGE &&
on->state != OSPF6_NEIGHBOR_LOADING)
continue;
@@ -231,14 +220,11 @@ ospf6_maxage_remover (struct thread *thread)
}
}
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
- {
- oi = (struct ospf6_interface *) getdata (j);
- OSPF6_LSDB_MAXAGE_REMOVER (oi->lsdb);
- }
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
+ OSPF6_LSDB_MAXAGE_REMOVER (oi->lsdb);
+
OSPF6_LSDB_MAXAGE_REMOVER (oa->lsdb);
}
OSPF6_LSDB_MAXAGE_REMOVER (o->lsdb);
@@ -466,11 +452,9 @@ ospf6_show (struct vty *vty, struct ospf6 *o)
/* Areas */
vty_out (vty, " Number of areas in this router is %u%s",
listcount (o->area_list), VNL);
- for (n = listhead (o->area_list); n; nextnode (n))
- {
- oa = (struct ospf6_area *) getdata (n);
- ospf6_area_show (vty, oa);
- }
+
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, n, oa))
+ ospf6_area_show (vty, oa);
}
/* show top level structures */
@@ -629,15 +613,11 @@ config_write_ospf6 (struct vty *vty)
ospf6_redistribute_config_write (vty);
ospf6_area_config_write (vty);
- for (j = listhead (ospf6->area_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, j, oa))
{
- oa = (struct ospf6_area *) getdata (j);
- for (k = listhead (oa->if_list); k; nextnode (k))
- {
- oi = (struct ospf6_interface *) getdata (k);
- vty_out (vty, " interface %s area %s%s",
- oi->interface->name, oa->name, VNL);
- }
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, k, oi))
+ vty_out (vty, " interface %s area %s%s",
+ oi->interface->name, oa->name, VNL);
}
vty_out (vty, "!%s", VNL);
return 0;
diff --git a/ospf6d/ospf6d.c b/ospf6d/ospf6d.c
index d10d1df6..e8fba97d 100644
--- a/ospf6d/ospf6d.c
+++ b/ospf6d/ospf6d.c
@@ -187,19 +187,16 @@ DEFUN (show_ipv6_ospf6_database,
level = parse_show_level (argc, argv);
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, NULL, NULL, NULL, oa->lsdb);
}
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, NULL, NULL, NULL, oi->lsdb);
@@ -262,21 +259,18 @@ DEFUN (show_ipv6_ospf6_database_type,
switch (OSPF6_LSA_SCOPE (type))
{
case OSPF6_SCOPE_AREA:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, NULL, NULL, oa->lsdb);
}
break;
case OSPF6_SCOPE_LINKLOCAL:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, NULL, NULL, oi->lsdb);
@@ -353,19 +347,16 @@ DEFUN (show_ipv6_ospf6_database_id,
argv++;
level = parse_show_level (argc, argv);
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, NULL, &id, NULL, oa->lsdb);
}
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, NULL, &id, NULL, oi->lsdb);
@@ -452,19 +443,16 @@ DEFUN (show_ipv6_ospf6_database_router,
argv++;
level = parse_show_level (argc, argv);
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, NULL, NULL, &adv_router, oa->lsdb);
}
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, NULL, NULL, &adv_router, oi->lsdb);
@@ -569,21 +557,18 @@ DEFUN (show_ipv6_ospf6_database_type_id,
switch (OSPF6_LSA_SCOPE (type))
{
case OSPF6_SCOPE_AREA:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, &id, NULL, oa->lsdb);
}
break;
case OSPF6_SCOPE_LINKLOCAL:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, &id, NULL, oi->lsdb);
@@ -728,21 +713,18 @@ DEFUN (show_ipv6_ospf6_database_type_router,
switch (OSPF6_LSA_SCOPE (type))
{
case OSPF6_SCOPE_AREA:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, NULL, &adv_router, oa->lsdb);
}
break;
case OSPF6_SCOPE_LINKLOCAL:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, NULL, &adv_router, oi->lsdb);
@@ -881,19 +863,16 @@ DEFUN (show_ipv6_ospf6_database_id_router,
argv++;
level = parse_show_level (argc, argv);
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, NULL, &id, &adv_router, oa->lsdb);
}
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, NULL, &id, &adv_router, oi->lsdb);
@@ -967,19 +946,16 @@ DEFUN (show_ipv6_ospf6_database_adv_router_linkstate_id,
argv++;
level = parse_show_level (argc, argv);
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, NULL, &id, &adv_router, oa->lsdb);
}
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, NULL, &id, &adv_router, oi->lsdb);
@@ -1071,21 +1047,18 @@ DEFUN (show_ipv6_ospf6_database_type_id_router,
switch (OSPF6_LSA_SCOPE (type))
{
case OSPF6_SCOPE_AREA:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oa->lsdb);
}
break;
case OSPF6_SCOPE_LINKLOCAL:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oi->lsdb);
@@ -1196,21 +1169,18 @@ DEFUN (show_ipv6_ospf6_database_type_adv_router_linkstate_id,
switch (OSPF6_LSA_SCOPE (type))
{
case OSPF6_SCOPE_AREA:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oa->lsdb);
}
break;
case OSPF6_SCOPE_LINKLOCAL:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oi->lsdb);
@@ -1282,19 +1252,16 @@ DEFUN (show_ipv6_ospf6_database_self_originated,
adv_router = o->router_id;
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, NULL, NULL, &adv_router, oa->lsdb);
}
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, NULL, NULL, &adv_router, oi->lsdb);
@@ -1362,21 +1329,18 @@ DEFUN (show_ipv6_ospf6_database_type_self_originated,
switch (OSPF6_LSA_SCOPE (type))
{
case OSPF6_SCOPE_AREA:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, NULL, &adv_router, oa->lsdb);
}
break;
case OSPF6_SCOPE_LINKLOCAL:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, NULL, &adv_router, oi->lsdb);
@@ -1478,21 +1442,18 @@ DEFUN (show_ipv6_ospf6_database_type_self_originated_linkstate_id,
switch (OSPF6_LSA_SCOPE (type))
{
case OSPF6_SCOPE_AREA:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oa->lsdb);
}
break;
case OSPF6_SCOPE_LINKLOCAL:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oi->lsdb);
@@ -1594,21 +1555,18 @@ DEFUN (show_ipv6_ospf6_database_type_id_self_originated,
switch (OSPF6_LSA_SCOPE (type))
{
case OSPF6_SCOPE_AREA:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
vty_out (vty, AREA_LSDB_TITLE_FORMAT, VNL, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oa->lsdb);
}
break;
case OSPF6_SCOPE_LINKLOCAL:
- for (i = listhead (o->area_list); i; nextnode (i))
+ for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
{
- oa = (struct ospf6_area *) getdata (i);
- for (j = listhead (oa->if_list); j; nextnode (j))
+ for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
{
- oi = (struct ospf6_interface *) getdata (j);
vty_out (vty, IF_LSDB_TITLE_FORMAT, VNL,
oi->interface->name, oa->name, VNL, VNL);
ospf6_lsdb_show (vty, level, &type, &id, &adv_router, oi->lsdb);
@@ -1730,10 +1688,8 @@ DEFUN (show_ipv6_ospf6_linkstate,
struct listnode *node;
struct ospf6_area *oa;
- for (node = listhead (ospf6->area_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
{
- oa = OSPF6_AREA (getdata (node));
-
vty_out (vty, "%s SPF Result in Area %s%s%s",
VNL, oa->name, VNL, VNL);
ospf6_linkstate_table_show (vty, argc, argv, oa->spf_table);
@@ -1787,10 +1743,8 @@ DEFUN (show_ipv6_ospf6_linkstate_detail,
sargv[sargc++] = "detail";
sargv[sargc] = NULL;
- for (node = listhead (ospf6->area_list); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
{
- oa = OSPF6_AREA (getdata (node));
-
vty_out (vty, "%s SPF Result in Area %s%s%s",
VNL, oa->name, VNL, VNL);
ospf6_linkstate_table_show (vty, sargc, sargv, oa->spf_table);
diff --git a/ospf6d/ospf6d.h b/ospf6d/ospf6d.h
index 6fcf200e..4b718d7a 100644
--- a/ospf6d/ospf6d.h
+++ b/ospf6d/ospf6d.h
@@ -50,7 +50,7 @@ extern struct thread_master *master;
#endif /* IPV6_DROP_MEMBERSHIP */
#endif /* ! IPV6_LEAVE_GROUP */
-/* cast macro */
+/* cast macro: XXX - these *must* die, ick ick. */
#define OSPF6_PROCESS(x) ((struct ospf6 *) (x))
#define OSPF6_AREA(x) ((struct ospf6_area *) (x))
#define OSPF6_INTERFACE(x) ((struct ospf6_interface *) (x))