summaryrefslogtreecommitdiffstats
path: root/app/channel.cpp
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2018-08-31 11:55:55 -0700
committerPatrick Venture <venture@google.com>2018-09-07 23:45:41 +0000
commit0b02be925a29357f69abbc9e9a58e7c5aaed2eab (patch)
treec1b39f817d98ffda7b987f9e3f864f576e3bf9ea /app/channel.cpp
parent26f80ab2cc41deadc913190d906f71266c4ed224 (diff)
downloadphosphor-host-ipmid-0b02be925a29357f69abbc9e9a58e7c5aaed2eab.tar.gz
phosphor-host-ipmid-0b02be925a29357f69abbc9e9a58e7c5aaed2eab.zip
add .clang-format
Change-Id: I7c2a527b4751a560703a61fcbe9638b150546af5 Signed-off-by: Patrick Venture <venture@google.com>
Diffstat (limited to 'app/channel.cpp')
-rw-r--r--app/channel.cpp93
1 files changed, 49 insertions, 44 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);
}
OpenPOWER on IntegriCloud