oem-ibm: Check if a FRU is IBM specific

The major difference between the standard FRUs
and the IBM specific FRUs is the format in which
the VPD data is written and its model type.
If the model property is filled it is a IBM specific FRU,
if not then that can be an industry standard FRU.

Change-Id: I9c01b99e37107bc3caeb88336626bc9e514e78f0
Signed-off-by: Sampa Misra <sampmisr@in.ibm.com>
diff --git a/oem/ibm/libpldmresponder/utils.cpp b/oem/ibm/libpldmresponder/utils.cpp
index 7126ff8..5e8658f 100644
--- a/oem/ibm/libpldmresponder/utils.cpp
+++ b/oem/ibm/libpldmresponder/utils.cpp
@@ -1,5 +1,7 @@
 #include "utils.hpp"
 
+#include "common/utils.hpp"
+
 #include <libpldm/base.h>
 #include <sys/socket.h>
 #include <sys/types.h>
@@ -7,6 +9,7 @@
 #include <unistd.h>
 
 #include <phosphor-logging/lg2.hpp>
+#include <xyz/openbmc_project/Inventory/Decorator/Asset/client.hpp>
 
 PHOSPHOR_LOG2_USING;
 
@@ -137,6 +140,28 @@
     return 0;
 }
 
+bool checkIfIBMFru(const std::string& objPath)
+{
+    using DecoratorAsset =
+        sdbusplus::client::xyz::openbmc_project::inventory::decorator::Asset<>;
+
+    try
+    {
+        auto propVal = pldm::utils::DBusHandler().getDbusPropertyVariant(
+            objPath.c_str(), "Model", DecoratorAsset::interface);
+        const auto& model = std::get<std::string>(propVal);
+        if (!model.empty())
+        {
+            return true;
+        }
+    }
+    catch (const std::exception&)
+    {
+        return false;
+    }
+    return false;
+}
+
 } // namespace utils
 } // namespace responder
 } // namespace pldm
diff --git a/oem/ibm/libpldmresponder/utils.hpp b/oem/ibm/libpldmresponder/utils.hpp
index e8f341d..f2e2153 100644
--- a/oem/ibm/libpldmresponder/utils.hpp
+++ b/oem/ibm/libpldmresponder/utils.hpp
@@ -36,6 +36,14 @@
 int writeToUnixSocket(const int sock, const char* buf,
                       const uint64_t blockSize);
 
+/** @brief checks if given FRU is IBM specific
+ *
+ *  @param[in] objPath - FRU object path
+ *
+ *  @return bool - true if IBM specific FRU
+ */
+bool checkIfIBMFru(const std::string& objPath);
+
 } // namespace utils
 } // namespace responder
 } // namespace pldm