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

Method parseMapping

Server/src/Config.cpp:653–746  ·  view source on GitHub ↗

* Parse the mapping configuration * * \param [in] node Reference to the yaml NODE */

Source from the content-addressed store, hash-verified

651 * \param [in] node Reference to the yaml NODE
652 */
653void Config::parseMapping(const YAML::Node &node) {
654 if (node["groups"] and node["groups"].Type() == YAML::NodeType::Map) {
655
656 if (node["groups"]["router_group"] and node["groups"]["router_group"].Type() == YAML::NodeType::Sequence) {
657
658 std::string name;
659 for (std::size_t i = 0; i < node["groups"]["router_group"].size(); i++) {
660
661 if (node["groups"]["router_group"][i].Type() == YAML::NodeType::Map) {
662 const YAML::Node &cur_node = node["groups"]["router_group"][i];
663
664 name = cur_node["name"].as<std::string>();
665
666 if (debug_general)
667 std::cout << " Config: mappings.groups.router_group name = " << name << std::endl;
668
669 if (debug_general) std::cout << " Config: getting regexp_hostname list" << std::endl;
670 if (cur_node["regexp_hostname"] and
671 cur_node["regexp_hostname"].Type() == YAML::NodeType::Sequence) {
672
673 parseRegexpList(cur_node["regexp_hostname"], name, match_router_group_by_name);
674
675 } else if (cur_node["regexp_hostname"])
676 throw "Invalid mapping.groups.router_group.regexp_hostname, should be of type list/sequence";
677
678
679 if (debug_general) std::cout << " Config: getting prefix_range list" << std::endl;
680 if (cur_node["prefix_range"] and cur_node["prefix_range"].Type() == YAML::NodeType::Sequence) {
681
682 parsePrefixList(cur_node["prefix_range"], name, match_router_group_by_ip);
683
684 } else if (cur_node["prefix_range"])
685 throw "Invalid mapping.groups.router_group.prefix_range, should be of type list/sequence";
686 }
687 }
688 }
689
690 if (node["groups"]["peer_group"] and node["groups"]["peer_group"].Type() == YAML::NodeType::Sequence) {
691
692 std::string name;
693 for (std::size_t i = 0; i < node["groups"]["peer_group"].size(); i++) {
694
695 if (node["groups"]["peer_group"][i].Type() == YAML::NodeType::Map) {
696 const YAML::Node &cur_node = node["groups"]["peer_group"][i];
697
698 name = cur_node["name"].as<std::string>();
699
700 if (debug_general)
701 std::cout << " Config: mappings.groups.peer_group name = " << name << std::endl;
702
703 if (debug_general) std::cout << " Config: getting regexp_hostname list" << std::endl;
704 if (cur_node["regexp_hostname"] and
705 cur_node["regexp_hostname"].Type() == YAML::NodeType::Sequence) {
706
707 parseRegexpList(cur_node["regexp_hostname"], name, match_peer_group_by_name);
708
709 } else if (cur_node["regexp_hostname"])
710 throw "Invalid mapping.groups.peer_group.regexp_hostname, should be of type list/sequence";

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected