summaryrefslogtreecommitdiffstats
path: root/transporthandler.cpp
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2018-10-12 17:18:14 -0700
committerWilliam A. Kennington III <wak@google.com>2018-10-18 15:08:55 -0700
commit4c0080287f2bb19ecfbe5cdd4a334f8769e7d0cd (patch)
treef2edadbb00b55c212c280c90f0cb35d96702bf4e /transporthandler.cpp
parent1181af741589db873676f177ed85d6bc04884aa1 (diff)
downloadphosphor-host-ipmid-4c0080287f2bb19ecfbe5cdd4a334f8769e7d0cd.tar.gz
phosphor-host-ipmid-4c0080287f2bb19ecfbe5cdd4a334f8769e7d0cd.zip
Convert variant usage to std interface
This is just a refactoring to use the c++17 std::variant interfaces instead of the mapbox::variant specific ones. We should be able to use mapbox::variant and std::variant interchangeably now. Tested: Built against sdbusplus with mapbox::variant and sbusplus using std::variant. Both variant compile and test out. Change-Id: I6fbaad3d12dd34968db6a10f3d74a65e07d0f0cc Signed-off-by: William A. Kennington III <wak@google.com>
Diffstat (limited to 'transporthandler.cpp')
-rw-r--r--transporthandler.cpp38
1 files changed, 21 insertions, 17 deletions
diff --git a/transporthandler.cpp b/transporthandler.cpp
index 9c42887..39b1c9f 100644
--- a/transporthandler.cpp
+++ b/transporthandler.cpp
@@ -12,6 +12,7 @@
#include <fstream>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/log.hpp>
+#include <sdbusplus/message/types.hpp>
#include <sdbusplus/timer.hpp>
#include <string>
#include <xyz/openbmc_project/Common/error.hpp>
@@ -47,6 +48,7 @@ using namespace phosphor::logging;
using namespace sdbusplus::xyz::openbmc_project::Common::Error;
namespace fs = std::filesystem;
+namespace variant_ns = sdbusplus::message::variant_ns;
void register_netfn_transport_functions() __attribute__((constructor));
@@ -97,7 +99,8 @@ ipmi_ret_t getNetworkData(uint8_t lan_param, uint8_t* data, int channel)
bus, ipObjectInfo.second, ipObjectInfo.first,
ipmi::network::IP_INTERFACE);
- ipaddress = properties["Address"].get<std::string>();
+ ipaddress =
+ variant_ns::get<std::string>(properties["Address"]);
}
// ignore the exception, as it is a valid condition that
// the system is not configured with any IP.
@@ -171,7 +174,7 @@ ipmi_ret_t getNetworkData(uint8_t lan_param, uint8_t* data, int channel)
bus, ipmi::network::SERVICE, networkInterfacePath,
ipmi::network::ETHERNET_INTERFACE, "DHCPEnabled");
- auto dhcpEnabled = variant.get<bool>();
+ auto dhcpEnabled = variant_ns::get<bool>(variant);
// As per IPMI spec 2=>DHCP, 1=STATIC
auto ipsrc = dhcpEnabled ? ipmi::network::IPOrigin::DHCP
: ipmi::network::IPOrigin::STATIC;
@@ -201,7 +204,8 @@ ipmi_ret_t getNetworkData(uint8_t lan_param, uint8_t* data, int channel)
bus, ipObjectInfo.second, ipObjectInfo.first,
ipmi::network::IP_INTERFACE);
- auto prefix = properties["PrefixLength"].get<uint8_t>();
+ auto prefix = variant_ns::get<uint8_t>(
+ properties["PrefixLength"]);
mask = ipmi::network::MASK_32_BIT;
mask = htonl(mask << (ipmi::network::BITS_32 - prefix));
}
@@ -238,8 +242,8 @@ ipmi_ret_t getNetworkData(uint8_t lan_param, uint8_t* data, int channel)
bus, systemObject.second, systemObject.first,
ipmi::network::SYSTEMCONFIG_INTERFACE);
- gateway = systemProperties["DefaultGateway"]
- .get<std::string>();
+ gateway = variant_ns::get<std::string>(
+ systemProperties["DefaultGateway"]);
}
// ignore the exception, as it is a valid condition that
// the system is not configured with any IP.
@@ -271,7 +275,7 @@ ipmi_ret_t getNetworkData(uint8_t lan_param, uint8_t* data, int channel)
bus, macObjectInfo.second, macObjectInfo.first,
ipmi::network::MAC_INTERFACE, "MACAddress");
- macAddress = variant.get<std::string>();
+ macAddress = variant_ns::get<std::string>(variant);
}
else if (channelConf->lan_set_in_progress == SET_IN_PROGRESS)
{
@@ -777,11 +781,9 @@ void applyChanges(int channel)
}
// get the configured mode on the system.
- auto enableDHCP =
- ipmi::getDbusProperty(
- bus, ipmi::network::SERVICE, networkInterfacePath,
- ipmi::network::ETHERNET_INTERFACE, "DHCPEnabled")
- .get<bool>();
+ auto enableDHCP = variant_ns::get<bool>(ipmi::getDbusProperty(
+ bus, ipmi::network::SERVICE, networkInterfacePath,
+ ipmi::network::ETHERNET_INTERFACE, "DHCPEnabled"));
// if ip address source is not given then get the ip source mode
// from the system so that it can be applied later.
@@ -824,11 +826,13 @@ void applyChanges(int channel)
ipmi::network::IP_INTERFACE);
ipaddress = channelConf->ipaddr.empty()
- ? properties["Address"].get<std::string>()
+ ? variant_ns::get<std::string>(
+ properties["Address"])
: channelConf->ipaddr;
prefix = channelConf->netmask.empty()
- ? properties["PrefixLength"].get<uint8_t>()
+ ? variant_ns::get<uint8_t>(
+ properties["PrefixLength"])
: ipmi::network::toPrefix(
AF_INET, channelConf->netmask);
}
@@ -844,10 +848,10 @@ void applyChanges(int channel)
bus, systemObject.second, systemObject.first,
ipmi::network::SYSTEMCONFIG_INTERFACE);
- gateway =
- channelConf->gateway.empty()
- ? systemProperties["DefaultGateway"].get<std::string>()
- : channelConf->gateway;
+ gateway = channelConf->gateway.empty()
+ ? variant_ns::get<std::string>(
+ systemProperties["DefaultGateway"])
+ : channelConf->gateway;
}
}
OpenPOWER on IntegriCloud