oem ibm: support reading LIDs based on type

This commit reads the LIDs requested by Host. Host
sends request as T or P side. This commit evaluates the
current boot side and reads the appropriate LIDs.

Also this commit stores the image LIDs sent by Host
during an inband code update

Change-Id: Ia4bae68fa95f19bc228ef7002493d54abab3dc93
Signed-off-by: Sampa Misra <sampmisr@in.ibm.com>
diff --git a/meson.build b/meson.build
index 0c50ba8..acd0e98 100644
--- a/meson.build
+++ b/meson.build
@@ -29,6 +29,7 @@
   conf_data.set_quoted('LID_ALTERNATE_DIR', '/var/lib/phosphor-software-manager/hostfw/alternate')
   conf_data.set_quoted('LID_RUNNING_PATCH_DIR', '/usr/local/share/hostfw/running')
   conf_data.set_quoted('LID_ALTERNATE_PATCH_DIR', '/usr/local/share/hostfw/alternate')
+  conf_data.set_quoted('LID_STAGING_DIR', '/var/lib/phosphor-software-manager/hostfw/staging')
   conf_data.set('DMA_MAXSIZE', get_option('oem-ibm-dma-maxsize'))
   add_global_arguments('-DOEM_IBM', language : 'c')
   add_global_arguments('-DOEM_IBM', language : 'cpp')
diff --git a/oem/ibm/libpldmresponder/file_io.cpp b/oem/ibm/libpldmresponder/file_io.cpp
index 6b963d0..1192510 100644
--- a/oem/ibm/libpldmresponder/file_io.cpp
+++ b/oem/ibm/libpldmresponder/file_io.cpp
@@ -602,7 +602,8 @@
 }
 
 Response rwFileByTypeIntoMemory(uint8_t cmd, const pldm_msg* request,
-                                size_t payloadLength)
+                                size_t payloadLength,
+                                oem_platform::Handler* oemPlatformHandler)
 {
     Response response(
         sizeof(pldm_msg_hdr) + PLDM_RW_FILE_BY_TYPE_MEM_RESP_BYTES, 0);
@@ -655,8 +656,10 @@
     }
 
     rc = cmd == PLDM_WRITE_FILE_BY_TYPE_FROM_MEMORY
-             ? handler->writeFromMemory(offset, length, address)
-             : handler->readIntoMemory(offset, length, address);
+             ? handler->writeFromMemory(offset, length, address,
+                                        oemPlatformHandler)
+             : handler->readIntoMemory(offset, length, address,
+                                       oemPlatformHandler);
     encode_rw_file_by_type_memory_resp(request->hdr.instance_id, cmd, rc,
                                        length, responsePtr);
     return response;
@@ -666,14 +669,14 @@
                                             size_t payloadLength)
 {
     return rwFileByTypeIntoMemory(PLDM_WRITE_FILE_BY_TYPE_FROM_MEMORY, request,
-                                  payloadLength);
+                                  payloadLength, oemPlatformHandler);
 }
 
 Response Handler::readFileByTypeIntoMemory(const pldm_msg* request,
                                            size_t payloadLength)
 {
     return rwFileByTypeIntoMemory(PLDM_READ_FILE_BY_TYPE_INTO_MEMORY, request,
-                                  payloadLength);
+                                  payloadLength, oemPlatformHandler);
 }
 
 Response Handler::writeFileByType(const pldm_msg* request, size_t payloadLength)
@@ -719,7 +722,7 @@
 
     rc = handler->write(reinterpret_cast<const char*>(
                             request->payload + PLDM_RW_FILE_BY_TYPE_REQ_BYTES),
-                        offset, length);
+                        offset, length, oemPlatformHandler);
     encode_rw_file_by_type_resp(request->hdr.instance_id,
                                 PLDM_WRITE_FILE_BY_TYPE, rc, length,
                                 responsePtr);
@@ -766,7 +769,7 @@
         return response;
     }
 
-    rc = handler->read(offset, length, response);
+    rc = handler->read(offset, length, response, oemPlatformHandler);
     responsePtr = reinterpret_cast<pldm_msg*>(response.data());
     encode_rw_file_by_type_resp(request->hdr.instance_id,
                                 PLDM_READ_FILE_BY_TYPE, rc, length,
diff --git a/oem/ibm/libpldmresponder/file_io_by_type.hpp b/oem/ibm/libpldmresponder/file_io_by_type.hpp
index 6bb87c6..502dbae 100644
--- a/oem/ibm/libpldmresponder/file_io_by_type.hpp
+++ b/oem/ibm/libpldmresponder/file_io_by_type.hpp
@@ -24,10 +24,13 @@
      *  @param[in] offset - offset to read/write
      *  @param[in] length - length to be read/write mentioned by Host
      *  @param[in] address - DMA address
+     *  @param[in] oemPlatformHandler - oem handler for PLDM platform related
+     *                                  tasks
      *  @return PLDM status code
      */
     virtual int writeFromMemory(uint32_t offset, uint32_t length,
-                                uint64_t address) = 0;
+                                uint64_t address,
+                                oem_platform::Handler* oemPlatformHandler) = 0;
 
     /** @brief Method to read an oem file type into host memory. Individual
      *  file types need to override this method to do the file specific
@@ -35,27 +38,35 @@
      *  @param[in] offset - offset to read
      *  @param[in/out] length - length to be read mentioned by Host
      *  @param[in] address - DMA address
+     *  @param[in] oemPlatformHandler - oem handler for PLDM platform related
+     *                                  tasks
      *  @return PLDM status code
      */
     virtual int readIntoMemory(uint32_t offset, uint32_t& length,
-                               uint64_t address) = 0;
+                               uint64_t address,
+                               oem_platform::Handler* oemPlatformHandler) = 0;
 
     /** @brief Method to read an oem file type's content into the PLDM response.
      *  @param[in] offset - offset to read
      *  @param[in/out] length - length to be read
      *  @param[in] response - PLDM response
+     *  @param[in] oemPlatformHandler - oem handler for PLDM platform related
+     *                                  tasks
      *  @return PLDM status code
      */
-    virtual int read(uint32_t offset, uint32_t& length, Response& response) = 0;
+    virtual int read(uint32_t offset, uint32_t& length, Response& response,
+                     oem_platform::Handler* oemPlatformHandler) = 0;
 
     /** @brief Method to write an oem file by type
      *  @param[in] buffer - buffer to be written to file
      *  @param[in] offset - offset to write to
      *  @param[in/out] length - length to be written
+     *  @param[in] oemPlatformHandler - oem handler for PLDM platform related
+     *                                  tasks
      *  @return PLDM status code
      */
-    virtual int write(const char* buffer, uint32_t offset,
-                      uint32_t& length) = 0;
+    virtual int write(const char* buffer, uint32_t offset, uint32_t& length,
+                      oem_platform::Handler* oemPlatformHandler) = 0;
 
     virtual int fileAck(uint8_t fileStatus) = 0;
 
diff --git a/oem/ibm/libpldmresponder/file_io_type_cert.cpp b/oem/ibm/libpldmresponder/file_io_type_cert.cpp
index f78dbf1..b49903c 100644
--- a/oem/ibm/libpldmresponder/file_io_type_cert.cpp
+++ b/oem/ibm/libpldmresponder/file_io_type_cert.cpp
@@ -21,7 +21,8 @@
 CertMap CertHandler::certMap;
 
 int CertHandler::writeFromMemory(uint32_t offset, uint32_t length,
-                                 uint64_t address)
+                                 uint64_t address,
+                                 oem_platform::Handler* /*oemPlatformHandler*/)
 {
     auto it = certMap.find(certType);
     if (it == certMap.end())
@@ -46,7 +47,8 @@
 }
 
 int CertHandler::readIntoMemory(uint32_t offset, uint32_t& length,
-                                uint64_t address)
+                                uint64_t address,
+                                oem_platform::Handler* /*oemPlatformHandler*/)
 {
     if (certType != PLDM_FILE_TYPE_CERT_SIGNING_REQUEST)
     {
@@ -55,7 +57,8 @@
     return transferFileData(csrFilePath, true, offset, length, address);
 }
 
-int CertHandler::read(uint32_t offset, uint32_t& length, Response& response)
+int CertHandler::read(uint32_t offset, uint32_t& length, Response& response,
+                      oem_platform::Handler* /*oemPlatformHandler*/)
 {
     if (certType != PLDM_FILE_TYPE_CERT_SIGNING_REQUEST)
     {
@@ -64,7 +67,8 @@
     return readFile(csrFilePath, offset, length, response);
 }
 
-int CertHandler::write(const char* buffer, uint32_t offset, uint32_t& length)
+int CertHandler::write(const char* buffer, uint32_t offset, uint32_t& length,
+                       oem_platform::Handler* /*oemPlatformHandler*/)
 {
     auto it = certMap.find(certType);
     if (it == certMap.end())
diff --git a/oem/ibm/libpldmresponder/file_io_type_cert.hpp b/oem/ibm/libpldmresponder/file_io_type_cert.hpp
index a1c8d9f..ee34575 100644
--- a/oem/ibm/libpldmresponder/file_io_type_cert.hpp
+++ b/oem/ibm/libpldmresponder/file_io_type_cert.hpp
@@ -30,12 +30,16 @@
     {}
 
     virtual int writeFromMemory(uint32_t offset, uint32_t length,
-                                uint64_t address);
+                                uint64_t address,
+                                oem_platform::Handler* /*oemPlatformHandler*/);
     virtual int readIntoMemory(uint32_t offset, uint32_t& length,
-                               uint64_t address);
-    virtual int read(uint32_t offset, uint32_t& length, Response& response);
+                               uint64_t address,
+                               oem_platform::Handler* /*oemPlatformHandler*/);
+    virtual int read(uint32_t offset, uint32_t& length, Response& response,
+                     oem_platform::Handler* /*oemPlatformHandler*/);
 
-    virtual int write(const char* buffer, uint32_t offset, uint32_t& length);
+    virtual int write(const char* buffer, uint32_t offset, uint32_t& length,
+                      oem_platform::Handler* /*oemPlatformHandler*/);
 
     virtual int fileAck(uint8_t /*fileStatus*/)
     {
diff --git a/oem/ibm/libpldmresponder/file_io_type_dump.cpp b/oem/ibm/libpldmresponder/file_io_type_dump.cpp
index 3486372..04f3639 100644
--- a/oem/ibm/libpldmresponder/file_io_type_dump.cpp
+++ b/oem/ibm/libpldmresponder/file_io_type_dump.cpp
@@ -121,7 +121,9 @@
     return socketInterface;
 }
 
-int DumpHandler::writeFromMemory(uint32_t, uint32_t length, uint64_t address)
+int DumpHandler::writeFromMemory(uint32_t /*offset*/, uint32_t length,
+                                 uint64_t address,
+                                 oem_platform::Handler* /*oemPlatformHandler*/)
 {
     if (DumpHandler::fd == -1)
     {
@@ -143,7 +145,9 @@
     return transferFileDataToSocket(DumpHandler::fd, length, address);
 }
 
-int DumpHandler::write(const char* buffer, uint32_t, uint32_t& length)
+int DumpHandler::write(const char* buffer, uint32_t /*offset*/,
+                       uint32_t& length,
+                       oem_platform::Handler* /*oemPlatformHandler*/)
 {
     int rc = writeToUnixSocket(DumpHandler::fd, buffer, length);
     if (rc < 0)
diff --git a/oem/ibm/libpldmresponder/file_io_type_dump.hpp b/oem/ibm/libpldmresponder/file_io_type_dump.hpp
index 34b880f..cb4a1ad 100644
--- a/oem/ibm/libpldmresponder/file_io_type_dump.hpp
+++ b/oem/ibm/libpldmresponder/file_io_type_dump.hpp
@@ -21,20 +21,24 @@
     {}
 
     virtual int writeFromMemory(uint32_t offset, uint32_t length,
-                                uint64_t address);
+                                uint64_t address,
+                                oem_platform::Handler* /*oemPlatformHandler*/);
 
     virtual int readIntoMemory(uint32_t /*offset*/, uint32_t& /*length*/,
-                               uint64_t /*address*/)
+                               uint64_t /*address*/,
+                               oem_platform::Handler* /*oemPlatformHandler*/)
     {
         return PLDM_ERROR_UNSUPPORTED_PLDM_CMD;
     }
     virtual int read(uint32_t /*offset*/, uint32_t& /*length*/,
-                     Response& /*response*/)
+                     Response& /*response*/,
+                     oem_platform::Handler* /*oemPlatformHandler*/)
     {
         return PLDM_ERROR_UNSUPPORTED_PLDM_CMD;
     }
 
-    virtual int write(const char* buffer, uint32_t offset, uint32_t& length);
+    virtual int write(const char* buffer, uint32_t offset, uint32_t& length,
+                      oem_platform::Handler* /*oemPlatformHandler*/);
 
     virtual int newFileAvailable(uint64_t length);
 
diff --git a/oem/ibm/libpldmresponder/file_io_type_lid.hpp b/oem/ibm/libpldmresponder/file_io_type_lid.hpp
index 3086158..531d762 100644
--- a/oem/ibm/libpldmresponder/file_io_type_lid.hpp
+++ b/oem/ibm/libpldmresponder/file_io_type_lid.hpp
@@ -28,6 +28,8 @@
      */
     LidHandler(uint32_t fileHandle, bool permSide) : FileHandler(fileHandle)
     {
+        sideToRead = permSide ? Pside : Tside;
+        isPatchDir = false;
         std::string dir = permSide ? LID_ALTERNATE_DIR : LID_RUNNING_DIR;
         std::stringstream stream;
         stream << std::hex << fileHandle;
@@ -38,6 +40,7 @@
         if (fs::is_regular_file(patch))
         {
             lidPath = patch;
+            isPatchDir = true;
         }
         else
         {
@@ -45,27 +48,183 @@
         }
     }
 
-    virtual int writeFromMemory(uint32_t /*offset*/, uint32_t /*length*/,
-                                uint64_t /*address*/)
+    /** @brief Method to construct the LID path based on current boot side
+     *  @param[in] oemPlatformHandler - OEM platform handler
+     *  @return bool - true if a new path is constructed
+     */
+    bool constructLIDPath(oem_platform::Handler* oemPlatformHandler)
     {
-        return PLDM_ERROR_UNSUPPORTED_PLDM_CMD;
+        if (oemPlatformHandler != nullptr)
+        {
+            pldm::responder::oem_ibm_platform::Handler* oemIbmPlatformHandler =
+                dynamic_cast<pldm::responder::oem_ibm_platform::Handler*>(
+                    oemPlatformHandler);
+            std::string dir = LID_ALTERNATE_DIR;
+            if (isPatchDir)
+            {
+                dir = LID_ALTERNATE_PATCH_DIR;
+            }
+            if (oemIbmPlatformHandler->codeUpdate->fetchCurrentBootSide() ==
+                sideToRead)
+            {
+                if (isPatchDir)
+                {
+                    dir = LID_RUNNING_PATCH_DIR;
+                }
+                else
+                {
+                    dir = LID_RUNNING_DIR;
+                }
+            }
+            else if (oemIbmPlatformHandler->codeUpdate
+                         ->isCodeUpdateInProgress())
+            {
+                return false;
+            }
+
+            std::stringstream stream;
+            stream << std::hex << fileHandle;
+            auto lidName = stream.str() + ".lid";
+            lidPath = std::move(dir) + '/' + lidName;
+        }
+        return true;
+    }
+
+    virtual int writeFromMemory(uint32_t offset, uint32_t length,
+                                uint64_t address,
+                                oem_platform::Handler* oemPlatformHandler)
+    {
+        if (oemPlatformHandler != nullptr)
+        {
+            pldm::responder::oem_ibm_platform::Handler* oemIbmPlatformHandler =
+                dynamic_cast<pldm::responder::oem_ibm_platform::Handler*>(
+                    oemPlatformHandler);
+            if (oemIbmPlatformHandler->codeUpdate->isCodeUpdateInProgress())
+            {
+                std::string dir = LID_STAGING_DIR;
+                std::stringstream stream;
+                stream << std::hex << fileHandle;
+                auto lidName = stream.str() + ".lid";
+                lidPath = std::move(dir) + '/' + lidName;
+            }
+        }
+        std::cout << "got writeFromMemory() for LID " << lidPath.c_str()
+                  << " and offset " << offset << " and length " << length
+                  << "\n";
+        bool fileExists = fs::exists(lidPath);
+        int flags{};
+        if (fileExists)
+        {
+            flags = O_RDWR;
+        }
+        else
+        {
+            flags = O_WRONLY | O_CREAT | O_TRUNC | O_SYNC;
+        }
+        auto fd = open(lidPath.c_str(), flags);
+        if (fd == -1)
+        {
+            std::cerr << "Could not open file for writing  " << lidPath.c_str()
+                      << "\n";
+            return PLDM_ERROR;
+        }
+        close(fd);
+
+        auto rc = transferFileData(lidPath, false, offset, length, address);
+        if (rc != PLDM_SUCCESS)
+        {
+            std::cout << "writeFileFromMemory failed with rc= " << rc << " \n";
+            return rc;
+        }
+        return rc;
     }
 
     virtual int readIntoMemory(uint32_t offset, uint32_t& length,
-                               uint64_t address)
+                               uint64_t address,
+                               oem_platform::Handler* oemPlatformHandler)
     {
-        return transferFileData(lidPath, true, offset, length, address);
+        if (constructLIDPath(oemPlatformHandler))
+        {
+            return transferFileData(lidPath, true, offset, length, address);
+        }
+        return PLDM_ERROR;
     }
 
-    virtual int write(const char* /*buffer*/, uint32_t /*offset*/,
-                      uint32_t& /*length*/)
+    virtual int write(const char* buffer, uint32_t offset, uint32_t& length,
+                      oem_platform::Handler* oemPlatformHandler)
     {
-        return PLDM_ERROR_UNSUPPORTED_PLDM_CMD;
+        if (oemPlatformHandler != nullptr)
+        {
+            pldm::responder::oem_ibm_platform::Handler* oemIbmPlatformHandler =
+                dynamic_cast<pldm::responder::oem_ibm_platform::Handler*>(
+                    oemPlatformHandler);
+            if (oemIbmPlatformHandler->codeUpdate->isCodeUpdateInProgress())
+            {
+                std::string dir = LID_STAGING_DIR;
+                std::stringstream stream;
+                stream << std::hex << fileHandle;
+                auto lidName = stream.str() + ".lid";
+                lidPath = std::move(dir) + '/' + lidName;
+            }
+        }
+        std::cout << "got write() call for LID " << lidPath.c_str()
+                  << " and offset " << offset << " and length " << length
+                  << "\n";
+        bool fileExists = fs::exists(lidPath);
+        int flags{};
+        if (fileExists)
+        {
+            flags = O_RDWR;
+            size_t fileSize = fs::file_size(lidPath);
+            if (offset > fileSize)
+            {
+                std::cerr << "Offset exceeds file size, OFFSET=" << offset
+                          << " FILE_SIZE=" << fileSize << "\n";
+                return PLDM_DATA_OUT_OF_RANGE;
+            }
+        }
+        else
+        {
+            flags = O_WRONLY | O_CREAT | O_TRUNC | O_SYNC;
+            if (offset > 0)
+            {
+                std::cerr << "Offset is non zero in a new file \n";
+                return PLDM_DATA_OUT_OF_RANGE;
+            }
+        }
+        auto fd = open(lidPath.c_str(), flags);
+        if (fd == -1)
+        {
+            std::cerr << "could not open file " << lidPath.c_str() << "\n";
+            return PLDM_ERROR;
+        }
+        auto rc = lseek(fd, offset, SEEK_SET);
+        if (rc == -1)
+        {
+            std::cerr << "lseek failed, ERROR=" << errno
+                      << ", OFFSET=" << offset << "\n";
+            return PLDM_ERROR;
+        }
+        std::cout << "lseek returned " << rc << "\n";
+        rc = ::write(fd, buffer, length);
+        if (rc == -1)
+        {
+            std::cerr << "file write failed, ERROR=" << errno
+                      << ", LENGTH=" << length << ", OFFSET=" << offset << "\n";
+            return PLDM_ERROR;
+        }
+        close(fd);
+        return rc;
     }
 
-    virtual int read(uint32_t offset, uint32_t& length, Response& response)
+    virtual int read(uint32_t offset, uint32_t& length, Response& response,
+                     oem_platform::Handler* oemPlatformHandler)
     {
-        return readFile(lidPath, offset, length, response);
+        if (constructLIDPath(oemPlatformHandler))
+        {
+            return readFile(lidPath, offset, length, response);
+        }
+        return PLDM_ERROR;
     }
 
     virtual int fileAck(uint8_t /*fileStatus*/)
@@ -86,6 +245,8 @@
 
   protected:
     std::string lidPath;
+    std::string sideToRead;
+    bool isPatchDir;
 };
 
 } // namespace responder
diff --git a/oem/ibm/libpldmresponder/file_io_type_pel.cpp b/oem/ibm/libpldmresponder/file_io_type_pel.cpp
index aaff222..9197749 100644
--- a/oem/ibm/libpldmresponder/file_io_type_pel.cpp
+++ b/oem/ibm/libpldmresponder/file_io_type_pel.cpp
@@ -92,7 +92,8 @@
 } // namespace detail
 
 int PelHandler::readIntoMemory(uint32_t offset, uint32_t& length,
-                               uint64_t address)
+                               uint64_t address,
+                               oem_platform::Handler* /*oemPlatformHandler*/)
 {
     static constexpr auto logObjPath = "/xyz/openbmc_project/logging";
     static constexpr auto logInterface = "org.open_power.Logging.PEL";
@@ -122,7 +123,8 @@
     return PLDM_SUCCESS;
 }
 
-int PelHandler::read(uint32_t offset, uint32_t& length, Response& response)
+int PelHandler::read(uint32_t offset, uint32_t& length, Response& response,
+                     oem_platform::Handler* /*oemPlatformHandler*/)
 {
     static constexpr auto logObjPath = "/xyz/openbmc_project/logging";
     static constexpr auto logInterface = "org.open_power.Logging.PEL";
@@ -188,7 +190,8 @@
 }
 
 int PelHandler::writeFromMemory(uint32_t offset, uint32_t length,
-                                uint64_t address)
+                                uint64_t address,
+                                oem_platform::Handler* /*oemPlatformHandler*/)
 {
     char tmpFile[] = "/tmp/pel.XXXXXX";
     int fd = mkstemp(tmpFile);
diff --git a/oem/ibm/libpldmresponder/file_io_type_pel.hpp b/oem/ibm/libpldmresponder/file_io_type_pel.hpp
index 90d012f..fb01b3e 100644
--- a/oem/ibm/libpldmresponder/file_io_type_pel.hpp
+++ b/oem/ibm/libpldmresponder/file_io_type_pel.hpp
@@ -23,13 +23,19 @@
     {}
 
     virtual int writeFromMemory(uint32_t offset, uint32_t length,
-                                uint64_t address);
+                                uint64_t address,
+                                oem_platform::Handler* /*oemPlatformHandler*/);
+
     virtual int readIntoMemory(uint32_t offset, uint32_t& length,
-                               uint64_t address);
-    virtual int read(uint32_t offset, uint32_t& length, Response& response);
+                               uint64_t address,
+                               oem_platform::Handler* /*oemPlatformHandler*/);
+
+    virtual int read(uint32_t offset, uint32_t& length, Response& response,
+                     oem_platform::Handler* /*oemPlatformHandler*/);
 
     virtual int write(const char* /*buffer*/, uint32_t /*offset*/,
-                      uint32_t& /*length*/)
+                      uint32_t& /*length*/,
+                      oem_platform::Handler* /*oemPlatformHandler*/)
     {
         return PLDM_ERROR_UNSUPPORTED_PLDM_CMD;
     }
diff --git a/oem/ibm/libpldmresponder/inband_code_update.cpp b/oem/ibm/libpldmresponder/inband_code_update.cpp
index f17b209..489ad69 100644
--- a/oem/ibm/libpldmresponder/inband_code_update.cpp
+++ b/oem/ibm/libpldmresponder/inband_code_update.cpp
@@ -76,7 +76,6 @@
     static constexpr auto propIntf = "org.freedesktop.DBus.Properties";
 
     auto& bus = dBusIntf->getBus();
-
     try
     {
         auto method = bus.new_method_call(mapperService, functionalObjPath,
@@ -166,7 +165,6 @@
 uint8_t fetchBootSide(uint16_t entityInstance, CodeUpdate* codeUpdate)
 {
     uint8_t sensorOpState = tSideNum;
-
     if (entityInstance == 0)
     {
         auto currSide = codeUpdate->fetchCurrentBootSide();
diff --git a/oem/ibm/libpldmresponder/inband_code_update.hpp b/oem/ibm/libpldmresponder/inband_code_update.hpp
index 6607de0..237a662 100644
--- a/oem/ibm/libpldmresponder/inband_code_update.hpp
+++ b/oem/ibm/libpldmresponder/inband_code_update.hpp
@@ -75,6 +75,24 @@
     /* @brief Method to set the oem platform handler in CodeUpdate class */
     void setOemPlatformHandler(pldm::responder::oem_platform::Handler* handler);
 
+    /* @brief Method to check whether code update is
+     *        going on
+     *  @return - bool
+     */
+    bool isCodeUpdateInProgress()
+    {
+        return codeUpdateInProgress;
+    }
+
+    /* @brief Method to indicate whether code update
+     *        is going on
+     * @param[in] progress - yes/no
+     */
+    void setCodeUpdateProgress(bool progress)
+    {
+        codeUpdateInProgress = progress;
+    }
+
     virtual ~CodeUpdate()
     {}