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

Method UpdateDBAttrs

Server/src/bgp/parseBGP.cpp:386–457  ·  view source on GitHub ↗

* Update the Database path attributes * * \details This method will update the database for the supplied path attributes * * \param attrs Reference to the parsed attributes map */

Source from the content-addressed store, hash-verified

384 * \param attrs Reference to the parsed attributes map
385 */
386void parseBGP::UpdateDBAttrs(bgp_msg::UpdateMsg::parsed_attrs_map &attrs) {
387
388 /*
389 * Setup the record
390 */
391 base_attr.as_path = (string)attrs[bgp_msg::ATTR_TYPE_AS_PATH];
392 base_attr.cluster_list = (string)attrs[bgp_msg::ATTR_TYPE_CLUSTER_LIST];
393 base_attr.community_list = (string)attrs[bgp_msg::ATTR_TYPE_COMMUNITIES];
394 base_attr.ext_community_list = (string)attrs[bgp_msg::ATTR_TYPE_EXT_COMMUNITY];
395 base_attr.large_community_list = (string)attrs[bgp_msg::ATTR_TYPE_LARGE_COMMUNITY];
396
397 base_attr.atomic_agg = ((string)attrs[bgp_msg::ATTR_TYPE_ATOMIC_AGGREGATE]).compare("1") == 0 ? true : false;
398
399 if (((string)attrs[bgp_msg::ATTR_TYPE_LOCAL_PREF]).length() > 0)
400 base_attr.local_pref = std::stoul(((string)attrs[bgp_msg::ATTR_TYPE_LOCAL_PREF]));
401 else
402 base_attr.local_pref = 0;
403
404 if (((string)attrs[bgp_msg::ATTR_TYPE_MED]).length() > 0)
405 base_attr.med = std::stoul(((string)attrs[bgp_msg::ATTR_TYPE_MED]));
406 else
407 base_attr.med = 0;
408
409 if (((string)attrs[bgp_msg::ATTR_TYPE_INTERNAL_AS_COUNT]).length() > 0)
410 base_attr.as_path_count = std::stoi(((string)attrs[bgp_msg::ATTR_TYPE_INTERNAL_AS_COUNT]));
411 else
412 base_attr.as_path_count = 0;
413
414 if (((string)attrs[bgp_msg::ATTR_TYPE_INTERNAL_AS_ORIGIN]).length() > 0)
415 base_attr.origin_as = std::stoul(((string)attrs[bgp_msg::ATTR_TYPE_INTERNAL_AS_ORIGIN]));
416 else
417 base_attr.origin_as = 0;
418
419 if (((string)attrs[bgp_msg::ATTR_TYPE_ORIGINATOR_ID]).length() > 0)
420 strncpy(base_attr.originator_id, ((string)attrs[bgp_msg::ATTR_TYPE_ORIGINATOR_ID]).c_str(), sizeof(base_attr.originator_id));
421 else
422 bzero(base_attr.originator_id, sizeof(base_attr.originator_id));
423
424 if ( ((string)attrs[bgp_msg::ATTR_TYPE_NEXT_HOP]).find_first_of(':') == string::npos)
425 base_attr.nexthop_isIPv4 = true;
426 else // is IPv6
427 base_attr.nexthop_isIPv4 = false;
428
429 if ( ((string)attrs[bgp_msg::ATTR_TYPE_AGGEGATOR]).length() > 0)
430 strncpy(base_attr.aggregator, ((string)attrs[bgp_msg::ATTR_TYPE_AGGEGATOR]).c_str(), sizeof(base_attr.aggregator));
431 else
432 bzero(base_attr.aggregator, sizeof(base_attr.aggregator));
433
434 if ( ((string)attrs[bgp_msg::ATTR_TYPE_ORIGIN]).length() > 0)
435 strncpy(base_attr.origin, ((string)attrs[bgp_msg::ATTR_TYPE_ORIGIN]).c_str(), sizeof(base_attr.origin));
436 else
437 bzero(base_attr.origin, sizeof(base_attr.origin));
438
439 if ( ((string)attrs[bgp_msg::ATTR_TYPE_NEXT_HOP]).length() > 0)
440 strncpy(base_attr.next_hop, ((string)attrs[bgp_msg::ATTR_TYPE_NEXT_HOP]).c_str(), sizeof(base_attr.next_hop));
441
442 else {
443 // Skip adding path attributes if next hop is missing

Callers

nothing calls this directly

Calls 1

update_baseAttributeMethod · 0.80

Tested by

no test coverage detected