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

Method UpdateDBWdrawnPrefixes

Server/src/bgp/parseBGP.cpp:724–761  ·  view source on GitHub ↗

* Update the Database withdrawn prefixes * * \details This method will update the database for the supplied advertised prefixes * * \param wdrawn_prefixes Reference to the list of withdrawn prefixes */

Source from the content-addressed store, hash-verified

722 * \param wdrawn_prefixes Reference to the list<prefix_tuple> of withdrawn prefixes
723 */
724void parseBGP::UpdateDBWdrawnPrefixes(std::list<bgp::prefix_tuple> &wdrawn_prefixes) {
725 vector<MsgBusInterface::obj_rib> rib_list;
726 MsgBusInterface::obj_rib rib_entry;
727
728 /*
729 * Loop through all prefixes and add/update them in the DB
730 */
731 for (std::list<bgp::prefix_tuple>::iterator it = wdrawn_prefixes.begin();
732 it != wdrawn_prefixes.end();
733 it++) {
734
735 bgp::prefix_tuple &tuple = (*it);
736 memcpy(rib_entry.path_attr_hash_id, path_hash_id, sizeof(rib_entry.path_attr_hash_id));
737 memcpy(rib_entry.peer_hash_id, p_entry->hash_id, sizeof(rib_entry.peer_hash_id));
738 strncpy(rib_entry.prefix, tuple.prefix.c_str(), sizeof(rib_entry.prefix));
739
740 rib_entry.prefix_len = tuple.len;
741
742 rib_entry.isIPv4 = tuple.isIPv4 ? 1 : 0;
743
744 memcpy(rib_entry.prefix_bin, tuple.prefix_bin, sizeof(rib_entry.prefix_bin));
745
746 rib_entry.path_id = tuple.path_id;
747 snprintf(rib_entry.labels, sizeof(rib_entry.labels), "%s", tuple.labels.c_str());
748
749 SELF_DEBUG("%s: Removing prefix=%s len=%d", p_entry->peer_addr, rib_entry.prefix, rib_entry.prefix_len);
750
751 // Add entry to the list
752 rib_list.insert(rib_list.end(), rib_entry);
753 }
754
755 // Update the DB
756 if (rib_list.size() > 0)
757 mbus_ptr->update_unicastPrefix(*p_entry, rib_list, NULL, mbus_ptr->UNICAST_PREFIX_ACTION_DEL);
758
759 rib_list.clear();
760 wdrawn_prefixes.clear();
761}
762
763/**
764 * Update the Database for bgp-ls

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.80
update_unicastPrefixMethod · 0.80

Tested by

no test coverage detected