summaryrefslogtreecommitdiffstats
path: root/ospf6d/ospf6_area.c
diff options
context:
space:
mode:
authorpaul <paul>2005-04-07 07:30:20 +0000
committerpaul <paul>2005-04-07 07:30:20 +0000
commit1eb8ef2584833f18fb674e127d59cb5a7f771482 (patch)
treef5b09d4781de9a9b08839fefb6530e64d2d2ec31 /ospf6d/ospf6_area.c
parent5920990fecba7e2430af3cfaa8bcbaed40d0ba1a (diff)
downloadquagga-1eb8ef2584833f18fb674e127d59cb5a7f771482.tar.bz2
quagga-1eb8ef2584833f18fb674e127d59cb5a7f771482.tar.xz
2005-04-07 Paul Jakma <paul.jakma@sun.com>quagga_post_listloop_cleanup
* (global): Fix up list loops to match changes in lib/linklist, and some basic auditing of usage. * configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES * HACKING: Add notes about deprecating interfaces and commands. * lib/linklist.h: Add usage comments. Rename getdata macro to listgetdata. Rename nextnode to listnextnode and fix its odd behaviour to be less dangerous. Make listgetdata macro assert node is not null, NULL list entries should be bug condition. ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use with for loop, Suggested by Jim Carlson of Sun. Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the "safety" of previous macro. LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to distinguish from the similarly named functions, and reflect their effect better. Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section with the old defines which were modified above, for backwards compatibility - guarded to prevent Quagga using it.. * lib/linklist.c: fix up for linklist.h changes. * ospf6d/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.
Diffstat (limited to 'ospf6d/ospf6_area.c')
-rw-r--r--ospf6d/ospf6_area.c48
1 files changed, 17 insertions, 31 deletions
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)
{