Skip to content

Commit

Permalink
Use bgp_nlri_print() for MP_UNREACH too.
Browse files Browse the repository at this point in the history
  • Loading branch information
fenner committed Apr 18, 2019
1 parent 1546ed2 commit 8193828
Showing 1 changed file with 4 additions and 147 deletions.
151 changes: 4 additions & 147 deletions print-bgp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8193828

Please sign in to comment.