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

Method UpdateDbBgpLs

Server/src/bgp/parseBGP.cpp:774–938  ·  view source on GitHub ↗

* Update the Database for bgp-ls * * \details This method will update the database for the BGP-LS information * * \note MUST BE called after adding the attributes since the path_hash_id must be set first. * * \param [in] remove True if the records should be deleted, false if they are to be added/updated * \param [in] ls_data Reference to the parsed link state nlri information *

Source from the content-addressed store, hash-verified

772 * \param [in] ls_attrs Reference to the parsed link state attribute information
773 */
774void parseBGP::UpdateDbBgpLs(bool remove, bgp_msg::UpdateMsg::parsed_data_ls ls_data,
775 bgp_msg::UpdateMsg::parsed_ls_attrs_map &ls_attrs) {
776 /*
777 * Update table entry with attributes based on NLRI
778 */
779 if (ls_data.nodes.size() > 0) {
780 SELF_DEBUG("%s: Updating BGP-LS: Nodes %d", p_entry->peer_addr, ls_data.nodes.size());
781
782 // Merge attributes to each table entry
783 for (list<MsgBusInterface::obj_ls_node>::iterator it = ls_data.nodes.begin();
784 it != ls_data.nodes.end(); it++) {
785
786 if (ls_attrs.find(bgp_msg::MPLinkStateAttr::ATTR_NODE_NAME) != ls_attrs.end())
787 memcpy((*it).name, ls_attrs[bgp_msg::MPLinkStateAttr::ATTR_NODE_NAME].data(), sizeof((*it).name));
788
789 if (ls_attrs.find(bgp_msg::MPLinkStateAttr::ATTR_NODE_IPV4_ROUTER_ID_LOCAL) != ls_attrs.end())
790 memcpy((*it).router_id, ls_attrs[bgp_msg::MPLinkStateAttr::ATTR_NODE_IPV4_ROUTER_ID_LOCAL].data(), 4);
791
792 if (ls_attrs.find(bgp_msg::MPLinkStateAttr::ATTR_NODE_IPV6_ROUTER_ID_LOCAL) != ls_attrs.end()) {
793 memcpy((*it).router_id, ls_attrs[bgp_msg::MPLinkStateAttr::ATTR_NODE_IPV6_ROUTER_ID_LOCAL].data(), 16);
794 (*it).isIPv4 = false;
795 }
796
797 if (ls_attrs.find(bgp_msg::MPLinkStateAttr::ATTR_NODE_MT_ID) != ls_attrs.end()) {
798 strncpy((char *)&(*it).mt_id, (char *)ls_attrs[bgp_msg::MPLinkStateAttr::ATTR_NODE_MT_ID].data(),
799 strlen((char *)ls_attrs[bgp_msg::MPLinkStateAttr::ATTR_NODE_MT_ID].data()) + 1);
800 }
801
802 if (ls_attrs.find(bgp_msg::MPLinkStateAttr::ATTR_NODE_FLAG) != ls_attrs.end())
803 memcpy((*it).flags, ls_attrs[bgp_msg::MPLinkStateAttr::ATTR_NODE_FLAG].data(), sizeof((*it).flags));
804
805 if (ls_attrs.find(bgp_msg::MPLinkStateAttr::ATTR_NODE_ISIS_AREA_ID) != ls_attrs.end())
806 memcpy((*it).isis_area_id, ls_attrs[bgp_msg::MPLinkStateAttr::ATTR_NODE_ISIS_AREA_ID].data(), sizeof((*it).isis_area_id));
807
808 if (ls_attrs.find(bgp_msg::MPLinkStateAttr::ATTR_NODE_SR_CAPABILITIES) != ls_attrs.end()) {
809 memcpy((*it).sr_capabilities_tlv, ls_attrs[bgp_msg::MPLinkStateAttr::ATTR_NODE_SR_CAPABILITIES].data(), sizeof((*it).sr_capabilities_tlv));
810 }
811 }
812
813 if (remove)
814 mbus_ptr->update_LsNode(*p_entry, base_attr, ls_data.nodes, mbus_ptr->LS_ACTION_DEL);
815 else
816 mbus_ptr->update_LsNode(*p_entry, base_attr, ls_data.nodes, mbus_ptr->LS_ACTION_ADD);
817 }
818
819 if (ls_data.links.size() > 0) {
820 SELF_DEBUG("%s: Updating BGP-LS: Links %d ", p_entry->peer_addr, ls_data.links.size());
821
822 // Merge attributes to each table entry
823 for (list<MsgBusInterface::obj_ls_link>::iterator it = ls_data.links.begin();
824 it != ls_data.links.end(); it++) {
825
826 if (not (*it).isIPv4 and ls_attrs.find(bgp_msg::MPLinkStateAttr::ATTR_NODE_IPV6_ROUTER_ID_LOCAL) != ls_attrs.end())
827 memcpy((*it).router_id, ls_attrs[bgp_msg::MPLinkStateAttr::ATTR_NODE_IPV6_ROUTER_ID_LOCAL].data(), 16);
828
829 else if (ls_attrs.find(bgp_msg::MPLinkStateAttr::ATTR_NODE_IPV4_ROUTER_ID_LOCAL) != ls_attrs.end()) {
830 memcpy((*it).router_id, ls_attrs[bgp_msg::MPLinkStateAttr::ATTR_NODE_IPV4_ROUTER_ID_LOCAL].data(), 4);
831 (*it).isIPv4 = true;

Callers

nothing calls this directly

Calls 4

sizeMethod · 0.80
update_LsNodeMethod · 0.80
update_LsLinkMethod · 0.80
update_LsPrefixMethod · 0.80

Tested by

no test coverage detected