Support broadcast message

1. Support send/recv broadcast message
2. Fix an issue of inconsistent addr between src addr of incoming message
and target addr of response

Tested:
1. CMC broadcast message can be sent and received (BNP)
2. IPMI command injected to i2c bus0 via IPMB header can return correct value (WFP)

Change-Id: Ic03ee4ef6552a40d20594c4abb337f71ae5763eb
Signed-off-by: Qiang XU <qiang.xu@linux.intel.com>
diff --git a/ipmbbridged.hpp b/ipmbbridged.hpp
index 01b2f44..d781e17 100644
--- a/ipmbbridged.hpp
+++ b/ipmbbridged.hpp
@@ -21,6 +21,11 @@
 #include <sdbusplus/message.hpp>
 #include <vector>
 
+extern "C" {
+#include <i2c/smbus.h>
+#include <linux/i2c-dev.h>
+}
+
 #ifndef IPMBBRIDGED_HPP
 #define IPMBBRIDGED_HPP
 
@@ -49,6 +54,11 @@
 constexpr uint8_t ipmbI2cNumberOfRetries = 2;
 
 /**
+ * @brief Ipmb boardcast address
+ */
+constexpr uint8_t broadcastAddress = 0x0;
+
+/**
  * @brief Ipmb defines
  */
 constexpr size_t ipmbMaxDataSize = 256;
@@ -273,7 +283,7 @@
 
     void processI2cEvent();
 
-    void ipmbResponseSend(std::shared_ptr<std::vector<uint8_t>> buffer,
+    void ipmbSendI2cFrame(std::shared_ptr<std::vector<uint8_t>> buffer,
                           size_t retriesAttempted);
 
     std::tuple<int, uint8_t, uint8_t, uint8_t, uint8_t, std::vector<uint8_t>>
@@ -309,4 +319,36 @@
     void makeRequestValid(std::shared_ptr<IpmbRequest> request);
 };
 
+/**
+ * @brief ioWrite class declaration
+ */
+class ioWrite
+{
+  public:
+    ioWrite(std::vector<uint8_t> &buffer)
+    {
+        i2cmsg[0].addr = ipmbAddressTo7BitSet(buffer[0]);
+        i2cmsg[0].len = buffer.size() - ipmbAddressSize;
+        i2cmsg[0].buf = buffer.data() + ipmbAddressSize;
+
+        msgRdwr.msgs = i2cmsg;
+        msgRdwr.nmsgs = 1;
+    };
+
+    int name()
+    {
+        return static_cast<int>(I2C_RDWR);
+    }
+
+    void *data()
+    {
+        return &msgRdwr;
+    }
+
+  private:
+    int myname;
+    i2c_rdwr_ioctl_data msgRdwr = {0};
+    i2c_msg i2cmsg[1] = {0};
+};
+
 #endif