MCPcopy Create free account
hub / github.com/SNAS/openbmp / parseExtCommunities

Method parseExtCommunities

Server/src/bgp/ExtCommunity.cpp:51–121  ·  view source on GitHub ↗

* Parse the extended communities path attribute (8 byte as per RFC4360) * * \details * Will parse the EXTENDED COMMUNITIES data passed. Parsed data will be stored * in parsed_data. * * \param [in] attr_len Length of the attribute data * \param [in] data Pointer to the attribute data * \param [out] parsed_data Reference to pars

Source from the content-addressed store, hash-verified

49 *
50 */
51 void ExtCommunity::parseExtCommunities(int attr_len, u_char *data, bgp_msg::UpdateMsg::parsed_update_data &parsed_data) {
52
53 std::string decodeStr = "";
54 extcomm_hdr ec_hdr;
55
56 if ( (attr_len % 8) ) {
57 LOG_NOTICE("%s: Parsing extended community len=%d is invalid, expecting divisible by 8", peer_addr.c_str(), attr_len);
58 return;
59 }
60
61 /*
62 * Loop through consecutive entries
63 */
64 for (int i = 0; i < attr_len; i += 8) {
65 // Setup extended community header
66 ec_hdr.high_type = data[0];
67 ec_hdr.low_type = data[1];
68 ec_hdr.value = data + 2;
69
70 /*
71 * Docode the community by type
72 */
73 switch (ec_hdr.high_type << 2 >> 2) {
74 case EXT_TYPE_IPV4 :
75 decodeStr.append(decodeType_common(ec_hdr, true, true));
76 break;
77
78 case EXT_TYPE_2OCTET_AS :
79 decodeStr.append(decodeType_common(ec_hdr));
80 break;
81
82 case EXT_TYPE_4OCTET_AS :
83 decodeStr.append(decodeType_common(ec_hdr, true));
84 break;
85
86 case EXT_TYPE_GENERIC :
87 decodeStr.append(decodeType_Generic(ec_hdr));
88 break;
89
90 case EXT_TYPE_GENERIC_4OCTET_AS :
91 decodeStr.append(decodeType_Generic(ec_hdr, true));
92 break;
93
94 case EXT_TYPE_GENERIC_IPV4 :
95 decodeStr.append(decodeType_Generic(ec_hdr, true, true));
96 break;
97
98 case EXT_TYPE_OPAQUE :
99 decodeStr.append(decodeType_Opaque(ec_hdr));
100 break;
101
102 case EXT_TYPE_EVPN :
103 decodeStr.append(decodeType_EVPN(ec_hdr));
104 break;
105
106 case EXT_TYPE_QOS_MARK : // TODO: Implement
107 case EXT_TYPE_FLOW_SPEC : // TODO: Implement
108 case EXT_TYPE_COS_CAP : // TODO: Implement

Callers 1

parseAttrDataMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected