move blob command enum to blob_interface header
Move the blob command enum to the blob_interface header that can be
safely included by other code.
Change-Id: If7c613cac9bdd460fc9a6cb3b59e4fc0dd3a861d
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/src/ipmiblob/blob_handler.cpp b/src/ipmiblob/blob_handler.cpp
index 2b79e19..039b7e0 100644
--- a/src/ipmiblob/blob_handler.cpp
+++ b/src/ipmiblob/blob_handler.cpp
@@ -48,7 +48,7 @@
std::copy(ipmiPhosphorOen.begin(), ipmiPhosphorOen.end(),
std::back_inserter(request));
- request.push_back(command);
+ request.push_back(static_cast<std::uint8_t>(command));
if (payload.size() > 0)
{
diff --git a/src/ipmiblob/blob_handler.hpp b/src/ipmiblob/blob_handler.hpp
index 5e24b91..68708d8 100644
--- a/src/ipmiblob/blob_handler.hpp
+++ b/src/ipmiblob/blob_handler.hpp
@@ -11,21 +11,6 @@
class BlobHandler : public BlobInterface
{
public:
- enum BlobOEMCommands
- {
- bmcBlobGetCount = 0,
- bmcBlobEnumerate = 1,
- bmcBlobOpen = 2,
- bmcBlobRead = 3,
- bmcBlobWrite = 4,
- bmcBlobCommit = 5,
- bmcBlobClose = 6,
- bmcBlobDelete = 7,
- bmcBlobStat = 8,
- bmcBlobSessionStat = 9,
- bmcBlobWriteMeta = 10,
- };
-
/**
* Create a BlobInterface pointer for use given an ipmi handler.
*
diff --git a/src/ipmiblob/blob_interface.hpp b/src/ipmiblob/blob_interface.hpp
index 26ca837..fbd8c6a 100644
--- a/src/ipmiblob/blob_interface.hpp
+++ b/src/ipmiblob/blob_interface.hpp
@@ -7,6 +7,21 @@
namespace ipmiblob
{
+enum class BlobOEMCommands : std::uint8_t
+{
+ bmcBlobGetCount = 0,
+ bmcBlobEnumerate = 1,
+ bmcBlobOpen = 2,
+ bmcBlobRead = 3,
+ bmcBlobWrite = 4,
+ bmcBlobCommit = 5,
+ bmcBlobClose = 6,
+ bmcBlobDelete = 7,
+ bmcBlobStat = 8,
+ bmcBlobSessionStat = 9,
+ bmcBlobWriteMeta = 10,
+};
+
struct StatResponse
{
std::uint16_t blob_state;
diff --git a/test/tools_blob_unittest.cpp b/test/tools_blob_unittest.cpp
index e9f2c96..3afb61b 100644
--- a/test/tools_blob_unittest.cpp
+++ b/test/tools_blob_unittest.cpp
@@ -44,7 +44,8 @@
BlobHandler blob(std::move(ipmi));
std::vector<std::uint8_t> request = {
- 0xcf, 0xc2, 0x00, BlobHandler::BlobOEMCommands::bmcBlobGetCount};
+ 0xcf, 0xc2, 0x00,
+ static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobGetCount)};
/* return 1 blob count. */
std::vector<std::uint8_t> resp = {0xcf, 0xc2, 0x00, 0x00, 0x00,
@@ -66,8 +67,10 @@
BlobHandler blob(std::move(ipmi));
std::vector<std::uint8_t> request = {
- 0xcf, 0xc2, 0x00, BlobHandler::BlobOEMCommands::bmcBlobEnumerate,
- 0x00, 0x00, 0x01, 0x00,
+ 0xcf, 0xc2,
+ 0x00, static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobEnumerate),
+ 0x00, 0x00,
+ 0x01, 0x00,
0x00, 0x00};
/* return value. */
@@ -92,8 +95,10 @@
BlobHandler blob(std::move(ipmi));
std::vector<std::uint8_t> request = {
- 0xcf, 0xc2, 0x00, BlobHandler::BlobOEMCommands::bmcBlobEnumerate,
- 0x00, 0x00, 0x01, 0x00,
+ 0xcf, 0xc2,
+ 0x00, static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobEnumerate),
+ 0x00, 0x00,
+ 0x01, 0x00,
0x00, 0x00};
/* return value. */
@@ -115,7 +120,8 @@
BlobHandler blob(std::move(ipmi));
std::vector<std::uint8_t> request1 = {
- 0xcf, 0xc2, 0x00, BlobHandler::BlobOEMCommands::bmcBlobGetCount};
+ 0xcf, 0xc2, 0x00,
+ static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobGetCount)};
/* return 1 blob count. */
std::vector<std::uint8_t> resp1 = {0xcf, 0xc2, 0x00, 0x00, 0x00,
@@ -127,8 +133,10 @@
EXPECT_CALL(*ipmiMock, sendPacket(Eq(request1))).WillOnce(Return(resp1));
std::vector<std::uint8_t> request2 = {
- 0xcf, 0xc2, 0x00, BlobHandler::BlobOEMCommands::bmcBlobEnumerate,
- 0x00, 0x00, 0x00, 0x00,
+ 0xcf, 0xc2,
+ 0x00, static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobEnumerate),
+ 0x00, 0x00,
+ 0x00, 0x00,
0x00, 0x00};
/* return value. */
@@ -157,9 +165,12 @@
BlobHandler blob(std::move(ipmi));
std::vector<std::uint8_t> request = {
- 0xcf, 0xc2, 0x00, BlobHandler::BlobOEMCommands::bmcBlobStat,
- 0x00, 0x00, 'a', 'b',
- 'c', 'd', 0x00};
+ 0xcf, 0xc2,
+ 0x00, static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobStat),
+ 0x00, 0x00,
+ 'a', 'b',
+ 'c', 'd',
+ 0x00};
/* return blob_state: 0xffff, size: 0x00, metadata 0x3445 */
std::vector<std::uint8_t> resp = {0xcf, 0xc2, 0x00, 0x00, 0x00, 0xff, 0xff,
@@ -189,9 +200,12 @@
BlobHandler blob(std::move(ipmi));
std::vector<std::uint8_t> request = {
- 0xcf, 0xc2, 0x00, BlobHandler::BlobOEMCommands::bmcBlobStat,
- 0x00, 0x00, 'a', 'b',
- 'c', 'd', 0x00};
+ 0xcf, 0xc2,
+ 0x00, static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobStat),
+ 0x00, 0x00,
+ 'a', 'b',
+ 'c', 'd',
+ 0x00};
/* return blob_state: 0xffff, size: 0x00, metadata 0x3445 */
std::vector<std::uint8_t> resp = {0xcf, 0xc2, 0x00, 0x00, 0x00, 0xff,
@@ -222,8 +236,10 @@
BlobHandler blob(std::move(ipmi));
std::vector<std::uint8_t> request = {
- 0xcf, 0xc2, 0x00, BlobHandler::BlobOEMCommands::bmcBlobSessionStat,
- 0x00, 0x00, 0x01, 0x00};
+ 0xcf, 0xc2,
+ 0x00, static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobSessionStat),
+ 0x00, 0x00,
+ 0x01, 0x00};
/* return blob_state: 0xffff, size: 0x00, metadata 0x3445 */
std::vector<std::uint8_t> resp = {0xcf, 0xc2, 0x00, 0x00, 0x00, 0xff,
@@ -254,9 +270,12 @@
BlobHandler blob(std::move(ipmi));
std::vector<std::uint8_t> request = {
- 0xcf, 0xc2, 0x00, BlobHandler::BlobOEMCommands::bmcBlobOpen,
- 0x00, 0x00, 0x02, 0x04,
- 'a', 'b', 'c', 'd',
+ 0xcf, 0xc2,
+ 0x00, static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobOpen),
+ 0x00, 0x00,
+ 0x02, 0x04,
+ 'a', 'b',
+ 'c', 'd',
0x00};
std::vector<std::uint8_t> resp = {0xcf, 0xc2, 0x00, 0x00, 0x00, 0xfe, 0xed};
@@ -284,8 +303,10 @@
BlobHandler blob(std::move(ipmi));
std::vector<std::uint8_t> request = {
- 0xcf, 0xc2, 0x00, BlobHandler::BlobOEMCommands::bmcBlobClose,
- 0x00, 0x00, 0x01, 0x00};
+ 0xcf, 0xc2,
+ 0x00, static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobClose),
+ 0x00, 0x00,
+ 0x01, 0x00};
std::vector<std::uint8_t> resp = {0xcf, 0xc2, 0x00};
std::vector<std::uint8_t> reqCrc = {0x01, 0x00};
EXPECT_CALL(crcMock, generateCrc(Eq(reqCrc))).WillOnce(Return(0x00));
@@ -304,8 +325,10 @@
BlobHandler blob(std::move(ipmi));
std::vector<std::uint8_t> request = {
- 0xcf, 0xc2, 0x00, BlobHandler::BlobOEMCommands::bmcBlobCommit,
- 0x00, 0x00, 0x01, 0x00,
+ 0xcf, 0xc2,
+ 0x00, static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobCommit),
+ 0x00, 0x00,
+ 0x01, 0x00,
0x00};
std::vector<std::uint8_t> resp = {0xcf, 0xc2, 0x00};
@@ -326,10 +349,14 @@
BlobHandler blob(std::move(ipmi));
std::vector<std::uint8_t> request = {
- 0xcf, 0xc2, 0x00, BlobHandler::BlobOEMCommands::bmcBlobWrite,
- 0x00, 0x00, 0x01, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 'a', 'b', 'c', 'd'};
+ 0xcf, 0xc2,
+ 0x00, static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobWrite),
+ 0x00, 0x00,
+ 0x01, 0x00,
+ 0x00, 0x00,
+ 0x00, 0x00,
+ 'a', 'b',
+ 'c', 'd'};
std::vector<std::uint8_t> bytes = {'a', 'b', 'c', 'd'};
std::vector<std::uint8_t> resp = {0xcf, 0xc2, 0x00};
@@ -351,10 +378,14 @@
BlobHandler blob(std::move(ipmi));
std::vector<std::uint8_t> request = {
- 0xcf, 0xc2, 0x00, BlobHandler::BlobOEMCommands::bmcBlobRead,
- 0x00, 0x00, 0x01, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x04, 0x00, 0x00, 0x00};
+ 0xcf, 0xc2,
+ 0x00, static_cast<std::uint8_t>(BlobOEMCommands::bmcBlobRead),
+ 0x00, 0x00,
+ 0x01, 0x00,
+ 0x00, 0x00,
+ 0x00, 0x00,
+ 0x04, 0x00,
+ 0x00, 0x00};
std::vector<std::uint8_t> expectedBytes = {'a', 'b', 'c', 'd'};
std::vector<std::uint8_t> resp = {0xcf, 0xc2, 0x00, 0x00, 0x00,