Synchronize channel info between network and ipmi

Synchronizing the channel privilege config between network
interface(generic) and channel managament(IPMI).
 1) During start-up get the network interface privilege and
    update the IPMI data base(NV).
 2) Catch the signal for network interface channel privilege
    and update the ipmi data base(Volatile and NV data).
 3) During ipmi privilege update(NV), send it to network interface
    over DBUS.

Unit Test:
 Verified the changes by modifying MaxPrivilege in network interfaces
and signal catching logic and vise versa as specified in description.

Change-Id: Iaa7e9e248f1cac6ab560137c8c136abdd44e190e
Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>
Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
diff --git a/user_channel/channel_mgmt.hpp b/user_channel/channel_mgmt.hpp
index 053fa39..5c35041 100644
--- a/user_channel/channel_mgmt.hpp
+++ b/user_channel/channel_mgmt.hpp
@@ -29,6 +29,11 @@
 
 using Json = nlohmann::json;
 
+using DbusVariant =
+    sdbusplus::message::variant<std::vector<std::string>, std::string, bool>;
+
+using DbusChObjProperties = std::vector<std::pair<std::string, DbusVariant>>;
+
 static constexpr const char* ipmiChannelMutex = "ipmi_channel_mutex";
 static constexpr const char* ipmiChMutexCleanupLockFile =
     "/var/lib/ipmi/ipmi_channel_mutex_cleanup";
@@ -61,7 +66,7 @@
     ChannelConfig(ChannelConfig&&) = delete;
     ChannelConfig& operator=(ChannelConfig&&) = delete;
 
-    ~ChannelConfig() = default;
+    ~ChannelConfig();
     ChannelConfig();
 
     /** @brief determines valid channel
@@ -172,6 +177,36 @@
                                          const uint8_t& priv,
                                          EAuthType& authType);
 
+    /** @brief conver to channel privilege from system privilege
+     *
+     *  @param[in] value - privilege value
+     *
+     *  @return Channel privilege
+     */
+    CommandPrivilege convertToPrivLimitIndex(const std::string& value);
+
+    /** @brief function to write persistent channel configuration to config file
+     *
+     *  @return 0 for success, -errno for failure.
+     */
+    int writeChannelPersistData();
+
+    /** @brief function to write volatile channel configuration to config file
+     *
+     *  @return 0 for success, -errno for failure.
+     */
+    int writeChannelVolatileData();
+
+    /** @brief function to get channel data based on channel number
+     *
+     *  @param[in] chNum - channel number
+     *
+     *  @return 0 for success, -errno for failure.
+     */
+    ChannelData* getChannelDataPtr(const uint8_t& chNum);
+
+    uint32_t signalFlag = 0;
+
     std::unique_ptr<boost::interprocess::named_recursive_mutex> channelMutex{
         nullptr};
 
@@ -182,6 +217,8 @@
     std::time_t getUpdatedFileTime(const std::string& fileName);
     boost::interprocess::file_lock mutexCleanupLock;
     sdbusplus::bus::bus bus;
+    bool signalHndlrObjectState = false;
+    boost::interprocess::file_lock sigHndlrLock;
 
     /** @brief function to initialize persistent channel configuration
      *
@@ -209,24 +246,12 @@
      */
     int readChannelPersistData();
 
-    /** @brief function to write persistent channel configuration to config file
-     *
-     *  @return 0 for success, -errno for failure.
-     */
-    int writeChannelPersistData();
-
     /** @brief function to read volatile channel data
      *
      *  @return 0 for success, -errno for failure.
      */
     int readChannelVolatileData();
 
-    /** @brief function to write volatile channel configuration to config file
-     *
-     *  @return 0 for success, -errno for failure.
-     */
-    int writeChannelVolatileData();
-
     /** @brief function to check and reload persistent channel data
      *
      *  @return 0 for success, -errno for failure.
@@ -239,6 +264,45 @@
      */
     int checkAndReloadVolatileData();
 
+    /** @brief function to sync channel privilege with system network channel
+     * privilege
+     *
+     *  @return 0 for success, -errno for failure.
+     */
+    int syncNetworkChannelConfig();
+
+    /** @brief function to set D-Bus property value
+     *
+     *  @param[in] bus - bus
+     *  @param[in] service - service name
+     *  @param[in] objPath - object path
+     *  @param[in] interface - interface
+     *  @param[in] property - property name
+     *  @param[in] value - property value
+     *
+     *  @return 0 for success, -errno for failure.
+     */
+    int setDbusProperty(sdbusplus::bus::bus& bus, const std::string& service,
+                        const std::string& objPath,
+                        const std::string& interface,
+                        const std::string& property, const DbusVariant& value);
+
+    /** @brief function to get D-Bus property value
+     *
+     *  @param[in] bus - bus
+     *  @param[in] service - service name
+     *  @param[in] objPath - object path
+     *  @param[in] interface - interface
+     *  @param[in] property - property name
+     *  @param[out] value - property value
+     *
+     *  @return 0 for success, -errno for failure.
+     */
+    int getDbusProperty(sdbusplus::bus::bus& bus, const std::string& service,
+                        const std::string& objPath,
+                        const std::string& interface,
+                        const std::string& property, DbusVariant& value);
+
     /** @brief function to read json config file
      *
      *  @param[in] configFile - configuration file name
@@ -273,14 +337,6 @@
      */
     std::string convertToAccessModeString(const uint8_t& value);
 
-    /** @brief conver to channel privilege from system privilege
-     *
-     *  @param[in] value - privilege value
-     *
-     *  @return Channel privilege
-     */
-    CommandPrivilege convertToPrivLimitIndex(const std::string& value);
-
     /** @brief function to convert privilege value to string
      *
      *  @param[in] value - privilege value