bgpd: drop machineparse / random "show" improvements

Signed-off-by: Lou Berger <lberger@labn.net>
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index 9f06538..99e86b4 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -484,6 +484,9 @@
   char v4_header[] = "   Network          Next Hop            Metric LocPrf Weight Path%s";
   char v4_header_tag[] = "   Network          Next Hop      In tag/Out tag%s";
 
+  unsigned long output_count = 0;
+  unsigned long total_count  = 0;
+
   bgp = bgp_get_default ();
   if (bgp == NULL)
     {
@@ -509,6 +512,7 @@
 	  for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
 	    for (ri = rm->info; ri; ri = ri->next)
 	      {
+                total_count++;
 		if (type == bgp_show_type_neighbor)
 		  {
 		    union sockunion *su = output_arg;
@@ -568,9 +572,19 @@
 		  route_vty_out_tag (vty, &rm->p, ri, 0, SAFI_MPLS_VPN);
 	        else
 		  route_vty_out (vty, &rm->p, ri, 0, SAFI_MPLS_VPN);
+                output_count++;
 	      }
         }
     }
+
+  if (output_count == 0)
+    {
+      vty_out (vty, "No prefixes displayed, %ld exist%s", total_count, VTY_NEWLINE);
+    }
+  else
+    vty_out (vty, "%sDisplayed %ld out of %ld total prefixes%s",
+	     VTY_NEWLINE, output_count, total_count, VTY_NEWLINE);
+
   return CMD_SUCCESS;
 }
 
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 0ea7ced..7890e3a 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -5940,8 +5940,12 @@
 
 /* called from terminal list command */
 void
-route_vty_out (struct vty *vty, struct prefix *p,
-	       struct bgp_info *binfo, int display, safi_t safi)
+route_vty_out(
+    struct vty *vty,
+    struct prefix *p,
+    struct bgp_info *binfo,
+    int display,
+    safi_t safi)
 {
   struct attr *attr;
   
@@ -5949,7 +5953,7 @@
   route_vty_short_status_out (vty, binfo);
   
   /* print prefix and mask */
-  if (! display)
+  if (!display)
     route_vty_out_route (p, vty);
   else
     vty_out (vty, "%*s", 17, " ");
@@ -6025,14 +6029,14 @@
 
 
       if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
-	vty_out (vty, "%10u", attr->med);
+	vty_out (vty, "%10u ", attr->med);
       else
-	vty_out (vty, "          ");
+	  vty_out (vty, "          ");
 
       if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
-	vty_out (vty, "%7u", attr->local_pref);
+	vty_out (vty, "%7u ", attr->local_pref);
       else
-	vty_out (vty, "       ");
+	  vty_out (vty, "       ");
 
       vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0));
     
@@ -6090,12 +6094,12 @@
 #endif /* HAVE_IPV6 */
 
       if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
-	vty_out (vty, "%10u", attr->med);
+	vty_out (vty, "%10u ", attr->med);
       else
 	vty_out (vty, "          ");
 
       if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
-	vty_out (vty, "%7u", attr->local_pref);
+	vty_out (vty, "%7u ", attr->local_pref);
       else
 	vty_out (vty, "       ");
       
@@ -6346,7 +6350,11 @@
 	    vty_out (vty, " (inaccessible)"); 
 	  else if (binfo->extra && binfo->extra->igpmetric)
 	    vty_out (vty, " (metric %u)", binfo->extra->igpmetric);
-	  vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN));
+	  if (!sockunion2str (&binfo->peer->su, buf, sizeof(buf))) {
+	    buf[0] = '?';
+	    buf[1] = 0;
+	  }
+	  vty_out (vty, " from %s", buf);
 	  if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
 	    vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id));
 	  else
@@ -6500,9 +6508,11 @@
   int header = 1;
   int display;
   unsigned long output_count;
+  unsigned long total_count;
 
   /* This is first entry point, so reset total line. */
   output_count = 0;
+  total_count  = 0;
 
   /* Start processing of routes. */
   for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) 
@@ -6512,6 +6522,7 @@
 
 	for (ri = rn->info; ri; ri = ri->next)
 	  {
+            total_count++;
 	    if (type == bgp_show_type_flap_statistics
 		|| type == bgp_show_type_flap_address
 		|| type == bgp_show_type_flap_prefix
@@ -6706,11 +6717,11 @@
   if (output_count == 0)
     {
       if (type == bgp_show_type_normal)
-	vty_out (vty, "No BGP network exists%s", VTY_NEWLINE);
+        vty_out (vty, "No BGP prefixes displayed, %ld exist%s", total_count, VTY_NEWLINE);
     }
   else
-    vty_out (vty, "%sTotal number of prefixes %ld%s",
-	     VTY_NEWLINE, output_count, VTY_NEWLINE);
+    vty_out (vty, "%sDisplayed  %ld out of %ld total prefixes%s",
+	     VTY_NEWLINE, output_count, total_count, VTY_NEWLINE);
 
   return CMD_SUCCESS;
 }
@@ -9786,7 +9797,7 @@
   
   if (!bgp->rib[afi][safi])
     {
-      vty_out (vty, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE);
+      vty_out (vty, "%% No RIB exists for the AFI/SAFI%s", VTY_NEWLINE);
       return CMD_WARNING;
     }
   
@@ -9877,7 +9888,7 @@
 
   if (!bgp)
     {
-      vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
+      vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE);
       return CMD_WARNING;
     }
   if (strncmp (afi_str, "ipv", 3) == 0)