2003-07-12 Paul Jakma <paul@dishone.st>

	* (global): Add/fixup NSSA ABR translation functionality
	* ospfd.h: Adjust the NSSA ROLE defines. Rename STATE to TRANSLATE.
	  Rename the LSA_NSSA_GET define to LSA_OPTIONS_NSSA_GET.
	* ospfd.c: Adjust to match changes to ospfd.h
	* ospf_te.c: Adjust to match change to LSA_NSSA_GET.
	* ospf_lsa.h: slights reformatting.
	  Add new NSSA functions, ospf_translated_nssa_compare() (not
	  currently used), ospf_translated_nssa_refresh() and
	  ospf_translated_nssa_originate().
	* ospf_lsa.c: Implemented aforementioned new functions. Fix up
	  several NSSA hooks to /not/ be called for Type-5s which are
	  translated. Add additional hooks. Set the ROUTER_LSA_NT bit in
	  router-lsa flags if ABR does translation. New function,
	  ospf_lsa_translated_nssa_new() implemented. Dont register
	  translated LSAs for refreshing - instead we implicitly rely on
	  the ASBR refreshing the Type-7, and refresh the translated Type-5
	  at the same time. Some minor reformatting. Extra debug info added.
	  Also, existing debug statements modified to report LSA Id.
	* ospf_flood.c: call ospf_translated_nssa_refresh() when refreshing
	  Type-7. minor reformatting.
	* ospf_dump.c: Dump NSSA LSAs.
	* ospf_asbr.h: slight reformatting. Export
	  ospf_external_route_lookup() (though, not used. probably will
          undo this).
        * ospf_abr.c: Slight reformatting in many places. Update to match
          ospfd.h changes.
          (ospf_abr_translate_nssa): make it work, using the new ospf_lsa
	  translation functions.
	  (Several places): change struct prefix * to struct prefix_ipv4 *.
	  (might as well do the casts at higher levels). Add more debug
	  info.
	  (ospf_abr_announce_stub_defaults): announce default to NSSA areas
	  too.
	  (ospf_abr_announce_nssa_defaults): do nothing. this function
          probably should die. (see ospf_abr_announce_stub_defaults).
	  (ospf_abr_task_timer): run NSSA tasks.
diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c
index aedac32..0d455ec 100644
--- a/ospfd/ospf_te.c
+++ b/ospfd/ospf_te.c
@@ -414,8 +414,8 @@
     {
     case OSPF_IFTYPE_POINTOPOINT:
       /* Take the router ID of the neighbor. */
-      if (((nbr = ospf_nbr_lookup_ptop (oi->nbrs, oi->area->top->router_id)))
-      &&  (nbr->state == NSM_Full))
+      if ((nbr = ospf_nbr_lookup_ptop (oi))
+	  && nbr->state == NSM_Full)
         {
           lp->link_id.value = nbr->router_id;
           done = 1;
@@ -429,7 +429,7 @@
 
       if (nbr->state == NSM_Full
       || (IPV4_ADDR_SAME (&oi->address->u.prefix4, &DR (oi))
-      &&  ospf_nbr_count (oi->nbrs, NSM_Full) > 0))
+      &&  ospf_nbr_count (oi, NSM_Full) > 0))
         {
           lp->link_id.value = DR (oi);
           done = 1;
@@ -628,7 +628,7 @@
       zlog_warn ("ospf_mpls_te_ism_change: Cannot get linkparams from OI(%s)?", IF_NAME (oi));
       goto out;
     }
-  if (oi->area == NULL || oi->area->top == NULL)
+  if (oi->area == NULL || oi->area->ospf == NULL)
     {
       zlog_warn ("ospf_mpls_te_ism_change: Cannot refer to OSPF from OI(%s)?",
 IF_NAME (oi));
@@ -879,7 +879,7 @@
 
   options  = LSA_OPTIONS_GET (area);
 #ifdef HAVE_NSSA
-  options |= LSA_NSSA_GET (area);
+  options |= LSA_OPTIONS_NSSA_GET (area);
 #endif /* HAVE_NSSA */
   options |= OSPF_OPTION_O; /* Don't forget this :-) */
 
@@ -891,7 +891,7 @@
     zlog_info ("LSA[Type%d:%s]: Create an Opaque-LSA/MPLS-TE instance", lsa_type, inet_ntoa (lsa_id));
 
   /* Set opaque-LSA header fields. */
-  lsa_header_set (s, options, lsa_type, lsa_id);
+  lsa_header_set (s, options, lsa_type, lsa_id, area->ospf->router_id);
 
   /* Set opaque-LSA body fields. */
   ospf_mpls_te_lsa_body_set (s, lp);
@@ -939,7 +939,7 @@
     }
 
   /* Install this LSA into LSDB. */
-  if (ospf_lsa_install (NULL/*oi*/, new) == NULL)
+  if (ospf_lsa_install (area->ospf, NULL/*oi*/, new) == NULL)
     {
       zlog_warn ("ospf_mpls_te_lsa_originate1: ospf_lsa_install() ?");
       ospf_lsa_free (new);
@@ -950,7 +950,7 @@
   lp->flags |= LPFLG_LSA_ENGAGED;
 
   /* Update new LSA origination count. */
-  area->top->lsa_originate_count++;
+  area->ospf->lsa_originate_count++;
 
   /* Flood new LSA through area. */
   ospf_flood_through_area (area, NULL/*nbr*/, new);
@@ -1059,7 +1059,7 @@
 
   /* Install this LSA into LSDB. */
   /* Given "lsa" will be freed in the next function. */
-  if (ospf_lsa_install (NULL/*oi*/, new) == NULL)
+  if (ospf_lsa_install (area->ospf, NULL/*oi*/, new) == NULL)
     {
       zlog_warn ("ospf_mpls_te_lsa_refresh: ospf_lsa_install() ?");
       ospf_lsa_free (new);