summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/channel.cpp93
-rw-r--r--app/channel.hpp54
-rw-r--r--app/watchdog.cpp85
-rw-r--r--app/watchdog.hpp36
-rw-r--r--app/watchdog_service.cpp20
-rw-r--r--app/watchdog_service.hpp165
6 files changed, 221 insertions, 232 deletions
diff --git a/app/channel.cpp b/app/channel.cpp
index 3c011fd..2fee5cc 100644
--- a/app/channel.cpp
+++ b/app/channel.cpp
@@ -1,17 +1,17 @@
#include "channel.hpp"
-#include "types.hpp"
+
+#include "net.hpp"
#include "transporthandler.hpp"
+#include "types.hpp"
#include "utils.hpp"
-#include "net.hpp"
-#include <fstream>
-#include <string>
#include <arpa/inet.h>
-#include <phosphor-logging/log.hpp>
+#include <fstream>
#include <phosphor-logging/elog-errors.hpp>
-#include "xyz/openbmc_project/Common/error.hpp"
-
+#include <phosphor-logging/log.hpp>
+#include <string>
+#include <xyz/openbmc_project/Common/error.hpp>
using namespace phosphor::logging;
using namespace sdbusplus::xyz::openbmc_project::Common::Error;
@@ -22,8 +22,8 @@ using namespace sdbusplus::xyz::openbmc_project::Common::Error;
*/
struct GetChannelAccessRequest
{
- uint8_t channelNumber; //!< Channel number.
- uint8_t volatileSetting; //!< Get non-volatile or the volatile setting.
+ uint8_t channelNumber; //!< Channel number.
+ uint8_t volatileSetting; //!< Get non-volatile or the volatile setting.
} __attribute__((packed));
/** @struct GetChannelAccessResponse
@@ -32,20 +32,21 @@ struct GetChannelAccessRequest
*/
struct GetChannelAccessResponse
{
- uint8_t settings; //!< Channel settings.
- uint8_t privilegeLimit; //!< Channel privilege level limit.
+ uint8_t settings; //!< Channel settings.
+ uint8_t privilegeLimit; //!< Channel privilege level limit.
} __attribute__((packed));
-
ipmi_ret_t ipmi_get_channel_access(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_request_t request,
+ ipmi_response_t response,
+ ipmi_data_len_t data_len,
+ ipmi_context_t context)
{
- auto requestData = reinterpret_cast<const GetChannelAccessRequest*>
- (request);
+ auto requestData =
+ reinterpret_cast<const GetChannelAccessRequest*>(request);
std::vector<uint8_t> outPayload(sizeof(GetChannelAccessResponse));
- auto responseData = reinterpret_cast<GetChannelAccessResponse*>
- (outPayload.data());
+ auto responseData =
+ reinterpret_cast<GetChannelAccessResponse*>(outPayload.data());
/*
* The value Eh is used as a way to identify the current channel that
@@ -71,7 +72,7 @@ ipmi_ret_t ipmi_get_channel_access(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
constexpr auto channelSetting = 0x32;
responseData->settings = channelSetting;
- //Defaulting the channel privilege to administrator level.
+ // Defaulting the channel privilege to administrator level.
responseData->privilegeLimit = PRIVILEGE_ADMIN;
*data_len = outPayload.size();
@@ -91,26 +92,35 @@ ipmi_ret_t ipmi_get_channel_access(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
#define IPMI_CHANNEL_MEDIUM_TYPE_OTHER 6
ipmi_ret_t ipmi_app_channel_info(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_request_t request,
+ ipmi_response_t response,
+ ipmi_data_len_t data_len,
+ ipmi_context_t context)
{
ipmi_ret_t rc = IPMI_CC_OK;
- uint8_t resp[] = {
- 1,
- IPMI_CHANNEL_MEDIUM_TYPE_OTHER,
- IPMI_CHANNEL_TYPE_IPMB,
- 1,0x41,0xA7,0x00,0,0};
- uint8_t *p = (uint8_t*) request;
+ uint8_t resp[] = {1,
+ IPMI_CHANNEL_MEDIUM_TYPE_OTHER,
+ IPMI_CHANNEL_TYPE_IPMB,
+ 1,
+ 0x41,
+ 0xA7,
+ 0x00,
+ 0,
+ 0};
+ uint8_t* p = (uint8_t*)request;
int channel = (*p) & CHANNEL_MASK;
std::string ethdevice = ipmi::network::ChanneltoEthernet(channel);
// The supported channels numbers are those which are configured.
// Channel Number E is used as way to identify the current channel
// that the command is being is received from.
- if (channel != 0xe && ethdevice.empty()) {
+ if (channel != 0xe && ethdevice.empty())
+ {
rc = IPMI_CC_PARM_OUT_OF_RANGE;
*data_len = 0;
- } else {
+ }
+ else
+ {
*data_len = sizeof(resp);
memcpy(response, resp, *data_len);
}
@@ -161,7 +171,6 @@ std::vector<uint8_t> getCipherRecords()
records.push_back(record.value(oem, 0));
records.push_back(record.value(oem, 0) >> 8);
records.push_back(record.value(oem, 0) >> 16);
-
}
else
{
@@ -182,10 +191,9 @@ std::vector<uint8_t> getCipherRecords()
return records;
}
-} //namespace cipher
+} // namespace cipher
-ipmi_ret_t getChannelCipherSuites(ipmi_netfn_t netfn,
- ipmi_cmd_t cmd,
+ipmi_ret_t getChannelCipherSuites(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
ipmi_request_t request,
ipmi_response_t response,
ipmi_data_len_t data_len,
@@ -197,7 +205,6 @@ ipmi_ret_t getChannelCipherSuites(ipmi_netfn_t netfn,
auto requestData =
reinterpret_cast<const GetChannelCipherRequest*>(request);
-
if (*data_len < sizeof(GetChannelCipherRequest))
{
*data_len = 0;
@@ -208,7 +215,7 @@ ipmi_ret_t getChannelCipherSuites(ipmi_netfn_t netfn,
// Support only for list algorithms by cipher suite
if (cipher::listCipherSuite !=
- (requestData->listIndex & cipher::listTypeMask))
+ (requestData->listIndex & cipher::listTypeMask))
{
return IPMI_CC_INVALID_FIELD_REQUEST;
}
@@ -220,7 +227,7 @@ ipmi_ret_t getChannelCipherSuites(ipmi_netfn_t netfn,
records = cipher::getCipherRecords();
recordInit = true;
}
- catch (const std::exception &e)
+ catch (const std::exception& e)
{
return IPMI_CC_UNSPECIFIED_ERROR;
}
@@ -228,17 +235,16 @@ ipmi_ret_t getChannelCipherSuites(ipmi_netfn_t netfn,
// List index(00h-3Fh), 0h selects the first set of 16, 1h selects the next
// set of 16 and so on.
- auto index = static_cast<size_t>(
- requestData->listIndex & cipher::listIndexMask);
+ auto index =
+ static_cast<size_t>(requestData->listIndex & cipher::listIndexMask);
// Calculate the number of record data bytes to be returned.
auto start = std::min(index * cipher::respSize, records.size());
- auto end = std::min((index * cipher::respSize) + cipher::respSize,
- records.size());
+ auto end =
+ std::min((index * cipher::respSize) + cipher::respSize, records.size());
auto size = end - start;
- auto responseData = reinterpret_cast<GetChannelCipherRespHeader*>
- (response);
+ auto responseData = reinterpret_cast<GetChannelCipherRespHeader*>(response);
responseData->channelNumber = cipher::defaultChannelNumber;
if (!size)
@@ -247,8 +253,7 @@ ipmi_ret_t getChannelCipherSuites(ipmi_netfn_t netfn,
}
else
{
- std::copy_n(records.data() + start,
- size,
+ std::copy_n(records.data() + start, size,
static_cast<uint8_t*>(response) + 1);
*data_len = size + sizeof(GetChannelCipherRespHeader);
}
diff --git a/app/channel.hpp b/app/channel.hpp
index 79522e4..1b761f8 100644
--- a/app/channel.hpp
+++ b/app/channel.hpp
@@ -12,13 +12,11 @@
*
* @return IPMI_CC_OK on success, non-zero otherwise.
*/
-ipmi_ret_t ipmi_set_channel_access(
- 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_ret_t ipmi_set_channel_access(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);
/** @brief The get channel access IPMI command.
*
@@ -31,13 +29,11 @@ ipmi_ret_t ipmi_set_channel_access(
*
* @return IPMI_CC_OK on success, non-zero otherwise.
*/
-ipmi_ret_t ipmi_get_channel_access(
- 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_ret_t ipmi_get_channel_access(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);
/** @brief The get channel info IPMI command.
*
@@ -50,13 +46,11 @@ ipmi_ret_t ipmi_get_channel_access(
*
* @return IPMI_CC_OK on success, non-zero otherwise.
*/
-ipmi_ret_t ipmi_app_channel_info(
- 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_ret_t ipmi_app_channel_info(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);
/** @brief Implementation of get channel cipher suites command
*
@@ -69,8 +63,7 @@ ipmi_ret_t ipmi_app_channel_info(
*
* @return IPMI_CC_OK on success, non-zero otherwise.
*/
-ipmi_ret_t getChannelCipherSuites(ipmi_netfn_t netfn,
- ipmi_cmd_t cmd,
+ipmi_ret_t getChannelCipherSuites(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
ipmi_request_t request,
ipmi_response_t response,
ipmi_data_len_t data_len,
@@ -86,8 +79,7 @@ static constexpr auto listIndexMask = 0x3F;
static constexpr auto respSize = 16;
using Json = nlohmann::json;
-static constexpr auto configFile =
- "/usr/share/ipmi-providers/cipher_list.json";
+static constexpr auto configFile = "/usr/share/ipmi-providers/cipher_list.json";
static constexpr auto cipher = "cipher";
static constexpr auto stdCipherSuite = 0xC0;
static constexpr auto oemCipherSuite = 0xC1;
@@ -98,7 +90,7 @@ static constexpr auto integrityTag = 0x40;
static constexpr auto conf = "confidentiality";
static constexpr auto confTag = 0x80;
-} //namespace cipher
+} // namespace cipher
/** @struct GetChannelCipherRequest
*
@@ -106,9 +98,9 @@ static constexpr auto confTag = 0x80;
*/
struct GetChannelCipherRequest
{
- uint8_t channelNumber; //!< Channel Number
- uint8_t payloadType; //!< Payload type number
- uint8_t listIndex; //!< List Index
+ uint8_t channelNumber; //!< Channel Number
+ uint8_t payloadType; //!< Payload type number
+ uint8_t listIndex; //!< List Index
} __attribute__((packed));
/** @struct GetChannelCipherRespHeader
@@ -117,7 +109,5 @@ struct GetChannelCipherRequest
*/
struct GetChannelCipherRespHeader
{
- uint8_t channelNumber; //!< Channel Number
+ uint8_t channelNumber; //!< Channel Number
} __attribute__((packed));
-
-
diff --git a/app/watchdog.cpp b/app/watchdog.cpp
index da8ccf3..ad167df 100644
--- a/app/watchdog.cpp
+++ b/app/watchdog.cpp
@@ -1,29 +1,29 @@
#include "watchdog.hpp"
-#include <cstdint>
+#include "ipmid.hpp"
+#include "watchdog_service.hpp"
+
#include <endian.h>
-#include <phosphor-logging/elog.hpp>
+
+#include <cstdint>
#include <phosphor-logging/elog-errors.hpp>
+#include <phosphor-logging/elog.hpp>
#include <phosphor-logging/log.hpp>
#include <string>
#include <xyz/openbmc_project/Common/error.hpp>
-#include "watchdog_service.hpp"
#include "host-ipmid/ipmid-api.h"
-#include "ipmid.hpp"
using phosphor::logging::level;
using phosphor::logging::log;
using phosphor::logging::report;
using sdbusplus::xyz::openbmc_project::Common::Error::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_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)
{
// We never return data with this command so immediately get rid of it
*data_len = 0;
@@ -66,7 +66,8 @@ ipmi_ret_t ipmi_app_watchdog_reset(
static constexpr uint8_t wd_dont_stop = 0x1 << 6;
static constexpr uint8_t wd_timeout_action_mask = 0x3;
-enum class IpmiAction : uint8_t {
+enum class IpmiAction : uint8_t
+{
None = 0x0,
HardReset = 0x1,
PowerOff = 0x2,
@@ -79,7 +80,7 @@ enum class IpmiAction : uint8_t {
*/
WatchdogService::Action ipmiActionToWdAction(IpmiAction ipmi_action)
{
- switch(ipmi_action)
+ switch (ipmi_action)
{
case IpmiAction::None:
{
@@ -104,24 +105,23 @@ WatchdogService::Action ipmiActionToWdAction(IpmiAction ipmi_action)
}
}
-struct wd_set_req {
+struct wd_set_req
+{
uint8_t timer_use;
uint8_t timer_action;
- uint8_t pretimeout; // (seconds)
+ uint8_t pretimeout; // (seconds)
uint8_t expire_flags;
- uint16_t initial_countdown; // Little Endian (deciseconds)
-} __attribute__ ((packed));
+ uint16_t initial_countdown; // Little Endian (deciseconds)
+} __attribute__((packed));
static_assert(sizeof(wd_set_req) == 6, "wd_set_req has invalid size.");
static_assert(sizeof(wd_set_req) <= MAX_IPMI_BUFFER,
- "wd_get_res can't fit in request buffer.");
+ "wd_get_res can't fit in request buffer.");
-ipmi_ret_t ipmi_app_watchdog_set(
- 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_ret_t ipmi_app_watchdog_set(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)
{
// Extract the request data
if (*data_len < sizeof(wd_set_req))
@@ -144,8 +144,8 @@ ipmi_ret_t ipmi_app_watchdog_set(
}
// Set the action based on the request
- const auto ipmi_action = static_cast<IpmiAction>(
- req.timer_action & wd_timeout_action_mask);
+ const auto ipmi_action =
+ static_cast<IpmiAction>(req.timer_action & wd_timeout_action_mask);
wd_service.setExpireAction(ipmiActionToWdAction(ipmi_action));
// Set the new interval and the time remaining deci -> mill seconds
@@ -158,7 +158,7 @@ ipmi_ret_t ipmi_app_watchdog_set(
return IPMI_CC_OK;
}
- catch (const std::domain_error &)
+ catch (const std::domain_error&)
{
return IPMI_CC_INVALID_FIELD_REQUEST;
}
@@ -188,7 +188,7 @@ ipmi_ret_t ipmi_app_watchdog_set(
*/
IpmiAction wdActionToIpmiAction(WatchdogService::Action wd_action)
{
- switch(wd_action)
+ switch (wd_action)
{
case WatchdogService::Action::None:
{
@@ -216,28 +216,27 @@ IpmiAction wdActionToIpmiAction(WatchdogService::Action wd_action)
}
}
-struct wd_get_res {
+struct wd_get_res
+{
uint8_t timer_use;
uint8_t timer_action;
uint8_t pretimeout;
uint8_t expire_flags;
- uint16_t initial_countdown; // Little Endian (deciseconds)
- uint16_t present_countdown; // Little Endian (deciseconds)
-} __attribute__ ((packed));
+ uint16_t initial_countdown; // Little Endian (deciseconds)
+ uint16_t present_countdown; // Little Endian (deciseconds)
+} __attribute__((packed));
static_assert(sizeof(wd_get_res) == 8, "wd_get_res has invalid size.");
static_assert(sizeof(wd_get_res) <= MAX_IPMI_BUFFER,
- "wd_get_res can't fit in response buffer.");
+ "wd_get_res can't fit in response buffer.");
static constexpr uint8_t wd_dont_log = 0x1 << 7;
static constexpr uint8_t wd_running = 0x1 << 6;
-ipmi_ret_t ipmi_app_watchdog_get(
- 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_ret_t ipmi_app_watchdog_get(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)
{
// Assume we will fail and send no data outside the return code
*data_len = 0;
@@ -250,8 +249,8 @@ ipmi_ret_t ipmi_app_watchdog_get(
// Build and return the response
wd_get_res res;
res.timer_use = wd_dont_log;
- res.timer_action = static_cast<uint8_t>(
- wdActionToIpmiAction(wd_prop.expireAction));
+ res.timer_action =
+ static_cast<uint8_t>(wdActionToIpmiAction(wd_prop.expireAction));
if (wd_prop.enabled)
{
res.timer_use |= wd_running;
diff --git a/app/watchdog.hpp b/app/watchdog.hpp
index 5359a33..507695f 100644
--- a/app/watchdog.hpp
+++ b/app/watchdog.hpp
@@ -13,13 +13,11 @@
*
* @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_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);
/** @brief The SET watchdog IPMI command.
*
@@ -32,13 +30,11 @@ ipmi_ret_t ipmi_app_watchdog_reset(
*
* @return IPMI_CC_OK on success, an IPMI error code otherwise.
*/
-ipmi_ret_t ipmi_app_watchdog_set(
- 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_ret_t ipmi_app_watchdog_set(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);
/** @brief The GET watchdog IPMI command.
* @param[in] netfn
@@ -50,10 +46,8 @@ ipmi_ret_t ipmi_app_watchdog_set(
*
* @return IPMI_CC_OK on success, an IPMI error code otherwise.
*/
-ipmi_ret_t ipmi_app_watchdog_get(
- 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_ret_t ipmi_app_watchdog_get(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);
diff --git a/app/watchdog_service.cpp b/app/watchdog_service.cpp
index 6c9edd4..923264b 100644
--- a/app/watchdog_service.cpp
+++ b/app/watchdog_service.cpp
@@ -1,8 +1,8 @@
#include "watchdog_service.hpp"
#include <exception>
-#include <phosphor-logging/elog.hpp>
#include <phosphor-logging/elog-errors.hpp>
+#include <phosphor-logging/elog.hpp>
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/message.hpp>
@@ -13,8 +13,8 @@
#include "host-ipmid/ipmid-api.h"
-using phosphor::logging::entry;
using phosphor::logging::elog;
+using phosphor::logging::entry;
using phosphor::logging::level;
using phosphor::logging::log;
using sdbusplus::message::variant_ns::get;
@@ -29,16 +29,14 @@ static constexpr char prop_intf[] = "org.freedesktop.DBus.Properties";
ipmi::ServiceCache WatchdogService::wd_service(wd_intf, wd_path);
-WatchdogService::WatchdogService()
- : bus(ipmid_get_sd_bus_connection())
+WatchdogService::WatchdogService() : bus(ipmid_get_sd_bus_connection())
{
}
void WatchdogService::resetTimeRemaining(bool enableWatchdog)
{
bool wasValid = wd_service.isValid(bus);
- auto request = wd_service.newMethodCall(
- bus, wd_intf, "ResetTimeRemaining");
+ auto request = wd_service.newMethodCall(bus, wd_intf, "ResetTimeRemaining");
request.append(enableWatchdog);
auto response = bus.call(request);
if (response.is_method_error())
@@ -50,8 +48,8 @@ void WatchdogService::resetTimeRemaining(bool enableWatchdog)
return resetTimeRemaining(enableWatchdog);
}
log<level::ERR>(
- "WatchdogService: Method error resetting time remaining",
- entry("ENABLE_WATCHDOG=%d", !!enableWatchdog));
+ "WatchdogService: Method error resetting time remaining",
+ entry("ENABLE_WATCHDOG=%d", !!enableWatchdog));
elog<InternalFailure>();
}
}
@@ -81,7 +79,7 @@ WatchdogService::Properties WatchdogService::getProperties()
wd_prop.initialized = get<bool>(properties.at("Initialized"));
wd_prop.enabled = get<bool>(properties.at("Enabled"));
wd_prop.expireAction = Watchdog::convertActionFromString(
- get<std::string>(properties.at("ExpireAction")));
+ get<std::string>(properties.at("ExpireAction")));
wd_prop.interval = get<uint64_t>(properties.at("Interval"));
wd_prop.timeRemaining = get<uint64_t>(properties.at("TimeRemaining"));
return wd_prop;
@@ -97,7 +95,7 @@ WatchdogService::Properties WatchdogService::getProperties()
// Needed instead of elog<InternalFailure>() since the compiler can't
// deduce the that elog<>() always throws
throw std::runtime_error(
- "WatchdogService: Should not reach end of getProperties");
+ "WatchdogService: Should not reach end of getProperties");
}
template <typename T>
@@ -137,7 +135,7 @@ T WatchdogService::getProperty(const std::string& key)
// Needed instead of elog<InternalFailure>() since the compiler can't
// deduce the that elog<>() always throws
throw std::runtime_error(
- "WatchdogService: Should not reach end of getProperty");
+ "WatchdogService: Should not reach end of getProperty");
}
template <typename T>
diff --git a/app/watchdog_service.hpp b/app/watchdog_service.hpp
index dfc913a..8056fb7 100644
--- a/app/watchdog_service.hpp
+++ b/app/watchdog_service.hpp
@@ -1,104 +1,107 @@
#pragma once
+#include "utils.hpp"
+
#include <sdbusplus/bus.hpp>
#include <xyz/openbmc_project/State/Watchdog/server.hpp>
-#include "utils.hpp"
-
/** @class WatchdogService
* @brief Access to the running OpenBMC watchdog implementation.
* @details Easy accessor for servers that implement the
* xyz.openbmc_project.State.Watchdog DBus API.
*/
-class WatchdogService {
- public:
- WatchdogService();
+class WatchdogService
+{
+ public:
+ WatchdogService();
- using Action = sdbusplus::xyz::openbmc_project::State::server::Watchdog::Action;
+ using Action =
+ sdbusplus::xyz::openbmc_project::State::server::Watchdog::Action;
- /** @brief Resets the time remaining on the watchdog.
- * Equivalent to setTimeRemaining(getInterval()).
- * Optionally enables the watchdog.
- *
- * @param[in] enableWatchdog - Should the call also enable the watchdog
- */
- void resetTimeRemaining(bool enableWatchdog);
+ /** @brief Resets the time remaining on the watchdog.
+ * Equivalent to setTimeRemaining(getInterval()).
+ * Optionally enables the watchdog.
+ *
+ * @param[in] enableWatchdog - Should the call also enable the watchdog
+ */
+ void resetTimeRemaining(bool enableWatchdog);
- /** @brief Contains a copy of the properties enumerated by the
- * watchdog service.
- */
- struct Properties {
- bool initialized;
- bool enabled;
- Action expireAction;
- uint64_t interval;
- uint64_t timeRemaining;
- };
+ /** @brief Contains a copy of the properties enumerated by the
+ * watchdog service.
+ */
+ struct Properties
+ {
+ bool initialized;
+ bool enabled;
+ Action expireAction;
+ uint64_t interval;
+ uint64_t timeRemaining;
+ };
- /** @brief Retrieves a copy of the currently set properties on the
- * host watchdog
- *
- * @return A populated WatchdogProperties struct
- */
- Properties getProperties();
+ /** @brief Retrieves a copy of the currently set properties on the
+ * host watchdog
+ *
+ * @return A populated WatchdogProperties struct
+ */
+ Properties getProperties();
- /** @brief Get the value of the initialized property on the host
- * watchdog
- *
- * @return The value of the property
- */
- bool getInitialized();
+ /** @brief Get the value of the initialized property on the host
+ * watchdog
+ *
+ * @return The value of the property
+ */
+ bool getInitialized();
- /** @brief Sets the value of the initialized property on the host
- * watchdog
- *
- * @param[in] initialized - The new initializedvalue
- */
- void setInitialized(bool initialized);
+ /** @brief Sets the value of the initialized property on the host
+ * watchdog
+ *
+ * @param[in] initialized - The new initializedvalue
+ */
+ void setInitialized(bool initialized);
- /** @brief Sets the value of the enabled property on the host watchdog
- *
- * @param[in] enabled - The new enabled value
- */
- void setEnabled(bool enabled);
+ /** @brief Sets the value of the enabled property on the host watchdog
+ *
+ * @param[in] enabled - The new enabled value
+ */
+ void setEnabled(bool enabled);
- /** @brief Sets the value of the expireAction property on the host watchdog
- *
- * @param[in] expireAction - The new expireAction value
- */
- void setExpireAction(Action expireAction);
+ /** @brief Sets the value of the expireAction property on the host watchdog
+ *
+ * @param[in] expireAction - The new expireAction value
+ */
+ void setExpireAction(Action expireAction);
- /** @brief Sets the value of the interval property on the host watchdog
- *
- * @param[in] interval - The new interval value
- */
- void setInterval(uint64_t interval);
+ /** @brief Sets the value of the interval property on the host watchdog
+ *
+ * @param[in] interval - The new interval value
+ */
+ void setInterval(uint64_t interval);
- /** @brief Sets the value of the timeRemaining property on the host
- * watchdog
- *
- * @param[in] timeRemaining - The new timeRemaining value
- */
- void setTimeRemaining(uint64_t timeRemaining);
+ /** @brief Sets the value of the timeRemaining property on the host
+ * watchdog
+ *
+ * @param[in] timeRemaining - The new timeRemaining value
+ */
+ void setTimeRemaining(uint64_t timeRemaining);
- private:
- /** @brief sdbusplus handle */
- sdbusplus::bus::bus bus;
- /** @brief The name of the mapped host watchdog service */
- static ipmi::ServiceCache wd_service;
+ private:
+ /** @brief sdbusplus handle */
+ sdbusplus::bus::bus bus;
+ /** @brief The name of the mapped host watchdog service */
+ static ipmi::ServiceCache wd_service;
- /** @brief Gets the value of the property on the host watchdog
- *
- * @param[in] key - The name of the property
- * @return The value of the property
- */
- template <typename T>
- T getProperty(const std::string& key);
+ /** @brief Gets the value of the property on the host watchdog
+ *
+ * @param[in] key - The name of the property
+ * @return The value of the property
+ */
+ template <typename T>
+ T getProperty(const std::string& key);
- /** @brief Sets the value of the property on the host watchdog
- *
- * @param[in] key - The name of the property
- * @param[in] val - The new value
- */
- template <typename T>
- void setProperty(const std::string& key, const T& val);
+ /** @brief Sets the value of the property on the host watchdog
+ *
+ * @param[in] key - The name of the property
+ * @param[in] val - The new value
+ */
+ template <typename T>
+ void setProperty(const std::string& key, const T& val);
};
OpenPOWER on IntegriCloud