network_config: Sync default values
Change-Id: Ica6b2177138b30135c1a060475955a1ae53569e3
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/util.cpp b/src/util.cpp
index cad1ed8..7f55e2e 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -1,3 +1,5 @@
+#include "config.h"
+
#include "util.hpp"
#include "config_parser.hpp"
@@ -366,6 +368,12 @@
bool getIPv6AcceptRA(const config::Parser& config)
{
+#ifdef ENABLE_IPV6_ACCEPT_RA
+ constexpr bool def = true;
+#else
+ constexpr bool def = false;
+#endif
+
auto value = config.map.getLastValueString("Network", "IPv6AcceptRA");
if (value == nullptr)
{
@@ -374,7 +382,7 @@
config.getFilename().native());
log<level::NOTICE>(msg.c_str(),
entry("FILE=%s", config.getFilename().c_str()));
- return false;
+ return def;
}
auto ret = config::parseBool(*value);
if (!ret.has_value())
@@ -386,11 +394,13 @@
entry("FILE=%s", config.getFilename().c_str()),
entry("VALUE=%s", value->c_str()));
}
- return ret.value_or(false);
+ return ret.value_or(def);
}
EthernetInterfaceIntf::DHCPConf getDHCPValue(const config::Parser& config)
{
+ constexpr auto def = EthernetInterfaceIntf::DHCPConf::both;
+
const auto value = config.map.getLastValueString("Network", "DHCP");
if (value == nullptr)
{
@@ -399,7 +409,7 @@
config.getFilename().native());
log<level::NOTICE>(msg.c_str(),
entry("FILE=%s", config.getFilename().c_str()));
- return EthernetInterfaceIntf::DHCPConf::none;
+ return def;
}
if (config::icaseeq(*value, "ipv4"))
{
@@ -417,9 +427,10 @@
log<level::NOTICE>(str.c_str(),
entry("FILE=%s", config.getFilename().c_str()),
entry("VALUE=%s", value->c_str()));
+ return def;
}
- return ret.value_or(false) ? EthernetInterfaceIntf::DHCPConf::both
- : EthernetInterfaceIntf::DHCPConf::none;
+ return *ret ? EthernetInterfaceIntf::DHCPConf::both
+ : EthernetInterfaceIntf::DHCPConf::none;
}
namespace mac_address