google-ipmi-sys: Convert input to use std::span<const uint8_t>
Change-Id: I533de34c04e3d2577cb9076add441153b2994c30
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/cable.cpp b/cable.cpp
index d06cf23..cac7fea 100644
--- a/cable.cpp
+++ b/cable.cpp
@@ -21,6 +21,7 @@
#include <cstdint>
#include <cstring>
#include <ipmid/api-types.hpp>
+#include <span>
#include <string>
#include <vector>
@@ -34,8 +35,7 @@
uint8_t ifNameLength;
} __attribute__((packed));
-Resp cableCheck(const std::vector<std::uint8_t>& data,
- const HandlerInterface* handler)
+Resp cableCheck(std::span<const uint8_t> data, const HandlerInterface* handler)
{
// There is an IPMI LAN channel statistics command which could be used for
// this type of check, however, we're not able to wait for the OpenBMC
diff --git a/cable.hpp b/cable.hpp
index 79a4d2e..138ade0 100644
--- a/cable.hpp
+++ b/cable.hpp
@@ -19,7 +19,7 @@
#include <ipmid/api.h>
#include <ipmid/api-types.hpp>
-#include <vector>
+#include <span>
namespace google
{
@@ -34,8 +34,7 @@
//
// Handle the cablecheck. Sys must supply which ethernet device they're
// interested in.
-Resp cableCheck(const std::vector<std::uint8_t>& data,
- const HandlerInterface* handler);
+Resp cableCheck(std::span<const uint8_t> data, const HandlerInterface* handler);
} // namespace ipmi
} // namespace google
diff --git a/cpld.cpp b/cpld.cpp
index f91fed4..e5dc276 100644
--- a/cpld.cpp
+++ b/cpld.cpp
@@ -20,6 +20,7 @@
#include <cstring>
#include <ipmid/api-types.hpp>
+#include <span>
#include <vector>
namespace google
@@ -35,8 +36,7 @@
//
// Handle reading the cpld version from the tmpfs.
//
-Resp cpldVersion(const std::vector<std::uint8_t>& data,
- const HandlerInterface* handler)
+Resp cpldVersion(std::span<const uint8_t> data, const HandlerInterface* handler)
{
struct CpldRequest request;
diff --git a/cpld.hpp b/cpld.hpp
index 84db3ba..9f4d169 100644
--- a/cpld.hpp
+++ b/cpld.hpp
@@ -19,7 +19,7 @@
#include <ipmid/api.h>
#include <ipmid/api-types.hpp>
-#include <vector>
+#include <span>
namespace google
{
@@ -35,7 +35,7 @@
} __attribute__((packed));
// Given a cpld identifier, return a version if available.
-Resp cpldVersion(const std::vector<std::uint8_t>& data,
+Resp cpldVersion(std::span<const uint8_t> data,
const HandlerInterface* handler);
} // namespace ipmi
diff --git a/entity_name.cpp b/entity_name.cpp
index 3702ad5..854b1dc 100644
--- a/entity_name.cpp
+++ b/entity_name.cpp
@@ -21,6 +21,7 @@
#include <cstdint>
#include <cstring>
#include <ipmid/api-types.hpp>
+#include <span>
#include <string>
#include <vector>
@@ -45,8 +46,7 @@
uint8_t entityInstance;
} __attribute__((packed));
-Resp getEntityName(const std::vector<std::uint8_t>& data,
- HandlerInterface* handler)
+Resp getEntityName(std::span<const uint8_t> data, HandlerInterface* handler)
{
struct GetEntityNameRequest request;
diff --git a/entity_name.hpp b/entity_name.hpp
index fb04770..d1a9913 100644
--- a/entity_name.hpp
+++ b/entity_name.hpp
@@ -19,6 +19,7 @@
#include <ipmid/api.h>
#include <ipmid/api-types.hpp>
+#include <span>
#include <vector>
namespace google
@@ -33,8 +34,7 @@
// Handle the "entity id:entity instance" to entity name mapping command.
// Sys can query the entity name for a particular "entity id:entity instance".
-Resp getEntityName(const std::vector<std::uint8_t>& data,
- HandlerInterface* handler);
+Resp getEntityName(std::span<const uint8_t> data, HandlerInterface* handler);
} // namespace ipmi
} // namespace google
diff --git a/eth.cpp b/eth.cpp
index bbe1940..748aa18 100644
--- a/eth.cpp
+++ b/eth.cpp
@@ -20,6 +20,7 @@
#include <cstdint>
#include <cstring>
#include <ipmid/api-types.hpp>
+#include <span>
#include <string>
#include <tuple>
#include <vector>
@@ -35,7 +36,7 @@
#define MAX_IPMI_BUFFER 64
#endif
-Resp getEthDevice(const std::vector<std::uint8_t>& data,
+Resp getEthDevice(std::span<const uint8_t> data,
const HandlerInterface* handler)
{
std::tuple<std::uint8_t, std::string> details =
diff --git a/eth.hpp b/eth.hpp
index 0fe8d4e..67ed7b9 100644
--- a/eth.hpp
+++ b/eth.hpp
@@ -19,7 +19,7 @@
#include <ipmid/api.h>
#include <ipmid/api-types.hpp>
-#include <vector>
+#include <span>
namespace google
{
@@ -39,7 +39,7 @@
// Handle the eth query command.
// Sys can query the ifName and IPMI channel of the BMC's NCSI ethernet
// device.
-Resp getEthDevice(const std::vector<std::uint8_t>& data,
+Resp getEthDevice(std::span<const uint8_t> data,
const HandlerInterface* handler);
} // namespace ipmi
diff --git a/flash_size.cpp b/flash_size.cpp
index 4fb4976..ee143f8 100644
--- a/flash_size.cpp
+++ b/flash_size.cpp
@@ -23,6 +23,7 @@
#include <cstdint>
#include <cstring>
#include <ipmid/api-types.hpp>
+#include <span>
#include <string>
#include <vector>
@@ -31,7 +32,7 @@
namespace ipmi
{
-Resp getFlashSize(const std::vector<std::uint8_t>&, HandlerInterface* handler)
+Resp getFlashSize(std::span<const uint8_t>, HandlerInterface* handler)
{
uint32_t flashSize;
try
diff --git a/flash_size.hpp b/flash_size.hpp
index 9ae1c5f..34c5549 100644
--- a/flash_size.hpp
+++ b/flash_size.hpp
@@ -19,7 +19,7 @@
#include <ipmid/api.h>
#include <ipmid/api-types.hpp>
-#include <vector>
+#include <span>
namespace google
{
@@ -31,8 +31,7 @@
uint32_t flashSize;
} __attribute__((packed));
-Resp getFlashSize(const std::vector<std::uint8_t>& data,
- HandlerInterface* handler);
+Resp getFlashSize(std::span<const uint8_t> data, HandlerInterface* handler);
} // namespace ipmi
} // namespace google
diff --git a/host_power_off.cpp b/host_power_off.cpp
index 98e5daa..939ba6e 100644
--- a/host_power_off.cpp
+++ b/host_power_off.cpp
@@ -23,6 +23,7 @@
#include <cstdint>
#include <cstring>
#include <ipmid/api-types.hpp>
+#include <span>
#include <vector>
namespace google
@@ -30,7 +31,7 @@
namespace ipmi
{
-Resp hostPowerOff(const std::vector<uint8_t>& data,
+Resp hostPowerOff(std::span<const uint8_t> data,
const HandlerInterface* handler)
{
struct HostPowerOffRequest request;
diff --git a/host_power_off.hpp b/host_power_off.hpp
index 49231a3..0cbe9c2 100644
--- a/host_power_off.hpp
+++ b/host_power_off.hpp
@@ -19,6 +19,7 @@
#include <ipmid/api.h>
#include <ipmid/api-types.hpp>
+#include <span>
#include <vector>
namespace google
@@ -33,7 +34,7 @@
} __attribute__((packed));
// Disable the fallback watchdog with given time delay and Power Off Host
-Resp hostPowerOff(const std::vector<std::uint8_t>& data,
+Resp hostPowerOff(std::span<const uint8_t> data,
const HandlerInterface* handler);
} // namespace ipmi
diff --git a/ipmi.cpp b/ipmi.cpp
index 0451c6e..1f760f4 100644
--- a/ipmi.cpp
+++ b/ipmi.cpp
@@ -33,7 +33,7 @@
#include <ipmid/api-types.hpp>
#include <ipmid/message.hpp>
#include <optional>
-#include <vector>
+#include <span>
namespace google
{
@@ -41,7 +41,7 @@
{
Resp handleSysCommand(HandlerInterface* handler, ::ipmi::Context::ptr,
- uint8_t cmd, const std::vector<uint8_t>& data)
+ uint8_t cmd, std::span<const uint8_t> data)
{
switch (cmd)
{
diff --git a/ipmi.hpp b/ipmi.hpp
index ef8c627..8194f0f 100644
--- a/ipmi.hpp
+++ b/ipmi.hpp
@@ -21,7 +21,7 @@
#include <ipmid/api-types.hpp>
#include <ipmid/message.hpp>
#include <optional>
-#include <vector>
+#include <span>
namespace google
{
@@ -30,7 +30,7 @@
// Handle the google-ipmi-sys IPMI OEM commands.
Resp handleSysCommand(HandlerInterface* handler, ::ipmi::Context::ptr ctx,
- uint8_t cmd, const std::vector<uint8_t>& data);
+ uint8_t cmd, std::span<const uint8_t> data);
} // namespace ipmi
} // namespace google
diff --git a/machine_name.cpp b/machine_name.cpp
index c1b9c4e..d17a592 100644
--- a/machine_name.cpp
+++ b/machine_name.cpp
@@ -22,6 +22,7 @@
#include <cstring>
#include <ipmid/api-types.hpp>
#include <optional>
+#include <span>
#include <string>
#include <vector>
@@ -30,7 +31,7 @@
namespace ipmi
{
-Resp getMachineName(const std::vector<std::uint8_t>&, HandlerInterface* handler)
+Resp getMachineName(std::span<const uint8_t>, HandlerInterface* handler)
{
static std::optional<std::string> machineName;
if (!machineName)
diff --git a/machine_name.hpp b/machine_name.hpp
index 4c8a60c..13baadd 100644
--- a/machine_name.hpp
+++ b/machine_name.hpp
@@ -19,7 +19,7 @@
#include <ipmid/api.h>
#include <ipmid/api-types.hpp>
-#include <vector>
+#include <span>
namespace google
{
@@ -32,8 +32,7 @@
} __attribute__((packed));
// Handle the machine name command.
-Resp getMachineName(const std::vector<std::uint8_t>& data,
- HandlerInterface* handler);
+Resp getMachineName(std::span<const uint8_t> data, HandlerInterface* handler);
} // namespace ipmi
} // namespace google
diff --git a/main.cpp b/main.cpp
index 63ece82..e903e1c 100644
--- a/main.cpp
+++ b/main.cpp
@@ -48,12 +48,13 @@
"Registering OEM:[%#08X], Cmd:[%#04X] for Sys Commands\n",
oem::googOemNumber, oem::google::sysCmd);
- ::ipmi::registerOemHandler(
- ::ipmi::prioOemBase, oem::googOemNumber, oem::google::sysCmd,
- ::ipmi::Privilege::User,
- [](::ipmi::Context::ptr ctx, uint8_t cmd, std::vector<uint8_t> data) {
- return handleSysCommand(&handlerImpl, ctx, cmd, data);
- });
+ ::ipmi::registerOemHandler(::ipmi::prioOemBase, oem::googOemNumber,
+ oem::google::sysCmd, ::ipmi::Privilege::User,
+ [](::ipmi::Context::ptr ctx, uint8_t cmd,
+ const std::vector<uint8_t>& data) {
+ return handleSysCommand(&handlerImpl, ctx,
+ cmd, data);
+ });
}
} // namespace ipmi
diff --git a/pcie_i2c.cpp b/pcie_i2c.cpp
index 46088a5..2c7af4d 100644
--- a/pcie_i2c.cpp
+++ b/pcie_i2c.cpp
@@ -20,6 +20,7 @@
#include <cstdint>
#include <cstring>
#include <ipmid/api-types.hpp>
+#include <span>
#include <string>
#include <tuple>
#include <vector>
@@ -38,7 +39,7 @@
uint8_t entry;
} __attribute__((packed));
-Resp pcieSlotCount(const std::vector<std::uint8_t>&, HandlerInterface* handler)
+Resp pcieSlotCount(std::span<const uint8_t>, HandlerInterface* handler)
{
// If there are already entries in the vector, clear them.
handler->buildI2cPcieMapping();
@@ -50,7 +51,7 @@
std::vector<std::uint8_t>{value});
}
-Resp pcieSlotI2cBusMapping(const std::vector<std::uint8_t>& data,
+Resp pcieSlotI2cBusMapping(std::span<const uint8_t> data,
HandlerInterface* handler)
{
struct PcieSlotI2cBusMappingRequest request;
diff --git a/pcie_i2c.hpp b/pcie_i2c.hpp
index 5f1cd35..63d4df8 100644
--- a/pcie_i2c.hpp
+++ b/pcie_i2c.hpp
@@ -19,7 +19,7 @@
#include <ipmid/api.h>
#include <ipmid/api-types.hpp>
-#include <vector>
+#include <span>
namespace google
{
@@ -39,12 +39,11 @@
// Handle the pcie slot count command.
// Sys can query the number of pcie slots.
-Resp pcieSlotCount(const std::vector<std::uint8_t>& data,
- HandlerInterface* handler);
+Resp pcieSlotCount(std::span<const uint8_t> data, HandlerInterface* handler);
// Handle the pcie slot to i2c bus mapping command.
// Sys can query which i2c bus is routed to which pcie slot.
-Resp pcieSlotI2cBusMapping(const std::vector<std::uint8_t>& data,
+Resp pcieSlotI2cBusMapping(std::span<const uint8_t> data,
HandlerInterface* handler);
} // namespace ipmi
diff --git a/psu.cpp b/psu.cpp
index 1e2ed92..32a3fe2 100644
--- a/psu.cpp
+++ b/psu.cpp
@@ -21,6 +21,7 @@
#include <cstdint>
#include <cstring>
#include <ipmid/api-types.hpp>
+#include <span>
#include <vector>
namespace google
@@ -28,7 +29,7 @@
namespace ipmi
{
-Resp psuHardReset(const std::vector<std::uint8_t>& data,
+Resp psuHardReset(std::span<const uint8_t> data,
const HandlerInterface* handler)
{
struct PsuResetRequest request;
@@ -54,7 +55,7 @@
std::vector<uint8_t>{});
}
-Resp psuHardResetOnShutdown(const std::vector<std::uint8_t>&,
+Resp psuHardResetOnShutdown(std::span<const uint8_t>,
const HandlerInterface* handler)
{
try
diff --git a/psu.hpp b/psu.hpp
index b022881..56beb61 100644
--- a/psu.hpp
+++ b/psu.hpp
@@ -19,7 +19,7 @@
#include <ipmid/api.h>
#include <ipmid/api-types.hpp>
-#include <vector>
+#include <span>
namespace google
{
@@ -33,11 +33,11 @@
} __attribute__((packed));
// Set a time-delayed PSU hard reset.
-Resp psuHardReset(const std::vector<std::uint8_t>& data,
+Resp psuHardReset(std::span<const uint8_t> data,
const HandlerInterface* handler);
// Arm for PSU hard reset on host shutdown.
-Resp psuHardResetOnShutdown(const std::vector<std::uint8_t>& data,
+Resp psuHardResetOnShutdown(std::span<const uint8_t> data,
const HandlerInterface* handler);
} // namespace ipmi