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

Method parsev6ExtCommunities

Server/src/bgp/ExtCommunity.cpp:581–615  ·  view source on GitHub ↗

* Parse the extended communities path attribute (20 byte as per RFC5701) * * \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 par

Source from the content-addressed store, hash-verified

579 *
580 */
581 void ExtCommunity::parsev6ExtCommunities(int attr_len, u_char *data, bgp_msg::UpdateMsg::parsed_update_data &parsed_data) {
582 std::string decodeStr = "";
583 extcomm_hdr ec_hdr;
584
585 LOG_INFO("%s: Parsing IPv6 extended community len=%d", peer_addr.c_str(), attr_len);
586
587 if ( (attr_len % 20) ) {
588 LOG_NOTICE("%s: Parsing IPv6 extended community len=%d is invalid, expecting divisible by 20", peer_addr.c_str(), attr_len);
589 return;
590 }
591
592 /*
593 * Loop through consecutive entries
594 */
595 for (int i = 0; i < attr_len; i += 20) {
596 // Setup extended community header
597 ec_hdr.high_type = data[0];
598 ec_hdr.low_type = data[1];
599 ec_hdr.value = data + 2;
600
601 /*
602 * Docode the community by type
603 */
604 switch (ec_hdr.high_type << 2 >> 2) {
605 case 0 : // Currently IPv6 specific uses this type field
606 decodeStr.append(decodeType_IPv6Specific(ec_hdr));
607 break;
608
609 default :
610 LOG_NOTICE("%s: Unexpected type for IPv6 %d,%d", peer_addr.c_str(),
611 ec_hdr.high_type, ec_hdr.low_type);
612 break;
613 }
614 }
615 }
616
617
618 /**

Callers 1

parseAttrDataMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected