bgpd: add "show ip bgp scan detail" command

* bgp_nexthop.c: (show_ip_bgp_scan) transform into
  show_ip_bgp_scan_tables(), which uses inet_ntop() and can dump
  nexthops on request; (show_ip_bgp_scan_detail_cmd) new function
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c
index de303e3..cb5a050 100644
--- a/bgpd/bgp_nexthop.c
+++ b/bgpd/bgp_nexthop.c
@@ -1189,16 +1189,13 @@
        "Configure background scanner interval\n"
        "Scanner interval (seconds)\n")
 
-DEFUN (show_ip_bgp_scan,
-       show_ip_bgp_scan_cmd,
-       "show ip bgp scan",
-       SHOW_STR
-       IP_STR
-       BGP_STR
-       "BGP scan status\n")
+static int
+show_ip_bgp_scan_tables (struct vty *vty, const char detail)
 {
   struct bgp_node *rn;
   struct bgp_nexthop_cache *bnc;
+  char buf[INET6_ADDRSTRLEN];
+  u_char i;
 
   if (bgp_scan_thread)
     vty_out (vty, "BGP scan is running%s", VTY_NEWLINE);
@@ -1211,28 +1208,37 @@
     if ((bnc = rn->info) != NULL)
       {
 	if (bnc->valid)
+	{
 	  vty_out (vty, " %s valid [IGP metric %d]%s",
-		   inet_ntoa (rn->p.u.prefix4), bnc->metric, VTY_NEWLINE);
+		   inet_ntop (AF_INET, &rn->p.u.prefix4, buf, INET6_ADDRSTRLEN), bnc->metric, VTY_NEWLINE);
+	  if (detail)
+	    for (i = 0; i < bnc->nexthop_num; i++)
+	      vty_out (vty, "  %s%s", inet_ntop (AF_INET, &bnc->nexthop[i].gate.ipv4, buf, INET6_ADDRSTRLEN), VTY_NEWLINE);
+	}
 	else
 	  vty_out (vty, " %s invalid%s",
-		   inet_ntoa (rn->p.u.prefix4), VTY_NEWLINE);
+		   inet_ntop (AF_INET, &rn->p.u.prefix4, buf, INET6_ADDRSTRLEN), VTY_NEWLINE);
       }
 
 #ifdef HAVE_IPV6
   {
-    char buf[BUFSIZ];
     for (rn = bgp_table_top (bgp_nexthop_cache_table[AFI_IP6]); 
          rn; 
          rn = bgp_route_next (rn))
       if ((bnc = rn->info) != NULL)
 	{
 	  if (bnc->valid)
+	  {
 	    vty_out (vty, " %s valid [IGP metric %d]%s",
-		     inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, BUFSIZ),
+		     inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, INET6_ADDRSTRLEN),
 		     bnc->metric, VTY_NEWLINE);
+	    if (detail)
+	      for (i = 0; i < bnc->nexthop_num; i++)
+	        vty_out (vty, "  %s%s", inet_ntop (AF_INET6, &bnc->nexthop[i].gate.ipv4, buf, INET6_ADDRSTRLEN), VTY_NEWLINE);
+	  }
 	  else
 	    vty_out (vty, " %s invalid%s",
-		     inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, BUFSIZ),
+		     inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, INET6_ADDRSTRLEN),
 		     VTY_NEWLINE);
 	}
   }
@@ -1248,14 +1254,12 @@
 
 #ifdef HAVE_IPV6
   {
-    char buf[BUFSIZ];
-
     for (rn = bgp_table_top (bgp_connected_table[AFI_IP6]); 
          rn; 
          rn = bgp_route_next (rn))
       if (rn->info != NULL)
 	vty_out (vty, " %s/%d%s",
-		 inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, BUFSIZ),
+		 inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, INET6_ADDRSTRLEN),
 		 rn->p.prefixlen,
 		 VTY_NEWLINE);
   }
@@ -1264,6 +1268,29 @@
   return CMD_SUCCESS;
 }
 
+DEFUN (show_ip_bgp_scan,
+       show_ip_bgp_scan_cmd,
+       "show ip bgp scan",
+       SHOW_STR
+       IP_STR
+       BGP_STR
+       "BGP scan status\n")
+{
+  return show_ip_bgp_scan_tables (vty, 0);
+}
+
+DEFUN (show_ip_bgp_scan_detail,
+       show_ip_bgp_scan_detail_cmd,
+       "show ip bgp scan detail",
+       SHOW_STR
+       IP_STR
+       BGP_STR
+       "BGP scan status\n"
+       "More detailed output\n")
+{
+  return show_ip_bgp_scan_tables (vty, 1);
+}
+
 int
 bgp_config_write_scan_time (struct vty *vty)
 {
@@ -1305,8 +1332,10 @@
   install_element (BGP_NODE, &no_bgp_scan_time_cmd);
   install_element (BGP_NODE, &no_bgp_scan_time_val_cmd);
   install_element (VIEW_NODE, &show_ip_bgp_scan_cmd);
+  install_element (VIEW_NODE, &show_ip_bgp_scan_detail_cmd);
   install_element (RESTRICTED_NODE, &show_ip_bgp_scan_cmd);
   install_element (ENABLE_NODE, &show_ip_bgp_scan_cmd);
+  install_element (ENABLE_NODE, &show_ip_bgp_scan_detail_cmd);
 }
 
 void