summaryrefslogtreecommitdiff
path: root/ripd/ripd.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 /ripd/ripd.c
parent5920990fecba7e2430af3cfaa8bcbaed40d0ba1a (diff)
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 'ripd/ripd.c')
-rw-r--r--ripd/ripd.c45
1 files changed, 16 insertions, 29 deletions
diff --git a/ripd/ripd.c b/ripd/ripd.c
index afdcd832..3dd91dae 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -365,13 +365,10 @@ rip_nexthop_check (struct in_addr *addr)
/* If nexthop address matches local configured address then it is
invalid nexthop. */
- for (node = listhead (iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
- ifp = getdata (node);
-
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, ifc))
{
- ifc = getdata (cnode);
p = ifc->address;
if (p->family == AF_INET
@@ -2440,7 +2437,8 @@ rip_update_interface (struct connected *ifc, u_char version, int route_type)
void
rip_update_process (int route_type)
{
- struct listnode *node, *ifnode;
+ struct listnode *node;
+ struct listnode *ifnode, *ifnnode;
struct connected *connected;
struct interface *ifp;
struct rip_interface *ri;
@@ -2449,10 +2447,8 @@ rip_update_process (int route_type)
struct prefix_ipv4 *p;
/* Send RIP update to each interface. */
- for (node = listhead (iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
- ifp = getdata (node);
-
if (if_is_loopback (ifp))
continue;
@@ -2480,8 +2476,7 @@ rip_update_process (int route_type)
}
/* send update on each connected network */
-
- LIST_LOOP(ifp->connected, connected, ifnode)
+ for (ALL_LIST_ELEMENTS (ifp->connected, ifnode, ifnnode, connected))
{
struct prefix_ipv4 *ifaddr;
int done = 0;
@@ -2716,7 +2711,7 @@ rip_request_send (struct sockaddr_in *to, struct interface *ifp,
{
struct rte *rte;
struct rip_packet rip_packet;
- struct listnode *node;
+ struct listnode *node, *nnode;
memset (&rip_packet, 0, sizeof (rip_packet));
@@ -2740,7 +2735,7 @@ rip_request_send (struct sockaddr_in *to, struct interface *ifp,
}
/* send request on each connected network */
- LIST_LOOP(ifp->connected, connected, node)
+ for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, connected))
{
struct prefix_ipv4 *p;
@@ -3533,9 +3528,8 @@ DEFUN (show_ip_rip_status,
vty_out (vty, " Interface Send Recv Key-chain%s", VTY_NEWLINE);
- for (node = listhead (iflist); node; node = nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
- ifp = getdata (node);
ri = ifp->info;
if (ri->enable_network || ri->enable_interface)
@@ -3563,9 +3557,8 @@ DEFUN (show_ip_rip_status,
{
int found_passive = 0;
- for (node = listhead (iflist); node; node = nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
- ifp = getdata (node);
ri = ifp->info;
if ((ri->enable_network || ri->enable_interface) && ri->passive)
@@ -3761,13 +3754,10 @@ void
rip_distribute_update_all (struct prefix_list *notused)
{
struct interface *ifp;
- struct listnode *node;
+ struct listnode *node, *nnode;
- for (node = listhead (iflist); node; nextnode (node))
- {
- ifp = getdata (node);
- rip_distribute_update_interface (ifp);
- }
+ for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp))
+ rip_distribute_update_interface (ifp);
}
/* ARGSUSED */
void
@@ -3955,13 +3945,10 @@ void
rip_routemap_update (const char *notused)
{
struct interface *ifp;
- struct listnode *node;
+ struct listnode *node, *nnode;
- for (node = listhead (iflist); node; nextnode (node))
- {
- ifp = getdata (node);
- rip_if_rmap_update_interface (ifp);
- }
+ for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp))
+ rip_if_rmap_update_interface (ifp);
rip_routemap_update_redistribute ();
}