split handler out of main file
Split the ethstats ipmi handler out of the main file as a first step
towards making it testable.
This allows for dependency injection.
Tested: Compiled.
Change-Id: Ic1657aa9c2b7e4bf0018299add8cd70576fae11b
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/ethstats.hpp b/ethstats.hpp
index 12805de..bf6b707 100644
--- a/ethstats.hpp
+++ b/ethstats.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include <ipmid/api.h>
+
#include <cstdint>
namespace ethstats
@@ -10,8 +12,8 @@
*/
struct EthStatRequest
{
- uint8_t statId;
- uint8_t if_name_len;
+ std::uint8_t statId;
+ std::uint8_t if_name_len;
} __attribute__((packed));
/**
@@ -19,8 +21,8 @@
*/
struct EthStatReply
{
- uint8_t statId;
- uint64_t value;
+ std::uint8_t statId;
+ std::uint64_t value;
} __attribute__((packed));
enum EthernetStatisticsIds
@@ -49,4 +51,17 @@
TX_WINDOW_ERRORS = 21,
};
+/**
+ * Handle the OEM IPMI EthStat Command.
+ *
+ * @param[in] cmd - the OEM command.
+ * @param[in] reqBuf - the IPMI request buffer.
+ * @param[in,out] replyCmdBuf - the IPMI reply buffer.
+ * @param[in,out] dataLen - the length of the request and reply.
+ * @return the IPMI result code.
+ */
+ipmi_ret_t handleEthStatCommand(ipmi_cmd_t cmd __attribute__((unused)),
+ const std::uint8_t* reqBuf,
+ std::uint8_t* replyCmdBuf, size_t* dataLen);
+
} // namespace ethstats