Merge svn revision 975 from Zebra repository.
diff --git a/ospf6d/ChangeLog b/ospf6d/ChangeLog
index b9181d0..5dd2a66 100644
--- a/ospf6d/ChangeLog
+++ b/ospf6d/ChangeLog
@@ -1,3 +1,10 @@
+2004-09-02  Yasuhiro Ohara  <yasu@sfc.wide.ad.jp>
+
+	* *.[ch]: Logging LSAs of particular type is added.
+	lsa_handler is now using vector in order to adjust
+	existing LSA modules.
+	* ospf6d.h: version 0.9.7l
+
 2004-08-28  Hasso Tepper  <hasso at quagga.net>
 
 	* ospf6_main.c: Modify for sigevents.
diff --git a/ospf6d/ospf6_abr.c b/ospf6d/ospf6_abr.c
index 2d4b10f..29188ab 100644
--- a/ospf6d/ospf6_abr.c
+++ b/ospf6d/ospf6_abr.c
@@ -158,29 +158,33 @@
   struct ospf6_inter_router_lsa *router_lsa;
   struct ospf6_route_table *summary_table = NULL;
   u_int16_t type;
+  char buf[64];
+  int is_debug = 0;
 
-  if (IS_OSPF6_DEBUG_ABR)
+  if (route->type == OSPF6_DEST_TYPE_ROUTER)
     {
-      char buf[64];
-      if (route->type == OSPF6_DEST_TYPE_ROUTER)
+      if (IS_OSPF6_DEBUG_ABR || IS_OSPF6_DEBUG_ORIGINATE (INTER_ROUTER))
         {
+          is_debug++;
           inet_ntop (AF_INET, &(ADV_ROUTER_IN_PREFIX (&route->prefix)),
                      buf, sizeof (buf));
           zlog_info ("Originating summary in area %s for ASBR %s",
                      area->name, buf);
         }
-      else
+      summary_table = area->summary_router;
+    }
+  else
+    {
+      if (IS_OSPF6_DEBUG_ABR || IS_OSPF6_DEBUG_ORIGINATE (INTER_PREFIX))
         {
+          is_debug++;
           prefix2str (&route->prefix, buf, sizeof (buf));
           zlog_info ("Originating summary in area %s for %s",
                      area->name, buf);
         }
+      summary_table = area->summary_prefix;
     }
 
-  if (route->type == OSPF6_DEST_TYPE_ROUTER)
-    summary_table = area->summary_router;
-  else
-    summary_table = area->summary_prefix;
   summary = ospf6_route_lookup (&route->prefix, summary_table);
   if (summary)
     old = ospf6_lsdb_lookup (summary->path.origin.type,
@@ -190,7 +194,7 @@
   /* if this route has just removed, remove corresponding LSA */
   if (CHECK_FLAG (route->flag, OSPF6_ROUTE_REMOVE))
     {
-      if (IS_OSPF6_DEBUG_ABR)
+      if (is_debug)
         zlog_info ("The route has just removed, purge previous LSA");
       if (summary)
         ospf6_route_remove (summary, summary_table);
@@ -205,7 +209,7 @@
       (route->type != OSPF6_DEST_TYPE_ROUTER ||
        ! CHECK_FLAG (route->path.router_bits, OSPF6_ROUTER_BIT_E)))
     {
-      if (IS_OSPF6_DEBUG_ABR)
+      if (is_debug)
         zlog_info ("Route type is none of network, range nor ASBR, withdraw");
       if (summary)
         ospf6_route_remove (summary, summary_table);
@@ -218,7 +222,7 @@
   if (route->path.type == OSPF6_PATH_TYPE_EXTERNAL1 ||
       route->path.type == OSPF6_PATH_TYPE_EXTERNAL2)
     {
-      if (IS_OSPF6_DEBUG_ABR)
+      if (is_debug)
         zlog_info ("Path type is external, withdraw");
       if (summary)
         ospf6_route_remove (summary, summary_table);
@@ -230,7 +234,7 @@
   /* do not generate if the path's area is the same as target area */
   if (route->path.area_id == area->area_id)
     {
-      if (IS_OSPF6_DEBUG_ABR)
+      if (is_debug)
         zlog_info ("The route is in the area itself, ignore");
       if (summary)
         ospf6_route_remove (summary, summary_table);
@@ -243,7 +247,7 @@
   oi = ospf6_interface_lookup_by_ifindex (route->nexthop[0].ifindex);
   if (oi && oi->area && oi->area == area)
     {
-      if (IS_OSPF6_DEBUG_ABR)
+      if (is_debug)
         zlog_info ("The route's nexthop is in the same area, ignore");
       if (summary)
         ospf6_route_remove (summary, summary_table);
@@ -255,7 +259,7 @@
   /* do not generate if the route cost is greater or equal to LSInfinity */
   if (route->path.cost >= LS_INFINITY)
     {
-      if (IS_OSPF6_DEBUG_ABR)
+      if (is_debug)
         zlog_info ("The cost exceeds LSInfinity, withdraw");
       if (summary)
         ospf6_route_remove (summary, summary_table);
@@ -270,7 +274,7 @@
       /* Only the prefered best path is considered */
       if (! CHECK_FLAG (route->flag, OSPF6_ROUTE_BEST))
         {
-          if (IS_OSPF6_DEBUG_ABR)
+          if (is_debug)
             zlog_info ("This is the secondary path to the ASBR, ignore");
           if (summary)
             ospf6_route_remove (summary, summary_table);
@@ -299,9 +303,8 @@
           (route->path.area_id != BACKBONE_AREA_ID ||
            ! IS_AREA_TRANSIT (area)))
         {
-          if (IS_OSPF6_DEBUG_ABR)
+          if (is_debug)
             {
-              char buf[64];
               prefix2str (&range->prefix, buf, sizeof (buf));
               zlog_info ("Suppressed by range %s of area %s",
                          buf, route_area->name);
@@ -321,7 +324,7 @@
       /* If DoNotAdvertise is set */
       if (CHECK_FLAG (route->flag, OSPF6_ROUTE_DO_NOT_ADVERTISE))
         {
-          if (IS_OSPF6_DEBUG_ABR)
+          if (is_debug)
             zlog_info ("This is the range with DoNotAdvertise set. ignore");
           if (summary)
             ospf6_route_remove (summary, summary_table);
@@ -333,7 +336,7 @@
       /* Whether the route have active longer prefix */
       if (! CHECK_FLAG (route->flag, OSPF6_ROUTE_ACTIVE_SUMMARY))
         {
-          if (IS_OSPF6_DEBUG_ABR)
+          if (is_debug)
             zlog_info ("The range is not active. withdraw");
           if (summary)
             ospf6_route_remove (summary, summary_table);
@@ -427,9 +430,6 @@
   /* create LSA */
   lsa = ospf6_lsa_create (lsa_header);
 
-  if (IS_OSPF6_DEBUG_ABR)
-    zlog_info ("Originate as %s", lsa->name);
-
   /* Originate */
   ospf6_lsa_originate_area (lsa, area);
 }
@@ -500,13 +500,18 @@
   u_int32_t cost = 0;
   int i;
   char buf[64];
-
-  if (IS_OSPF6_DEBUG_ABR)
-    zlog_info ("Examin %s in area %s", lsa->name, oa->name);
+  int is_debug = 0;
 
   if (lsa->header->type == htons (OSPF6_LSTYPE_INTER_PREFIX))
     {
       struct ospf6_inter_prefix_lsa *prefix_lsa;
+
+      if (IS_OSPF6_DEBUG_EXAMIN (INTER_PREFIX))
+        {
+          is_debug++;
+          zlog_info ("Examin %s in area %s", lsa->name, oa->name);
+        }
+
       prefix_lsa = (struct ospf6_inter_prefix_lsa *)
         OSPF6_LSA_HEADER_END (lsa->header);
       prefix.family = AF_INET6;
@@ -521,6 +526,13 @@
   else if (lsa->header->type == htons (OSPF6_LSTYPE_INTER_ROUTER))
     {
       struct ospf6_inter_router_lsa *router_lsa;
+
+      if (IS_OSPF6_DEBUG_EXAMIN (INTER_ROUTER))
+        {
+          is_debug++;
+          zlog_info ("Examin %s in area %s", lsa->name, oa->name);
+        }
+
       router_lsa = (struct ospf6_inter_router_lsa *)
         OSPF6_LSA_HEADER_END (lsa->header);
       ospf6_linkstate_prefix (router_lsa->router_id, htonl (0), &prefix);
@@ -552,7 +564,7 @@
   /* (1) if cost == LSInfinity or if the LSA is MaxAge */
   if (cost == LS_INFINITY)
     {
-      if (IS_OSPF6_DEBUG_ABR)
+      if (is_debug)
         zlog_info ("cost is LS_INFINITY, ignore");
       if (old)
         ospf6_route_remove (old, oa->ospf6->route_table);
@@ -560,7 +572,7 @@
     }
   if (OSPF6_LSA_IS_MAXAGE (lsa))
     {
-      if (IS_OSPF6_DEBUG_ABR)
+      if (is_debug)
         zlog_info ("LSA is MaxAge, ignore");
       if (old)
         ospf6_route_remove (old, oa->ospf6->route_table);
@@ -570,7 +582,7 @@
   /* (2) if the LSA is self-originated, ignore */
   if (lsa->header->adv_router == oa->ospf6->router_id)
     {
-      if (IS_OSPF6_DEBUG_ABR)
+      if (is_debug)
         zlog_info ("LSA is self-originated, ignore");
       if (old)
         ospf6_route_remove (old, oa->ospf6->route_table);
@@ -583,7 +595,7 @@
       range = ospf6_route_lookup (&prefix, oa->range_table);
       if (range)
         {
-          if (IS_OSPF6_DEBUG_ABR)
+          if (is_debug)
             zlog_info ("Prefix is equal to address range, ignore");
           if (old)
             ospf6_route_remove (old, oa->ospf6->route_table);
@@ -598,7 +610,7 @@
       CHECK_FLAG (abr_entry->flag, OSPF6_ROUTE_REMOVE) ||
       ! CHECK_FLAG (abr_entry->path.router_bits, OSPF6_ROUTER_BIT_B))
     {
-      if (IS_OSPF6_DEBUG_ABR)
+      if (is_debug)
         zlog_info ("ABR router entry does not exist, ignore");
       if (old)
         ospf6_route_remove (old, oa->ospf6->route_table);
@@ -628,7 +640,7 @@
   for (i = 0; i < OSPF6_MULTI_PATH_LIMIT; i++)
     route->nexthop[i] = abr_entry->nexthop[i];
 
-  if (IS_OSPF6_DEBUG_ABR)
+  if (is_debug)
     zlog_info ("Install route: %s", buf);
   ospf6_route_add (route, table);
 }
@@ -641,14 +653,6 @@
   listnode node;
   u_int16_t type;
 
-  if (IS_OSPF6_DEBUG_ABR)
-    {
-      char buf[16];
-      inet_ntop (AF_INET, &router_id, buf, sizeof (buf));
-      zlog_info ("Router entry of %s changed", buf);
-      zlog_info ("Examin summary LSAs originated by the router");
-    }
-
   type = htons (OSPF6_LSTYPE_INTER_ROUTER);
   for (node = listhead (ospf6->area_list); node; nextnode (node))
     {
diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c
index 312d88f..78d70a2 100644
--- a/ospf6d/ospf6_area.c
+++ b/ospf6d/ospf6_area.c
@@ -59,6 +59,12 @@
     {
     case OSPF6_LSTYPE_ROUTER:
     case OSPF6_LSTYPE_NETWORK:
+      if (IS_OSPF6_DEBUG_EXAMIN_TYPE (lsa->header->type))
+        {
+          zlog_info ("Examin %s", lsa->name);
+          zlog_info ("Schedule SPF Calculation for %s",
+                     OSPF6_AREA (lsa->lsdb->data)->name);
+        }
       ospf6_spf_schedule (OSPF6_AREA (lsa->lsdb->data));
       break;
 
@@ -72,9 +78,6 @@
       break;
 
     default:
-      if (IS_OSPF6_DEBUG_LSA (RECV))
-	zlog_info ("Unknown LSA in Area %s's lsdb",
-                   OSPF6_AREA (lsa->lsdb->data)->name);
       break;
     }
 }
@@ -86,6 +89,12 @@
     {
     case OSPF6_LSTYPE_ROUTER:
     case OSPF6_LSTYPE_NETWORK:
+      if (IS_OSPF6_DEBUG_EXAMIN_TYPE (lsa->header->type))
+        {
+          zlog_info ("LSA disappearing: %s", lsa->name);
+          zlog_info ("Schedule SPF Calculation for %s",
+                     OSPF6_AREA (lsa->lsdb->data)->name);
+        }
       ospf6_spf_schedule (OSPF6_AREA (lsa->lsdb->data));
       break;
 
@@ -99,9 +108,6 @@
       break;
 
     default:
-      if (IS_OSPF6_DEBUG_LSA (RECV))
-	zlog_info ("Unknown LSA in Area %s's lsdb",
-                   OSPF6_AREA (lsa->lsdb->data)->name);
       break;
     }
 }
diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c
index 3352465..3b161ac 100644
--- a/ospf6d/ospf6_asbr.c
+++ b/ospf6d/ospf6_asbr.c
@@ -81,7 +81,7 @@
                            route->path.origin.id, ospf6->router_id,
                            ospf6->lsdb);
 
-  if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+  if (IS_OSPF6_DEBUG_ASBR || IS_OSPF6_DEBUG_ORIGINATE (AS_EXTERNAL))
     {
       prefix2str (&route->prefix, buf, sizeof (buf));
       zlog_info ("Originate AS-External-LSA for %s", buf);
@@ -175,19 +175,19 @@
   external = (struct ospf6_as_external_lsa *)
     OSPF6_LSA_HEADER_END (lsa->header);
 
-  if (IS_OSPF6_DEBUG_ASBR)
+  if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
     zlog_info ("Calculate AS-External route for %s", lsa->name);
 
   if (lsa->header->adv_router == ospf6->router_id)
     {
-      if (IS_OSPF6_DEBUG_ASBR)
+      if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
         zlog_info ("Ignore self-originated AS-External-LSA");
       return;
     }
 
   if (OSPF6_ASBR_METRIC (external) == LS_INFINITY)
     {
-      if (IS_OSPF6_DEBUG_ASBR)
+      if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
         zlog_info ("Ignore LSA with LSInfinity Metric");
       return;
     }
@@ -196,7 +196,7 @@
   asbr_entry = ospf6_route_lookup (&asbr_id, ospf6->brouter_table);
   if (asbr_entry == NULL)
     {
-      if (IS_OSPF6_DEBUG_ASBR)
+      if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
         {
           prefix2str (&asbr_id, buf, sizeof (buf));
           zlog_info ("ASBR entry not found: %s", buf);
@@ -234,7 +234,7 @@
   for (i = 0; i < OSPF6_MULTI_PATH_LIMIT; i++)
     ospf6_nexthop_copy (&route->nexthop[i], &asbr_entry->nexthop[i]);
 
-  if (IS_OSPF6_DEBUG_ASBR)
+  if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
     {
       prefix2str (&route->prefix, buf, sizeof (buf));
       zlog_info ("AS-External route add: %s", buf);
@@ -254,12 +254,12 @@
   external = (struct ospf6_as_external_lsa *)
     OSPF6_LSA_HEADER_END (lsa->header);
 
-  if (IS_OSPF6_DEBUG_ASBR)
+  if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
     zlog_info ("Withdraw AS-External route for %s", lsa->name);
 
   if (lsa->header->adv_router == ospf6->router_id)
     {
-      if (IS_OSPF6_DEBUG_ASBR)
+      if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
         zlog_info ("Ignore self-originated AS-External-LSA");
       return;
     }
@@ -272,7 +272,7 @@
   route = ospf6_route_lookup (&prefix, ospf6->route_table);
   if (route == NULL)
     {
-      if (IS_OSPF6_DEBUG_ASBR)
+      if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
         {
           prefix2str (&prefix, buf, sizeof (buf));
           zlog_info ("AS-External route %s not found", buf);
@@ -293,7 +293,7 @@
       if (route->path.origin.adv_router != lsa->header->adv_router)
         continue;
 
-      if (IS_OSPF6_DEBUG_ASBR)
+      if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
         {
           prefix2str (&route->prefix, buf, sizeof (buf));
           zlog_info ("AS-External route remove: %s", buf);
@@ -310,7 +310,7 @@
   u_int16_t type;
   u_int32_t router;
 
-  if (IS_OSPF6_DEBUG_ASBR)
+  if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
     {
       ospf6_linkstate_prefix2str (&asbr_entry->prefix, buf, sizeof (buf));
       zlog_info ("New ASBR %s found", buf);
@@ -325,7 +325,7 @@
         ospf6_asbr_lsa_add (lsa);
     }
 
-  if (IS_OSPF6_DEBUG_ASBR)
+  if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
     {
       ospf6_linkstate_prefix2str (&asbr_entry->prefix, buf, sizeof (buf));
       zlog_info ("Calculation for new ASBR %s done", buf);
@@ -340,7 +340,7 @@
   u_int16_t type;
   u_int32_t router;
 
-  if (IS_OSPF6_DEBUG_ASBR)
+  if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
     {
       ospf6_linkstate_prefix2str (&asbr_entry->prefix, buf, sizeof (buf));
       zlog_info ("ASBR %s disappeared", buf);
@@ -352,7 +352,7 @@
        lsa; lsa = ospf6_lsdb_type_router_next (type, router, lsa))
     ospf6_asbr_lsa_remove (lsa);
 
-  if (IS_OSPF6_DEBUG_ASBR)
+  if (IS_OSPF6_DEBUG_EXAMIN (AS_EXTERNAL))
     {
       ospf6_linkstate_prefix2str (&asbr_entry->prefix, buf, sizeof (buf));
       zlog_info ("Calculation for old ASBR %s done", buf);
diff --git a/ospf6d/ospf6_flood.c b/ospf6d/ospf6_flood.c
index ec5c1c6..e9ba52b 100644
--- a/ospf6d/ospf6_flood.c
+++ b/ospf6d/ospf6_flood.c
@@ -25,6 +25,7 @@
 #include "thread.h"
 #include "linklist.h"
 #include "vty.h"
+#include "command.h"
 
 #include "ospf6d.h"
 #include "ospf6_proto.h"
@@ -41,6 +42,8 @@
 
 #include "ospf6_flood.h"
 
+unsigned char conf_debug_ospf6_flooding;
+
 struct ospf6_lsdb *
 ospf6_get_scoped_lsdb (struct ospf6_lsa *lsa)
 {
@@ -99,7 +102,7 @@
      suppress this update of the LSA */
   if (old && ! OSPF6_LSA_IS_DIFFER (lsa, old))
     {
-      if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+      if (IS_OSPF6_DEBUG_ORIGINATE_TYPE (lsa->header->type))
         zlog_info ("Suppress updating LSA: %s", lsa->name);
       ospf6_lsa_delete (lsa);
       return;
@@ -112,7 +115,8 @@
   lsa->refresh = thread_add_timer (master, ospf6_lsa_refresh, lsa,
                                    LS_REFRESH_TIME);
 
-  if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+  if (IS_OSPF6_DEBUG_LSA_TYPE (lsa->header->type) ||
+      IS_OSPF6_DEBUG_ORIGINATE_TYPE (lsa->header->type))
     {
       zlog_info ("LSA Originate:");
       ospf6_lsa_header_print (lsa);
@@ -185,14 +189,14 @@
 
   /* The LSA must be on the retrans-list of a neighbor. It means
      the "lsa" is a copied one, and we have to decrement the
-     retransmission count of the original one (instead of "lsa"'s).
+     retransmission count of the original one (instead of this "lsa"'s).
      In order to find the original LSA, first we have to find
      appropriate LSDB that have the original LSA. */
   lsdb = ospf6_get_scoped_lsdb (lsa);
 
   /* Find the original LSA of which the retrans_count should be decremented */
   orig = ospf6_lsdb_lookup (lsa->header->type, lsa->header->id,
-                           lsa->header->adv_router, lsdb);
+                            lsa->header->adv_router, lsdb);
   if (orig)
     {
       orig->retrans_count--;
@@ -207,7 +211,8 @@
   struct ospf6_lsa *old;
   struct timeval now;
 
-  if (IS_OSPF6_DEBUG_LSA (RECV) || IS_OSPF6_DEBUG_LSA (DATABASE))
+  if (IS_OSPF6_DEBUG_LSA_TYPE (lsa->header->type) ||
+      IS_OSPF6_DEBUG_EXAMIN_TYPE (lsa->header->type))
     zlog_info ("Install LSA: %s", lsa->name);
 
   /* Remove the old instance from all neighbors' Link state
@@ -244,22 +249,27 @@
   struct ospf6_neighbor *on;
   struct ospf6_lsa *req;
   int retrans_added = 0;
+  int is_debug = 0;
 
-  if (IS_OSPF6_DEBUG_LSA (SEND))
-    zlog_info ("Flooding on %s: %s", oi->interface->name, lsa->name);
+  if (IS_OSPF6_DEBUG_FLOODING ||
+      IS_OSPF6_DEBUG_FLOOD_TYPE (lsa->header->type))
+    {
+      is_debug++;
+      zlog_info ("Flooding on %s: %s", oi->interface->name, lsa->name);
+    }
 
   /* (1) For each neighbor */
   for (node = listhead (oi->neighbor_list); node; nextnode (node))
     {
       on = (struct ospf6_neighbor *) getdata (node);
 
-      if (IS_OSPF6_DEBUG_LSA (SEND))
+      if (is_debug)
         zlog_info ("To neighbor %s", on->name);
 
       /* (a) if neighbor state < Exchange, examin next */
       if (on->state < OSPF6_NEIGHBOR_EXCHANGE)
         {
-          if (IS_OSPF6_DEBUG_LSA (SEND))
+          if (is_debug)
             zlog_info ("Neighbor state less than ExChange, next neighbor");
           continue;
         }
@@ -267,14 +277,14 @@
       /* (b) if neighbor not yet Full, check request-list */
       if (on->state != OSPF6_NEIGHBOR_FULL)
         {
-          if (IS_OSPF6_DEBUG_LSA (SEND))
+          if (is_debug)
             zlog_info ("Neighbor not yet Full");
 
           req = ospf6_lsdb_lookup (lsa->header->type, lsa->header->id,
                                    lsa->header->adv_router, on->request_list);
           if (req == NULL)
             {
-              if (IS_OSPF6_DEBUG_LSA (SEND))
+              if (is_debug)
                 zlog_info ("Not on request-list for this neighbor");
               /* fall through */
             }
@@ -283,7 +293,7 @@
               /* If new LSA less recent, examin next neighbor */
               if (ospf6_lsa_compare (lsa, req) > 0)
                 {
-                  if (IS_OSPF6_DEBUG_LSA (SEND))
+                  if (is_debug)
                     zlog_info ("Requesting is newer, next neighbor");
                   continue;
                 }
@@ -292,7 +302,7 @@
                  examin next neighbor */
               if (ospf6_lsa_compare (lsa, req) == 0)
                 {
-                  if (IS_OSPF6_DEBUG_LSA (SEND))
+                  if (is_debug)
                     zlog_info ("Requesting the same, remove it, next neighbor");
                   ospf6_lsdb_remove (req, on->request_list);
                   continue;
@@ -301,7 +311,7 @@
               /* If the new LSA is more recent, delete from request-list */
               if (ospf6_lsa_compare (lsa, req) < 0)
                 {
-                  if (IS_OSPF6_DEBUG_LSA (SEND))
+                  if (is_debug)
                     zlog_info ("Received is newer, remove requesting");
                   ospf6_lsdb_remove (req, on->request_list);
                   /* fall through */
@@ -313,13 +323,13 @@
          examin next neighbor */
       if (from == on)
         {
-          if (IS_OSPF6_DEBUG_LSA (SEND))
+          if (is_debug)
             zlog_info ("Received is from the neighbor, next neighbor");
           continue;
         }
 
       /* (d) add retrans-list, schedule retransmission */
-      if (IS_OSPF6_DEBUG_LSA (SEND))
+      if (is_debug)
         zlog_info ("Add retrans-list of this neighbor");
       ospf6_increment_retrans_count (lsa);
       ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list);
@@ -333,7 +343,7 @@
   /* (2) examin next interface if not added to retrans-list */
   if (retrans_added == 0)
     {
-      if (IS_OSPF6_DEBUG_LSA (SEND))
+      if (is_debug)
         zlog_info ("No retransmission scheduled, next interface");
       return;
     }
@@ -343,7 +353,7 @@
   if (from && from->ospf6_if == oi &&
       (from->router_id == oi->drouter || from->router_id == oi->bdrouter))
     {
-      if (IS_OSPF6_DEBUG_LSA (SEND))
+      if (is_debug)
         zlog_info ("Received is from the I/F's DR or BDR, next interface");
       return;
     }
@@ -352,13 +362,13 @@
      and the interface state is BDR, examin next interface */
   if (from && from->ospf6_if == oi && oi->state == OSPF6_INTERFACE_BDR)
     {
-      if (IS_OSPF6_DEBUG_LSA (SEND))
+      if (is_debug)
         zlog_info ("Received is from the I/F, itself BDR, next interface");
       return;
     }
 
   /* (5) flood the LSA out the interface. */
-  if (IS_OSPF6_DEBUG_LSA (SEND))
+  if (is_debug)
     zlog_info ("Schedule flooding for the interface");
   if (if_is_broadcast (oi->interface))
     {
@@ -451,7 +461,8 @@
                                lsa->header->adv_router, on->retrans_list);
       if (rem && ! ospf6_lsa_compare (rem, lsa))
         {
-          if (IS_OSPF6_DEBUG_LSA (DATABASE))
+          if (IS_OSPF6_DEBUG_FLOODING ||
+              IS_OSPF6_DEBUG_FLOOD_TYPE (lsa->header->type))
             zlog_info ("Remove %s from retrans_list of %s",
                        rem->name, on->name);
           ospf6_decrement_retrans_count (rem);
@@ -522,6 +533,11 @@
                                 struct ospf6_neighbor *from)
 {
   struct ospf6_interface *oi;
+  int is_debug = 0;
+
+  if (IS_OSPF6_DEBUG_FLOODING ||
+      IS_OSPF6_DEBUG_FLOOD_TYPE (lsa->header->type))
+    is_debug++;
 
   assert (from && from->ospf6_if);
   oi = from->ospf6_if;
@@ -530,7 +546,7 @@
      No acknowledgement sent. */
   if (CHECK_FLAG (lsa->flag, OSPF6_LSA_FLOODBACK))
     {
-      if (IS_OSPF6_DEBUG_LSA (RECV))
+      if (is_debug)
         zlog_info ("No acknowledgement (BDR & FloodBack)");
       return;
     }
@@ -543,7 +559,7 @@
     {
       if (oi->drouter == from->router_id)
         {
-          if (IS_OSPF6_DEBUG_LSA (RECV))
+          if (is_debug)
             zlog_info ("Delayed acknowledgement (BDR & MoreRecent & from DR)");
           /* Delayed acknowledgement */
           ospf6_lsdb_add (ospf6_lsa_copy (lsa), oi->lsack_list);
@@ -553,7 +569,7 @@
         }
       else
         {
-          if (IS_OSPF6_DEBUG_LSA (RECV))
+          if (is_debug)
             zlog_info ("No acknowledgement (BDR & MoreRecent & ! from DR)");
         }
       return;
@@ -567,7 +583,7 @@
     {
       if (oi->drouter == from->router_id)
         {
-          if (IS_OSPF6_DEBUG_LSA (RECV))
+          if (is_debug)
             zlog_info ("Delayed acknowledgement (BDR & Duplicate & ImpliedAck & from DR)");
           /* Delayed acknowledgement */
           ospf6_lsdb_add (ospf6_lsa_copy (lsa), oi->lsack_list);
@@ -577,7 +593,7 @@
         }
       else
         {
-          if (IS_OSPF6_DEBUG_LSA (RECV))
+          if (is_debug)
             zlog_info ("No acknowledgement (BDR & Duplicate & ImpliedAck & ! from DR)");
         }
       return;
@@ -588,7 +604,7 @@
   if (CHECK_FLAG (lsa->flag, OSPF6_LSA_DUPLICATE) &&
       ! CHECK_FLAG (lsa->flag, OSPF6_LSA_IMPLIEDACK))
     {
-      if (IS_OSPF6_DEBUG_LSA (RECV))
+      if (is_debug)
         zlog_info ("Direct acknowledgement (BDR & Duplicate)");
       ospf6_lsdb_add (ospf6_lsa_copy (lsa), from->lsack_list);
       if (from->thread_send_lsack == NULL)
@@ -609,6 +625,11 @@
                                 struct ospf6_neighbor *from)
 {
   struct ospf6_interface *oi;
+  int is_debug = 0;
+
+  if (IS_OSPF6_DEBUG_FLOODING ||
+      IS_OSPF6_DEBUG_FLOOD_TYPE (lsa->header->type))
+    is_debug++;
 
   assert (from && from->ospf6_if);
   oi = from->ospf6_if;
@@ -617,7 +638,7 @@
      No acknowledgement sent. */
   if (CHECK_FLAG (lsa->flag, OSPF6_LSA_FLOODBACK))
     {
-      if (IS_OSPF6_DEBUG_LSA (RECV))
+      if (is_debug)
         zlog_info ("No acknowledgement (AllOther & FloodBack)");
       return;
     }
@@ -626,7 +647,7 @@
      back out receiving interface. Delayed acknowledgement sent. */
   if (ismore_recent < 0)
     {
-      if (IS_OSPF6_DEBUG_LSA (RECV))
+      if (is_debug)
         zlog_info ("Delayed acknowledgement (AllOther & MoreRecent)");
       /* Delayed acknowledgement */
       ospf6_lsdb_add (ospf6_lsa_copy (lsa), oi->lsack_list);
@@ -641,7 +662,7 @@
   if (CHECK_FLAG (lsa->flag, OSPF6_LSA_DUPLICATE) &&
       CHECK_FLAG (lsa->flag, OSPF6_LSA_IMPLIEDACK))
     {
-      if (IS_OSPF6_DEBUG_LSA (RECV))
+      if (is_debug)
         zlog_info ("No acknowledgement (AllOther & Duplicate & ImpliedAck)");
       return;
     }
@@ -651,7 +672,7 @@
   if (CHECK_FLAG (lsa->flag, OSPF6_LSA_DUPLICATE) &&
       ! CHECK_FLAG (lsa->flag, OSPF6_LSA_IMPLIEDACK))
     {
-      if (IS_OSPF6_DEBUG_LSA (RECV))
+      if (is_debug)
         zlog_info ("Direct acknowledgement (AllOther & Duplicate)");
       ospf6_lsdb_add (ospf6_lsa_copy (lsa), from->lsack_list);
       if (from->thread_send_lsack == NULL)
@@ -733,6 +754,7 @@
   struct ospf6_lsa *new = NULL, *old = NULL, *rem = NULL;
   int ismore_recent;
   unsigned short cksum;
+  int is_debug = 0;
 
   ismore_recent = 1;
   assert (from);
@@ -740,8 +762,10 @@
   /* make lsa structure for received lsa */
   new = ospf6_lsa_create (lsa_header);
 
-  if (IS_OSPF6_DEBUG_LSA (RECV))
+  if (IS_OSPF6_DEBUG_FLOODING ||
+      IS_OSPF6_DEBUG_FLOOD_TYPE (new->header->type))
     {
+      is_debug++;
       zlog_info ("LSA Receive from %s", from->name);
       ospf6_lsa_header_print (new);
     }
@@ -750,7 +774,7 @@
   cksum = ntohs (new->header->checksum);
   if (ntohs (ospf6_lsa_checksum (new->header)) != cksum)
     {
-      if (IS_OSPF6_DEBUG_LSA (RECV))
+      if (is_debug)
         zlog_info ("Wrong LSA Checksum, discard");
       ospf6_lsa_delete (new);
       return;
@@ -761,7 +785,7 @@
   if (IS_AREA_STUB (from->ospf6_if->area) &&
       OSPF6_LSA_SCOPE (new->header->type) == OSPF6_SCOPE_AS)
     {
-      if (IS_OSPF6_DEBUG_LSA (RECV))
+      if (is_debug)
         zlog_info ("AS-External-LSA (or AS-scope LSA) in stub area, discard");
       ospf6_lsa_delete (new);
       return;
@@ -783,7 +807,7 @@
       new->lsdb = from->ospf6_if->area->ospf6->lsdb;
       break;
     default:
-      if (IS_OSPF6_DEBUG_LSA (RECV))
+      if (is_debug)
         zlog_info ("LSA has reserved scope, discard");
       ospf6_lsa_delete (new);
       return;
@@ -794,7 +818,7 @@
   if (ospf6_is_maxage_lsa_drop (new, from))
     {
       /* log */
-      if (IS_OSPF6_DEBUG_LSA (RECV))
+      if (is_debug)
         zlog_info ("Drop MaxAge LSA with direct acknowledgement.");
 
       /* a) Acknowledge back to neighbor (Direct acknowledgement, 13.5) */
@@ -817,7 +841,7 @@
       ismore_recent = ospf6_lsa_compare (new, old);
       if (ntohl (new->header->seqnum) == ntohl (old->header->seqnum))
         {
-          if (IS_OSPF6_DEBUG_LSA (RECV))
+          if (is_debug)
             zlog_info ("Received is duplicated LSA");
           SET_FLAG (new->flag, OSPF6_LSA_DUPLICATE);
         }
@@ -837,7 +861,7 @@
           timersub (&now, &old->installed, &res);
           if (res.tv_sec < MIN_LS_ARRIVAL)
             {
-              if (IS_OSPF6_DEBUG_LSA (RECV) || IS_OSPF6_DEBUG_LSA (TIMER))
+              if (is_debug)
                 zlog_info ("LSA can't be updated within MinLSArrival, discard");
               ospf6_lsa_delete (new);
               return;   /* examin next lsa */
@@ -846,7 +870,7 @@
 
       gettimeofday (&new->received, (struct timezone *) NULL);
 
-      if (IS_OSPF6_DEBUG_LSA (RECV))
+      if (is_debug)
         zlog_info ("Flood, Install, Possibly acknowledge the received LSA");
 
       /* (b) immediately flood and (c) remove from all retrans-list */
@@ -873,7 +897,7 @@
           /* Self-originated LSA (newer than ours) is received from
              another router. We have to make a new instance of the LSA
              or have to flush this LSA. */
-          if (IS_OSPF6_DEBUG_LSA (RECV))
+          if (is_debug)
             {
               zlog_info ("Newer instance of the self-originated LSA");
               zlog_info ("Schedule reorigination");
@@ -891,7 +915,7 @@
       /* if no database copy, should go above state (5) */
       assert (old);
 
-      if (IS_OSPF6_DEBUG_LSA (RECV))
+      if (is_debug)
         {
           zlog_info ("Received is not newer, on the neighbor's request-list");
           zlog_info ("BadLSReq, discard the received LSA");
@@ -907,7 +931,7 @@
   /* (7) if neither one is more recent */
   if (ismore_recent == 0)
     {
-      if (IS_OSPF6_DEBUG_LSA (RECV))
+      if (is_debug)
         zlog_info ("The same instance as database copy (neither recent)");
 
       /* (a) if on retrans-list, Treat this LSA as an Ack: Implied Ack */
@@ -915,7 +939,7 @@
                                new->header->adv_router, from->retrans_list);
       if (rem)
         {
-          if (IS_OSPF6_DEBUG_LSA (RECV))
+          if (is_debug)
             {
               zlog_info ("It is on the neighbor's retrans-list.");
               zlog_info ("Treat as an Implied acknowledgement");
@@ -925,7 +949,7 @@
           ospf6_lsdb_remove (rem, from->retrans_list);
         }
 
-      if (IS_OSPF6_DEBUG_LSA (RECV))
+      if (is_debug)
         zlog_info ("Possibly acknowledge and then discard");
 
       /* (b) possibly acknowledge */
@@ -944,7 +968,7 @@
       if (OSPF6_LSA_IS_MAXAGE (old) &&
           old->header->seqnum == htonl (MAX_SEQUENCE_NUMBER))
         {
-          if (IS_OSPF6_DEBUG_LSA (RECV))
+          if (is_debug)
             {
               zlog_info ("The LSA is in Seqnumber Wrapping");
               zlog_info ("MaxAge & MaxSeqNum, discard");
@@ -955,7 +979,7 @@
 
       /* Otherwise, Send database copy of this LSA to this neighbor */
         {
-          if (IS_OSPF6_DEBUG_LSA (RECV))
+          if (is_debug)
             {
               zlog_info ("Database copy is more recent.");
               zlog_info ("Send back directly and then discard");
@@ -975,4 +999,49 @@
 }
 
 
+DEFUN (debug_ospf6_flooding,
+       debug_ospf6_flooding_cmd,
+       "debug ospf6 flooding",
+       DEBUG_STR
+       OSPF6_STR
+       "Debug OSPFv3 flooding function\n"
+      )
+{
+  OSPF6_DEBUG_FLOODING_ON ();
+  return CMD_SUCCESS;
+}
+
+DEFUN (no_debug_ospf6_flooding,
+       no_debug_ospf6_flooding_cmd,
+       "no debug ospf6 flooding",
+       NO_STR
+       DEBUG_STR
+       OSPF6_STR
+       "Debug OSPFv3 flooding function\n"
+      )
+{
+  OSPF6_DEBUG_FLOODING_OFF ();
+  return CMD_SUCCESS;
+}
+
+int
+config_write_ospf6_debug_flood (struct vty *vty)
+{
+  if (IS_OSPF6_DEBUG_FLOODING)
+    vty_out (vty, "debug ospf6 flooding%s", VNL);
+  return 0;
+}
+
+void
+install_element_ospf6_debug_flood ()
+{
+  install_element (ENABLE_NODE, &debug_ospf6_flooding_cmd);
+  install_element (ENABLE_NODE, &no_debug_ospf6_flooding_cmd);
+  install_element (CONFIG_NODE, &debug_ospf6_flooding_cmd);
+  install_element (CONFIG_NODE, &no_debug_ospf6_flooding_cmd);
+}
+
+
+
+
 
diff --git a/ospf6d/ospf6_flood.h b/ospf6d/ospf6_flood.h
index e894e56..4851c14 100644
--- a/ospf6d/ospf6_flood.h
+++ b/ospf6d/ospf6_flood.h
@@ -22,6 +22,15 @@
 #ifndef OSPF6_FLOOD_H
 #define OSPF6_FLOOD_H
 
+/* Debug option */
+extern unsigned char conf_debug_ospf6_flooding;
+#define OSPF6_DEBUG_FLOODING_ON() \
+  (conf_debug_ospf6_flooding = 1)
+#define OSPF6_DEBUG_FLOODING_OFF() \
+  (conf_debug_ospf6_flooding = 0)
+#define IS_OSPF6_DEBUG_FLOODING \
+  (conf_debug_ospf6_flooding)
+
 /* Function Prototypes */
 struct ospf6_lsdb *ospf6_get_scoped_lsdb (struct ospf6_lsa *lsa);
 struct ospf6_lsdb *ospf6_get_scoped_lsdb_self (struct ospf6_lsa *lsa);
@@ -49,6 +58,9 @@
                         struct ospf6_lsa_header *header);
 void ospf6_install_lsa (struct ospf6_lsa *lsa);
 
+int config_write_ospf6_debug_flood (struct vty *vty);
+void install_element_ospf6_debug_flood ();
+
 #endif /* OSPF6_FLOOD_H */
 
 
diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c
index 52986e0..a8ea1d3 100644
--- a/ospf6d/ospf6_interface.c
+++ b/ospf6d/ospf6_interface.c
@@ -98,9 +98,6 @@
         break;
 
       default:
-        if (IS_OSPF6_DEBUG_LSA (RECV))
-          zlog_info ("Unknown LSA in Interface %s's lsdb",
-                     OSPF6_INTERFACE (lsa->lsdb->data)->interface->name);
         break;
     }
 }
@@ -143,8 +140,9 @@
   iobuflen = ospf6_iobuf_size (ifp->mtu6);
   if (oi->ifmtu > iobuflen)
     {
-      zlog_info ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
-                 ifp->name, iobuflen);
+      if (IS_OSPF6_DEBUG_INTERFACE)
+        zlog_info ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
+                   ifp->name, iobuflen);
       oi->ifmtu = iobuflen;
     }
 
@@ -275,8 +273,9 @@
   iobuflen = ospf6_iobuf_size (ifp->mtu6);
   if (oi->ifmtu > iobuflen)
     {
-      zlog_info ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
-                 ifp->name, iobuflen);
+      if (IS_OSPF6_DEBUG_INTERFACE)
+        zlog_info ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.",
+                   ifp->name, iobuflen);
       oi->ifmtu = iobuflen;
     }
 
@@ -355,11 +354,11 @@
       if (c->address->family != AF_INET6)
         continue;
 
-      CONTINUE_IF_ADDRESS_LINKLOCAL (c->address);
-      CONTINUE_IF_ADDRESS_UNSPECIFIED (c->address);
-      CONTINUE_IF_ADDRESS_LOOPBACK (c->address);
-      CONTINUE_IF_ADDRESS_V4COMPAT (c->address);
-      CONTINUE_IF_ADDRESS_V4MAPPED (c->address);
+      CONTINUE_IF_ADDRESS_LINKLOCAL (IS_OSPF6_DEBUG_INTERFACE, c->address);
+      CONTINUE_IF_ADDRESS_UNSPECIFIED (IS_OSPF6_DEBUG_INTERFACE, c->address);
+      CONTINUE_IF_ADDRESS_LOOPBACK (IS_OSPF6_DEBUG_INTERFACE, c->address);
+      CONTINUE_IF_ADDRESS_V4COMPAT (IS_OSPF6_DEBUG_INTERFACE, c->address);
+      CONTINUE_IF_ADDRESS_V4MAPPED (IS_OSPF6_DEBUG_INTERFACE, c->address);
 
       /* apply filter */
       if (oi->plist_name)
@@ -373,8 +372,9 @@
           ret = prefix_list_apply (plist, (void *) c->address);
           if (ret == PREFIX_DENY)
             {
-              zlog_info ("%s on %s filtered by prefix-list %s ",
-                         buf, oi->interface->name, oi->plist_name);
+              if (IS_OSPF6_DEBUG_INTERFACE)
+                zlog_info ("%s on %s filtered by prefix-list %s ",
+                           buf, oi->interface->name, oi->plist_name);
               continue;
             }
         }
diff --git a/ospf6d/ospf6_intra.c b/ospf6d/ospf6_intra.c
index 8383fd9..d707ee7 100644
--- a/ospf6d/ospf6_intra.c
+++ b/ospf6d/ospf6_intra.c
@@ -121,7 +121,7 @@
   oa = (struct ospf6_area *) THREAD_ARG (thread);
   oa->thread_router_lsa = NULL;
 
-  if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+  if (IS_OSPF6_DEBUG_ORIGINATE (ROUTER))
     zlog_info ("Originate Router-LSA for Area %s", oa->name);
 
   memset (buffer, 0, sizeof (buffer));
@@ -179,7 +179,7 @@
           if ((caddr_t) lsdesc == (caddr_t) router_lsa +
                                   sizeof (struct ospf6_router_lsa))
             {
-              if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+              if (IS_OSPF6_DEBUG_ORIGINATE (ROUTER))
                 zlog_info ("Size limit setting for Router-LSA too short");
               return 0;
             }
@@ -292,7 +292,7 @@
     }
   else
     {
-      if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+      if (IS_OSPF6_DEBUG_ORIGINATE (ROUTER))
         zlog_info ("Nothing to describe in Router-LSA, suppress");
     }
 
@@ -377,7 +377,7 @@
       return 0;
     }
 
-  if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+  if (IS_OSPF6_DEBUG_ORIGINATE (NETWORK))
     zlog_info ("Originate Network-LSA for Interface %s", oi->interface->name);
 
   /* If none of neighbor is adjacent to us */
@@ -390,7 +390,7 @@
     }
   if (count == 0)
     {
-      if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+      if (IS_OSPF6_DEBUG_ORIGINATE (NETWORK))
         zlog_info ("Interface stub, ignore");
       if (old)
         ospf6_lsa_purge (old);
@@ -547,13 +547,13 @@
       return 0;
     }
 
-  if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+  if (IS_OSPF6_DEBUG_ORIGINATE (LINK))
     zlog_info ("Originate Link-LSA for Interface %s", oi->interface->name);
 
   /* can't make Link-LSA if linklocal address not set */
   if (oi->linklocal_addr == NULL)
     {
-      if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+      if (IS_OSPF6_DEBUG_ORIGINATE (LINK))
         zlog_info ("No Linklocal address on %s, defer originating",
                    oi->interface->name);
       if (old)
@@ -639,7 +639,7 @@
   inet_ntop (AF_INET, &intra_prefix_lsa->ref_adv_router,
              adv_router, sizeof (adv_router));
   vty_out (vty, "     Reference: %s Id: %s Adv: %s%s",
-           OSPF6_LSTYPE_NAME (intra_prefix_lsa->ref_type), id, adv_router,
+           ospf6_lstype_name (intra_prefix_lsa->ref_type), id, adv_router,
            VNL);
 
   start = (char *) intra_prefix_lsa + sizeof (struct ospf6_intra_prefix_lsa);
@@ -707,7 +707,7 @@
       return 0;
     }
 
-  if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+  if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
     zlog_info ("Originate Intra-Area-Prefix-LSA for area %s's stub prefix",
                oa->name);
 
@@ -730,7 +730,7 @@
 
       if (oi->state == OSPF6_INTERFACE_DOWN)
         {
-          if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+          if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
             zlog_info ("  Interface %s is down, ignore", oi->interface->name);
           continue;
         }
@@ -746,20 +746,20 @@
           oi->state != OSPF6_INTERFACE_POINTTOPOINT &&
           full_count != 0)
         {
-          if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+          if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
             zlog_info ("  Interface %s is not stub, ignore",
                        oi->interface->name);
           continue;
         }
 
-      if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+      if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
         zlog_info ("  Interface %s:", oi->interface->name);
 
       /* connected prefix to advertise */
       for (route = ospf6_route_head (oi->route_connected); route;
            route = ospf6_route_best_next (route))
         {
-          if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+          if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
             {
               prefix2str (&route->prefix, buf, sizeof (buf));
               zlog_info ("    include %s", buf);
@@ -796,7 +796,7 @@
 
   if (prefix_num == 0)
     {
-      if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+      if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
         zlog_info ("Quit to Advertise Intra-Prefix: no route to advertise");
       return 0;
     }
@@ -865,7 +865,7 @@
       return 0;
     }
 
-  if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+  if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
     zlog_info ("Originate Intra-Area-Prefix-LSA for interface %s's prefix",
                oi->interface->name);
 
@@ -882,7 +882,7 @@
 
   if (oi->state != OSPF6_INTERFACE_DR)
     {
-      if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+      if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
         zlog_info ("  Interface is not DR");
       if (old)
         ospf6_lsa_purge (old);
@@ -898,7 +898,7 @@
     }
   if (full_count == 0)
     {
-      if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+      if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
         zlog_info ("  Interface is stub");
       if (old)
         ospf6_lsa_purge (old);
@@ -915,7 +915,7 @@
       if (OSPF6_LSA_IS_MAXAGE (lsa))
         continue;
 
-      if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+      if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
         zlog_info ("  include prefix from %s", lsa->name);
 
       if (lsa->header->adv_router != oi->area->ospf6->router_id)
@@ -923,7 +923,7 @@
           on = ospf6_neighbor_lookup (lsa->header->adv_router, oi);
           if (on == NULL || on->state != OSPF6_NEIGHBOR_FULL)
             {
-              if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+              if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
                 zlog_info ("    Neighbor not found or not Full, ignore");
               continue;
             }
@@ -962,7 +962,7 @@
           route->path.area_id = oi->area->area_id;
           route->path.type = OSPF6_PATH_TYPE_INTRA;
 
-          if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+          if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
             {
               prefix2str (&route->prefix, buf, sizeof (buf));
               zlog_info ("    include %s", buf);
@@ -971,7 +971,7 @@
           ospf6_route_add (route, route_advertise);
           prefix_num--;
         }
-      if (current != end && IS_OSPF6_DEBUG_LSA (ORIGINATE))
+      if (current != end && IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
         zlog_info ("Trailing garbage in %s", lsa->name);
     }
 
@@ -995,7 +995,7 @@
 
   if (prefix_num == 0)
     {
-      if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+      if (IS_OSPF6_DEBUG_ORIGINATE (INTRA_PREFIX))
         zlog_info ("Quit to Advertise Intra-Prefix: no route to advertise");
       return 0;
     }
@@ -1039,7 +1039,7 @@
   if (OSPF6_LSA_IS_MAXAGE (lsa))
     return;
 
-  if (IS_OSPF6_DEBUG_ROUTE (INTRA))
+  if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX))
     zlog_info ("%s found", lsa->name);
 
   oa = OSPF6_AREA (lsa->lsdb->data);
@@ -1054,7 +1054,7 @@
                             intra_prefix_lsa->ref_id, &ls_prefix);
   else
     {
-      if (IS_OSPF6_DEBUG_ROUTE (INTRA))
+      if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX))
         zlog_info ("Unknown reference LS-type: %#hx",
                    ntohs (intra_prefix_lsa->ref_type));
       return;
@@ -1063,7 +1063,7 @@
   ls_entry = ospf6_route_lookup (&ls_prefix, oa->spf_table);
   if (ls_entry == NULL)
     {
-      if (IS_OSPF6_DEBUG_ROUTE (INTRA))
+      if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX))
         {
           ospf6_linkstate_prefix2str (&ls_prefix, buf, sizeof (buf));
           zlog_info ("LS entry does not exist: %s", buf);
@@ -1105,7 +1105,7 @@
            i < OSPF6_MULTI_PATH_LIMIT; i++)
         ospf6_nexthop_copy (&route->nexthop[i], &ls_entry->nexthop[i]);
 
-      if (IS_OSPF6_DEBUG_ROUTE (INTRA))
+      if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX))
         {
           prefix2str (&route->prefix, buf, sizeof (buf));
           zlog_info ("  add %s", buf);
@@ -1115,7 +1115,7 @@
       prefix_num--;
     }
 
-  if (current != end && IS_OSPF6_DEBUG_ROUTE (INTRA))
+  if (current != end && IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX))
     zlog_info ("Trailing garbage ignored");
 }
 
@@ -1131,7 +1131,7 @@
   char *start, *current, *end;
   char buf[64];
 
-  if (IS_OSPF6_DEBUG_ROUTE (INTRA))
+  if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX))
     zlog_info ("%s disappearing", lsa->name);
 
   oa = OSPF6_AREA (lsa->lsdb->data);
@@ -1176,7 +1176,7 @@
               route->path.origin.adv_router != lsa->header->adv_router)
             continue;
 
-          if (IS_OSPF6_DEBUG_ROUTE (INTRA))
+          if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX))
             {
               prefix2str (&route->prefix, buf, sizeof (buf));
               zlog_info ("remove %s", buf);
@@ -1185,7 +1185,7 @@
         }
     }
 
-  if (current != end && IS_OSPF6_DEBUG_ROUTE (INTRA))
+  if (current != end && IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX))
     zlog_info ("Trailing garbage ignored");
 }
 
@@ -1198,9 +1198,8 @@
   void (*hook_add) (struct ospf6_route *) = NULL;
   void (*hook_remove) (struct ospf6_route *) = NULL;
 
-  if (IS_OSPF6_DEBUG_ROUTE (INTRA))
-    zlog_info ("Intra-area routing table calculation for area %s",
-               oa->name);
+  if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX))
+    zlog_info ("Re-examin intra-routes for area %s", oa->name);
 
   hook_add = oa->route_table->hook_add;
   hook_remove = oa->route_table->hook_remove;
@@ -1241,9 +1240,8 @@
       route->flag = 0;
     }
 
-  if (IS_OSPF6_DEBUG_ROUTE (INTRA))
-    zlog_info ("Intra-area routing table calculation for area %s: Done",
-               oa->name);
+  if (IS_OSPF6_DEBUG_EXAMIN (INTRA_PREFIX))
+    zlog_info ("Re-examin intra-routes for area %s: Done", oa->name);
 }
 
 void
diff --git a/ospf6d/ospf6_lsa.c b/ospf6d/ospf6_lsa.c
index 6c8341f..6cc6f4d 100644
--- a/ospf6d/ospf6_lsa.c
+++ b/ospf6d/ospf6_lsa.c
@@ -24,6 +24,8 @@
 /* Include other stuffs */
 #include "log.h"
 #include "linklist.h"
+#include "vector.h"
+#include "vty.h"
 #include "command.h"
 #include "memory.h"
 #include "thread.h"
@@ -41,27 +43,85 @@
 #include "ospf6_flood.h"
 #include "ospf6d.h"
 
-unsigned char conf_debug_ospf6_lsa = 0;
+vector ospf6_lsa_handler_vector;
 
-struct ospf6_lsa_handler *ospf6_lsa_handler[OSPF6_LSTYPE_SIZE];
+int
+ospf6_unknown_lsa_show (struct vty *vty, struct ospf6_lsa *lsa)
+{
+  u_char *start, *end, *current;
+  char byte[4];
 
-char *ospf6_lstype_str[OSPF6_LSTYPE_SIZE] =
-  {"Unknown", "Router", "Network", "Inter-Prefix", "Inter-Router",
-   "AS-External", "Group-Membership", "Type-7", "Link", "Intra-Prefix"};
+  start = (char *) lsa->header + sizeof (struct ospf6_lsa_header);
+  end = (char *) lsa->header + ntohs (lsa->header->length);
+
+  vty_out (vty, "        Unknown contents:%s", VNL);
+  for (current = start; current < end; current ++)
+    {
+      if ((current - start) % 16 == 0)
+        vty_out (vty, "%s        ", VNL);
+      else if ((current - start) % 4 == 0)
+        vty_out (vty, " ");
+
+      snprintf (byte, sizeof (byte), "%02x", *current);
+      vty_out (vty, "%s", byte);
+    }
+
+  vty_out (vty, "%s%s", VNL, VNL);
+  return 0;
+}
+
+struct ospf6_lsa_handler unknown_handler =
+{
+  OSPF6_LSTYPE_UNKNOWN,
+  "Unknown",
+  ospf6_unknown_lsa_show,
+  OSPF6_LSA_DEBUG,
+};
+
+void
+ospf6_install_lsa_handler (struct ospf6_lsa_handler *handler)
+{
+  /* type in handler is host byte order */
+  int index = handler->type & OSPF6_LSTYPE_FCODE_MASK;
+  vector_set_index (ospf6_lsa_handler_vector, index, handler);
+}
+
+struct ospf6_lsa_handler *
+ospf6_get_lsa_handler (u_int16_t type)
+{
+  struct ospf6_lsa_handler *handler = NULL;
+  int index = ntohs (type) & OSPF6_LSTYPE_FCODE_MASK;
+
+  if (index >= vector_max (ospf6_lsa_handler_vector))
+    handler = &unknown_handler;
+  else
+    handler = vector_slot (ospf6_lsa_handler_vector, index);
+
+  return handler;
+}
 
 char *
 ospf6_lstype_name (u_int16_t type)
 {
   static char buf[8];
-  int index = OSPF6_LSTYPE_INDEX (type);
+  struct ospf6_lsa_handler *handler;
 
-  if (ospf6_lsa_handler[index])
-    return ospf6_lsa_handler[index]->name;
+  handler = ospf6_get_lsa_handler (type);
+  if (handler && handler != &unknown_handler)
+    return handler->name;
 
   snprintf (buf, sizeof (buf), "0x%04hx", ntohs (type));
   return buf;
 }
 
+u_char
+ospf6_lstype_debug (u_int16_t type)
+{
+  struct ospf6_lsa_handler *handler;
+  handler = ospf6_get_lsa_handler (type);
+  return handler->debug;
+}
+
 /* RFC2328: Section 13.2 */
 int
 ospf6_lsa_is_differ (struct ospf6_lsa *lsa1,
@@ -170,7 +230,7 @@
 ospf6_lsa_premature_aging (struct ospf6_lsa *lsa)
 {
   /* log */
-  if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+  if (IS_OSPF6_DEBUG_LSA_TYPE (lsa->header->type))
     zlog_info ("LSA: Premature aging: %s", lsa->name);
 
   THREAD_OFF (lsa->expire);
@@ -241,7 +301,7 @@
   inet_ntop (AF_INET, &lsa->header->adv_router, adv_router,
              sizeof (adv_router));
   snprintf (buf, size, "[%s Id:%s Adv:%s]",
-            OSPF6_LSTYPE_NAME (lsa->header->type), id, adv_router);
+            ospf6_lstype_name (lsa->header->type), id, adv_router);
   return buf;
 }
 
@@ -253,7 +313,7 @@
   inet_ntop (AF_INET, &header->adv_router, adv_router,
              sizeof (adv_router));
   zlog_info ("    [%s Id:%s Adv:%s]",
-             OSPF6_LSTYPE_NAME (header->type), id, adv_router);
+             ospf6_lstype_name (header->type), id, adv_router);
   zlog_info ("    Age: %4hu SeqNum: %#08lx Cksum: %04hx Len: %d",
              ntohs (header->age), (u_long) ntohl (header->seqnum),
              ntohs (header->checksum), ntohs (header->length));
@@ -293,7 +353,7 @@
   timerstring (&res, duration, sizeof (duration));
 
   vty_out (vty, "%-12s %-15s %-15s %4hu %8lx %04hx %4hu %8s%s",
-           OSPF6_LSTYPE_NAME (lsa->header->type),
+           ospf6_lstype_name (lsa->header->type),
            id, adv_router, ospf6_lsa_age_current (lsa),
            (u_long) ntohl (lsa->header->seqnum),
            ntohs (lsa->header->checksum), ntohs (lsa->header->length),
@@ -340,7 +400,7 @@
 
   vty_out (vty, "%s", VNL);
   vty_out (vty, "Age: %4hu Type: %s%s", ospf6_lsa_age_current (lsa),
-           OSPF6_LSTYPE_NAME (lsa->header->type), VNL);
+           ospf6_lstype_name (lsa->header->type), VNL);
   vty_out (vty, "Link State ID: %s%s", id, VNL);
   vty_out (vty, "Advertising Router: %s%s", adv_router, VNL);
   vty_out (vty, "LS Sequence Number: %#010lx%s",
@@ -358,7 +418,7 @@
 ospf6_lsa_show (struct vty *vty, struct ospf6_lsa *lsa)
 {
   char adv_router[64], id[64];
-  int index;
+  struct ospf6_lsa_handler *handler;
 
   assert (lsa && lsa->header);
 
@@ -367,7 +427,7 @@
              adv_router, sizeof (adv_router));
 
   vty_out (vty, "Age: %4hu Type: %s%s", ospf6_lsa_age_current (lsa),
-           OSPF6_LSTYPE_NAME (lsa->header->type), VNL);
+           ospf6_lstype_name (lsa->header->type), VNL);
   vty_out (vty, "Link State ID: %s%s", id, VNL);
   vty_out (vty, "Advertising Router: %s%s", adv_router, VNL);
   vty_out (vty, "LS Sequence Number: %#010lx%s",
@@ -376,14 +436,10 @@
            ntohs (lsa->header->checksum),
            ntohs (lsa->header->length), VNL);
 
-  index = OSPF6_LSTYPE_INDEX (lsa->header->type);
-  if (ospf6_lsa_handler[index]->show)
-    (*ospf6_lsa_handler[index]->show) (vty, lsa);
-  else
-    {
-      ospf6_lsa_show_dump (vty, lsa);
-      vty_out (vty, "%sUnknown LSA type ...%s", VNL, VNL);
-    }
+  handler = ospf6_get_lsa_handler (lsa->header->type);
+  if (handler->show == NULL)
+    handler = &unknown_handler;
+  (*handler->show) (vty, lsa);
 
   vty_out (vty, "%s", VNL);
 }
@@ -420,10 +476,6 @@
   /* calculate birth of this lsa */
   ospf6_lsa_age_set (lsa);
 
-  if (IS_OSPF6_DEBUG_LSA (MEMORY))
-    zlog_info ("Create LSA Memory: %s (%p/%p)",
-               lsa->name, lsa, lsa->header);
-
   return lsa;
 }
 
@@ -455,10 +507,6 @@
   /* calculate birth of this lsa */
   ospf6_lsa_age_set (lsa);
 
-  if (IS_OSPF6_DEBUG_LSA (MEMORY))
-    zlog_info ("Create LSA (Header-only) Memory: %s (%p/%p)",
-               lsa->name, lsa, lsa->header);
-
   return lsa;
 }
 
@@ -471,11 +519,6 @@
   THREAD_OFF (lsa->expire);
   THREAD_OFF (lsa->refresh);
 
-  if (IS_OSPF6_DEBUG_LSA (MEMORY))
-    zlog_info ("Delete LSA %s Memory: %s (%p/%p)",
-               (CHECK_FLAG (lsa->flag, OSPF6_LSA_HEADERONLY) ?
-                "(Header-only) " : ""), lsa->name, lsa, lsa->header);
-
   /* do free */
   XFREE (MTYPE_OSPF6_LSA, lsa->header);
   XFREE (MTYPE_OSPF6_LSA, lsa);
@@ -486,9 +529,6 @@
 {
   struct ospf6_lsa *copy = NULL;
 
-  if (IS_OSPF6_DEBUG_LSA (MEMORY))
-    zlog_info ("Create LSA Copy from %s", lsa->name);
-
   ospf6_lsa_age_current (lsa);
   if (CHECK_FLAG (lsa->flag, OSPF6_LSA_HEADERONLY))
     copy = ospf6_lsa_create_headeronly (lsa->header);
@@ -542,7 +582,7 @@
 
   lsa->expire = (struct thread *) NULL;
 
-  if (IS_OSPF6_DEBUG_LSA (TIMER))
+  if (IS_OSPF6_DEBUG_LSA_TYPE (lsa->header->type))
     {
       zlog_info ("LSA Expire:");
       ospf6_lsa_header_print (lsa);
@@ -555,8 +595,6 @@
   ospf6_flood (NULL, lsa);
 
   /* reinstall lsa */
-  if (IS_OSPF6_DEBUG_LSA (DATABASE))
-    zlog_info ("Reinstall MaxAge %s", lsa->name);
   ospf6_install_lsa (lsa);
 
   /* schedule maxage remover */
@@ -582,7 +620,7 @@
                             old->header->adv_router, lsdb_self);
   if (self == NULL)
     {
-      if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+      if (IS_OSPF6_DEBUG_LSA_TYPE (old->header->type))
         zlog_info ("Refresh: could not find self LSA, flush %s", old->name);
       ospf6_lsa_premature_aging (old);
       return 0;
@@ -603,7 +641,7 @@
   /* store it in the LSDB for self-originated LSAs */
   ospf6_lsdb_add (ospf6_lsa_copy (new), lsdb_self);
 
-  if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+  if (IS_OSPF6_DEBUG_LSA_TYPE (new->header->type))
     {
       zlog_info ("LSA Refresh:");
       ospf6_lsa_header_print (new);
@@ -661,211 +699,299 @@
   return (lsa_header->checksum);
 }
 
-int
-ospf6_unknown_lsa_show (struct vty *vty, struct ospf6_lsa *lsa)
-{
-  u_char *start, *end, *current;
-  char byte[4];
-
-  start = (char *) lsa->header + sizeof (struct ospf6_lsa_header);
-  end = (char *) lsa->header + ntohs (lsa->header->length);
-
-  vty_out (vty, "        Unknown contents:%s", VNL);
-  for (current = start; current < end; current ++)
-    {
-      if ((current - start) % 16 == 0)
-        vty_out (vty, "%s        ", VNL);
-      else if ((current - start) % 4 == 0)
-        vty_out (vty, " ");
-
-      snprintf (byte, sizeof (byte), "%02x", *current);
-      vty_out (vty, "%s", byte);
-    }
-
-  vty_out (vty, "%s%s", VNL, VNL);
-  return 0;
-}
-
-void
-ospf6_install_lsa_handler (struct ospf6_lsa_handler *handler)
-{
-  /* might need to adjust dynamic array length ... */
-  int index = OSPF6_LSTYPE_INDEX (htons (handler->type));
-  ospf6_lsa_handler[index] = handler;
-}
-
-struct ospf6_lsa_handler unknown_handler =
-{
-  OSPF6_LSTYPE_UNKNOWN,
-  "Unknown",
-  ospf6_unknown_lsa_show
-};
-
 void
 ospf6_lsa_init ()
 {
-  memset (ospf6_lsa_handler, 0, sizeof (ospf6_lsa_handler));
+  ospf6_lsa_handler_vector = vector_init (0);
   ospf6_install_lsa_handler (&unknown_handler);
 }
 
 
-
-DEFUN (debug_ospf6_lsa_sendrecv,
-       debug_ospf6_lsa_sendrecv_cmd,
-       "debug ospf6 lsa (send|recv|originate|timer|database|memory|all)",
-       DEBUG_STR
-       OSPF6_STR
-       "Debug Link State Advertisements (LSAs)\n"
-       "Debug Sending LSAs\n"
-       "Debug Receiving LSAs\n"
-       "Debug Originating LSAs\n"
-       "Debug Timer Event of LSAs\n"
-       "Debug LSA Database\n"
-       "Debug Memory of LSAs\n"
-       "Debug LSAs all\n"
-      )
+char *
+ospf6_lsa_handler_name (struct ospf6_lsa_handler *h)
 {
-  unsigned char level = 0;
+  static char buf[64];
+  int i, size = strlen (h->name);
 
-  if (argc)
+  if (h->name == "Unknown" &&
+      h->type != OSPF6_LSTYPE_UNKNOWN)
     {
-      if (! strncmp (argv[0], "s", 1))
-        level = OSPF6_DEBUG_LSA_SEND;
-      else if (! strncmp (argv[0], "r", 1))
-        level = OSPF6_DEBUG_LSA_RECV;
-      else if (! strncmp (argv[0], "o", 1))
-        level = OSPF6_DEBUG_LSA_ORIGINATE;
-      else if (! strncmp (argv[0], "t", 1))
-        level = OSPF6_DEBUG_LSA_TIMER;
-      else if (! strncmp (argv[0], "d", 1))
-        level = OSPF6_DEBUG_LSA_DATABASE;
-      else if (! strncmp (argv[0], "m", 1))
-        level = OSPF6_DEBUG_LSA_MEMORY;
-      else if (! strncmp (argv[0], "a", 1))
-        {
-          level = OSPF6_DEBUG_LSA_SEND | OSPF6_DEBUG_LSA_RECV |
-                  OSPF6_DEBUG_LSA_ORIGINATE | OSPF6_DEBUG_LSA_TIMER |
-                  OSPF6_DEBUG_LSA_DATABASE | OSPF6_DEBUG_LSA_MEMORY;
-        }
-    }
-  else
-    {
-      level = OSPF6_DEBUG_LSA_SEND | OSPF6_DEBUG_LSA_RECV |
-              OSPF6_DEBUG_LSA_ORIGINATE | OSPF6_DEBUG_LSA_TIMER;
+      snprintf (buf, sizeof (buf), "%#04hx", h->type);
+      return buf;
     }
 
-  OSPF6_DEBUG_LSA_ON (level);
-  return CMD_SUCCESS;
-}
-
-ALIAS (debug_ospf6_lsa_sendrecv,
-       debug_ospf6_lsa_cmd,
-       "debug ospf6 lsa",
-       NO_STR
-       DEBUG_STR
-       OSPF6_STR
-       "Debug Link State Advertisements (LSAs)\n"
-      );
-
-DEFUN (no_debug_ospf6_lsa_sendrecv,
-       no_debug_ospf6_lsa_sendrecv_cmd,
-       "no debug ospf6 lsa (send|recv|originate|timer|database|memory|all)",
-       NO_STR
-       DEBUG_STR
-       OSPF6_STR
-       "Debug Link State Advertisements (LSAs)\n"
-       "Debug Sending LSAs\n"
-       "Debug Receiving LSAs\n"
-       "Debug Originating LSAs\n"
-       "Debug Timer Event of LSAs\n"
-       "Debug LSA Database\n"
-       "Debug Memory of LSAs\n"
-       "Debug LSAs all\n"
-      )
-{
-  unsigned char level = 0;
-
-  if (argc)
+  for (i = 0; i < MIN (size, sizeof (buf)); i++)
     {
-      if (! strncmp (argv[0], "s", 1))
-        level = OSPF6_DEBUG_LSA_SEND;
-      else if (! strncmp (argv[0], "r", 1))
-        level = OSPF6_DEBUG_LSA_RECV;
-      else if (! strncmp (argv[0], "o", 1))
-        level = OSPF6_DEBUG_LSA_ORIGINATE;
-      else if (! strncmp (argv[0], "t", 1))
-        level = OSPF6_DEBUG_LSA_TIMER;
-      else if (! strncmp (argv[0], "d", 1))
-        level = OSPF6_DEBUG_LSA_DATABASE;
-      else if (! strncmp (argv[0], "m", 1))
-        level = OSPF6_DEBUG_LSA_MEMORY;
-      else if (! strncmp (argv[0], "a", 1))
-        {
-          level = OSPF6_DEBUG_LSA_SEND | OSPF6_DEBUG_LSA_RECV |
-                  OSPF6_DEBUG_LSA_ORIGINATE | OSPF6_DEBUG_LSA_TIMER |
-                  OSPF6_DEBUG_LSA_DATABASE | OSPF6_DEBUG_LSA_MEMORY;
-        }
-    }
-  else
-    {
-      level = OSPF6_DEBUG_LSA_SEND | OSPF6_DEBUG_LSA_RECV |
-              OSPF6_DEBUG_LSA_ORIGINATE | OSPF6_DEBUG_LSA_TIMER;
-    }
-
-  OSPF6_DEBUG_LSA_OFF (level);
-  return CMD_SUCCESS;
-}
-
-ALIAS (no_debug_ospf6_lsa_sendrecv,
-       no_debug_ospf6_lsa_cmd,
-       "no debug ospf6 lsa",
-       NO_STR
-       DEBUG_STR
-       OSPF6_STR
-       "Debug Link State Advertisements (LSAs)\n"
-      );
-
-int
-config_write_ospf6_debug_lsa (struct vty *vty)
-{
-  if (conf_debug_ospf6_lsa == OSPF6_DEBUG_LSA_ALL)
-    vty_out (vty, "debug ospf6 lsa all%s", VNL);
-  else
-    {
-      if (conf_debug_ospf6_lsa == OSPF6_DEBUG_LSA_DEFAULT)
-        vty_out (vty, "debug ospf6 lsa%s", VNL);
+      if (! islower (h->name[i]))
+        buf[i] = tolower (h->name[i]);
       else
-        {
-          if (IS_OSPF6_DEBUG_LSA (SEND))
-            vty_out (vty, "debug ospf6 lsa send%s", VNL);
-          if (IS_OSPF6_DEBUG_LSA (RECV))
-            vty_out (vty, "debug ospf6 lsa recv%s", VNL);
-          if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
-            vty_out (vty, "debug ospf6 lsa originate%s", VNL);
-          if (IS_OSPF6_DEBUG_LSA (TIMER))
-            vty_out (vty, "debug ospf6 lsa timer%s", VNL);
-        }
+        buf[i] = h->name[i];
+    }
+  buf[size] = '\0';
+  return buf;
+}
 
-      if (IS_OSPF6_DEBUG_LSA (DATABASE))
-        vty_out (vty, "debug ospf6 lsa database%s", VNL);
-      if (IS_OSPF6_DEBUG_LSA (MEMORY))
-        vty_out (vty, "debug ospf6 lsa memory%s", VNL);
+DEFUN (debug_ospf6_lsa_type,
+       debug_ospf6_lsa_hex_cmd,
+       "debug ospf6 lsa XXXX/0xXXXX",
+       DEBUG_STR
+       OSPF6_STR
+       "Debug Link State Advertisements (LSAs)\n"
+       "Specify LS type as Hexadecimal\n"
+      )
+{
+  int i;
+  struct ospf6_lsa_handler *handler = NULL;
+  unsigned long val;
+  char *endptr = NULL;
+  u_int16_t type = 0;
+
+  assert (argc);
+
+  if ((strlen (argv[0]) == 6 && ! strncmp (argv[0], "0x", 2)) ||
+      (strlen (argv[0]) == 4))
+    {
+      val = strtoul (argv[0], &endptr, 16);
+      if (*endptr == '\0')
+        type = val;
     }
 
-  return 0;
+  for (i = 0; i < vector_max (ospf6_lsa_handler_vector); i++)
+    {
+      handler = vector_slot (ospf6_lsa_handler_vector, i);
+      if (handler == NULL)
+        continue;
+      if (type && handler->type == type)
+        break;
+      if (! strcasecmp (argv[0], handler->name))
+        break;
+      handler = NULL;
+    }
+
+  if (type && handler == NULL)
+    {
+      handler = (struct ospf6_lsa_handler *)
+        malloc (sizeof (struct ospf6_lsa_handler));
+      memset (handler, 0, sizeof (struct ospf6_lsa_handler));
+      handler->type = type;
+      handler->name = "Unknown";
+      handler->show = ospf6_unknown_lsa_show;
+      vector_set_index (ospf6_lsa_handler_vector,
+                        handler->type & OSPF6_LSTYPE_FCODE_MASK, handler);
+    }
+
+  if (handler == NULL)
+    handler = &unknown_handler;
+
+  if (argc >= 2)
+    {
+      if (! strcmp (argv[1], "originate"))
+        SET_FLAG (handler->debug, OSPF6_LSA_DEBUG_ORIGINATE);
+      if (! strcmp (argv[1], "examin"))
+        SET_FLAG (handler->debug, OSPF6_LSA_DEBUG_EXAMIN);
+      if (! strcmp (argv[1], "flooding"))
+        SET_FLAG (handler->debug, OSPF6_LSA_DEBUG_FLOOD);
+    }
+  else
+    SET_FLAG (handler->debug, OSPF6_LSA_DEBUG);
+
+  return CMD_SUCCESS;
 }
 
+DEFUN (no_debug_ospf6_lsa_type,
+       no_debug_ospf6_lsa_hex_cmd,
+       "no debug ospf6 lsa XXXX/0xXXXX",
+       NO_STR
+       DEBUG_STR
+       OSPF6_STR
+       "Debug Link State Advertisements (LSAs)\n"
+       "Specify LS type as Hexadecimal\n"
+      )
+{
+  int i;
+  struct ospf6_lsa_handler *handler = NULL;
+  unsigned long val;
+  char *endptr = NULL;
+  u_int16_t type = 0;
+
+  assert (argc);
+
+  if ((strlen (argv[0]) == 6 && ! strncmp (argv[0], "0x", 2)) ||
+      (strlen (argv[0]) == 4))
+    {
+      val = strtoul (argv[0], &endptr, 16);
+      if (*endptr == '\0')
+        type = val;
+    }
+
+  for (i = 0; i < vector_max (ospf6_lsa_handler_vector); i++)
+    {
+      handler = vector_slot (ospf6_lsa_handler_vector, i);
+      if (handler == NULL)
+        continue;
+      if (type && handler->type == type)
+        break;
+      if (! strcasecmp (argv[0], handler->name))
+        break;
+    }
+
+  if (handler == NULL)
+    return CMD_SUCCESS;
+
+  if (argc >= 2)
+    {
+      if (! strcmp (argv[1], "originate"))
+        UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG_ORIGINATE);
+      if (! strcmp (argv[1], "examin"))
+        UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG_EXAMIN);
+      if (! strcmp (argv[1], "flooding"))
+        UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG_FLOOD);
+    }
+  else
+    UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG);
+
+  if (handler->debug == 0 &&
+      handler->name == "Unknown" && type != OSPF6_LSTYPE_UNKNOWN)
+    {
+      free (handler);
+      vector_slot (ospf6_lsa_handler_vector, i) = NULL;
+    }
+
+  return CMD_SUCCESS;
+}
+
+struct cmd_element debug_ospf6_lsa_type_cmd;
+struct cmd_element debug_ospf6_lsa_type_detail_cmd;
+struct cmd_element no_debug_ospf6_lsa_type_cmd;
+struct cmd_element no_debug_ospf6_lsa_type_detail_cmd;
+
 void
 install_element_ospf6_debug_lsa ()
 {
-  install_element (ENABLE_NODE, &debug_ospf6_lsa_cmd);
-  install_element (ENABLE_NODE, &debug_ospf6_lsa_sendrecv_cmd);
-  install_element (ENABLE_NODE, &no_debug_ospf6_lsa_cmd);
-  install_element (ENABLE_NODE, &no_debug_ospf6_lsa_sendrecv_cmd);
-  install_element (CONFIG_NODE, &debug_ospf6_lsa_cmd);
-  install_element (CONFIG_NODE, &debug_ospf6_lsa_sendrecv_cmd);
-  install_element (CONFIG_NODE, &no_debug_ospf6_lsa_cmd);
-  install_element (CONFIG_NODE, &no_debug_ospf6_lsa_sendrecv_cmd);
+  int i;
+  struct ospf6_lsa_handler *handler;
+#define STRSIZE  256
+#define DOCSIZE  1024
+  static char strbuf[STRSIZE];
+  static char docbuf[DOCSIZE];
+  static char detail_strbuf[STRSIZE];
+  static char detail_docbuf[DOCSIZE];
+  char *str, *no_str;
+  char *doc, *no_doc;
+
+  strbuf[0] = '\0';
+  no_str = &strbuf[strlen (strbuf)];
+  strncat (strbuf, "no ", STRSIZE - strlen (strbuf));
+  str = &strbuf[strlen (strbuf)];
+
+  strncat (strbuf, "debug ospf6 lsa (", STRSIZE - strlen (strbuf));
+  for (i = 0; i < vector_max (ospf6_lsa_handler_vector); i++)
+    {
+      handler = vector_slot (ospf6_lsa_handler_vector, i);
+      if (handler == NULL)
+        continue;
+      strncat (strbuf, ospf6_lsa_handler_name (handler),
+               STRSIZE - strlen (strbuf));
+      strncat (strbuf, "|", STRSIZE - strlen (strbuf));
+    }
+  strbuf[strlen (strbuf) - 1] = ')';
+  strbuf[strlen (strbuf)] = '\0';
+
+  docbuf[0] = '\0';
+  no_doc = &docbuf[strlen (docbuf)];
+  strncat (docbuf, NO_STR, DOCSIZE - strlen (docbuf));
+  doc = &docbuf[strlen (docbuf)];
+
+  strncat (docbuf, DEBUG_STR, DOCSIZE - strlen (docbuf));
+  strncat (docbuf, OSPF6_STR, DOCSIZE - strlen (docbuf));
+  strncat (docbuf, "Debug Link State Advertisements (LSAs)\n",
+           DOCSIZE - strlen (docbuf));
+
+  for (i = 0; i < vector_max (ospf6_lsa_handler_vector); i++)
+    {
+      handler = vector_slot (ospf6_lsa_handler_vector, i);
+      if (handler == NULL)
+        continue;
+      strncat (docbuf, "Debug ", DOCSIZE - strlen (docbuf));
+      strncat (docbuf, handler->name, DOCSIZE - strlen (docbuf));
+      strncat (docbuf, "-LSA\n", DOCSIZE - strlen (docbuf));
+    }
+  docbuf[strlen (docbuf)] = '\0';
+
+  debug_ospf6_lsa_type_cmd.string = str;
+  debug_ospf6_lsa_type_cmd.func = debug_ospf6_lsa_type;
+  debug_ospf6_lsa_type_cmd.doc = doc;
+
+  no_debug_ospf6_lsa_type_cmd.string = no_str;
+  no_debug_ospf6_lsa_type_cmd.func = no_debug_ospf6_lsa_type;
+  no_debug_ospf6_lsa_type_cmd.doc = no_doc;
+
+  strncpy (detail_strbuf, strbuf, STRSIZE);
+  strncat (detail_strbuf, " (originate|examin|flooding)",
+           STRSIZE - strlen (detail_strbuf));
+  detail_strbuf[strlen (detail_strbuf)] = '\0';
+  no_str = &detail_strbuf[0];
+  str = &detail_strbuf[strlen ("no ")];
+
+  strncpy (detail_docbuf, docbuf, DOCSIZE);
+  strncat (detail_docbuf, "Debug Originating LSA\n",
+           DOCSIZE - strlen (detail_docbuf));
+  strncat (detail_docbuf, "Debug Examining LSA\n",
+           DOCSIZE - strlen (detail_docbuf));
+  strncat (detail_docbuf, "Debug Flooding LSA\n",
+           DOCSIZE - strlen (detail_docbuf));
+  detail_docbuf[strlen (detail_docbuf)] = '\0';
+  no_doc = &detail_docbuf[0];
+  doc = &detail_docbuf[strlen (NO_STR)];
+
+  debug_ospf6_lsa_type_detail_cmd.string = str;
+  debug_ospf6_lsa_type_detail_cmd.func = debug_ospf6_lsa_type;
+  debug_ospf6_lsa_type_detail_cmd.doc = doc;
+
+  no_debug_ospf6_lsa_type_detail_cmd.string = no_str;
+  no_debug_ospf6_lsa_type_detail_cmd.func = no_debug_ospf6_lsa_type;
+  no_debug_ospf6_lsa_type_detail_cmd.doc = no_doc;
+
+  install_element (ENABLE_NODE, &debug_ospf6_lsa_hex_cmd);
+  install_element (ENABLE_NODE, &debug_ospf6_lsa_type_cmd);
+  install_element (ENABLE_NODE, &debug_ospf6_lsa_type_detail_cmd);
+  install_element (ENABLE_NODE, &no_debug_ospf6_lsa_hex_cmd);
+  install_element (ENABLE_NODE, &no_debug_ospf6_lsa_type_cmd);
+  install_element (ENABLE_NODE, &no_debug_ospf6_lsa_type_detail_cmd);
+  install_element (CONFIG_NODE, &debug_ospf6_lsa_hex_cmd);
+  install_element (CONFIG_NODE, &debug_ospf6_lsa_type_cmd);
+  install_element (CONFIG_NODE, &debug_ospf6_lsa_type_detail_cmd);
+  install_element (CONFIG_NODE, &no_debug_ospf6_lsa_hex_cmd);
+  install_element (CONFIG_NODE, &no_debug_ospf6_lsa_type_cmd);
+  install_element (CONFIG_NODE, &no_debug_ospf6_lsa_type_detail_cmd);
+}
+
+int
+config_write_ospf6_debug_lsa (struct vty *vty)
+{
+  int i;
+  struct ospf6_lsa_handler *handler;
+
+  for (i = 0; i < vector_max (ospf6_lsa_handler_vector); i++)
+    {
+      handler = vector_slot (ospf6_lsa_handler_vector, i);
+      if (handler == NULL)
+        continue;
+      if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG))
+        vty_out (vty, "debug ospf6 lsa %s%s",
+                 ospf6_lsa_handler_name (handler), VNL);
+      if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG_ORIGINATE))
+        vty_out (vty, "debug ospf6 lsa %s originate%s",
+                 ospf6_lsa_handler_name (handler), VNL);
+      if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG_EXAMIN))
+        vty_out (vty, "debug ospf6 lsa %s examin%s",
+                 ospf6_lsa_handler_name (handler), VNL);
+      if (CHECK_FLAG (handler->debug, OSPF6_LSA_DEBUG_FLOOD))
+        vty_out (vty, "debug ospf6 lsa %s flooding%s",
+                 ospf6_lsa_handler_name (handler), VNL);
+    }
+
+  return 0;
 }
 
 
diff --git a/ospf6d/ospf6_lsa.h b/ospf6d/ospf6_lsa.h
index be28449..0f81b6a 100644
--- a/ospf6d/ospf6_lsa.h
+++ b/ospf6d/ospf6_lsa.h
@@ -23,21 +23,28 @@
 #define OSPF6_LSA_H
 
 /* Debug option */
-extern unsigned char conf_debug_ospf6_lsa;
-#define OSPF6_DEBUG_LSA_SEND      0x01
-#define OSPF6_DEBUG_LSA_RECV      0x02
-#define OSPF6_DEBUG_LSA_ORIGINATE 0x04
-#define OSPF6_DEBUG_LSA_TIMER     0x08
-#define OSPF6_DEBUG_LSA_DATABASE  0x10
-#define OSPF6_DEBUG_LSA_MEMORY    0x80
-#define OSPF6_DEBUG_LSA_ALL       0x9f
-#define OSPF6_DEBUG_LSA_DEFAULT   0x0f
-#define OSPF6_DEBUG_LSA_ON(level) \
-  (conf_debug_ospf6_lsa |= (level))
-#define OSPF6_DEBUG_LSA_OFF(level) \
-  (conf_debug_ospf6_lsa &= ~(level))
-#define IS_OSPF6_DEBUG_LSA(e) \
-  (conf_debug_ospf6_lsa & OSPF6_DEBUG_LSA_ ## e)
+#define OSPF6_LSA_DEBUG           0x01
+#define OSPF6_LSA_DEBUG_ORIGINATE 0x02
+#define OSPF6_LSA_DEBUG_EXAMIN    0x04
+#define OSPF6_LSA_DEBUG_FLOOD     0x08
+
+#define IS_OSPF6_DEBUG_LSA(name)                        \
+  (ospf6_lstype_debug (htons (OSPF6_LSTYPE_ ## name)) & \
+   OSPF6_LSA_DEBUG)
+#define IS_OSPF6_DEBUG_ORIGINATE(name)                  \
+  (ospf6_lstype_debug (htons (OSPF6_LSTYPE_ ## name)) & \
+   OSPF6_LSA_DEBUG_ORIGINATE)
+#define IS_OSPF6_DEBUG_EXAMIN(name)                     \
+  (ospf6_lstype_debug (htons (OSPF6_LSTYPE_ ## name)) & \
+   OSPF6_LSA_DEBUG_EXAMIN)
+#define IS_OSPF6_DEBUG_LSA_TYPE(type) \
+  (ospf6_lstype_debug (type) & OSPF6_LSA_DEBUG)
+#define IS_OSPF6_DEBUG_ORIGINATE_TYPE(type) \
+  (ospf6_lstype_debug (type) & OSPF6_LSA_DEBUG_ORIGINATE)
+#define IS_OSPF6_DEBUG_EXAMIN_TYPE(type) \
+  (ospf6_lstype_debug (type) & OSPF6_LSA_DEBUG_EXAMIN)
+#define IS_OSPF6_DEBUG_FLOOD_TYPE(type) \
+  (ospf6_lstype_debug (type) & OSPF6_LSA_DEBUG_FLOOD)
 
 /* LSA definition */
 
@@ -135,65 +142,60 @@
 
 struct ospf6_lsa_handler
 {
-  u_int16_t type; /* network byte order */
+  u_int16_t type; /* host byte order */
   char *name;
   int (*show) (struct vty *, struct ospf6_lsa *);
+  u_char debug;
 };
 
-#define OSPF6_LSTYPE_INDEX(type) \
-  ((ntohs (type) & OSPF6_LSTYPE_FCODE_MASK) < OSPF6_LSTYPE_SIZE ? \
-   (ntohs (type) & OSPF6_LSTYPE_FCODE_MASK) : OSPF6_LSTYPE_UNKNOWN)
-#define OSPF6_LSTYPE_NAME(type) (ospf6_lstype_name (type))
-
 /* Macro for LSA Origination */
-/* void (CONTINUE_IF_...) (struct prefix *addr); */
-
-#define CONTINUE_IF_ADDRESS_LINKLOCAL(addr)\
+/* addr is (struct prefix *) */
+#define CONTINUE_IF_ADDRESS_LINKLOCAL(debug,addr)      \
   if (IN6_IS_ADDR_LINKLOCAL (&(addr)->u.prefix6))      \
     {                                                  \
       char buf[64];                                    \
       prefix2str (addr, buf, sizeof (buf));            \
-      if (IS_OSPF6_DEBUG_LSA (ORIGINATE))              \
+      if (debug)                                       \
         zlog_info ("Filter out Linklocal: %s", buf);   \
       continue;                                        \
     }
 
-#define CONTINUE_IF_ADDRESS_UNSPECIFIED(addr)          \
+#define CONTINUE_IF_ADDRESS_UNSPECIFIED(debug,addr)    \
   if (IN6_IS_ADDR_UNSPECIFIED (&(addr)->u.prefix6))    \
     {                                                  \
       char buf[64];                                    \
       prefix2str (addr, buf, sizeof (buf));            \
-      if (IS_OSPF6_DEBUG_LSA (ORIGINATE))              \
+      if (debug)                                       \
         zlog_info ("Filter out Unspecified: %s", buf); \
       continue;                                        \
     }
 
-#define CONTINUE_IF_ADDRESS_LOOPBACK(addr)             \
+#define CONTINUE_IF_ADDRESS_LOOPBACK(debug,addr)       \
   if (IN6_IS_ADDR_LOOPBACK (&(addr)->u.prefix6))       \
     {                                                  \
       char buf[64];                                    \
       prefix2str (addr, buf, sizeof (buf));            \
-      if (IS_OSPF6_DEBUG_LSA (ORIGINATE))              \
+      if (debug)                                       \
         zlog_info ("Filter out Loopback: %s", buf);    \
       continue;                                        \
     }
 
-#define CONTINUE_IF_ADDRESS_V4COMPAT(addr)             \
+#define CONTINUE_IF_ADDRESS_V4COMPAT(debug,addr)       \
   if (IN6_IS_ADDR_V4COMPAT (&(addr)->u.prefix6))       \
     {                                                  \
       char buf[64];                                    \
       prefix2str (addr, buf, sizeof (buf));            \
-      if (IS_OSPF6_DEBUG_LSA (ORIGINATE))              \
+      if (debug)                                       \
         zlog_info ("Filter out V4Compat: %s", buf);    \
       continue;                                        \
     }
 
-#define CONTINUE_IF_ADDRESS_V4MAPPED(addr)             \
+#define CONTINUE_IF_ADDRESS_V4MAPPED(debug,addr)       \
   if (IN6_IS_ADDR_V4MAPPED (&(addr)->u.prefix6))       \
     {                                                  \
       char buf[64];                                    \
       prefix2str (addr, buf, sizeof (buf));            \
-      if (IS_OSPF6_DEBUG_LSA (ORIGINATE))              \
+      if (debug)                                       \
         zlog_info ("Filter out V4Mapped: %s", buf);    \
       continue;                                        \
     }
@@ -201,6 +203,7 @@
 
 /* Function Prototypes */
 char *ospf6_lstype_name (u_int16_t type);
+u_char ospf6_lstype_debug (u_int16_t type);
 int ospf6_lsa_is_differ (struct ospf6_lsa *lsa1, struct ospf6_lsa *lsa2);
 int ospf6_lsa_is_changed (struct ospf6_lsa *lsa1, struct ospf6_lsa *lsa2);
 u_int16_t ospf6_lsa_age_current (struct ospf6_lsa *);
@@ -234,6 +237,7 @@
 
 void ospf6_install_lsa_handler (struct ospf6_lsa_handler *handler);
 void ospf6_lsa_init ();
+void ospf6_lsa_cmd_init ();
 
 int config_write_ospf6_debug_lsa (struct vty *vty);
 void install_element_ospf6_debug_lsa ();
diff --git a/ospf6d/ospf6_lsdb.h b/ospf6d/ospf6_lsdb.h
index a10f001..d32f78d 100644
--- a/ospf6d/ospf6_lsdb.h
+++ b/ospf6d/ospf6_lsdb.h
@@ -41,10 +41,10 @@
       {                                                                  \
         if (! OSPF6_LSA_IS_MAXAGE (lsa))                                 \
           continue;                                                      \
-        if (lsa->retrans_count != 0)                                         \
+        if (lsa->retrans_count != 0)                                     \
           continue;                                                      \
-        if (IS_OSPF6_DEBUG_LSA (TIMER))                                  \
-          zlog_info (" remove maxage %s", lsa->name);                    \
+        if (IS_OSPF6_DEBUG_LSA_TYPE (lsa->header->type))                 \
+          zlog_info ("Remove MaxAge %s", lsa->name);                     \
         ospf6_lsdb_remove (lsa, lsdb);                                   \
       }                                                                  \
   } while (0)
diff --git a/ospf6d/ospf6_message.c b/ospf6d/ospf6_message.c
index 276c847..ae699b9 100644
--- a/ospf6d/ospf6_message.c
+++ b/ospf6d/ospf6_message.c
@@ -147,7 +147,7 @@
       inet_ntop (AF_INET, &e->adv_router, adv_router, sizeof (adv_router));
       inet_ntop (AF_INET, &e->id, id, sizeof (id));
       zlog_info ("    [%s Id:%s Adv:%s]",
-                 OSPF6_LSTYPE_NAME (e->type), id, adv_router);
+                 ospf6_lstype_name (e->type), id, adv_router);
     }
 
   if (p != OSPF6_MESSAGE_END (oh))
@@ -937,7 +937,7 @@
               inet_ntop (AF_INET, &e->adv_router, adv_router,
                      sizeof (adv_router));
               zlog_info ("Can't find requested [%s Id:%s Adv:%s]",
-                         OSPF6_LSTYPE_NAME (e->type), id, adv_router);
+                         ospf6_lstype_name (e->type), id, adv_router);
             }
           thread_add_event (master, bad_lsreq, on, 0);
           return;
@@ -1752,9 +1752,6 @@
   if (oi->lsupdate_list->count == 0)
     return 0;
 
-  if (IS_OSPF6_DEBUG_LSA (SEND))
-    zlog_info ("LSA Send to %s", oi->interface->name);
-
   memset (sendbuf, 0, iobuflen);
   oh = (struct ospf6_header *) sendbuf;
   lsupdate = (struct ospf6_lsupdate *)((caddr_t) oh +
@@ -1773,9 +1770,6 @@
           break;
         }
 
-      if (IS_OSPF6_DEBUG_LSA (SEND))
-        ospf6_lsa_header_print (lsa);
-
       ospf6_lsa_age_update_to_send (lsa, oi->transdelay);
       memcpy (p, lsa->header, OSPF6_LSA_SIZE (lsa->header));
       p += OSPF6_LSA_SIZE (lsa->header);
diff --git a/ospf6d/ospf6_neighbor.c b/ospf6d/ospf6_neighbor.c
index e7818ab..402ca62 100644
--- a/ospf6d/ospf6_neighbor.c
+++ b/ospf6d/ospf6_neighbor.c
@@ -294,10 +294,6 @@
   for (lsa = ospf6_lsdb_head (on->ospf6_if->lsdb); lsa;
        lsa = ospf6_lsdb_next (lsa))
     {
-      if (IS_OSPF6_DEBUG_LSA (DATABASE))
-        zlog_info ("Add copy of %s to %s of %s", lsa->name,
-                   (OSPF6_LSA_IS_MAXAGE (lsa) ? "retrans_list" :
-                    "summary_list"), on->name);
       if (OSPF6_LSA_IS_MAXAGE (lsa))
         {
           ospf6_increment_retrans_count (lsa);
@@ -311,10 +307,6 @@
   for (lsa = ospf6_lsdb_head (on->ospf6_if->area->lsdb); lsa;
        lsa = ospf6_lsdb_next (lsa))
     {
-      if (IS_OSPF6_DEBUG_LSA (DATABASE))
-        zlog_info ("Add copy of %s to %s of %s", lsa->name,
-                   (OSPF6_LSA_IS_MAXAGE (lsa) ? "retrans_list" :
-                    "summary_list"), on->name);
       if (OSPF6_LSA_IS_MAXAGE (lsa))
         {
           ospf6_increment_retrans_count (lsa);
@@ -328,10 +320,6 @@
   for (lsa = ospf6_lsdb_head (on->ospf6_if->area->ospf6->lsdb); lsa;
        lsa = ospf6_lsdb_next (lsa))
     {
-      if (IS_OSPF6_DEBUG_LSA (DATABASE))
-        zlog_info ("Add copy of %s to %s of %s", lsa->name,
-                   (OSPF6_LSA_IS_MAXAGE (lsa) ? "retrans_list" :
-                    "summary_list"), on->name);
       if (OSPF6_LSA_IS_MAXAGE (lsa))
         {
           ospf6_increment_retrans_count (lsa);
diff --git a/ospf6d/ospf6_route.c b/ospf6d/ospf6_route.c
index dae9222..3ca21a3 100644
--- a/ospf6d/ospf6_route.c
+++ b/ospf6d/ospf6_route.c
@@ -720,7 +720,7 @@
   inet_ntop (AF_INET, &route->path.origin.adv_router, adv_router,
              sizeof (adv_router));
   vty_out (vty, "LS Origin: %s Id: %s Adv: %s%s",
-           OSPF6_LSTYPE_NAME (route->path.origin.type),
+           ospf6_lstype_name (route->path.origin.type),
            id, adv_router, VNL);
 
   /* Options */
diff --git a/ospf6d/ospf6_spf.c b/ospf6d/ospf6_spf.c
index 63bc10a..6d4237a 100644
--- a/ospf6d/ospf6_spf.c
+++ b/ospf6d/ospf6_spf.c
@@ -160,7 +160,7 @@
         zlog_info ("  Link to: %s", lsa->name);
       else
         zlog_info ("  Link to: [%s Id:%s Adv:%s] No LSA",
-                   OSPF6_LSTYPE_NAME (type), ibuf, abuf);
+                   ospf6_lstype_name (type), ibuf, abuf);
     }
 
   return lsa;
diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c
index 23ad09f..5ab208b 100644
--- a/ospf6d/ospf6_top.c
+++ b/ospf6d/ospf6_top.c
@@ -61,8 +61,6 @@
         break;
 
       default:
-        if (IS_OSPF6_DEBUG_LSA (RECV))
-          zlog_info ("Unknown LSA in AS-scoped lsdb");
         break;
     }
 }
@@ -77,8 +75,6 @@
         break;
 
       default:
-        if (IS_OSPF6_DEBUG_LSA (RECV))
-          zlog_info ("Unknown LSA in AS-scoped lsdb");
         break;
     }
 }
@@ -216,8 +212,6 @@
   listnode i, j, k;
 
   o->maxage_remover = (struct thread *) NULL;
-  if (IS_OSPF6_DEBUG_LSA (TIMER))
-    zlog_info ("Maxage Remover");
 
   for (i = listhead (o->area_list); i; nextnode (i))
     {
@@ -232,9 +226,6 @@
                   on->state != OSPF6_NEIGHBOR_LOADING)
                 continue;
 
-              if (IS_OSPF6_DEBUG_LSA (TIMER))
-                zlog_info ("Maxage Remover End: %s exchange or loading",
-                           on->name);
               return 0;
             }
         }
@@ -252,9 +243,6 @@
     }
   OSPF6_LSDB_MAXAGE_REMOVER (o->lsdb);
 
-  if (IS_OSPF6_DEBUG_LSA (TIMER))
-    zlog_info ("Maxage Remover End");
-
   return 0;
 }
 
diff --git a/ospf6d/ospf6d.c b/ospf6d/ospf6d.c
index a67600a..b954172 100644
--- a/ospf6d/ospf6d.c
+++ b/ospf6d/ospf6d.c
@@ -41,6 +41,7 @@
 #include "ospf6_intra.h"
 #include "ospf6_asbr.h"
 #include "ospf6_abr.h"
+#include "ospf6_flood.h"
 #include "ospf6d.h"
 
 char ospf6_daemon_version[] = OSPF6_DAEMON_VERSION;
@@ -111,6 +112,7 @@
   config_write_ospf6_debug_route (vty);
   config_write_ospf6_debug_asbr (vty);
   config_write_ospf6_debug_abr (vty);
+  config_write_ospf6_debug_flood (vty);
   vty_out (vty, "!%s", VNL);
   return 0;
 }
@@ -1717,6 +1719,18 @@
 void
 ospf6_init ()
 {
+  ospf6_top_init ();
+  ospf6_area_init ();
+  ospf6_interface_init ();
+  ospf6_neighbor_init ();
+  ospf6_zebra_init ();
+
+  ospf6_lsa_init ();
+  ospf6_spf_init ();
+  ospf6_intra_init ();
+  ospf6_asbr_init ();
+  ospf6_abr_init ();
+
   install_node (&debug_node, config_write_ospf6_debug);
 
   install_element_ospf6_debug_message ();
@@ -1728,6 +1742,7 @@
   install_element_ospf6_debug_route ();
   install_element_ospf6_debug_asbr ();
   install_element_ospf6_debug_abr ();
+  install_element_ospf6_debug_flood ();
 
   install_element (VIEW_NODE, &show_version_ospf6_cmd);
   install_element (ENABLE_NODE, &show_version_ospf6_cmd);
@@ -1818,18 +1833,6 @@
   INSTALL (ENABLE, database_type_id_self_originated_cmd);
   INSTALL (ENABLE, database_type_id_self_originated_detail_cmd);
 
-  ospf6_top_init ();
-  ospf6_area_init ();
-  ospf6_interface_init ();
-  ospf6_neighbor_init ();
-  ospf6_zebra_init ();
-
-  ospf6_lsa_init ();
-  ospf6_spf_init ();
-  ospf6_intra_init ();
-  ospf6_asbr_init ();
-  ospf6_abr_init ();
-
   /* Make ospf protocol socket. */
   ospf6_serv_sock ();
   thread_add_read (master, ospf6_receive, NULL, ospf6_sock);
diff --git a/ospf6d/ospf6d.h b/ospf6d/ospf6d.h
index b08d07c..3df9ea6 100644
--- a/ospf6d/ospf6d.h
+++ b/ospf6d/ospf6d.h
@@ -22,7 +22,7 @@
 #ifndef OSPF6D_H
 #define OSPF6D_H
 
-#define OSPF6_DAEMON_VERSION    "0.9.7k"
+#define OSPF6_DAEMON_VERSION    "0.9.7l"
 
 /* global variables */
 extern int errno;