]> The Tcpdump Group git mirrors - tcpdump/commitdiff
BGP: Print LARGE_COMMUNITY Path Attribute
authorFrancois-Xavier Le Bail <[email protected]>
Wed, 12 Oct 2016 12:16:27 +0000 (14:16 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Wed, 12 Oct 2016 12:16:27 +0000 (14:16 +0200)
Moreover:
Delete redundant empty lines

print-bgp.c

index d00cd8ad6b26ac489b2cd09ad12e6a85a626503d..e1b77502e3ef1b081c2c2f90886842394eb4da14 100644 (file)
@@ -139,6 +139,7 @@ struct bgp_route_refresh {
 #define BGPTYPE_AIGP                    26      /* RFC7311 */
 #define BGPTYPE_PE_DISTINGUISHER_LABEL  27      /* RFC6514 */
 #define BGPTYPE_ENTROPY_LABEL           28      /* RFC6790 */
+#define BGPTYPE_LARGE_COMMUNITY                30      /* draft-ietf-idr-large-community-02 */
 #define BGPTYPE_ATTR_SET               128      /* RFC6368 */
 
 #define BGP_MP_NLRI_MINSIZE              3       /* End of RIB Marker detection */
@@ -169,6 +170,7 @@ static const struct tok bgp_attr_values[] = {
     { BGPTYPE_AIGP,             "Accumulated IGP Metric"},
     { BGPTYPE_PE_DISTINGUISHER_LABEL, "PE Distinguisher Label"},
     { BGPTYPE_ENTROPY_LABEL,    "Entropy Label"},
+    { BGPTYPE_LARGE_COMMUNITY,  "Large Community"},
     { BGPTYPE_ATTR_SET,         "Attribute Set"},
     { 255,                      "Reserved for development"},
     { 0, NULL}
@@ -201,7 +203,6 @@ static const struct tok bgp_as_path_segment_close_values[] = {
 #define BGP_OPT_AUTH                    1
 #define BGP_OPT_CAP                     2
 
-
 static const struct tok bgp_opt_values[] = {
     { BGP_OPT_AUTH,             "Authentication Information"},
     { BGP_OPT_CAP,              "Capabilities Advertisement"},
@@ -355,7 +356,6 @@ static const struct tok bgp_aigp_values[] = {
     { 0, NULL}
 };
 
-
 /* Subsequent address family identifier, RFC2283 section 7 */
 #define SAFNUM_RES                      0
 #define SAFNUM_UNICAST                  1
@@ -430,7 +430,6 @@ static const struct tok bgp_safi_values[] = {
 #define BGP_EXT_COM_L2VPN_RT_0  0x000a  /* L2VPN Identifier,Format AS(2bytes):AN(4bytes) */
 #define BGP_EXT_COM_L2VPN_RT_1  0xF10a  /* L2VPN Identifier,Format IP address:AN(2bytes) */
 
-
 /* http://www.cisco.com/en/US/tech/tk436/tk428/technologies_tech_note09186a00801eb09a.shtml  */
 #define BGP_EXT_COM_EIGRP_GEN   0x8800
 #define BGP_EXT_COM_EIGRP_METRIC_AS_DELAY  0x8801
@@ -707,7 +706,6 @@ trunc:
     return (total_length);
 }
 
-
 /* RDs and RTs share the same semantics
  * we use bgp_vpn_rd_print for
  * printing route targets inside a NLRI */
@@ -1374,7 +1372,6 @@ bgp_attr_print(netdissect_options *ndo,
                }
                break;
 
-
         /*
          * Process AS4 byte path and AS2 byte path attributes here.
          */
@@ -2191,7 +2188,6 @@ bgp_attr_print(netdissect_options *ndo,
                              tok2str(bgp_aigp_values, "Unknown", type),
                              type, length));
 
-
                    /*
                     * Check if we can read the TLV data.
                     */
@@ -2267,7 +2263,23 @@ bgp_attr_print(netdissect_options *ndo,
                }
                 break;
 
-
+       case BGPTYPE_LARGE_COMMUNITY:
+               if (len == 0 || len % 12) {
+                       ND_PRINT((ndo, "invalid len"));
+                       break;
+               }
+               ND_PRINT((ndo, "\n\t    "));
+               while (len > 0) {
+                       ND_TCHECK2(*tptr, 12);
+                       ND_PRINT((ndo, "%u:%u:%u%s",
+                                EXTRACT_32BITS(tptr),
+                                EXTRACT_32BITS(tptr + 4),
+                                EXTRACT_32BITS(tptr + 8),
+                                (len > 12) ? ", " : ""));
+                        tptr += 12;
+                        len -= 12;
+               }
+               break;
        default:
            ND_TCHECK2(*pptr,len);
             ND_PRINT((ndo, "\n\t    no Attribute %u decoder", atype)); /* we have no decoder for the attribute */