summaryrefslogtreecommitdiffstats
path: root/process.cpp
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2018-11-12 10:46:30 -0800
committerPatrick Venture <venture@google.com>2018-11-13 11:07:44 -0800
commit4125880028cc4a825f710b9e1b09986aacd4e1bb (patch)
treeb6d8defec27f0aefd5ac9b82356a9dd931a95ec4 /process.cpp
parent45e428a2b22f5ba134fa07ede6be1f99d12a6c2c (diff)
downloadphosphor-ipmi-blobs-4125880028cc4a825f710b9e1b09986aacd4e1bb.tar.gz
phosphor-ipmi-blobs-4125880028cc4a825f710b9e1b09986aacd4e1bb.zip
process: add IPMI error return mechanism and update errors
The IPMI packet validation code must return specific IPMI errors corresponding to what error has occurred instead of the invalid command error. Update all IPMI handler pieces to return more specific errors. Change-Id: I8d21e92015d84cc0880e3b83991aed7288e19eab Signed-off-by: Patrick Venture <venture@google.com>
Diffstat (limited to 'process.cpp')
-rw-r--r--process.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/process.cpp b/process.cpp
index 245da69..7e6410d 100644
--- a/process.cpp
+++ b/process.cpp
@@ -48,7 +48,8 @@ static const std::unordered_map<BlobOEMCommands, IpmiBlobHandler> handlers = {
};
IpmiBlobHandler validateBlobCommand(CrcInterface* crc, const uint8_t* reqBuf,
- uint8_t* replyCmdBuf, size_t* dataLen)
+ uint8_t* replyCmdBuf, size_t* dataLen,
+ ipmi_ret_t* code)
{
size_t requestLength = (*dataLen);
/* We know dataLen is at least 1 already */
@@ -57,6 +58,7 @@ IpmiBlobHandler validateBlobCommand(CrcInterface* crc, const uint8_t* reqBuf,
/* Validate it's at least well-formed. */
if (!validateRequestLength(command, requestLength))
{
+ *code = IPMI_CC_REQ_DATA_LEN_INVALID;
return nullptr;
}
@@ -66,6 +68,7 @@ IpmiBlobHandler validateBlobCommand(CrcInterface* crc, const uint8_t* reqBuf,
/* Verify the request includes: command, crc16, data */
if (requestLength < sizeof(struct BmcRx))
{
+ *code = IPMI_CC_REQ_DATA_LEN_INVALID;
return nullptr;
}
@@ -91,6 +94,7 @@ IpmiBlobHandler validateBlobCommand(CrcInterface* crc, const uint8_t* reqBuf,
/* Crc expected but didn't match. */
if (crcValue != crc->get())
{
+ *code = IPMI_CC_UNSPECIFIED_ERROR;
return nullptr;
}
}
@@ -99,6 +103,7 @@ IpmiBlobHandler validateBlobCommand(CrcInterface* crc, const uint8_t* reqBuf,
auto found = handlers.find(command);
if (found == handlers.end())
{
+ *code = IPMI_CC_INVALID_FIELD_REQUEST;
return nullptr;
}
@@ -126,7 +131,7 @@ ipmi_ret_t processBlobCommand(IpmiBlobHandler cmd, ManagerInterface* mgr,
/* The response, if it has one byte, has three, to include the crc16. */
if (replyLength < (sizeof(uint16_t) + 1))
{
- return IPMI_CC_INVALID;
+ return IPMI_CC_UNSPECIFIED_ERROR;
}
/* The command, whatever it was, replied, so let's set the CRC. */
OpenPOWER on IntegriCloud