pldm: Moving utils function into the common directory

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I4fbd0da4bc6f27e9a9ed711962bd8737d8b55ebf
diff --git a/libpldmresponder/bios.cpp b/libpldmresponder/bios.cpp
index d815ce4..6776038 100644
--- a/libpldmresponder/bios.cpp
+++ b/libpldmresponder/bios.cpp
@@ -1,6 +1,6 @@
 #include "bios.hpp"
 
-#include "libpldmresponder/utils.hpp"
+#include "utils.hpp"
 #include "xyz/openbmc_project/Common/error.hpp"
 
 #include <array>
@@ -48,14 +48,15 @@
     auto t = time_t(timeSec);
     auto time = localtime(&t);
 
-    seconds = decimalToBcd(time->tm_sec);
-    minutes = decimalToBcd(time->tm_min);
-    hours = decimalToBcd(time->tm_hour);
-    day = decimalToBcd(time->tm_mday);
-    month =
-        decimalToBcd(time->tm_mon + 1); // The number of months in the range
-                                        // 0 to 11.PLDM expects range 1 to 12
-    year = decimalToBcd(time->tm_year + 1900); // The number of years since 1900
+    seconds = pldm::utils::decimalToBcd(time->tm_sec);
+    minutes = pldm::utils::decimalToBcd(time->tm_min);
+    hours = pldm::utils::decimalToBcd(time->tm_hour);
+    day = pldm::utils::decimalToBcd(time->tm_mday);
+    month = pldm::utils::decimalToBcd(time->tm_mon +
+                                      1); // The number of months in the range
+                                          // 0 to 11.PLDM expects range 1 to 12
+    year = pldm::utils::decimalToBcd(time->tm_year +
+                                     1900); // The number of years since 1900
 }
 
 size_t getTableTotalsize(size_t sizeWithoutPad)
@@ -126,7 +127,9 @@
     auto bus = sdbusplus::bus::new_default();
     try
     {
-        auto service = getService(bus, hostTimePath, timeInterface);
+
+        auto service =
+            pldm::utils::getService(bus, hostTimePath, timeInterface);
 
         auto method = bus.new_method_call(service.c_str(), hostTimePath,
                                           dbusProperties, "Get");
diff --git a/libpldmresponder/bios_parser.cpp b/libpldmresponder/bios_parser.cpp
index 86c07c6..062a342 100644
--- a/libpldmresponder/bios_parser.cpp
+++ b/libpldmresponder/bios_parser.cpp
@@ -1,6 +1,6 @@
 #include "bios_parser.hpp"
 
-#include "libpldmresponder/utils.hpp"
+#include "utils.hpp"
 
 #include <filesystem>
 #include <fstream>
@@ -230,7 +230,7 @@
 
     const auto& dbusValToValMap = internal::dbusValToValMaps.at(attrName);
     propValue =
-        pldm::responder::DBusHandler()
+        pldm::utils::DBusHandler()
             .getDbusPropertyVariant<internal::PropertyValue>(
                 dBusMap->objectPath.c_str(), dBusMap->propertyName.c_str(),
                 dBusMap->interface.c_str());
@@ -345,7 +345,7 @@
         return std::get<DefaultStr>(valueEntry);
     }
 
-    return pldm::responder::DBusHandler().getDbusProperty<std::string>(
+    return pldm::utils::DBusHandler().getDbusProperty<std::string>(
         dBusMap->objectPath.c_str(), dBusMap->propertyName.c_str(),
         dBusMap->interface.c_str());
 }
@@ -409,7 +409,7 @@
         return std::get<AttrDefaultValue>(valueEntry);
     }
 
-    return pldm::responder::DBusHandler().getDbusProperty<uint64_t>(
+    return pldm::utils::DBusHandler().getDbusProperty<uint64_t>(
         dBusMap->objectPath.c_str(), dBusMap->propertyName.c_str(),
         dBusMap->interface.c_str());
 }
diff --git a/libpldmresponder/meson.build b/libpldmresponder/meson.build
index 2fc0f76..fc47454 100644
--- a/libpldmresponder/meson.build
+++ b/libpldmresponder/meson.build
@@ -11,8 +11,8 @@
   'bios_parser.cpp',
   'pdr.cpp',
   'effecters.cpp',
-  'utils.cpp',
   'platform.cpp',
+  '../utils.cpp'
 ]
 
 if get_option('oem-ibm').enabled()
diff --git a/libpldmresponder/pdr.hpp b/libpldmresponder/pdr.hpp
index 87143a8..b32f878 100644
--- a/libpldmresponder/pdr.hpp
+++ b/libpldmresponder/pdr.hpp
@@ -298,13 +298,15 @@
         {
             std::cerr << "Failed parsing PDR JSON file, TYPE= " << pdrType
                       << " ERROR=" << e.what() << "\n";
-            reportError("xyz.openbmc_project.bmc.pldm.InternalFailure");
+            pldm::utils::reportError(
+                "xyz.openbmc_project.bmc.pldm.InternalFailure");
         }
         catch (const std::exception& e)
         {
             std::cerr << "Failed parsing PDR JSON file, TYPE= " << pdrType
                       << " ERROR=" << e.what() << "\n";
-            reportError("xyz.openbmc_project.bmc.pldm.InternalFailure");
+            pldm::utils::reportError(
+                "xyz.openbmc_project.bmc.pldm.InternalFailure");
         }
     }
 }
diff --git a/libpldmresponder/platform.cpp b/libpldmresponder/platform.cpp
index 1d6d042..9c5b688 100644
--- a/libpldmresponder/platform.cpp
+++ b/libpldmresponder/platform.cpp
@@ -1,6 +1,8 @@
 
 #include "platform.hpp"
 
+#include "utils.hpp"
+
 namespace pldm
 {
 namespace responder
@@ -106,9 +108,10 @@
     if (rc == PLDM_SUCCESS)
     {
         stateField.resize(compEffecterCnt);
-        const DBusHandler dBusIntf;
-        rc = setStateEffecterStatesHandler<DBusHandler>(dBusIntf, effecterId,
-                                                        stateField);
+
+        const pldm::utils::DBusHandler dBusIntf;
+        rc = setStateEffecterStatesHandler<pldm::utils::DBusHandler>(
+            dBusIntf, effecterId, stateField);
     }
 
     encode_set_state_effecter_states_resp(request->hdr.instance_id, rc,
diff --git a/libpldmresponder/platform.hpp b/libpldmresponder/platform.hpp
index 1c6c733..3de0e1f 100644
--- a/libpldmresponder/platform.hpp
+++ b/libpldmresponder/platform.hpp
@@ -4,7 +4,7 @@
 
 #include "handler.hpp"
 #include "libpldmresponder/pdr.hpp"
-#include "libpldmresponder/utils.hpp"
+#include "utils.hpp"
 
 #include <stdint.h>
 
diff --git a/libpldmresponder/utils.cpp b/libpldmresponder/utils.cpp
deleted file mode 100644
index 8290675..0000000
--- a/libpldmresponder/utils.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-#include "utils.hpp"
-
-#include "xyz/openbmc_project/Common/error.hpp"
-
-#include <array>
-#include <ctime>
-#include <iostream>
-#include <map>
-#include <stdexcept>
-#include <string>
-#include <vector>
-
-namespace pldm
-{
-
-constexpr auto mapperBusName = "xyz.openbmc_project.ObjectMapper";
-constexpr auto mapperPath = "/xyz/openbmc_project/object_mapper";
-constexpr auto mapperInterface = "xyz.openbmc_project.ObjectMapper";
-
-namespace responder
-{
-
-std::string getService(sdbusplus::bus::bus& bus, const std::string& path,
-                       const std::string& interface)
-{
-    using DbusInterfaceList = std::vector<std::string>;
-    std::map<std::string, std::vector<std::string>> mapperResponse;
-
-    try
-    {
-        auto mapper = bus.new_method_call(mapperBusName, mapperPath,
-                                          mapperInterface, "GetObject");
-        mapper.append(path, DbusInterfaceList({interface}));
-
-        auto mapperResponseMsg = bus.call(mapper);
-        mapperResponseMsg.read(mapperResponse);
-    }
-    catch (std::exception& e)
-    {
-        std::cerr << "Error in mapper call, ERROR=" << e.what()
-                  << " PATH=" << path.c_str()
-                  << " INTERFACE=" << interface.c_str() << "\n";
-        throw;
-    }
-    return mapperResponse.begin()->first;
-}
-
-void reportError(const char* errorMsg)
-{
-    static constexpr auto logObjPath = "/xyz/openbmc_project/logging";
-    static constexpr auto logInterface = "xyz.openbmc_project.Logging.Create";
-
-    static sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
-
-    try
-    {
-        auto service = getService(bus, logObjPath, logInterface);
-        using namespace sdbusplus::xyz::openbmc_project::Logging::server;
-        auto severity =
-            sdbusplus::xyz::openbmc_project::Logging::server::convertForMessage(
-                sdbusplus::xyz::openbmc_project::Logging::server::Entry::Level::
-                    Error);
-        auto method = bus.new_method_call(service.c_str(), logObjPath,
-                                          logInterface, "Create");
-        std::map<std::string, std::string> addlData{};
-        method.append(errorMsg, severity, addlData);
-        bus.call_noreply(method);
-    }
-    catch (const std::exception& e)
-    {
-        std::cerr << "failed to make a d-bus call to create error log, ERROR="
-                  << e.what() << "\n";
-    }
-}
-
-namespace utils
-{
-
-uint8_t getNumPadBytes(uint32_t data)
-{
-    uint8_t pad;
-    pad = ((data % 4) ? (4 - data % 4) : 0);
-    return pad;
-} // end getNumPadBytes
-
-} // end namespace utils
-} // namespace responder
-} // namespace pldm
diff --git a/oem/ibm/libpldmresponder/file_io.cpp b/oem/ibm/libpldmresponder/file_io.cpp
index 177fe3f..c35084c 100644
--- a/oem/ibm/libpldmresponder/file_io.cpp
+++ b/oem/ibm/libpldmresponder/file_io.cpp
@@ -4,7 +4,7 @@
 
 #include "file_io_by_type.hpp"
 #include "file_table.hpp"
-#include "libpldmresponder/utils.hpp"
+#include "utils.hpp"
 #include "xyz/openbmc_project/Common/error.hpp"
 
 #include <fcntl.h>
@@ -75,7 +75,7 @@
         return rc;
     }
 
-    utils::CustomFD xdmaFd(dmaFd);
+    pldm::utils::CustomFD xdmaFd(dmaFd);
 
     void* vgaMem;
     vgaMem = mmap(nullptr, pageAlignedLength, upstream ? PROT_WRITE : PROT_READ,
diff --git a/oem/ibm/libpldmresponder/file_io.hpp b/oem/ibm/libpldmresponder/file_io.hpp
index a22a8c8..3a504bf 100644
--- a/oem/ibm/libpldmresponder/file_io.hpp
+++ b/oem/ibm/libpldmresponder/file_io.hpp
@@ -1,7 +1,7 @@
 #pragma once
 
 #include "handler.hpp"
-#include "libpldmresponder/utils.hpp"
+#include "utils.hpp"
 
 #include <fcntl.h>
 #include <stdint.h>
@@ -107,7 +107,7 @@
                                    responsePtr);
         return response;
     }
-    utils::CustomFD fd(file);
+    pldm::utils::CustomFD fd(file);
 
     while (length > dma::maxSize)
     {
diff --git a/oem/ibm/libpldmresponder/file_io_by_type.cpp b/oem/ibm/libpldmresponder/file_io_by_type.cpp
index 7d001b9..e076253 100644
--- a/oem/ibm/libpldmresponder/file_io_by_type.cpp
+++ b/oem/ibm/libpldmresponder/file_io_by_type.cpp
@@ -4,7 +4,7 @@
 
 #include "file_io_type_lid.hpp"
 #include "file_io_type_pel.hpp"
-#include "libpldmresponder/utils.hpp"
+#include "utils.hpp"
 #include "xyz/openbmc_project/Common/error.hpp"
 
 #include <stdint.h>
diff --git a/oem/ibm/libpldmresponder/file_io_type_pel.cpp b/oem/ibm/libpldmresponder/file_io_type_pel.cpp
index 8029b47..ce9202a 100644
--- a/oem/ibm/libpldmresponder/file_io_type_pel.cpp
+++ b/oem/ibm/libpldmresponder/file_io_type_pel.cpp
@@ -2,7 +2,7 @@
 
 #include "file_io_type_pel.hpp"
 
-#include "libpldmresponder/utils.hpp"
+#include "utils.hpp"
 #include "xyz/openbmc_project/Common/error.hpp"
 
 #include <stdint.h>
@@ -34,7 +34,7 @@
 
     try
     {
-        auto service = getService(bus, logObjPath, logInterface);
+        auto service = pldm::utils::getService(bus, logObjPath, logInterface);
         auto method = bus.new_method_call(service.c_str(), logObjPath,
                                           logInterface, "GetPEL");
         method.append(fileHandle);
@@ -62,7 +62,7 @@
 
     try
     {
-        auto service = getService(bus, logObjPath, logInterface);
+        auto service = pldm::utils::getService(bus, logObjPath, logInterface);
         auto method = bus.new_method_call(service.c_str(), logObjPath,
                                           logInterface, "GetPEL");
         method.append(fileHandle);
@@ -149,7 +149,7 @@
 
     try
     {
-        auto service = getService(bus, logObjPath, logInterface);
+        auto service = pldm::utils::getService(bus, logObjPath, logInterface);
         auto method = bus.new_method_call(service.c_str(), logObjPath,
                                           logInterface, "HostAck");
         method.append(fileHandle);
@@ -173,7 +173,7 @@
 
     try
     {
-        auto service = getService(bus, logObjPath, logInterface);
+        auto service = pldm::utils::getService(bus, logObjPath, logInterface);
         using namespace sdbusplus::xyz::openbmc_project::Logging::server;
         std::map<std::string, std::string> addlData{};
         addlData.emplace("RAWPEL", std::move(pelFileName));
diff --git a/pldmd.cpp b/pldmd.cpp
index 6394b4d..dae5182 100644
--- a/pldmd.cpp
+++ b/pldmd.cpp
@@ -3,7 +3,7 @@
 #include "libpldmresponder/base.hpp"
 #include "libpldmresponder/bios.hpp"
 #include "libpldmresponder/platform.hpp"
-#include "libpldmresponder/utils.hpp"
+#include "utils.hpp"
 
 #include <err.h>
 #include <getopt.h>
@@ -163,7 +163,7 @@
         exit(EXIT_FAILURE);
     }
 
-    responder::utils::CustomFD socketFd(sockfd);
+    pldm::utils::CustomFD socketFd(sockfd);
 
     struct sockaddr_un addr
     {
diff --git a/test/meson.build b/test/meson.build
index a9cdd94..4366a2b 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -14,7 +14,7 @@
 
 gtest = dependency('gtest', main: true, disabler: true, required: true)
 gmock = dependency('gmock', disabler: true, required: true)
-pldmd = declare_dependency(sources: '../instance_id.cpp')
+pldmd = declare_dependency(sources: ['../instance_id.cpp', '../utils.cpp'])
 
 tests = [
   'libpldm_base_test',
@@ -30,6 +30,7 @@
   'libpldm_utils_test',
   'pldmd_instanceid_test',
   'pldmd_registration_test',
+  'pldm_utils_test',
 ]
 
 if get_option('oem-ibm').enabled()
diff --git a/test/pldm_utils_test.cpp b/test/pldm_utils_test.cpp
new file mode 100644
index 0000000..b512db9
--- /dev/null
+++ b/test/pldm_utils_test.cpp
@@ -0,0 +1,84 @@
+#include "utils.hpp"
+
+#include <gtest/gtest.h>
+
+using namespace pldm::utils;
+
+TEST(decodeDate, testGooduintToDate)
+{
+    uint64_t data = 20191212115959;
+    uint16_t year = 2019;
+    uint8_t month = 12;
+    uint8_t day = 12;
+    uint8_t hours = 11;
+    uint8_t minutes = 59;
+    uint8_t seconds = 59;
+
+    uint16_t retyear = 0;
+    uint8_t retmonth = 0;
+    uint8_t retday = 0;
+    uint8_t rethours = 0;
+    uint8_t retminutes = 0;
+    uint8_t retseconds = 0;
+
+    auto ret = uintToDate(data, &retyear, &retmonth, &retday, &rethours,
+                          &retminutes, &retseconds);
+
+    EXPECT_EQ(ret, true);
+    EXPECT_EQ(year, retyear);
+    EXPECT_EQ(month, retmonth);
+    EXPECT_EQ(day, retday);
+    EXPECT_EQ(hours, rethours);
+    EXPECT_EQ(minutes, retminutes);
+    EXPECT_EQ(seconds, retseconds);
+}
+
+TEST(decodeDate, testBaduintToDate)
+{
+    uint64_t data = 10191212115959;
+
+    uint16_t retyear = 0;
+    uint8_t retmonth = 0;
+    uint8_t retday = 0;
+    uint8_t rethours = 0;
+    uint8_t retminutes = 0;
+    uint8_t retseconds = 0;
+
+    auto ret = uintToDate(data, &retyear, &retmonth, &retday, &rethours,
+                          &retminutes, &retseconds);
+
+    EXPECT_EQ(ret, false);
+}
+
+TEST(decodeEffecterData, testGoodDecodeEffecterData)
+{
+    std::vector<uint8_t> effecterData = {2, 1, 1, 0, 1, 2};
+    uint16_t effecter_id = 2;
+    set_effecter_state_field stateField0 = {1, 1};
+    set_effecter_state_field stateField1 = {0, 0};
+    set_effecter_state_field stateField2 = {1, 2};
+
+    uint16_t retEffecter_id = 0;
+    std::vector<set_effecter_state_field> stateField = {};
+    auto rc = decodeEffecterData(effecterData, retEffecter_id, stateField);
+
+    EXPECT_EQ(rc, true);
+    EXPECT_EQ(effecter_id, retEffecter_id);
+    EXPECT_EQ(stateField[0].set_request, stateField0.set_request);
+    EXPECT_EQ(stateField[0].effecter_state, stateField0.effecter_state);
+    EXPECT_EQ(stateField[1].set_request, stateField1.set_request);
+    EXPECT_EQ(stateField[1].effecter_state, stateField1.effecter_state);
+    EXPECT_EQ(stateField[2].set_request, stateField2.set_request);
+    EXPECT_EQ(stateField[2].effecter_state, stateField2.effecter_state);
+}
+
+TEST(decodeEffecterData, testBadDecodeEffecterData)
+{
+    std::vector<uint8_t> effecterData = {2, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+
+    uint16_t retEffecter_id = 0;
+    std::vector<set_effecter_state_field> stateField = {};
+    auto rc = decodeEffecterData(effecterData, retEffecter_id, stateField);
+
+    EXPECT_EQ(rc, false);
+}
diff --git a/tool/pldm_cmd_helper.hpp b/tool/pldm_cmd_helper.hpp
index fbc87d7..d7beec9 100644
--- a/tool/pldm_cmd_helper.hpp
+++ b/tool/pldm_cmd_helper.hpp
@@ -1,6 +1,6 @@
 #pragma once
 
-#include "libpldmresponder/utils.hpp"
+#include "utils.hpp"
 
 #include <err.h>
 #include <sys/socket.h>
@@ -23,7 +23,7 @@
 namespace helper
 {
 
-using namespace pldm::responder::utils;
+using namespace pldm::utils;
 constexpr uint8_t PLDM_ENTITY_ID = 8;
 constexpr uint8_t MCTP_MSG_TYPE_PLDM = 1;
 constexpr uint8_t PLDM_LOCAL_INSTANCE_ID = 0;
diff --git a/utils.cpp b/utils.cpp
new file mode 100644
index 0000000..b9c5150
--- /dev/null
+++ b/utils.cpp
@@ -0,0 +1,146 @@
+#include "utils.hpp"
+
+#include <array>
+#include <ctime>
+#include <iostream>
+#include <map>
+#include <phosphor-logging/log.hpp>
+#include <stdexcept>
+#include <string>
+#include <vector>
+#include <xyz/openbmc_project/Common/error.hpp>
+
+namespace pldm
+{
+namespace utils
+{
+
+constexpr auto mapperBusName = "xyz.openbmc_project.ObjectMapper";
+constexpr auto mapperPath = "/xyz/openbmc_project/object_mapper";
+constexpr auto mapperInterface = "xyz.openbmc_project.ObjectMapper";
+
+uint8_t getNumPadBytes(uint32_t data)
+{
+    uint8_t pad;
+    pad = ((data % 4) ? (4 - data % 4) : 0);
+    return pad;
+} // end getNumPadBytes
+
+bool uintToDate(uint64_t data, uint16_t* year, uint8_t* month, uint8_t* day,
+                uint8_t* hour, uint8_t* min, uint8_t* sec)
+{
+    constexpr uint64_t max_data = 29991231115959;
+    constexpr uint64_t min_data = 19700101000000;
+    if (data < min_data || data > max_data)
+    {
+        return false;
+    }
+
+    *year = data / 10000000000;
+    data = data % 10000000000;
+    *month = data / 100000000;
+    data = data % 100000000;
+    *day = data / 1000000;
+    data = data % 1000000;
+    *hour = data / 10000;
+    data = data % 10000;
+    *min = data / 100;
+    *sec = data % 100;
+
+    return true;
+}
+
+bool decodeEffecterData(const std::vector<uint8_t>& effecterData,
+                        uint16_t& effecter_id,
+                        std::vector<set_effecter_state_field>& stateField)
+{
+    int flag = 0;
+    for (auto data : effecterData)
+    {
+        switch (flag)
+        {
+            case 0:
+                effecter_id = data;
+                flag = 1;
+                break;
+            case 1:
+                if (data == PLDM_REQUEST_SET)
+                {
+                    flag = 2;
+                }
+                else
+                {
+                    stateField.push_back({PLDM_NO_CHANGE, 0});
+                }
+                break;
+            case 2:
+                stateField.push_back({PLDM_REQUEST_SET, data});
+                flag = 1;
+                break;
+            default:
+                break;
+        }
+    }
+
+    if (stateField.size() < 1 || stateField.size() > 8)
+    {
+        return false;
+    }
+
+    return true;
+}
+
+std::string getService(sdbusplus::bus::bus& bus, const std::string& path,
+                       const std::string& interface)
+{
+    using DbusInterfaceList = std::vector<std::string>;
+    std::map<std::string, std::vector<std::string>> mapperResponse;
+
+    try
+    {
+        auto mapper = bus.new_method_call(mapperBusName, mapperPath,
+                                          mapperInterface, "GetObject");
+        mapper.append(path, DbusInterfaceList({interface}));
+
+        auto mapperResponseMsg = bus.call(mapper);
+        mapperResponseMsg.read(mapperResponse);
+    }
+    catch (std::exception& e)
+    {
+        std::cerr << "gete dbus service, PATH=" << path
+                  << " INTERFACE=" << interface << e.what() << "\n";
+        throw;
+    }
+    return mapperResponse.begin()->first;
+}
+
+void reportError(const char* errorMsg)
+{
+    static constexpr auto logObjPath = "/xyz/openbmc_project/logging";
+    static constexpr auto logInterface = "xyz.openbmc_project.Logging.Create";
+
+    static sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
+
+    try
+    {
+        auto service = getService(bus, logObjPath, logInterface);
+        using namespace sdbusplus::xyz::openbmc_project::Logging::server;
+        auto severity =
+            sdbusplus::xyz::openbmc_project::Logging::server::convertForMessage(
+                sdbusplus::xyz::openbmc_project::Logging::server::Entry::Level::
+                    Error);
+        auto method = bus.new_method_call(service.c_str(), logObjPath,
+                                          logInterface, "Create");
+        std::map<std::string, std::string> addlData{};
+        method.append(errorMsg, severity, addlData);
+        bus.call_noreply(method);
+    }
+    catch (const std::exception& e)
+    {
+        std::cerr << "failed to make a d-bus call to create error log, ERROR="
+                  << e.what() << "\n";
+    }
+}
+
+} // namespace utils
+} // namespace pldm
diff --git a/libpldmresponder/utils.hpp b/utils.hpp
similarity index 79%
rename from libpldmresponder/utils.hpp
rename to utils.hpp
index 453f6d9..bbdbc38 100644
--- a/libpldmresponder/utils.hpp
+++ b/utils.hpp
@@ -13,11 +13,11 @@
 #include <xyz/openbmc_project/Logging/Entry/server.hpp>
 
 #include "libpldm/base.h"
+#include "libpldm/bios.h"
+#include "libpldm/platform.h"
 
 namespace pldm
 {
-namespace responder
-{
 namespace utils
 {
 
@@ -60,7 +60,30 @@
  */
 uint8_t getNumPadBytes(uint32_t data);
 
-} // namespace utils
+/** @brief Convert uint64 to date
+ *
+ *  @param[in] data - time date of uint64
+ *  @param[out] year - year number in dec
+ *  @param[out] month - month number in dec
+ *  @param[out] day - day of the month in dec
+ *  @param[out] hour - number of hours in dec
+ *  @param[out] min - number of minutes in dec
+ *  @param[out] sec - number of seconds in dec
+ *  @return true if decode success, false if decode faild
+ */
+bool uintToDate(uint64_t data, uint16_t* year, uint8_t* month, uint8_t* day,
+                uint8_t* hour, uint8_t* min, uint8_t* sec);
+
+/** @brief Convert effecter data to structure of set_effecter_state_field
+ *
+ *  @param[in] effecterData - the date of effecter
+ *  @param[out] effecter_id - a handle that is used to identify and access the
+ * effecter
+ *  @param[out] stateField - structure of set_effecter_state_field
+ */
+bool decodeEffecterData(const std::vector<uint8_t>& effecterData,
+                        uint16_t& effecter_id,
+                        std::vector<set_effecter_state_field>& stateField);
 
 /**
  *  @brief Get the DBUS Service name for the input dbus path
@@ -171,5 +194,5 @@
     }
 };
 
-} // namespace responder
+} // namespace utils
 } // namespace pldm