From be376306918e84f411c1e4bdba15ec5b6a2219dc Mon Sep 17 00:00:00 2001 From: Vernon Mauery Date: Thu, 21 Mar 2019 13:02:05 -0700 Subject: Add user context parameter to legacy ipmi handler registration This part was originally omitted, but needed by some external provider libraries. This will more closely mimic the behavior of ipmid prior to the architecture update. Change-Id: I5db35222e268a117480285c700d88206d6505d92 Signed-off-by: Vernon Mauery --- include/ipmid/handler.hpp | 11 +++++++---- ipmid-new.cpp | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/ipmid/handler.hpp b/include/ipmid/handler.hpp index 1643e58..17beb42 100644 --- a/include/ipmid/handler.hpp +++ b/include/ipmid/handler.hpp @@ -278,12 +278,14 @@ template <> class IpmiHandler final : public HandlerBase { public: - explicit IpmiHandler(const ipmid_callback_t& handler) : handler_(handler) + explicit IpmiHandler(const ipmid_callback_t& handler, void* ctx = nullptr) : + handler_(handler), handlerCtx(ctx) { } private: ipmid_callback_t handler_; + void* handlerCtx; /** @brief call the registered handler with the request * @@ -315,7 +317,7 @@ class IpmiHandler final : public HandlerBase { ccRet = handler_(request->ctx->netFn, request->ctx->cmd, request->payload.data(), response->payload.data(), - &len, nullptr); + &len, handlerCtx); } catch (const std::exception& e) { @@ -453,9 +455,10 @@ class IpmiHandler final : public HandlerBase * * @return A shared_ptr to the created handler object */ -inline auto makeLegacyHandler(const ipmid_callback_t& handler) +inline auto makeLegacyHandler(const ipmid_callback_t& handler, + void* ctx = nullptr) { - HandlerBase::ptr ptr(new IpmiHandler(handler)); + HandlerBase::ptr ptr(new IpmiHandler(handler, ctx)); return ptr; } diff --git a/ipmid-new.cpp b/ipmid-new.cpp index 24d1ce5..ed45173 100644 --- a/ipmid-new.cpp +++ b/ipmid-new.cpp @@ -461,7 +461,7 @@ void ipmi_register_callback(ipmi_netfn_t netFn, ipmi_cmd_t cmd, ipmi_context_t context, ipmid_callback_t handler, ipmi_cmd_privilege_t priv) { - auto h = ipmi::makeLegacyHandler(handler); + auto h = ipmi::makeLegacyHandler(handler, context); // translate priv from deprecated enum to current ipmi::Privilege realPriv; switch (priv) -- cgit v1.2.1