From: vivek Date: Tue, 13 Mar 2018 18:14:26 +0000 (+0000) Subject: bgpd: Fix enum, use API for log string X-Git-Tag: frr-5.0-dev~155^2~1 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=b7d08f5ab50dffae02feb146dde3a5e752c6b3ff;p=mirror%2Ffrr.git bgpd: Fix enum, use API for log string Suggested-by: Philippe Guibert Signed-off-by: Vivek Venkatraman --- diff --git a/bgpd/bgp_attr.h b/bgpd/bgp_attr.h index 5bf2377558..5403f32543 100644 --- a/bgpd/bgp_attr.h +++ b/bgpd/bgp_attr.h @@ -99,7 +99,7 @@ struct overlay_index { }; enum pta_type { - PMSI_TNLTYPE_NO_INFO, + PMSI_TNLTYPE_NO_INFO = 0, PMSI_TNLTYPE_RSVP_TE_P2MP, PMSI_TNLTYPE_MLDP_P2MP, PMSI_TNLTYPE_PIM_SSM, diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c index 8b308c8f3e..2580d2e5a5 100644 --- a/bgpd/bgp_debug.c +++ b/bgpd/bgp_debug.c @@ -159,10 +159,6 @@ static const struct message bgp_notify_capability_msg[] = { /* Origin strings. */ const char *bgp_origin_str[] = {"i", "e", "?"}; const char *bgp_origin_long_str[] = {"IGP", "EGP", "incomplete"}; -const char *pmsi_tnltype_str[] = {"No info", "RSVP-TE P2MP", "mLDP P2MP", - "PIM-SSM", "PIM-SM", "PIM-BIDIR", - "Ingress Replication", "mLDP MP2MP"}; - /* Given a string return a pointer the corresponding peer structure */ static struct peer *bgp_find_peer(struct vty *vty, const char *peer_str) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 88e93f5710..de693a219c 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -82,6 +82,20 @@ extern const char *bgp_origin_str[]; extern const char *bgp_origin_long_str[]; +/* PMSI strings. */ +#define PMSI_TNLTYPE_STR_NO_INFO "No info" +#define PMSI_TNLTYPE_STR_DEFAULT PMSI_TNLTYPE_STR_NO_INFO +static const struct message bgp_pmsi_tnltype_str[] = { + {PMSI_TNLTYPE_NO_INFO, PMSI_TNLTYPE_STR_NO_INFO}, + {PMSI_TNLTYPE_RSVP_TE_P2MP, "RSVP-TE P2MP"}, + {PMSI_TNLTYPE_MLDP_P2MP, "mLDP P2MP"}, + {PMSI_TNLTYPE_PIM_SSM, "PIM-SSM"}, + {PMSI_TNLTYPE_PIM_SM, "PIM-SM"}, + {PMSI_TNLTYPE_PIM_BIDIR, "PIM-BIDIR"}, + {PMSI_TNLTYPE_INGR_REPL, "Ingress Replication"}, + {PMSI_TNLTYPE_MLDP_MP2MP, "mLDP MP2MP"}, + {0}}; + struct bgp_node *bgp_afi_node_get(struct bgp_table *table, afi_t afi, safi_t safi, struct prefix *p, struct prefix_rd *prd) @@ -7791,16 +7805,19 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p, /* Line 10 display PMSI tunnel attribute, if present */ if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL)) { + const char *str = lookup_msg(bgp_pmsi_tnltype_str, + attr->pmsi_tnl_type, + PMSI_TNLTYPE_STR_DEFAULT); + if (json_paths) { json_pmsi = json_object_new_object(); - json_object_string_add( - json_pmsi, "tunnelType", - pmsi_tnltype_str[attr->pmsi_tnl_type]); + json_object_string_add(json_pmsi, + "tunnelType", str); json_object_object_add(json_path, "pmsi", json_pmsi); } else vty_out(vty, " PMSI Tunnel Type: %s\n", - pmsi_tnltype_str[attr->pmsi_tnl_type]); + str); } }