summaryrefslogtreecommitdiff
path: root/ospfd/ospf_snmp.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 /ospfd/ospf_snmp.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 'ospfd/ospf_snmp.c')
-rw-r--r--ospfd/ospf_snmp.c48
1 files changed, 21 insertions, 27 deletions
diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c
index c1994ab4..4ed1fab8 100644
--- a/ospfd/ospf_snmp.c
+++ b/ospfd/ospf_snmp.c
@@ -499,13 +499,10 @@ ospf_admin_stat (struct ospf *ospf)
if (ospf == NULL)
return 0;
- for (node = listhead (ospf->oiflist); node; nextnode (node))
- {
- oi = getdata (node);
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
+ if (oi && oi->address)
+ return 1;
- if (oi && oi->address)
- return 1;
- }
return 0;
}
@@ -624,16 +621,14 @@ ospf_area_lookup_next (struct ospf *ospf, struct in_addr *area_id, int first)
node = listhead (ospf->areas);
if (node)
{
- area = getdata (node);
+ area = listgetdata (node);
*area_id = area->area_id;
return area;
}
return NULL;
}
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- area = getdata (node);
-
if (ntohl (area->area_id.s_addr) > ntohl (area_id->s_addr))
{
*area_id = area->area_id;
@@ -757,10 +752,8 @@ ospf_stub_area_lookup_next (struct in_addr *area_id, int first)
if (ospf == NULL)
return NULL;
- for (node = listhead (ospf->areas); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
{
- area = getdata (node);
-
if (area->external_routing == OSPF_AREA_STUB)
{
if (first)
@@ -1401,14 +1394,14 @@ ospf_snmp_if_free (struct ospf_snmp_if *osif)
void
ospf_snmp_if_delete (struct interface *ifp)
{
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct ospf_snmp_if *osif;
- LIST_LOOP (ospf_snmp_iflist, osif, nn)
+ for (ALL_LIST_ELEMENTS (ospf_snmp_iflist, node, nnode, osif))
{
if (osif->ifp == ifp)
{
- list_delete_node (ospf_snmp_iflist, nn);
+ list_delete_node (ospf_snmp_iflist, node);
ospf_snmp_if_free (osif);
return;
}
@@ -1418,7 +1411,7 @@ ospf_snmp_if_delete (struct interface *ifp)
void
ospf_snmp_if_update (struct interface *ifp)
{
- struct listnode *nn;
+ struct listnode *node;
struct listnode *pn;
struct connected *ifc;
struct prefix *p;
@@ -1433,7 +1426,7 @@ ospf_snmp_if_update (struct interface *ifp)
ifindex = 0;
/* Lookup first IPv4 address entry. */
- LIST_LOOP (ifp->connected, ifc, nn)
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
{
if (CONNECTED_POINTOPOINT_HOST(ifc))
p = ifc->destination;
@@ -1451,7 +1444,7 @@ ospf_snmp_if_update (struct interface *ifp)
/* Add interface to the list. */
pn = NULL;
- LIST_LOOP (ospf_snmp_iflist, osif, nn)
+ for (ALL_LIST_ELEMENTS_RO (ospf_snmp_iflist, node, osif))
{
if (addr)
{
@@ -1464,7 +1457,7 @@ ospf_snmp_if_update (struct interface *ifp)
if (osif->addr.s_addr != 0 || osif->ifindex > ifindex)
break;
}
- pn = nn;
+ pn = node;
}
osif = ospf_snmp_if_new ();
@@ -1480,10 +1473,10 @@ ospf_snmp_if_update (struct interface *ifp)
struct interface *
ospf_snmp_if_lookup (struct in_addr *ifaddr, unsigned int *ifindex)
{
- struct listnode *nn;
+ struct listnode *node;
struct ospf_snmp_if *osif;
- LIST_LOOP (ospf_snmp_iflist, osif, nn)
+ for (ALL_LIST_ELEMENTS_RO (ospf_snmp_iflist, node, osif))
{
if (ifaddr->s_addr)
{
@@ -1511,7 +1504,7 @@ ospf_snmp_if_lookup_next (struct in_addr *ifaddr, unsigned int *ifindex,
nn = listhead (ospf_snmp_iflist);
if (nn)
{
- osif = getdata (nn);
+ osif = listgetdata (nn);
*ifaddr = osif->addr;
*ifindex = osif->ifindex;
return osif->ifp;
@@ -1519,7 +1512,7 @@ ospf_snmp_if_lookup_next (struct in_addr *ifaddr, unsigned int *ifindex,
return NULL;
}
- LIST_LOOP (ospf_snmp_iflist, osif, nn)
+ for (ALL_LIST_ELEMENTS_RO (ospf_snmp_iflist, nn, osif))
{
if (ifaddr->s_addr)
{
@@ -2051,12 +2044,12 @@ struct ospf_neighbor *
ospf_snmp_nbr_lookup (struct ospf *ospf, struct in_addr *nbr_addr,
unsigned int *ifindex)
{
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct ospf_interface *oi;
struct ospf_neighbor *nbr;
struct route_node *rn;
- LIST_LOOP (ospf->oiflist, oi, nn)
+ for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
{
for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
if ((nbr = rn->info) != NULL
@@ -2086,7 +2079,8 @@ ospf_snmp_nbr_lookup_next (struct in_addr *nbr_addr, unsigned int *ifindex,
struct ospf *ospf = ospf;
ospf = ospf_lookup ();
- LIST_LOOP (ospf->oiflist, oi, nn)
+
+ for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, nn, oi))
{
for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
if ((nbr = rn->info) != NULL