rewrite Reset Watchdog Timer command to use new provider API
Modify to use the new provider API. One by one, change calls to
remove any legacy API constructs.
Tested-by: ipmitool mc watchdog get
ipmitool mc watchdog off
ipmitool mc watchdog reset
Change-Id: If6cd1d921908dc7f5462e99b0098b4897e743ebb
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/app/watchdog.cpp b/app/watchdog.cpp
index 51ba395..b1eea1c 100644
--- a/app/watchdog.cpp
+++ b/app/watchdog.cpp
@@ -38,15 +38,8 @@
commit<InternalFailure>();
}
-ipmi_ret_t ipmi_app_watchdog_reset(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
- ipmi_request_t request,
- ipmi_response_t response,
- ipmi_data_len_t data_len,
- ipmi_context_t context)
+ipmi::RspType<> ipmiAppResetWatchdogTimer()
{
- // We never return data with this command so immediately get rid of it
- *data_len = 0;
-
try
{
WatchdogService wd_service;
@@ -56,31 +49,33 @@
if (!wd_service.getInitialized())
{
lastCallSuccessful = true;
- return IPMI_WDOG_CC_NOT_INIT;
+
+ constexpr uint8_t ccWatchdogNotInit = 0x80;
+ return ipmi::response(ccWatchdogNotInit);
}
// The ipmi standard dictates we enable the watchdog during reset
wd_service.resetTimeRemaining(true);
lastCallSuccessful = true;
- return IPMI_CC_OK;
+ return ipmi::responseSuccess();
}
catch (const InternalFailure& e)
{
reportError();
- return IPMI_CC_UNSPECIFIED_ERROR;
+ return ipmi::responseUnspecifiedError();
}
catch (const std::exception& e)
{
const std::string e_str = std::string("wd_reset: ") + e.what();
log<level::ERR>(e_str.c_str());
reportError();
- return IPMI_CC_UNSPECIFIED_ERROR;
+ return ipmi::responseUnspecifiedError();
}
catch (...)
{
log<level::ERR>("wd_reset: Unknown Error");
reportError();
- return IPMI_CC_UNSPECIFIED_ERROR;
+ return ipmi::responseUnspecifiedError();
}
}
diff --git a/app/watchdog.hpp b/app/watchdog.hpp
index 32d6f16..3f91f4f 100644
--- a/app/watchdog.hpp
+++ b/app/watchdog.hpp
@@ -3,21 +3,8 @@
#include <ipmid/api.hpp>
/** @brief The RESET watchdog IPMI command.
- *
- * @param[in] netfn
- * @param[in] cmd
- * @param[in] request
- * @param[in,out] response
- * @param[out] data_len
- * @param[in] context
- *
- * @return IPMI_CC_OK on success, an IPMI error code otherwise.
*/
-ipmi_ret_t ipmi_app_watchdog_reset(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
- ipmi_request_t request,
- ipmi_response_t response,
- ipmi_data_len_t data_len,
- ipmi_context_t context);
+ipmi::RspType<> ipmiAppResetWatchdogTimer();
/** @brief The SET watchdog IPMI command.
*
diff --git a/apphandler.cpp b/apphandler.cpp
index 78ed077..8be092c 100644
--- a/apphandler.cpp
+++ b/apphandler.cpp
@@ -1035,8 +1035,9 @@
ipmi::Privilege::User, ipmiAppGetBtCapabilities);
// <Reset Watchdog Timer>
- ipmi_register_callback(NETFUN_APP, IPMI_CMD_RESET_WD, NULL,
- ipmi_app_watchdog_reset, PRIVILEGE_OPERATOR);
+ ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnApp,
+ ipmi::app::cmdResetWatchdogTimer,
+ ipmi::Privilege::Operator, ipmiAppResetWatchdogTimer);
// <Set Watchdog Timer>
ipmi_register_callback(NETFUN_APP, IPMI_CMD_SET_WD, NULL,