google-ipmi-sys: Refactor to use new version of OEM IPMI Handler
Using the new version of ipmi handler provide a higher level wrapper
over the same functionalities. It helps us parse the input and output to
have more control of the input/output we see.
The input and output will be
`std::uint8_t, std::optional<std::vector<uint8_t>>`.
This represents `subcommand` and any input data.
Changes to note,
- all subcommand in the request/response struct are removed. It will be
managed by the wrapper directly.
- Unit tests checking for input with only the subcommand are
removed.
- Move all reply struct to header files to be accessible in unit test.
Tested:
All IPMI OEM command still works the same as before this change.
Change-Id: I4230ab84a497a867248fe82224e32cc69b314b64
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/main.cpp b/main.cpp
index 09d0990..63ece82 100644
--- a/main.cpp
+++ b/main.cpp
@@ -20,8 +20,10 @@
#include <cstdint>
#include <cstdio>
#include <functional>
+#include <ipmid/api-types.hpp>
+#include <ipmid/handler.hpp>
#include <ipmid/iana.hpp>
-#include <ipmid/oemrouter.hpp>
+#include <span>
namespace oem
{
@@ -41,16 +43,17 @@
void setupGoogleOemSysCommands()
{
static Handler handlerImpl;
- oem::Router* oemRouter = oem::mutableRouter();
std::fprintf(stderr,
"Registering OEM:[%#08X], Cmd:[%#04X] for Sys Commands\n",
oem::googOemNumber, oem::google::sysCmd);
- using namespace std::placeholders;
- oemRouter->registerHandler(
- oem::googOemNumber, oem::google::sysCmd,
- std::bind(handleSysCommand, &handlerImpl, _1, _2, _3, _4));
+ ::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);
+ });
}
} // namespace ipmi