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

Method decodeType_IPv6Specific

Server/src/bgp/ExtCommunity.cpp:629–674  ·  view source on GitHub ↗

* Decode IPv6 Specific Type/Subtypes * * \details * Decodes the IPv6 specific and 2-octet, 4-octet. This is pretty much the as common for IPv4, * but with some differences. Converts to human readable form. * * \param [in] ec_hdr Reference to the extended community header * * \return Decoded string value */

Source from the content-addressed store, hash-verified

627 * \return Decoded string value
628 */
629 std::string ExtCommunity::decodeType_IPv6Specific(const extcomm_hdr &ec_hdr) {
630 std::stringstream val_ss;
631 uint16_t val_16b;
632 u_char ipv6_raw[16] = {0};
633 char ipv6_char[40] = {0};
634
635 memcpy(ipv6_raw, ec_hdr.value, 16);
636 if (inet_ntop(AF_INET6, ipv6_raw, ipv6_char, sizeof(ipv6_char)) != NULL)
637 return "";
638
639 memcpy(&val_16b, ec_hdr.value + 16, 2);
640 bgp::SWAP_BYTES(&val_16b);
641
642 switch (ec_hdr.low_type) {
643
644 case EXT_IPV6_ROUTE_ORIGIN :
645 val_ss << "soo=" << ipv6_char << ":" << val_16b;
646 break;
647
648 case EXT_IPV6_ROUTE_TARGET :
649 val_ss << "rt=" << ipv6_char << ":" << val_16b;
650 break;
651
652 case EXT_IPV6_CISCO_VPN_ID :
653 val_ss << "vpn-id=" << ipv6_char << ":0x" << std::hex << val_16b;
654
655 break;
656
657 case EXT_IPV6_VRF_IMPORT :
658 val_ss << "import=" << ipv6_char << ":" << val_16b;
659
660 break;
661
662 case EXT_IPV6_IA_P2MP_SEG_NH :
663 val_ss << "p2mp-nh=" << ipv6_char << ":" << val_16b;
664
665 break;
666
667 default :
668 LOG_INFO("%s: Extended community ipv6 specific type %d subtype = %d is not yet supported", peer_addr.c_str(),
669 ec_hdr.high_type, ec_hdr.low_type);
670 break;
671 }
672
673 return val_ss.str();
674 }
675}

Callers

nothing calls this directly

Calls 1

SWAP_BYTESFunction · 0.85

Tested by

no test coverage detected