2003-03-25 Paul Jakma <paul@dishone.st>

	* sync to latest zebra CVS
	* spec file: updated and added define for ospf-api/client

NB: OSPF-API has been broken by the zebra.org changes, which
has added struct ospf * as a new arg to many functions
diff --git a/ospfd/ospf_nsm.c b/ospfd/ospf_nsm.c
index 5730357..a8efdcc 100644
--- a/ospfd/ospf_nsm.c
+++ b/ospfd/ospf_nsm.c
@@ -222,13 +222,8 @@
 }
 
 int
-ospf_db_summary_add (struct ospf_lsa *lsa, void *v, int i)
+ospf_db_summary_add (struct ospf_neighbor *nbr, struct ospf_lsa *lsa)
 {
-  struct ospf_neighbor *nbr = (struct ospf_neighbor *) v;
-
-  if (lsa == NULL)
-    return 0;
-
 #ifdef HAVE_OPAQUE_LSA
   switch (lsa->data->type)
     {
@@ -283,73 +278,58 @@
 
 
 
-#ifdef HAVE_OPAQUE_LSA
-/* The area link state database consists of the router-LSAs,
-   network-LSAs, summary-LSAs, and type-9/10 opaque-LSAs contained
-			     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   in the area structure, along with the AS-external and type-11
-						     ^^^^^^^^^^^
-   opaque LSAs contained in the global structure.
-   ^^^^^^
-   AS-external and type-11 opaque LSAs are omitted from a virtual
-	       ^^^^^^^^^^^^^^^^^^
-   neighbor's Database summary list. AS-external and type-11 opaque
-						 ^^^^^^^^^^^^^^^^^^
-   LSAs are omitted from the Database summary list if the area has
-   been configured as a stub. */
-#else /* HAVE_OPAQUE_LSA */
 /* The area link state database consists of the router-LSAs,
    network-LSAs and summary-LSAs contained in the area structure,
-   along with the AS-external- LSAs contained in the global structure.
-   AS- external-LSAs are omitted from a virtual neighbor's Database
+   along with the AS-external-LSAs contained in the global structure.
+   AS-external-LSAs are omitted from a virtual neighbor's Database
    summary list.  AS-external-LSAs are omitted from the Database
    summary list if the area has been configured as a stub. */
-#endif /* HAVE_OPAQUE_LSA */
 int
 nsm_negotiation_done (struct ospf_neighbor *nbr)
 {
-  struct ospf_area *area;
+  struct ospf_area *area = nbr->oi->area;
+  struct ospf_lsa *lsa;
+  struct route_node *rn;
 
-  area = nbr->oi->area;
+  LSDB_LOOP (ROUTER_LSDB (area), rn, lsa)
+    ospf_db_summary_add (nbr, lsa);
+  LSDB_LOOP (NETWORK_LSDB (area), rn, lsa)
+    ospf_db_summary_add (nbr, lsa);
+  LSDB_LOOP (SUMMARY_LSDB (area), rn, lsa)
+    ospf_db_summary_add (nbr, lsa);
+  LSDB_LOOP (ASBR_SUMMARY_LSDB (area), rn, lsa)
+    ospf_db_summary_add (nbr, lsa);
 
-  foreach_lsa (ROUTER_LSDB (area), nbr, 0, ospf_db_summary_add);
-  foreach_lsa (NETWORK_LSDB (area), nbr, 0, ospf_db_summary_add);
-  foreach_lsa (SUMMARY_LSDB (area), nbr, 0, ospf_db_summary_add);
-  foreach_lsa (ASBR_SUMMARY_LSDB (area), nbr, 0, ospf_db_summary_add);
-  
 #ifdef HAVE_OPAQUE_LSA
   /* Process only if the neighbor is opaque capable. */
   if (CHECK_FLAG (nbr->options, OSPF_OPTION_O))
     {
-      foreach_lsa (OPAQUE_LINK_LSDB (area), nbr, 0, ospf_db_summary_add);
-      foreach_lsa (OPAQUE_AREA_LSDB (area), nbr, 0, ospf_db_summary_add);
+      LSDB_LOOP (OPAQUE_LINK_LSDB (area), rn, lsa)
+	ospf_db_summary_add (nbr, lsa);
+      LSDB_LOOP (OPAQUE_AREA_LSDB (area), rn, lsa)
+	ospf_db_summary_add (nbr, lsa);
     }
 #endif /* HAVE_OPAQUE_LSA */
 
-  if (nbr->oi->type != OSPF_IFTYPE_VIRTUALLINK &&
-      area->external_routing == OSPF_AREA_DEFAULT)
-    foreach_lsa (EXTERNAL_LSDB (ospf_top), nbr, 0, ospf_db_summary_add);
+  if (nbr->oi->type != OSPF_IFTYPE_VIRTUALLINK
+      && area->external_routing == OSPF_AREA_DEFAULT)
+    LSDB_LOOP (EXTERNAL_LSDB (nbr->oi->ospf), rn, lsa)
+      ospf_db_summary_add (nbr, lsa);
 
 #ifdef HAVE_OPAQUE_LSA
-  if (CHECK_FLAG (nbr->options, OSPF_OPTION_O) &&
-      (nbr->oi->type != OSPF_IFTYPE_VIRTUALLINK &&
-       area->external_routing == OSPF_AREA_DEFAULT))
-    foreach_lsa (OPAQUE_AS_LSDB (ospf_top),
-		 nbr, 0, ospf_db_summary_add);
+  if (CHECK_FLAG (nbr->options, OSPF_OPTION_O)
+      && (nbr->oi->type != OSPF_IFTYPE_VIRTUALLINK
+	  && area->external_routing == OSPF_AREA_DEFAULT))
+    LSDB_LOOP (OPAQUE_AS_LSDB (nbr->oi->ospf), rn, lsa)
+      ospf_db_summary_add (nbr, lsa);
 #endif /* HAVE_OPAQUE_LSA */
 
-  /* OSPF_NSM_TIMER_OFF (nbr->t_db_desc); */
-
   return 0;
 }
 
 int
 nsm_exchange_done (struct ospf_neighbor *nbr)
 {
-  struct ospf_interface *oi;
-
-  oi = nbr->oi;
-
   if (ospf_ls_request_isempty (nbr))
     return NSM_Full;
 
@@ -382,18 +362,18 @@
   next_state = nbr->state;
 
   /* These netowork types must be adjacency. */
-  if (oi->type == OSPF_IFTYPE_POINTOPOINT ||
-      oi->type == OSPF_IFTYPE_POINTOMULTIPOINT ||
-      oi->type == OSPF_IFTYPE_VIRTUALLINK)
+  if (oi->type == OSPF_IFTYPE_POINTOPOINT
+      || oi->type == OSPF_IFTYPE_POINTOMULTIPOINT
+      || oi->type == OSPF_IFTYPE_VIRTUALLINK)
     flag = 1;
 
   /* Router itself is the DRouter or the BDRouter. */
-  if (IPV4_ADDR_SAME (&oi->address->u.prefix4, &DR (oi)) ||
-      IPV4_ADDR_SAME (&oi->address->u.prefix4, &BDR (oi)))
+  if (IPV4_ADDR_SAME (&oi->address->u.prefix4, &DR (oi))
+      || IPV4_ADDR_SAME (&oi->address->u.prefix4, &BDR (oi)))
     flag = 1;
 
-  if (IPV4_ADDR_SAME (&nbr->address.u.prefix4, &DR (oi)) ||
-      IPV4_ADDR_SAME (&nbr->address.u.prefix4, &BDR (oi)))
+  if (IPV4_ADDR_SAME (&nbr->address.u.prefix4, &DR (oi))
+      || IPV4_ADDR_SAME (&nbr->address.u.prefix4, &BDR (oi)))
     flag = 1;
 
   if (nbr->state == NSM_TwoWay && flag == 1)
@@ -683,7 +663,7 @@
 void
 nsm_change_state (struct ospf_neighbor *nbr, int state)
 {
-  struct ospf_interface *oi;
+  struct ospf_interface *oi = nbr->oi;
   struct ospf_area *vl_area = NULL;
   u_char old_state;
   int x;
@@ -705,10 +685,8 @@
   /* Statistics. */
   nbr->state_change++;
 
-  oi = nbr->oi;
-
   if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
-    vl_area = ospf_area_lookup_by_area_id (oi->vl_data->vl_area_id);
+    vl_area = ospf_area_lookup_by_area_id (oi->ospf, oi->vl_data->vl_area_id);
   
   /* One of the neighboring routers changes to/from the FULL state. */
   if ((old_state != NSM_Full && state == NSM_Full) ||
@@ -719,31 +697,31 @@
 	  oi->full_nbrs++;
 	  oi->area->full_nbrs++;
 
-          ospf_check_abr_status ();
+          ospf_check_abr_status (oi->ospf);
 
 	  if (oi->type == OSPF_IFTYPE_VIRTUALLINK && vl_area)
             if (++vl_area->full_vls == 1)
-	      ospf_schedule_abr_task ();
+	      ospf_schedule_abr_task (oi->ospf);
 
 	  /* kevinm: refresh any redistributions */
-	  for (x = ZEBRA_ROUTE_SYSTEM; x < ZEBRA_ROUTE_MAX; x++) {
-	    if (x == ZEBRA_ROUTE_OSPF || x == ZEBRA_ROUTE_OSPF6)
-	      continue;
-	    ospf_external_lsa_refresh_type(x, force);
-	  }
-
+	  for (x = ZEBRA_ROUTE_SYSTEM; x < ZEBRA_ROUTE_MAX; x++)
+	    {
+	      if (x == ZEBRA_ROUTE_OSPF || x == ZEBRA_ROUTE_OSPF6)
+		continue;
+	      ospf_external_lsa_refresh_type (oi->ospf, x, force);
+	    }
 	}
       else
 	{
 	  oi->full_nbrs--;
 	  oi->area->full_nbrs--;
 
-          ospf_check_abr_status ();
+          ospf_check_abr_status (oi->ospf);
 
 	  if (oi->type == OSPF_IFTYPE_VIRTUALLINK && vl_area)
 	    if (vl_area->full_vls > 0)
 	      if (--vl_area->full_vls == 0)
-		ospf_schedule_abr_task ();
+		ospf_schedule_abr_task (oi->ospf);
  
           /* clear neighbor retransmit list */
           if (!ospf_ls_retransmit_isempty (nbr))
@@ -758,7 +736,7 @@
       if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
 	{
 	  struct ospf_area *vl_area =
-	    ospf_area_lookup_by_area_id (oi->vl_data->vl_area_id);
+	    ospf_area_lookup_by_area_id (oi->ospf, oi->vl_data->vl_area_id);
 	  
 	  if (vl_area)
 	    ospf_router_lsa_timer_add (vl_area);