Add compile option to disable white list checking for I2C master WR command

By default this white list checking is enabled,
we can disable it by using the below command,
./configure  --disable-i2c-whitelist-check

Tested:
Without the --disable-i2c-whitelist-check compile option,
the white list checking works as before
"ipmitool i2c bus=2 0x9c 8 0" command  will fail with error message:
Unable to perform I2C Master Write-Read
After adding the compile option, there is no such error.

Signed-off-by: Yong Li <yong.b.li@linux.intel.com>
Change-Id: I91ced8b0dfb1dbf51292a6b3dea6fd5c03bdbde7
diff --git a/apphandler.cpp b/apphandler.cpp
index 09b1c2f..392d68a 100644
--- a/apphandler.cpp
+++ b/apphandler.cpp
@@ -60,6 +60,7 @@
 using BMC = sdbusplus::xyz::openbmc_project::State::server::BMC;
 namespace fs = std::filesystem;
 
+#ifdef ENABLE_I2C_WHITELIST_CHECK
 typedef struct
 {
     uint8_t busId;
@@ -78,7 +79,6 @@
 static constexpr const char* i2cMasterWRWhitelistFile =
     "/usr/share/ipmi-providers/master_write_read_white_list.json";
 
-static constexpr uint8_t maxIPMIWriteReadSize = 144;
 static constexpr const char* filtersStr = "filters";
 static constexpr const char* busIdStr = "busId";
 static constexpr const char* slaveAddrStr = "slaveAddr";
@@ -86,6 +86,8 @@
 static constexpr const char* cmdStr = "command";
 static constexpr const char* cmdMaskStr = "commandMask";
 static constexpr int base_16 = 16;
+#endif // ENABLE_I2C_WHITELIST_CHECK
+static constexpr uint8_t maxIPMIWriteReadSize = 144;
 
 /**
  * @brief Returns the Version info from primary s/w object
@@ -1013,6 +1015,7 @@
     return IPMI_CC_OK;
 }
 
+#ifdef ENABLE_I2C_WHITELIST_CHECK
 inline std::vector<uint8_t> convertStringToData(const std::string& command)
 {
     std::istringstream iss(command);
@@ -1161,6 +1164,14 @@
     }
     return false;
 }
+#else
+static bool populateI2CMasterWRWhitelist()
+{
+    log<level::INFO>(
+        "I2C_WHITELIST_CHECK is disabled, do not populate whitelist");
+    return true;
+}
+#endif // ENABLE_I2C_WHITELIST_CHECK
 
 /** @brief implements master write read IPMI command which can be used for
  * low-level I2C/SMBus write, read or write-read access
@@ -1194,6 +1205,7 @@
         log<level::ERR>("Master write read command: Read & write count are 0");
         return ipmi::responseInvalidFieldRequest();
     }
+#ifdef ENABLE_I2C_WHITELIST_CHECK
     if (!isCmdWhitelisted(static_cast<uint8_t>(busId),
                           static_cast<uint8_t>(slaveAddr), writeData))
     {
@@ -1202,6 +1214,7 @@
                         entry("ADDR=0x%x", static_cast<uint8_t>(slaveAddr)));
         return ipmi::responseInvalidFieldRequest();
     }
+#endif // ENABLE_I2C_WHITELIST_CHECK
     std::vector<uint8_t> readBuf(readCount);
     std::string i2cBus =
         "/dev/i2c-" + std::to_string(static_cast<uint8_t>(busId));