* Parse the base configuration * * \param [in] node Reference to the yaml NODE */
| 137 | * \param [in] node Reference to the yaml NODE |
| 138 | */ |
| 139 | void Config::parseBase(const YAML::Node &node) { |
| 140 | std::string value; |
| 141 | |
| 142 | if (node["admin_id"]) { |
| 143 | try { |
| 144 | value = node["admin_id"].as<std::string>(); |
| 145 | |
| 146 | if (value.compare("hostname") == 0) { |
| 147 | gethostname(admin_id, sizeof(admin_id)); |
| 148 | } else { |
| 149 | std::strncpy(admin_id, value.c_str(), sizeof(admin_id)); |
| 150 | } |
| 151 | |
| 152 | if (debug_general) |
| 153 | std::cout << " Config: admin id : " << admin_id << std::endl; |
| 154 | |
| 155 | } catch (YAML::TypedBadConversion<std::string> err) { |
| 156 | printWarning("admin_id is not of type string", node["admin_id"]); |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | if (node["listen_port"]) { |
| 161 | try { |
| 162 | bmp_port = node["listen_port"].as<uint16_t>(); |
| 163 | |
| 164 | if (bmp_port < 25 || bmp_port > 65535) |
| 165 | throw "invalid listen_port, not within range of 25 - 65535)"; |
| 166 | |
| 167 | if (debug_general) |
| 168 | std::cout << " Config: bmp_port: " << bmp_port << std::endl; |
| 169 | |
| 170 | } catch (YAML::TypedBadConversion<uint16_t> err) { |
| 171 | printWarning("bmp_port is not of type unsigned 16 bit", node["listen_port"]); |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | if (node["listen_ipv4"]) { |
| 176 | bind_ipv4 = node["listen_ipv4"].as<std::string>(); |
| 177 | |
| 178 | if (debug_general) |
| 179 | std::cout << " Config: listen_ipv4: " << bind_ipv4 << "\n"; |
| 180 | } |
| 181 | |
| 182 | if (node["listen_ipv6"]) { |
| 183 | bind_ipv6 = node["listen_ipv6"].as<std::string>(); |
| 184 | |
| 185 | if (debug_general) |
| 186 | std::cout << " Config: listen_ipv6: " << bind_ipv6 << "\n"; |
| 187 | } |
| 188 | |
| 189 | if (node["listen_mode"]) { |
| 190 | try { |
| 191 | value = node["listen_mode"].as<std::string>(); |
| 192 | |
| 193 | if (value.compare("v4") == 0) { |
| 194 | svr_ipv4 = true; |
| 195 | } else if (value.compare("v6") == 0) { |
| 196 | svr_ipv6 = true; |
nothing calls this directly
no outgoing calls
no test coverage detected