From 819382837bea136c72b4b9dae7795dc01b3effe6 Mon Sep 17 00:00:00 2001 From: Bill Fenner Date: Thu, 18 Apr 2019 07:27:43 -0700 Subject: [PATCH] Use bgp_nlri_print() for MP_UNREACH too. --- print-bgp.c | 151 ++-------------------------------------------------- 1 file changed, 4 insertions(+), 147 deletions(-) diff --git a/print-bgp.c b/print-bgp.c index 22644bbee..1827e422a 100644 --- a/print-bgp.c +++ b/print-bgp.c @@ -2135,153 +2135,10 @@ bgp_attr_print(netdissect_options *ndo, add_path6 = check_add_path(ndo, tptr, (len-(tptr - pptr)), 128); while (tptr < pptr + len) { - switch (af<<8 | safi) { - case (AFNUM_INET<<8 | SAFNUM_UNICAST): - case (AFNUM_INET<<8 | SAFNUM_MULTICAST): - case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST): - if (add_path4) { - path_id = GET_BE_U_4(tptr); - tptr += 4; - } - advance = decode_prefix4(ndo, tptr, len, buf, sizeof(buf)); - if (advance == -1) - ND_PRINT("\n\t (illegal prefix length)"); - else if (advance == -2) - goto trunc; - else if (advance == -3) - break; /* bytes left, but not enough */ - else - ND_PRINT("\n\t %s", buf); - if (add_path4) { - ND_PRINT(" Path Id: %u", path_id); - } - break; - case (AFNUM_INET<<8 | SAFNUM_LABUNICAST): - advance = decode_labeled_prefix4(ndo, tptr, len, buf, sizeof(buf)); - if (advance == -1) - ND_PRINT("\n\t (illegal prefix length)"); - else if (advance == -2) - goto trunc; - else if (advance == -3) - break; /* bytes left, but not enough */ - else - ND_PRINT("\n\t %s", buf); - break; - case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST): - case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST): - case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST): - advance = decode_labeled_vpn_prefix4(ndo, tptr, buf, sizeof(buf)); - if (advance == -1) - ND_PRINT("\n\t (illegal prefix length)"); - else if (advance == -2) - goto trunc; - else - ND_PRINT("\n\t %s", buf); - break; - case (AFNUM_INET6<<8 | SAFNUM_UNICAST): - case (AFNUM_INET6<<8 | SAFNUM_MULTICAST): - case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST): - if (add_path6) { - path_id = GET_BE_U_4(tptr); - tptr += 4; - } - advance = decode_prefix6(ndo, tptr, len, buf, sizeof(buf)); - if (advance == -1) - ND_PRINT("\n\t (illegal prefix length)"); - else if (advance == -2) - goto trunc; - else if (advance == -3) - break; /* bytes left, but not enough */ - else - ND_PRINT("\n\t %s", buf); - if (add_path6) { - ND_PRINT(" Path Id: %u", path_id); - } - break; - case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST): - advance = decode_labeled_prefix6(ndo, tptr, len, buf, sizeof(buf)); - if (advance == -1) - ND_PRINT("\n\t (illegal prefix length)"); - else if (advance == -2) - goto trunc; - else if (advance == -3) - break; /* bytes left, but not enough */ - else - ND_PRINT("\n\t %s", buf); - break; - case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST): - case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST): - case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST): - advance = decode_labeled_vpn_prefix6(ndo, tptr, buf, sizeof(buf)); - if (advance == -1) - ND_PRINT("\n\t (illegal prefix length)"); - else if (advance == -2) - goto trunc; - else - ND_PRINT("\n\t %s", buf); - break; - case (AFNUM_VPLS<<8 | SAFNUM_VPLS): - case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST): - case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST): - case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST): - advance = decode_labeled_vpn_l2(ndo, tptr, buf, sizeof(buf)); - if (advance == -1) - ND_PRINT("\n\t (illegal length)"); - else if (advance == -2) - goto trunc; - else - ND_PRINT("\n\t %s", buf); - break; - case (AFNUM_NSAP<<8 | SAFNUM_UNICAST): - case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST): - case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST): - advance = decode_clnp_prefix(ndo, tptr, buf, sizeof(buf)); - if (advance == -1) - ND_PRINT("\n\t (illegal prefix length)"); - else if (advance == -2) - goto trunc; - else - ND_PRINT("\n\t %s", buf); - break; - case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST): - case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST): - case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST): - advance = decode_labeled_vpn_clnp_prefix(ndo, tptr, buf, sizeof(buf)); - if (advance == -1) - ND_PRINT("\n\t (illegal prefix length)"); - else if (advance == -2) - goto trunc; - else - ND_PRINT("\n\t %s", buf); - break; - case (AFNUM_INET<<8 | SAFNUM_MDT): - advance = decode_mdt_vpn_nlri(ndo, tptr, buf, sizeof(buf)); - if (advance == -1) - ND_PRINT("\n\t (illegal prefix length)"); - else if (advance == -2) - goto trunc; - else - ND_PRINT("\n\t %s", buf); - break; - case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): /* fall through */ - case (AFNUM_INET6<<8 | SAFNUM_MULTICAST_VPN): - advance = decode_multicast_vpn(ndo, tptr, buf, sizeof(buf)); - if (advance == -1) - ND_PRINT("\n\t (illegal prefix length)"); - else if (advance == -2) - goto trunc; - else - ND_PRINT("\n\t %s", buf); - break; - default: - ND_TCHECK_LEN(tptr - 3, tlen); - ND_PRINT("no AFI %u / SAFI %u decoder", af, safi); - if (ndo->ndo_vflag <= 1) - print_unknown_data(ndo, tptr-3, "\n\t ", tlen); - advance = 0; - tptr = pptr + len; - break; - } + advance = bgp_nlri_print(ndo, af, safi, tptr, len, buf, sizeof(buf), + add_path4, add_path6); + if (advance == -2) + goto trunc; if (advance < 0) break; tptr += advance;