config_parser: Split up sections
We can't always combine sections together in network files as sections
like
[Address]
Address=::1/128
Peer=fe80::1
[Address]
Address=::2/128
Peer=fe80::2
Require that they are grouped accordingly. Rewrite the storage logic of
the config parser to support this logical organization.
Change-Id: I34ae1523202f8770fe3dcac010fb6226dd28b9ec
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/dhcp_configuration.cpp b/src/dhcp_configuration.cpp
index 4308f96..ef0a6a6 100644
--- a/src/dhcp_configuration.cpp
+++ b/src/dhcp_configuration.cpp
@@ -85,18 +85,18 @@
config::Parser parser(config::pathForIntfConf(manager.getConfDir(),
*interfaceStrList.begin()));
- const auto& values = parser.getValues("DHCP", prop);
- if (values.empty())
+ auto value = parser.getMap().getLastValueString("DHCP", prop);
+ if (value == nullptr)
{
auto msg = fmt::format("Missing config section DHCP[{}]", prop);
log<level::NOTICE>(msg.c_str(), entry("PROP=%s", prop.c_str()));
return true;
}
- auto ret = config::parseBool(values.back());
+ auto ret = config::parseBool(*value);
if (!ret.has_value())
{
- auto msg = fmt::format("Failed to parse section DHCP[{}]: `{}`", prop,
- values.back());
+ auto msg =
+ fmt::format("Failed to parse section DHCP[{}]: `{}`", prop, *value);
log<level::NOTICE>(msg.c_str(), entry("PROP=%s", prop.c_str()));
}
return ret.value_or(true);