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.
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 9009638..4f3847d 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -1158,7 +1158,7 @@
   struct bgp_info_pair old_and_new;
   struct attr attr;
   struct peer_group *group;
-  struct listnode *nn;
+  struct listnode *node, *nnode;
 
   p = &rn->p;
 
@@ -1170,7 +1170,7 @@
   if (CHECK_FLAG(rsclient->sflags, PEER_STATUS_GROUP))
   {
     group = rsclient->group;
-    LIST_LOOP(group->peer, rsclient, nn)
+    for (ALL_LIST_ELEMENTS (group->peer, node, nnode, rsclient))
       {
         /* Nothing to do. */
         if (old_select && old_select == new_select)
@@ -1203,7 +1203,7 @@
   struct bgp_info *new_select;
   struct bgp_info *old_select;
   struct bgp_info_pair old_and_new;
-  struct listnode *nn;
+  struct listnode *node, *nnode;
   struct peer *peer;
   struct attr attr;
 
@@ -1235,7 +1235,7 @@
 
 
   /* Check each BGP peer. */
-  LIST_LOOP (bgp->peer, peer, nn)
+  for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
     {
       bgp_process_announce_selected (peer, new_select, rn, &attr, afi, safi);
     }
@@ -1954,7 +1954,7 @@
             struct prefix_rd *prd, u_char *tag, int soft_reconfig)
 {
   struct peer *rsclient;
-  struct listnode *nn;
+  struct listnode *node, *nnode;
   struct bgp *bgp;
   int ret;
 
@@ -1964,7 +1964,7 @@
   bgp = peer->bgp;
 
   /* Process the update for each RS-client. */
-  LIST_LOOP(bgp->rsclient, rsclient, nn)
+  for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
     {
       if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
         bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type,
@@ -1984,12 +1984,12 @@
   struct bgp_node *rn;
   struct bgp_info *ri;
   struct peer *rsclient;
-  struct listnode *nn;
+  struct listnode *node, *nnode;
 
   bgp = peer->bgp;
 
   /* Process the withdraw for each RS-client. */
-  LIST_LOOP (bgp->rsclient, rsclient, nn)
+  for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
     {
       if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
         bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag);
@@ -2316,7 +2316,7 @@
   struct bgp_node *rn;
   struct bgp_table *table;
   struct peer *rsclient;
-  struct listnode *nn;
+  struct listnode *node, *nnode;
 
   if (safi != SAFI_MPLS_VPN)
     bgp_clear_route_table (peer, afi, safi, NULL, NULL);
@@ -2326,7 +2326,7 @@
       if ((table = rn->info) != NULL)
        bgp_clear_route_table (peer, afi, safi, table, NULL);
 
-  LIST_LOOP (peer->bgp->rsclient, rsclient, nn)
+  for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient))
     {
       if (CHECK_FLAG(rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
         bgp_clear_route_table (peer, afi, safi, NULL, rsclient);
@@ -2389,12 +2389,12 @@
 bgp_cleanup_routes ()
 {
   struct bgp *bgp;
-  struct listnode *nn;
+  struct listnode *node, *nnode;
   struct bgp_node *rn;
   struct bgp_table *table;
   struct bgp_info *ri;
 
-  LIST_LOOP (bm->bgp, bgp, nn)
+  for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
     {
       table = bgp->rib[AFI_IP][SAFI_UNICAST];
 
@@ -2884,11 +2884,11 @@
                   struct bgp_static *bgp_static, afi_t afi, safi_t safi)
 {
   struct peer *rsclient;
-  struct listnode *nn;
+  struct listnode *node, *nnode;
 
   bgp_static_update_main (bgp, p, bgp_static, afi, safi);
 
-  LIST_LOOP(bgp->rsclient, rsclient, nn)
+  for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
     {
       bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi);
     }
@@ -4558,7 +4558,7 @@
 		      u_int32_t metric, u_char type)
 {
   struct bgp *bgp;
-  struct listnode *nn;
+  struct listnode *node, *nnode;
   struct bgp_info *new;
   struct bgp_info *bi;
   struct bgp_info info;
@@ -4577,7 +4577,7 @@
   attr.med = metric;
   attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
 
-  LIST_LOOP (bm->bgp, bgp, nn)
+  for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
     {
       afi = family2afi (p->family);
 
@@ -4673,12 +4673,12 @@
 bgp_redistribute_delete (struct prefix *p, u_char type)
 {
   struct bgp *bgp;
-  struct listnode *nn;
+  struct listnode *node, *nnode;
   afi_t afi;
   struct bgp_node *rn;
   struct bgp_info *ri;
 
-  LIST_LOOP (bm->bgp, bgp, nn)
+  for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
     {
       afi = family2afi (p->family);
 
@@ -5590,7 +5590,7 @@
   struct bgp_info *ri;
   struct prefix *p;
   struct peer *peer;
-  struct listnode *nn;
+  struct listnode *node, *nnode;
   char buf1[INET6_ADDRSTRLEN];
   char buf2[INET6_ADDRSTRLEN];
   int count = 0;
@@ -5649,7 +5649,7 @@
   vty_out (vty, ")%s", VTY_NEWLINE);
 
   /* advertised peer */
-  LIST_LOOP (bgp->peer, peer, nn)
+  for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
     {
       if (bgp_adj_out_lookup (peer, p, afi, safi, rn))
 	{