]> The Tcpdump Group git mirrors - tcpdump/commitdiff
BGP: add decoding of ADD-PATH capability
authorDenis Ovsienko <[email protected]>
Mon, 29 Jun 2015 15:06:31 +0000 (16:06 +0100)
committerDenis Ovsienko <[email protected]>
Mon, 29 Jun 2015 15:41:20 +0000 (16:41 +0100)
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.

print-bgp.c

index 562de9675002bfe6cf1244f985b5e0938fa829e0..c4099f59cca0839a6bc7e5b94e0decd187539446 100644 (file)
@@ -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_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[] = {
 #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_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}
 };
     { 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 },
 };
 
   { 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];
 
 /*
 static char astostr[20];
 
 /*
@@ -2320,6 +2330,28 @@ bgp_capabilities_print(netdissect_options *ndo,
                             EXTRACT_32BITS(opt + i + 2))));
                     }
                     break;
                             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));
                 default:
                     ND_PRINT((ndo, "\n\t\tno decoder for Capability %u",
                            cap_type));