Sigh -- looking at the code it really looks like machineparse = brief format and is used for normal output commands. I'll talk to Paul (who should be back today) and prepare a patch that either has it removed or renamed as appropriate...
Lou On 1/6/2016 8:44 AM, Lou Berger wrote: > Okay. I'll update the patch. > > Lou > > On 1/6/2016 8:23 AM, Donald Sharp wrote: >> I'm in agreement that the machineparse variable should be dropped. If >> we are going to go down the path of machine parsing I would prefer >> that we implement something fairly industry standard, like json. >> >> donald >> >> On Thu, Dec 24, 2015 at 1:10 PM, Lou Berger <[email protected] >> <mailto:[email protected]>> wrote: >> >> [DL: the machineparse foo should probably be dropped] >> >> Signed-off-by: Lou Berger <[email protected] >> <mailto:[email protected]>> >> --- >> bgpd/bgp_mplsvpn.c | 2 +- >> bgpd/bgp_route.c | 56 >> ++++++++++++++++++++++++++++++++++++++---------------- >> bgpd/bgp_route.h | 2 +- >> 3 files changed, 42 insertions(+), 18 deletions(-) >> >> diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c >> index 719822f..2d52d9f 100644 >> --- a/bgpd/bgp_mplsvpn.c >> +++ b/bgpd/bgp_mplsvpn.c >> @@ -564,7 +564,7 @@ bgp_show_mpls_vpn (struct vty *vty, struct >> prefix_rd *prd, enum bgp_show_type ty >> if (tags) >> route_vty_out_tag (vty, &rm->p, ri, 0, >> SAFI_MPLS_VPN); >> else >> - route_vty_out (vty, &rm->p, ri, 0, SAFI_MPLS_VPN); >> + route_vty_out (vty, &rm->p, ri, 0, >> SAFI_MPLS_VPN, 0); >> } >> } >> } >> diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c >> index c4b87a0..036d27d 100644 >> --- a/bgpd/bgp_route.c >> +++ b/bgpd/bgp_route.c >> @@ -5917,8 +5917,13 @@ route_vty_short_status_out (struct vty >> *vty, struct bgp_info *binfo) >> >> /* 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, >> + int machineparse) >> { >> struct attr *attr; >> >> @@ -5926,7 +5931,7 @@ route_vty_out (struct vty *vty, struct >> prefix *p, >> route_vty_short_status_out (vty, binfo); >> >> /* print prefix and mask */ >> - if (! display) >> + if (!display || machineparse) >> route_vty_out_route (p, vty); >> else >> vty_out (vty, "%*s", 17, " "); >> @@ -6002,20 +6007,29 @@ route_vty_out (struct vty *vty, struct >> prefix *p, >> >> >> 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 (machineparse) >> + vty_out (vty, "- "); >> + 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, " "); >> + if (machineparse) >> + vty_out (vty, "- "); >> + else >> + vty_out (vty, " "); >> >> vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0)); >> >> /* Print aspath */ >> if (attr->aspath) >> aspath_print_vty (vty, "%s", attr->aspath, " "); >> + else >> + if (machineparse) >> + vty_out (vty, "-"); >> >> /* Print origin */ >> vty_out (vty, "%s", bgp_origin_str[attr->origin]); >> @@ -6067,12 +6081,12 @@ route_vty_out_tmp (struct vty *vty, struct >> prefix *p, >> #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, " "); >> >> @@ -6323,7 +6337,11 @@ route_vty_out_detail (struct vty *vty, >> struct bgp *bgp, struct prefix *p, >> 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 >> @@ -6477,9 +6495,14 @@ bgp_show_table (struct vty *vty, struct >> bgp_table *table, struct in_addr *router >> int header = 1; >> int display; >> unsigned long output_count; >> + unsigned long total_count; >> + int machineparse = 0; >> >> /* This is first entry point, so reset total line. */ >> output_count = 0; >> + total_count = 0; >> + if (type == bgp_show_type_normal && output_arg == (void *)1) >> + machineparse = 1; >> >> /* Start processing of routes. */ >> for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) >> @@ -6489,6 +6512,7 @@ bgp_show_table (struct vty *vty, struct >> bgp_table *table, struct in_addr *router >> >> 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 >> @@ -6672,7 +6696,7 @@ bgp_show_table (struct vty *vty, struct >> bgp_table *table, struct in_addr *router >> || type == bgp_show_type_flap_neighbor) >> flap_route_vty_out (vty, &rn->p, ri, display, >> SAFI_UNICAST); >> else >> - route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST); >> + route_vty_out (vty, &rn->p, ri, display, >> SAFI_UNICAST, machineparse); >> display++; >> } >> if (display) >> @@ -6683,11 +6707,11 @@ bgp_show_table (struct vty *vty, struct >> bgp_table *table, struct in_addr *router >> 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; >> } >> @@ -9787,7 +9811,7 @@ bgp_table_stats (struct vty *vty, struct bgp >> *bgp, afi_t afi, safi_t safi) >> >> 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; >> } >> >> @@ -9878,7 +9902,7 @@ bgp_table_stats_vty (struct vty *vty, const >> char *name, >> >> 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) >> diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h >> index 455a413..97ce5d3 100644 >> --- a/bgpd/bgp_route.h >> +++ b/bgpd/bgp_route.h >> @@ -240,7 +240,7 @@ extern u_char bgp_distance_apply (struct >> prefix *, struct bgp_info *, struct bgp >> extern afi_t bgp_node_afi (struct vty *); >> extern safi_t bgp_node_safi (struct vty *); >> >> -extern void route_vty_out (struct vty *, struct prefix *, struct >> bgp_info *, int, safi_t); >> +extern void route_vty_out (struct vty *, struct prefix *, struct >> bgp_info *, int, safi_t, int); >> extern void route_vty_out_tag (struct vty *, struct prefix *, >> struct bgp_info *, int, safi_t); >> extern void route_vty_out_tmp (struct vty *, struct prefix *, >> struct attr *, safi_t); >> >> -- >> 2.1.3 >> >> >> _______________________________________________ >> Quagga-dev mailing list >> [email protected] <mailto:[email protected]> >> https://lists.quagga.net/mailman/listinfo/quagga-dev >> >> _______________________________________________ Quagga-dev mailing list [email protected] https://lists.quagga.net/mailman/listinfo/quagga-dev
