From: Denis Ovsienko Date: Mon, 29 Jun 2015 15:06:31 +0000 (+0100) Subject: BGP: add decoding of ADD-PATH capability X-Git-Tag: tcpdump-4.8.0~230 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/c9c3d3cfdf3a926e02114cfe611ffe20167ab5f4 BGP: add decoding of ADD-PATH capability This implements the capability part of draft-ietf-idr-add-paths-10 and seems to work for a packet capture I am looking into. The problem with the "extended NLRI encodings" defined in the same document is that they are going to use a different structure for the two previously assigned path attributes, which makes decoding of an UPDATE difficult without having both relevant OPENs from the same session. --- diff --git a/print-bgp.c b/print-bgp.c index 562de967..c4099f59 100644 --- a/print-bgp.c +++ b/print-bgp.c @@ -202,6 +202,7 @@ static const struct tok bgp_opt_values[] = { #define BGP_CAPCODE_RESTART 64 /* draft-ietf-idr-restart-05 */ #define BGP_CAPCODE_AS_NEW 65 /* XXX */ #define BGP_CAPCODE_DYN_CAP 67 /* XXX */ +#define BGP_CAPCODE_ADD_PATH 69 /* draft-ietf-idr-add-paths-10 */ #define BGP_CAPCODE_RR_CISCO 128 static const struct tok bgp_capcode_values[] = { @@ -211,6 +212,7 @@ static const struct tok bgp_capcode_values[] = { { BGP_CAPCODE_RESTART, "Graceful Restart"}, { BGP_CAPCODE_AS_NEW, "32-Bit AS Number"}, { BGP_CAPCODE_DYN_CAP, "Dynamic Capability"}, + { BGP_CAPCODE_ADD_PATH, "Multiple Paths"}, { BGP_CAPCODE_RR_CISCO, "Route Refresh (Cisco)"}, { 0, NULL} }; @@ -462,6 +464,14 @@ static const struct tok bgp_extd_comm_ospf_rtype_values[] = { { 0, NULL }, }; +/* ADD-PATH Send/Receive field values */ +static const struct tok bgp_add_path_recvsend[] = { + { 1, "Receive" }, + { 2, "Send" }, + { 3, "Both" }, + { 0, NULL }, +}; + static char astostr[20]; /* @@ -2320,6 +2330,28 @@ bgp_capabilities_print(netdissect_options *ndo, EXTRACT_32BITS(opt + i + 2)))); } break; + case BGP_CAPCODE_ADD_PATH: + cap_offset=2; + if (tcap_len == 0) { + ND_PRINT((ndo, " (bogus)")); /* length */ + break; + } + while (tcap_len > 0) { + if (tcap_len < 4) { + ND_PRINT((ndo, "\n\t\t(malformed)")); + break; + } + ND_PRINT((ndo, "\n\t\tAFI %s (%u), SAFI %s (%u), Send/Receive: %s", + tok2str(af_values,"Unknown",EXTRACT_16BITS(opt+i+cap_offset)), + EXTRACT_16BITS(opt+i+cap_offset), + tok2str(bgp_safi_values,"Unknown",opt[i+cap_offset+2]), + opt[i+cap_offset+2], + tok2str(bgp_add_path_recvsend,"Bogus (0x%02x)",opt[i+cap_offset+3]) + )); + tcap_len-=4; + cap_offset+=4; + } + break; default: ND_PRINT((ndo, "\n\t\tno decoder for Capability %u", cap_type));