diff --git a/user_channel/channel_mgmt.cpp b/user_channel/channel_mgmt.cpp
index 759de43..116521d 100644
--- a/user_channel/channel_mgmt.cpp
+++ b/user_channel/channel_mgmt.cpp
@@ -404,40 +404,38 @@
     return channelData[chNum].maxTransferSize;
 }
 
-ipmi_ret_t ChannelConfig::getChannelInfo(const uint8_t chNum,
-                                         ChannelInfo& chInfo)
+Cc ChannelConfig::getChannelInfo(const uint8_t chNum, ChannelInfo& chInfo)
 {
     if (!isValidChannel(chNum))
     {
         log<level::DEBUG>("Invalid channel");
-        return IPMI_CC_INVALID_FIELD_REQUEST;
+        return ccInvalidFieldRequest;
     }
 
     std::copy_n(reinterpret_cast<uint8_t*>(&channelData[chNum].chInfo),
                 sizeof(channelData[chNum].chInfo),
                 reinterpret_cast<uint8_t*>(&chInfo));
-
-    return IPMI_CC_OK;
+    return ccSuccess;
 }
 
-ipmi_ret_t ChannelConfig::getChannelAccessData(const uint8_t chNum,
-                                               ChannelAccess& chAccessData)
+Cc ChannelConfig::getChannelAccessData(const uint8_t chNum,
+                                       ChannelAccess& chAccessData)
 {
     if (!isValidChannel(chNum))
     {
         log<level::DEBUG>("Invalid channel");
-        return IPMI_CC_INVALID_FIELD_REQUEST;
+        return ccInvalidFieldRequest;
     }
 
     if (getChannelSessionSupport(chNum) == EChannelSessSupported::none)
     {
         log<level::DEBUG>("Session-less channel doesn't have access data.");
-        return IPMI_CC_ACTION_NOT_SUPPORTED_FOR_CHANNEL;
+        return ccActionNotSupportedForChannel;
     }
 
     if (checkAndReloadVolatileData() != 0)
     {
-        return IPMI_CC_UNSPECIFIED_ERROR;
+        return ccUnspecifiedError;
     }
 
     std::copy_n(
@@ -445,24 +443,23 @@
         sizeof(channelData[chNum].chAccess.chVolatileData),
         reinterpret_cast<uint8_t*>(&chAccessData));
 
-    return IPMI_CC_OK;
+    return ccSuccess;
 }
 
-ipmi_ret_t
-    ChannelConfig::setChannelAccessData(const uint8_t chNum,
-                                        const ChannelAccess& chAccessData,
-                                        const uint8_t setFlag)
+Cc ChannelConfig::setChannelAccessData(const uint8_t chNum,
+                                       const ChannelAccess& chAccessData,
+                                       const uint8_t setFlag)
 {
     if (!isValidChannel(chNum))
     {
         log<level::DEBUG>("Invalid channel");
-        return IPMI_CC_INVALID_FIELD_REQUEST;
+        return ccInvalidFieldRequest;
     }
 
     if (getChannelSessionSupport(chNum) == EChannelSessSupported::none)
     {
         log<level::DEBUG>("Session-less channel doesn't have access data.");
-        return IPMI_CC_ACTION_NOT_SUPPORTED_FOR_CHANNEL;
+        return ccActionNotSupportedForChannel;
     }
 
     if (((setFlag & setAccessMode) &&
@@ -471,7 +468,7 @@
          (!isValidPrivLimit(chAccessData.privLimit))))
     {
         log<level::DEBUG>("Invalid access mode / privilege limit specified");
-        return IPMI_CC_INVALID_FIELD_REQUEST;
+        return ccInvalidFieldRequest;
     }
 
     boost::interprocess::scoped_lock<boost::interprocess::named_recursive_mutex>
@@ -479,7 +476,7 @@
 
     if (checkAndReloadVolatileData() != 0)
     {
-        return IPMI_CC_UNSPECIFIED_ERROR;
+        return ccUnspecifiedError;
     }
 
     if (setFlag & setAccessMode)
@@ -512,30 +509,29 @@
     if (writeChannelVolatileData() != 0)
     {
         log<level::DEBUG>("Failed to update the channel volatile data");
-        return IPMI_CC_UNSPECIFIED_ERROR;
+        return ccUnspecifiedError;
     }
-    return IPMI_CC_OK;
+    return ccSuccess;
 }
 
-ipmi_ret_t
-    ChannelConfig::getChannelAccessPersistData(const uint8_t chNum,
-                                               ChannelAccess& chAccessData)
+Cc ChannelConfig::getChannelAccessPersistData(const uint8_t chNum,
+                                              ChannelAccess& chAccessData)
 {
     if (!isValidChannel(chNum))
     {
         log<level::DEBUG>("Invalid channel");
-        return IPMI_CC_INVALID_FIELD_REQUEST;
+        return ccInvalidFieldRequest;
     }
 
     if (getChannelSessionSupport(chNum) == EChannelSessSupported::none)
     {
         log<level::DEBUG>("Session-less channel doesn't have access data.");
-        return IPMI_CC_ACTION_NOT_SUPPORTED_FOR_CHANNEL;
+        return ccActionNotSupportedForChannel;
     }
 
     if (checkAndReloadNVData() != 0)
     {
-        return IPMI_CC_UNSPECIFIED_ERROR;
+        return ccUnspecifiedError;
     }
 
     std::copy_n(reinterpret_cast<uint8_t*>(
@@ -543,23 +539,23 @@
                 sizeof(channelData[chNum].chAccess.chNonVolatileData),
                 reinterpret_cast<uint8_t*>(&chAccessData));
 
-    return IPMI_CC_OK;
+    return ccSuccess;
 }
 
-ipmi_ret_t ChannelConfig::setChannelAccessPersistData(
-    const uint8_t chNum, const ChannelAccess& chAccessData,
-    const uint8_t setFlag)
+Cc ChannelConfig::setChannelAccessPersistData(const uint8_t chNum,
+                                              const ChannelAccess& chAccessData,
+                                              const uint8_t setFlag)
 {
     if (!isValidChannel(chNum))
     {
         log<level::DEBUG>("Invalid channel");
-        return IPMI_CC_INVALID_FIELD_REQUEST;
+        return ccInvalidFieldRequest;
     }
 
     if (getChannelSessionSupport(chNum) == EChannelSessSupported::none)
     {
         log<level::DEBUG>("Session-less channel doesn't have access data.");
-        return IPMI_CC_ACTION_NOT_SUPPORTED_FOR_CHANNEL;
+        return ccActionNotSupportedForChannel;
     }
 
     if (((setFlag & setAccessMode) &&
@@ -568,7 +564,7 @@
          (!isValidPrivLimit(chAccessData.privLimit))))
     {
         log<level::DEBUG>("Invalid access mode / privilege limit specified");
-        return IPMI_CC_INVALID_FIELD_REQUEST;
+        return ccInvalidFieldRequest;
     }
 
     boost::interprocess::scoped_lock<boost::interprocess::named_recursive_mutex>
@@ -576,7 +572,7 @@
 
     if (checkAndReloadNVData() != 0)
     {
-        return IPMI_CC_UNSPECIFIED_ERROR;
+        return ccUnspecifiedError;
     }
 
     if (setFlag & setAccessMode)
@@ -614,13 +610,13 @@
                 log<level::DEBUG>(
                     "Network interface does not exist",
                     entry("INTERFACE=%s", channelData[chNum].chName.c_str()));
-                return IPMI_CC_UNSPECIFIED_ERROR;
+                return ccUnspecifiedError;
             }
         }
         catch (const sdbusplus::exception::SdBusError& e)
         {
             log<level::ERR>("Exception: Network interface does not exist");
-            return IPMI_CC_INVALID_FIELD_REQUEST;
+            return ccInvalidFieldRequest;
         }
         signalFlag |= (1 << chNum);
         channelData[chNum].chAccess.chNonVolatileData.privLimit =
@@ -631,51 +627,50 @@
     if (writeChannelPersistData() != 0)
     {
         log<level::DEBUG>("Failed to update the presist data file");
-        return IPMI_CC_UNSPECIFIED_ERROR;
+        return ccUnspecifiedError;
     }
-    return IPMI_CC_OK;
+    return ccSuccess;
 }
 
-ipmi_ret_t
-    ChannelConfig::getChannelAuthTypeSupported(const uint8_t chNum,
-                                               uint8_t& authTypeSupported)
+Cc ChannelConfig::getChannelAuthTypeSupported(const uint8_t chNum,
+                                              uint8_t& authTypeSupported)
 {
     if (!isValidChannel(chNum))
     {
         log<level::DEBUG>("Invalid channel");
-        return IPMI_CC_INVALID_FIELD_REQUEST;
+        return ccInvalidFieldRequest;
     }
 
     authTypeSupported = channelData[chNum].chInfo.authTypeSupported;
-    return IPMI_CC_OK;
+    return ccSuccess;
 }
 
-ipmi_ret_t ChannelConfig::getChannelEnabledAuthType(const uint8_t chNum,
-                                                    const uint8_t priv,
-                                                    EAuthType& authType)
+Cc ChannelConfig::getChannelEnabledAuthType(const uint8_t chNum,
+                                            const uint8_t priv,
+                                            EAuthType& authType)
 {
     if (!isValidChannel(chNum))
     {
         log<level::DEBUG>("Invalid channel");
-        return IPMI_CC_INVALID_FIELD_REQUEST;
+        return ccInvalidFieldRequest;
     }
 
     if (getChannelSessionSupport(chNum) == EChannelSessSupported::none)
     {
         log<level::DEBUG>("Sessionless channel doesn't have access data.");
-        return IPMI_CC_INVALID_FIELD_REQUEST;
+        return ccInvalidFieldRequest;
     }
 
     if (!isValidPrivLimit(priv))
     {
         log<level::DEBUG>("Invalid privilege specified.");
-        return IPMI_CC_INVALID_FIELD_REQUEST;
+        return ccInvalidFieldRequest;
     }
 
     // TODO: Hardcoded for now. Need to implement.
     authType = EAuthType::none;
 
-    return IPMI_CC_OK;
+    return ccSuccess;
 }
 
 std::time_t ChannelConfig::getUpdatedFileTime(const std::string& fileName)
