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

Method UpdateDBL3Vpn

Server/src/bgp/parseBGP.cpp:468–561  ·  view source on GitHub ↗

* Update the Database advertised l3vpn * * \details This method will update the database for the supplied advertised prefixes * * \param [in] remove True if the records should be deleted, false if they are to be added/updated * \param [in] prefixes Reference to the list of advertised vpns * \param [in] attrs Reference to the parsed attributes map */

Source from the content-addressed store, hash-verified

466 * \param [in] attrs Reference to the parsed attributes map
467 */
468void parseBGP::UpdateDBL3Vpn(bool remove, std::list<bgp::vpn_tuple> &prefixes,
469 bgp_msg::UpdateMsg::parsed_attrs_map &attrs) {
470 vector<MsgBusInterface::obj_vpn> rib_list;
471 MsgBusInterface::obj_vpn rib_entry;
472 uint32_t value_32bit;
473 uint64_t value_64bit;
474
475 /*
476 * Loop through all vpn and add/update them in the DB
477 */
478 for (std::list<bgp::vpn_tuple>::iterator it = prefixes.begin();
479 it != prefixes.end();
480 it++) {
481 bgp::vpn_tuple &tuple = (*it);
482
483 memcpy(rib_entry.path_attr_hash_id, path_hash_id, sizeof(rib_entry.path_attr_hash_id));
484 memcpy(rib_entry.peer_hash_id, p_entry->hash_id, sizeof(rib_entry.peer_hash_id));
485
486 rib_entry.rd_type = tuple.rd_type;
487 rib_entry.rd_assigned_number = tuple.rd_assigned_number;
488 rib_entry.rd_administrator_subfield = tuple.rd_administrator_subfield;
489
490 strncpy(rib_entry.prefix, tuple.prefix.c_str(), sizeof(rib_entry.prefix));
491
492 rib_entry.prefix_len = tuple.len;
493
494 snprintf(rib_entry.labels, sizeof(rib_entry.labels), "%s", tuple.labels.c_str());
495
496 rib_entry.isIPv4 = tuple.isIPv4 ? 1 : 0;
497
498 memcpy(rib_entry.prefix_bin, tuple.prefix_bin, sizeof(rib_entry.prefix_bin));
499
500 // Add the ending IP for the prefix based on bits
501 if (rib_entry.isIPv4) {
502 if (tuple.len < 32) {
503 memcpy(&value_32bit, tuple.prefix_bin, 4);
504 bgp::SWAP_BYTES(&value_32bit);
505
506 value_32bit |= 0xFFFFFFFF >> tuple.len;
507 bgp::SWAP_BYTES(&value_32bit);
508 memcpy(rib_entry.prefix_bcast_bin, &value_32bit, 4);
509
510 } else
511 memcpy(rib_entry.prefix_bcast_bin, tuple.prefix_bin, sizeof(tuple.prefix_bin));
512
513 } else {
514 if (tuple.len < 128) {
515 if (tuple.len >= 64) {
516 // High order bytes are left alone
517 memcpy(rib_entry.prefix_bcast_bin, tuple.prefix_bin, 8);
518
519 // Low order bytes are updated
520 memcpy(&value_64bit, &tuple.prefix_bin[8], 8);
521 bgp::SWAP_BYTES(&value_64bit);
522
523 value_64bit |= 0xFFFFFFFFFFFFFFFF >> (tuple.len - 64);
524 bgp::SWAP_BYTES(&value_64bit);
525 memcpy(&rib_entry.prefix_bcast_bin[8], &value_64bit, 8);

Callers

nothing calls this directly

Calls 3

SWAP_BYTESFunction · 0.85
sizeMethod · 0.80
update_L3VpnMethod · 0.80

Tested by

no test coverage detected