summaryrefslogtreecommitdiff
path: root/redfish-core/lib/ethernet.hpp
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2021-12-14 01:39:53 +0300
committerEd Tanous <ed@tanous.net>2021-12-28 00:42:41 +0300
commit168e20c1306e3e689907ba43e14ea679e2328611 (patch)
tree7c578ede3cf14ffaf06ad9fbc245a97b71b21cc9 /redfish-core/lib/ethernet.hpp
parentb477fd4408bc0602cc86147121f03791d3f4824a (diff)
downloadbmcweb-168e20c1306e3e689907ba43e14ea679e2328611.tar.xz
Move to common variant
This saves approximately 34kB in the compressed binary size of bmcweb due to reduced template instantiations. This amounts to a 2.5% reduction in the overall size. Note, there were a few places where we broke const-correctness in the form of pulling a non-const reference out of a const variant. This new variant now requires const correctness, so some consts are added where required. Tested: Code compiles. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I6a60c8881c1268627eedb4ffddf16689dc5f6ed2
Diffstat (limited to 'redfish-core/lib/ethernet.hpp')
-rw-r--r--redfish-core/lib/ethernet.hpp37
1 files changed, 16 insertions, 21 deletions
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 98b556eade..79a1f501c8 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -19,13 +19,13 @@
#include <boost/container/flat_map.hpp>
#include <boost/container/flat_set.hpp>
#include <dbus_singleton.hpp>
+#include <dbus_utility.hpp>
#include <error_messages.hpp>
#include <registries/privilege_registry.hpp>
#include <utils/json_utils.hpp>
#include <optional>
#include <regex>
-#include <variant>
namespace redfish
{
@@ -34,19 +34,14 @@ namespace redfish
* DBus types primitives for several generic DBus interfaces
* TODO(Pawel) consider move this to separate file into boost::dbus
*/
-using PropertiesMapType = boost::container::flat_map<
- std::string, std::variant<std::string, bool, uint8_t, int16_t, uint16_t,
- int32_t, uint32_t, int64_t, uint64_t, double>>;
+using PropertiesMapType =
+ boost::container::flat_map<std::string, dbus::utility::DbusVariantType>;
using GetManagedObjects = std::vector<std::pair<
sdbusplus::message::object_path,
- std::vector<std::pair<
- std::string,
- boost::container::flat_map<
- std::string,
- std::variant<std::string, bool, uint8_t, int16_t, uint16_t, int32_t,
- uint32_t, int64_t, uint64_t, double,
- std::vector<std::string>>>>>>>;
+ std::vector<std::pair<std::string,
+ boost::container::flat_map<
+ std::string, dbus::utility::DbusVariantType>>>>>;
enum class LinkType
{
@@ -614,7 +609,7 @@ void changeVlanId(const std::string& ifaceId, const uint32_t& inputVlanId,
std::string("/xyz/openbmc_project/network/") + ifaceId,
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Network.VLAN", "Id",
- std::variant<uint32_t>(inputVlanId));
+ dbus::utility::DbusVariantType(inputVlanId));
}
/**
@@ -748,7 +743,7 @@ inline void updateIPv4DefaultGateway(
"/xyz/openbmc_project/network/" + ifaceId,
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Network.EthernetInterface", "DefaultGateway",
- std::variant<std::string>(gateway));
+ dbus::utility::DbusVariantType(gateway));
}
/**
* @brief Creates a static IPv4 entry
@@ -1055,7 +1050,7 @@ inline void
"xyz.openbmc_project.Network", "/xyz/openbmc_project/network/config",
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Network.SystemConfiguration", "HostName",
- std::variant<std::string>(hostname));
+ dbus::utility::DbusVariantType(hostname));
}
inline void
@@ -1075,7 +1070,7 @@ inline void
"/xyz/openbmc_project/network/" + ifaceId,
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Network.EthernetInterface", "DomainName",
- std::variant<std::vector<std::string>>(vectorDomainname));
+ dbus::utility::DbusVariantType(vectorDomainname));
}
inline bool isHostnameValid(const std::string& hostname)
@@ -1154,7 +1149,7 @@ inline void
"/xyz/openbmc_project/network/" + ifaceId,
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Network.MACAddress", "MACAddress",
- std::variant<std::string>(macAddress));
+ dbus::utility::DbusVariantType(macAddress));
}
inline void setDHCPEnabled(const std::string& ifaceId,
@@ -1177,7 +1172,7 @@ inline void setDHCPEnabled(const std::string& ifaceId,
"/xyz/openbmc_project/network/" + ifaceId,
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Network.EthernetInterface", propertyName,
- std::variant<std::string>{dhcp});
+ dbus::utility::DbusVariantType{dhcp});
}
inline void setEthernetInterfaceBoolProperty(
@@ -1197,7 +1192,7 @@ inline void setEthernetInterfaceBoolProperty(
"/xyz/openbmc_project/network/" + ifaceId,
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Network.EthernetInterface", propertyName,
- std::variant<bool>{value});
+ dbus::utility::DbusVariantType{value});
}
inline void setDHCPv4Config(const std::string& propertyName, const bool& value,
@@ -1217,7 +1212,7 @@ inline void setDHCPv4Config(const std::string& propertyName, const bool& value,
"/xyz/openbmc_project/network/config/dhcp",
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Network.DHCPConfiguration", propertyName,
- std::variant<bool>{value});
+ dbus::utility::DbusVariantType{value});
}
inline void handleDHCPPatch(const std::string& ifaceId,
@@ -1550,7 +1545,7 @@ inline void handleStaticNameServersPatch(
"/xyz/openbmc_project/network/" + ifaceId,
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Network.EthernetInterface", "StaticNameServers",
- std::variant<std::vector<std::string>>{updatedStaticNameServers});
+ dbus::utility::DbusVariantType{updatedStaticNameServers});
}
inline void handleIPv6StaticAddressesPatch(
@@ -2172,7 +2167,7 @@ inline void requestEthernetInterfacesRoutes(App& app)
"/xyz/openbmc_project/network/" + ifaceId,
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Network.VLAN", "Id",
- std::variant<uint32_t>(vlanId));
+ dbus::utility::DbusVariantType(vlanId));
}
else
{