move entry point handler to process
Move the entry point handler for IPMI messages to process for two
reasons:
1) this lets one build pieces of this library without including the
constructor
2) this code is part of the command processing, and as such should be
with its kin.
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I10ab19b1868a29b158570109b4211e9c8b01be18
diff --git a/main.cpp b/main.cpp
index bd071ae..e90969b 100644
--- a/main.cpp
+++ b/main.cpp
@@ -35,31 +35,6 @@
using namespace phosphor::logging;
-static ipmi_ret_t handleBlobCommand(ipmi_cmd_t cmd, const uint8_t* reqBuf,
- uint8_t* replyCmdBuf, size_t* dataLen)
-{
- /* It's holding at least a sub-command. The OEN is trimmed from the bytes
- * before this is called.
- */
- if ((*dataLen) < 1)
- {
- return IPMI_CC_REQ_DATA_LEN_INVALID;
- }
-
- /* on failure rc is set to the corresponding IPMI error. */
- ipmi_ret_t rc = IPMI_CC_OK;
- IpmiBlobHandler command =
- validateBlobCommand(reqBuf, replyCmdBuf, dataLen, &rc);
- if (command == nullptr)
- {
- (*dataLen) = 0;
- return rc;
- }
-
- return processBlobCommand(command, getBlobManager(), reqBuf, replyCmdBuf,
- dataLen);
-}
-
void setupBlobGlobalHandler() __attribute__((constructor));
void setupBlobGlobalHandler()
diff --git a/process.cpp b/process.cpp
index 661f59d..bad4d70 100644
--- a/process.cpp
+++ b/process.cpp
@@ -142,4 +142,30 @@
return result;
}
+
+ipmi_ret_t handleBlobCommand(ipmi_cmd_t cmd, const uint8_t* reqBuf,
+ uint8_t* replyCmdBuf, size_t* dataLen)
+{
+ /* It's holding at least a sub-command. The OEN is trimmed from the bytes
+ * before this is called.
+ */
+ if ((*dataLen) < 1)
+ {
+ return IPMI_CC_REQ_DATA_LEN_INVALID;
+ }
+
+ /* on failure rc is set to the corresponding IPMI error. */
+ ipmi_ret_t rc = IPMI_CC_OK;
+ IpmiBlobHandler command =
+ validateBlobCommand(reqBuf, replyCmdBuf, dataLen, &rc);
+ if (command == nullptr)
+ {
+ (*dataLen) = 0;
+ return rc;
+ }
+
+ return processBlobCommand(command, getBlobManager(), reqBuf, replyCmdBuf,
+ dataLen);
+}
+
} // namespace blobs
diff --git a/process.hpp b/process.hpp
index cdd7f72..da0031c 100644
--- a/process.hpp
+++ b/process.hpp
@@ -41,4 +41,11 @@
ipmi_ret_t processBlobCommand(IpmiBlobHandler cmd, ManagerInterface* mgr,
const uint8_t* reqBuf, uint8_t* replyCmdBuf,
size_t* dataLen);
+
+/**
+ * Given an IPMI command, request buffer, and reply buffer, validate the request
+ * and call processBlobCommand.
+ */
+ipmi_ret_t handleBlobCommand(ipmi_cmd_t cmd, const uint8_t* reqBuf,
+ uint8_t* replyCmdBuf, size_t* dataLen);
} // namespace blobs