ipmi: pull the netfn and command into parameters

Pull the netfn and cmd into parameters instead of hard-coding them for
blob commands.

Tested: Only ran unit-tests.
Change-Id: I1a73de32e14cc78ece94a26f6c447824af88c984
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/src/ipmiblob/blob_handler.cpp b/src/ipmiblob/blob_handler.cpp
index 039b7e0..6adbe89 100644
--- a/src/ipmiblob/blob_handler.cpp
+++ b/src/ipmiblob/blob_handler.cpp
@@ -67,7 +67,7 @@
 
     try
     {
-        reply = ipmi->sendPacket(request);
+        reply = ipmi->sendPacket(ipmiOEMNetFn, ipmiOEMBlobCmd, request);
     }
     catch (const IpmiException& e)
     {
diff --git a/src/ipmiblob/blob_handler.hpp b/src/ipmiblob/blob_handler.hpp
index 68708d8..c57b11d 100644
--- a/src/ipmiblob/blob_handler.hpp
+++ b/src/ipmiblob/blob_handler.hpp
@@ -130,4 +130,7 @@
     std::unique_ptr<IpmiInterface> ipmi;
 };
 
+constexpr int ipmiOEMNetFn = 46;
+constexpr int ipmiOEMBlobCmd = 128;
+
 } // namespace ipmiblob
diff --git a/src/ipmiblob/ipmi_handler.cpp b/src/ipmiblob/ipmi_handler.cpp
index 568b86c..682fe45 100644
--- a/src/ipmiblob/ipmi_handler.cpp
+++ b/src/ipmiblob/ipmi_handler.cpp
@@ -65,17 +65,15 @@
 }
 
 std::vector<std::uint8_t>
-    IpmiHandler::sendPacket(std::vector<std::uint8_t>& data)
+    IpmiHandler::sendPacket(std::uint8_t netfn, std::uint8_t cmd,
+                            std::vector<std::uint8_t>& data)
 {
     if (fd < 0)
     {
         open();
     }
 
-    constexpr int ipmiOEMNetFn = 46;
     constexpr int ipmiOEMLun = 0;
-    /* /openbmc/phosphor-host-ipmid/blob/master/host-ipmid/oemopenbmc.hpp */
-    constexpr int ipmiOEMBlobCmd = 128;
     constexpr int fifteenMs = 15 * 1000;
     constexpr int ipmiReadTimeout = fifteenMs;
     constexpr int ipmiResponseBufferLen = IPMI_MAX_MSG_LENGTH;
@@ -98,8 +96,8 @@
     request.msgid = sequence++;
     request.msg.data = reinterpret_cast<unsigned char*>(data.data());
     request.msg.data_len = data.size();
-    request.msg.netfn = ipmiOEMNetFn;
-    request.msg.cmd = ipmiOEMBlobCmd;
+    request.msg.netfn = netfn;
+    request.msg.cmd = cmd;
 
     struct ipmi_recv reply;
     reply.addr = reinterpret_cast<unsigned char*>(&systemAddress);
diff --git a/src/ipmiblob/ipmi_handler.hpp b/src/ipmiblob/ipmi_handler.hpp
index 34177ae..21d0fc7 100644
--- a/src/ipmiblob/ipmi_handler.hpp
+++ b/src/ipmiblob/ipmi_handler.hpp
@@ -37,7 +37,8 @@
      * @throws IpmiException on failure.
      */
     std::vector<std::uint8_t>
-        sendPacket(std::vector<std::uint8_t>& data) override;
+        sendPacket(std::uint8_t netfn, std::uint8_t cmd,
+                   std::vector<std::uint8_t>& data) override;
 
   private:
     const internal::Sys* sys;
diff --git a/src/ipmiblob/ipmi_interface.hpp b/src/ipmiblob/ipmi_interface.hpp
index bf7b448..4a62c2c 100644
--- a/src/ipmiblob/ipmi_interface.hpp
+++ b/src/ipmiblob/ipmi_interface.hpp
@@ -14,12 +14,15 @@
     /**
      * Send an IPMI packet to the BMC.
      *
+     * @param[in] netfn - the netfn for the IPMI packet.
+     * @param[in] cmd - the command.
      * @param[in] data - a vector of the IPMI packet contents.
      * @return the bytes returned.
      * @throws IpmiException on failure.
      */
     virtual std::vector<std::uint8_t>
-        sendPacket(std::vector<std::uint8_t>& data) = 0;
+        sendPacket(std::uint8_t netfn, std::uint8_t cmd,
+                   std::vector<std::uint8_t>& data) = 0;
 };
 
 } // namespace ipmiblob
diff --git a/src/ipmiblob/test/ipmi_interface_mock.hpp b/src/ipmiblob/test/ipmi_interface_mock.hpp
index c8324af..5f5514c 100644
--- a/src/ipmiblob/test/ipmi_interface_mock.hpp
+++ b/src/ipmiblob/test/ipmi_interface_mock.hpp
@@ -11,8 +11,9 @@
 {
   public:
     virtual ~IpmiInterfaceMock() = default;
-    MOCK_METHOD1(sendPacket,
-                 std::vector<std::uint8_t>(std::vector<std::uint8_t>&));
+    MOCK_METHOD3(sendPacket,
+                 std::vector<std::uint8_t>(std::uint8_t, std::uint8_t,
+                                           std::vector<std::uint8_t>&));
 };
 
 } // namespace ipmiblob