summaryrefslogtreecommitdiffstats
path: root/zebra/router-id.c
diff options
context:
space:
mode:
authorpaul <paul>2005-04-07 09:30:20 +0200
committerpaul <paul>2005-04-07 09:30:20 +0200
commit1eb8ef2584833f18fb674e127d59cb5a7f771482 (patch)
treef5b09d4781de9a9b08839fefb6530e64d2d2ec31 /zebra/router-id.c
parent * lib/prefix.[hc]: inet6_ntoa utility function copied from (diff)
downloadfrr-1eb8ef2584833f18fb674e127d59cb5a7f771482.tar.xz
frr-1eb8ef2584833f18fb674e127d59cb5a7f771482.zip
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (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 'zebra/router-id.c')
-rw-r--r--zebra/router-id.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/zebra/router-id.c b/zebra/router-id.c
index 3052e56a5..6194582e0 100644
--- a/zebra/router-id.c
+++ b/zebra/router-id.c
@@ -52,12 +52,10 @@ router_id_find_node (struct list *l, struct connected *ifc)
struct listnode *node;
struct connected *c;
- for (node = l->head; node; node = node->next)
- {
- c = (struct connected *) getdata (node);
- if (prefix_same (ifc->address, c->address))
- return c;
- }
+ for (ALL_LIST_ELEMENTS_RO (l, node, c))
+ if (prefix_same (ifc->address, c->address))
+ return c;
+
return NULL;
}
@@ -94,13 +92,13 @@ router_id_get (struct prefix *p)
else if (!list_isempty (&rid_lo_sorted_list))
{
node = listtail (&rid_lo_sorted_list);
- c = getdata (node);
+ c = listgetdata (node);
p->u.prefix4.s_addr = c->address->u.prefix4.s_addr;
}
else if (!list_isempty (&rid_all_sorted_list))
{
node = listtail (&rid_all_sorted_list);
- c = getdata (node);
+ c = listgetdata (node);
p->u.prefix4.s_addr = c->address->u.prefix4.s_addr;
}
}
@@ -115,9 +113,9 @@ router_id_set (struct prefix *p)
rid_user_assigned.u.prefix4.s_addr = p->u.prefix4.s_addr;
router_id_get (&p2);
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- zsend_router_id_update (client, &p2);
+
+ for (ALL_LIST_ELEMENTS_RO (zebrad.client_list, node, client))
+ zsend_router_id_update (client, &p2);
}
void
@@ -148,9 +146,8 @@ router_id_add_address (struct connected *ifc)
if (prefix_same (&before, &after))
return;
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- zsend_router_id_update (client, &after);
+ for (ALL_LIST_ELEMENTS_RO (zebrad.client_list, node, client))
+ zsend_router_id_update (client, &after);
}
void
@@ -182,9 +179,8 @@ router_id_del_address (struct connected *ifc)
if (prefix_same (&before, &after))
return;
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- zsend_router_id_update (client, &after);
+ for (ALL_LIST_ELEMENTS_RO (zebrad.client_list, node, client))
+ zsend_router_id_update (client, &after);
}
void