* *.c: Try to be less verbose by default (without any debug options
	  on).
	* isis_lsp.c (lsp_build_nonpseudo): Use stream_reset() instead of
	  touching endp directly.
	* isis_lsp.c (lsp_build_pseudo): Ditto.
diff --git a/isisd/ChangeLog b/isisd/ChangeLog
index d418d63..822d856 100644
--- a/isisd/ChangeLog
+++ b/isisd/ChangeLog
@@ -1,3 +1,11 @@
+2005-09-05 Hasso Tepper <hasso at quagga.net>
+
+	* *.c: Try to be less verbose by default (without any debug options
+	  on).
+	* isis_lsp.c (lsp_build_nonpseudo): Use stream_reset() instead of
+	  touching endp directly.
+	* isis_lsp.c (lsp_build_pseudo): Ditto.
+
 2005-09-03 Hasso Tepper <hasso at quagga.net>
 
 	* isis_lsp.c: Yet another regression introduced by stream cleanup.
diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c
index b99fa5d..e885a65 100644
--- a/isisd/isis_circuit.c
+++ b/isisd/isis_circuit.c
@@ -404,7 +404,9 @@
     }
   else
     {
-      zlog_warn ("isis_circuit_if_add: unsupported media");
+      /* It's normal in case of loopback etc. */
+      if (isis->debugs & DEBUG_EVENTS)
+	zlog_debug ("isis_circuit_if_add: unsupported media");
     }
 
   for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, conn))
@@ -842,7 +844,8 @@
       if (c->ipv6_router == 0)
 	{
 #endif /* HAVE_IPV6 */
-	  vty_out (vty, "ISIS circuit is already defined%s", VTY_NEWLINE);
+	  /* FIXME: Find the way to warn only vty users. */
+	  /* vty_out (vty, "ISIS circuit is already defined%s", VTY_NEWLINE); */
 	  return CMD_WARNING;
 #ifdef HAVE_IPV6
 	}
@@ -852,7 +855,8 @@
   /* this is here for ciscopability */
   if (!area)
     {
-      vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
+      /* FIXME: Find the way to warn only vty users. */
+      /* vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE); */
       return CMD_WARNING;
     }
 
diff --git a/isisd/isis_csm.c b/isisd/isis_csm.c
index 58a0b29..80d0c90 100644
--- a/isisd/isis_csm.c
+++ b/isisd/isis_csm.c
@@ -77,8 +77,8 @@
   int old_state;
 
   old_state = circuit ? circuit->state : C_STATE_NA;
-
-  zlog_debug ("CSM_EVENT: %s", EVENT2STR (event));
+  if (isis->debugs & DEBUG_EVENTS)
+    zlog_debug ("CSM_EVENT: %s", EVENT2STR (event));
 
   switch (old_state)
     {
@@ -178,8 +178,9 @@
       zlog_warn ("Invalid circuit state %d", old_state);
     }
 
-  zlog_debug ("CSM_STATE_CHANGE: %s -> %s ", STATE2STR (old_state),
-	      circuit ? STATE2STR (circuit->state) : STATE2STR (C_STATE_NA));
+  if (isis->debugs & DEBUG_EVENTS)
+    zlog_debug ("CSM_STATE_CHANGE: %s -> %s ", STATE2STR (old_state),
+		circuit ? STATE2STR (circuit->state) : STATE2STR (C_STATE_NA));
 
   return circuit;
 }
diff --git a/isisd/isis_dr.c b/isisd/isis_dr.c
index a5891f9..335946c 100644
--- a/isisd/isis_dr.c
+++ b/isisd/isis_dr.c
@@ -307,7 +307,8 @@
 {
   u_char old_dr[ISIS_SYS_ID_LEN + 2];
 
-  zlog_debug ("isis_dr_commence l%d", level);
+  if (isis->debugs & DEBUG_EVENTS)
+    zlog_debug ("isis_dr_commence l%d", level);
 
   /* Lets keep a pause in DR election */
   circuit->u.bc.run_dr_elect[level - 1] = 0;
diff --git a/isisd/isis_events.c b/isisd/isis_events.c
index d54036a..a8e60d6 100644
--- a/isisd/isis_events.c
+++ b/isisd/isis_events.c
@@ -283,8 +283,9 @@
   if (!adj || !adj->circuit || !adj->circuit->area)
     return;
 
-  zlog_debug ("ISIS-Evt (%s) Adjacency State change",
-	      adj->circuit->area->area_tag);
+  if (isis->debugs & DEBUG_EVENTS)
+    zlog_debug ("ISIS-Evt (%s) Adjacency State change",
+		adj->circuit->area->area_tag);
 
   /* LSP generation again */
   lsp_regenerate_schedule (adj->circuit->area);
@@ -304,8 +305,8 @@
   /* invalid arguments */
   if (!circuit || !circuit->area)
     return 0;
-
-  zlog_debug ("ISIS-Evt (%s) DIS status change", circuit->area->area_tag);
+  if (isis->debugs & DEBUG_EVENTS)
+    zlog_debug ("ISIS-Evt (%s) DIS status change", circuit->area->area_tag);
 
   /* LSP generation again */
   lsp_regenerate_schedule (circuit->area);
@@ -316,8 +317,9 @@
 void
 isis_event_auth_failure (char *area_tag, const char *error_string, u_char *sysid)
 {
-  zlog_debug ("ISIS-Evt (%s) Authentication failure %s from %s",
-	      area_tag, error_string, sysid_print (sysid));
+  if (isis->debugs & DEBUG_EVENTS)
+    zlog_debug ("ISIS-Evt (%s) Authentication failure %s from %s",
+		area_tag, error_string, sysid_print (sysid));
 
   return;
 }
diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c
index cb7b93b..2a9d146 100644
--- a/isisd/isis_lsp.c
+++ b/isisd/isis_lsp.c
@@ -501,13 +501,11 @@
 
   stream_forward_endp (lsp->pdu, ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);
 
-  /* #ifdef EXTREME_DEBUG */
-  /* logging */
-  zlog_debug ("New LSP with ID %s-%02x-%02x seqnum %08x", sysid_print (lsp_id),
-	      LSP_PSEUDO_ID (lsp->lsp_header->lsp_id),
-	      LSP_FRAGMENT (lsp->lsp_header->lsp_id),
-	      ntohl (lsp->lsp_header->seq_num));
-  /* #endif  EXTREME DEBUG */
+  if (isis->debugs & DEBUG_EVENTS)
+    zlog_debug ("New LSP with ID %s-%02x-%02x seqnum %08x",
+		sysid_print (lsp_id), LSP_PSEUDO_ID (lsp->lsp_header->lsp_id),
+		LSP_FRAGMENT (lsp->lsp_header->lsp_id),
+		ntohl (lsp->lsp_header->seq_num));
 
   return lsp;
 }
@@ -1302,7 +1300,7 @@
   /* Reset stream endp. Stream is always there and on every LSP refresh only
    * TLV part of it is overwritten. So we must seek past header we will not
    * touch. */
-  lsp->pdu->endp = 0;
+  stream_reset (lsp->pdu);
   stream_forward_endp (lsp->pdu, ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);
 
   /*
@@ -1912,7 +1910,7 @@
     }
 
   /* Reset endp of stream to overwrite only TLV part of it. */
-  lsp->pdu->endp = 0;
+  stream_reset (lsp->pdu);
   stream_forward_endp (lsp->pdu, ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);
 
   /*
diff --git a/isisd/isis_main.c b/isisd/isis_main.c
index a4f8058..2bb22cb 100644
--- a/isisd/isis_main.c
+++ b/isisd/isis_main.c
@@ -325,9 +325,7 @@
 
   /* Print banner. */
   zlog_notice ("Quagga-ISISd %s starting: vty@%d", QUAGGA_VERSION, vty_port);
-#ifdef HAVE_IPV6
-  zlog_debug ("IPv6 enabled");
-#endif
+
   /* Start finite state machine. */
   while (thread_fetch (master, &thread))
     thread_call (&thread);
diff --git a/isisd/isis_pdu.c b/isisd/isis_pdu.c
index e6a1e03..b15d455 100644
--- a/isisd/isis_pdu.c
+++ b/isisd/isis_pdu.c
@@ -1121,14 +1121,17 @@
 		      && circuit->u.bc.is_dr[level - 1] == 1))
 		{
 		  lsp->lsp_header->seq_num = htonl (ntohl (hdr->seq_num) + 1);
-		  zlog_debug ("LSP LEN: %d", ntohs (lsp->lsp_header->pdu_len));
+		  if (isis->debugs & DEBUG_UPDATE_PACKETS)
+		    zlog_debug ("LSP LEN: %d",
+				ntohs (lsp->lsp_header->pdu_len));
 		  iso_csum_create (STREAM_DATA (lsp->pdu) + 12,
 				   ntohs (lsp->lsp_header->pdu_len) - 12, 12);
 		  ISIS_FLAGS_SET_ALL (lsp->SRMflags);
-		  zlog_debug
-		    ("ISIS-Upd (%s): (1) re-originating LSP %s new seq 0x%08x",
-		     circuit->area->area_tag, rawlspid_print (hdr->lsp_id),
-		     ntohl (lsp->lsp_header->seq_num));
+		  if (isis->debugs & DEBUG_UPDATE_PACKETS)
+		    zlog_debug ("ISIS-Upd (%s): (1) re-originating LSP %s new "
+				"seq 0x%08x", circuit->area->area_tag,
+				rawlspid_print (hdr->lsp_id),
+				ntohl (lsp->lsp_header->seq_num));
 		  lsp->lsp_header->rem_lifetime =
 		    htons (isis_jitter
 			   (circuit->area->max_lsp_lifetime[level - 1],
@@ -1168,10 +1171,11 @@
 			   ntohs (lsp->lsp_header->pdu_len) - 12, 12);
 
 	  ISIS_FLAGS_SET_ALL (lsp->SRMflags);
-	  zlog_debug
-	    ("ISIS-Upd (%s): (2) re-originating LSP %s new seq 0x%08x",
-	     circuit->area->area_tag, rawlspid_print (hdr->lsp_id),
-	     ntohl (lsp->lsp_header->seq_num));
+	  if (isis->debugs & DEBUG_UPDATE_PACKETS)
+	    zlog_debug ("ISIS-Upd (%s): (2) re-originating LSP %s new seq "
+			"0x%08x", circuit->area->area_tag,
+			rawlspid_print (hdr->lsp_id),
+			ntohl (lsp->lsp_header->seq_num));
 	  lsp->lsp_header->rem_lifetime =
 	    htons (isis_jitter
 		   (circuit->area->max_lsp_lifetime[level - 1],
diff --git a/isisd/isis_spf.c b/isisd/isis_spf.c
index dc5765a..ba7acbf 100644
--- a/isisd/isis_spf.c
+++ b/isisd/isis_spf.c
@@ -781,8 +781,9 @@
 	  if (listcount (adj_list) == 0)
 	    {
 	      list_delete (adj_list);
-	      zlog_warn ("ISIS-Spf: no L%d adjacencies on circuit %s",
-			 level, circuit->interface->name);
+	      if (isis->debugs & DEBUG_SPF_EVENTS)
+		zlog_debug ("ISIS-Spf: no L%d adjacencies on circuit %s",
+			    level, circuit->interface->name);
 	      continue;
 	    }
 	  anode = listhead (adj_list);
diff --git a/isisd/isis_zebra.c b/isisd/isis_zebra.c
index 889c5bf..a385e6b 100644
--- a/isisd/isis_zebra.c
+++ b/isisd/isis_zebra.c
@@ -33,8 +33,10 @@
 #include "stream.h"
 #include "linklist.h"
 
+#include "isisd/dict.h"
 #include "isisd/isis_constants.h"
 #include "isisd/isis_common.h"
+#include "isisd/isisd.h"
 #include "isisd/isis_circuit.h"
 #include "isisd/isis_csm.h"
 #include "isisd/isis_route.h"
@@ -43,6 +45,8 @@
 struct zclient *zclient = NULL;
 
 extern struct thread_master *master;
+extern struct isis *isis;
+
 struct in_addr router_id_zebra;
 
 /* Router-id update message from zebra. */
@@ -66,9 +70,9 @@
 
   ifp = zebra_interface_add_read (zclient->ibuf);
 
-
-  zlog_debug ("Zebra I/F add: %s index %d flags %ld metric %d mtu %d",
-	      ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu);
+  if (isis->debugs & DEBUG_ZEBRA)
+    zlog_debug ("Zebra I/F add: %s index %d flags %ld metric %d mtu %d",
+		ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu);
 
   if (if_is_operative (ifp))
     isis_csm_state_change (IF_UP_FROM_Z, circuit_scan_by_ifp (ifp), ifp);
@@ -92,8 +96,9 @@
     zlog_warn ("Zebra: got delete of %s, but interface is still up",
 	       ifp->name);
 
-  zlog_debug ("Zebra I/F delete: %s index %d flags %ld metric %d mtu %d",
-	      ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu);
+  if (isis->debugs & DEBUG_ZEBRA)
+    zlog_debug ("Zebra I/F delete: %s index %d flags %ld metric %d mtu %d",
+		ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu);
 
 
   /* Cannot call if_delete because we should retain the pseudo interface
@@ -560,7 +565,8 @@
 
   if (command == ZEBRA_IPV4_ROUTE_ADD)
     {
-      zlog_debug ("IPv4 Route add from Z");
+      if (isis->debugs & DEBUG_ZEBRA)
+	zlog_debug ("IPv4 Route add from Z");
     }
 
   return 0;
diff --git a/isisd/isisd.c b/isisd/isisd.c
index e6679cf..a8d6950 100644
--- a/isisd/isisd.c
+++ b/isisd/isisd.c
@@ -171,7 +171,8 @@
   area->area_tag = strdup (area_tag);
   listnode_add (isis->area_list, area);
 
-  zlog_debug ("new IS-IS area instance %s", area->area_tag);
+  if (isis->debugs & DEBUG_EVENTS)
+    zlog_debug ("New IS-IS area instance %s", area->area_tag);
 
   vty->node = ISIS_NODE;
   vty->index = area;
@@ -260,7 +261,8 @@
        */
       memcpy (isis->sysid, GETSYSID (addr, ISIS_SYS_ID_LEN), ISIS_SYS_ID_LEN);
       isis->sysid_set = 1;
-      zlog_debug ("Router has SystemID %s", sysid_print (isis->sysid));
+      if (isis->debugs & DEBUG_EVENTS)
+	zlog_debug ("Router has SystemID %s", sysid_print (isis->sysid));
     }
   else
     {
diff --git a/isisd/isisd.h b/isisd/isisd.h
index 77de12e..7a9f764 100644
--- a/isisd/isisd.h
+++ b/isisd/isisd.h
@@ -144,5 +144,6 @@
 #define DEBUG_SPF_TRIGGERS               (1<<8)
 #define DEBUG_RTE_EVENTS                 (1<<9)
 #define DEBUG_EVENTS                     (1<<10)
+#define DEBUG_ZEBRA                      (1<<11)
 
 #endif /* ISISD_H */