user_channel: Optimize ipmi complete code

Encapsulate the custom status return code into an ipmi method and
then use it in cpp.

Change-Id: I72ce8bb4d262c98cb41635c985e229e1f9b593a3
Signed-off-by: George Liu <liuxiwei@ieisystem.com>
diff --git a/user_channel/channel_layer.hpp b/user_channel/channel_layer.hpp
index 37d2b90..a23e947 100644
--- a/user_channel/channel_layer.hpp
+++ b/user_channel/channel_layer.hpp
@@ -27,8 +27,19 @@
 static constexpr uint8_t maxIpmiChannels = 16;
 static constexpr uint8_t currentChNum = 0xE;
 static constexpr uint8_t invalidChannel = 0xff;
-static constexpr const uint8_t ccActionNotSupportedForChannel = 0x82;
-static constexpr const uint8_t ccAccessModeNotSupportedForChannel = 0x83;
+
+constexpr Cc ccActionNotSupportedForChannel = 0x82;
+constexpr Cc ccAccessModeNotSupportedForChannel = 0x83;
+
+static inline auto responseActionNotSupportedForChannel()
+{
+    return response(ccActionNotSupportedForChannel);
+}
+
+static inline auto responseAccessModeNotSupportedForChannel()
+{
+    return response(ccAccessModeNotSupportedForChannel);
+}
 
 /**
  * @array of privilege levels
diff --git a/user_channel/channelcommands.cpp b/user_channel/channelcommands.cpp
index b4caf0c..0fee78f 100644
--- a/user_channel/channelcommands.cpp
+++ b/user_channel/channelcommands.cpp
@@ -65,7 +65,7 @@
     {
         lg2::debug("Set channel access - No support on channel: {CHANNEL}",
                    "CHANNEL", chNum);
-        return response(ccActionNotSupportedForChannel);
+        return responseActionNotSupportedForChannel();
     }
 
     ChannelAccess chActData;
@@ -101,7 +101,7 @@
         case reserved:
         default:
             lg2::debug("Set channel access - Invalid access set mode");
-            return response(ccAccessModeNotSupportedForChannel);
+            return responseAccessModeNotSupportedForChannel();
     }
 
     // cannot static cast directly from uint2_t to enum; must go via int
@@ -122,7 +122,7 @@
         case reserved:
         default:
             lg2::debug("Set channel access - Invalid access priv mode");
-            return response(ccAccessModeNotSupportedForChannel);
+            return responseAccessModeNotSupportedForChannel();
     }
 
     if (setNVFlag != 0)
@@ -197,7 +197,7 @@
     {
         lg2::debug("Get channel access - No support on channel: {CHANNEL}",
                    "CHANNEL", chNum);
-        return response(ccActionNotSupportedForChannel);
+        return responseActionNotSupportedForChannel();
     }
 
     ChannelAccess chAccess = {};
@@ -343,7 +343,7 @@
     if (getChannelSessionSupport(chNum) == EChannelSessSupported::none)
     {
         lg2::debug("Get channel payload - No support on channel");
-        return response(ccActionNotSupportedForChannel);
+        return responseActionNotSupportedForChannel();
     }
     constexpr uint16_t stdPayloadType = standardPayloadBit(PayloadType::IPMI) |
                                         standardPayloadBit(PayloadType::SOL);
diff --git a/user_channel/usercommands.cpp b/user_channel/usercommands.cpp
index 78c2647..2d0ed1f 100644
--- a/user_channel/usercommands.cpp
+++ b/user_channel/usercommands.cpp
@@ -87,7 +87,7 @@
     if (getChannelSessionSupport(chNum) == EChannelSessSupported::none)
     {
         lg2::debug("Set user access - No support on channel");
-        return ipmi::response(ccActionNotSupportedForChannel);
+        return ipmi::responseActionNotSupportedForChannel();
     }
     if (!ipmiUserIsValidUserId(static_cast<uint8_t>(userId)))
     {
@@ -160,7 +160,7 @@
     if (getChannelSessionSupport(chNum) == EChannelSessSupported::none)
     {
         lg2::debug("Get user access - No support on channel");
-        return ipmi::response(ccActionNotSupportedForChannel);
+        return ipmi::responseActionNotSupportedForChannel();
     }
     if (!ipmiUserIsValidUserId(static_cast<uint8_t>(userId)))
     {
@@ -431,7 +431,7 @@
     if (getChannelSessionSupport(channel) == EChannelSessSupported::none)
     {
         lg2::debug("Get channel auth capabilities - No support on channel");
-        return ipmi::response(ccActionNotSupportedForChannel);
+        return ipmi::responseActionNotSupportedForChannel();
     }
 
     constexpr bool extDataSupport = true; // true for IPMI 2.0 extensions
@@ -524,7 +524,7 @@
     }
     if (getChannelSessionSupport(chNum) == EChannelSessSupported::none)
     {
-        return ipmi::response(ccActionNotSupportedForChannel);
+        return ipmi::responseActionNotSupportedForChannel();
     }
     if (!ipmiUserIsValidUserId(static_cast<uint8_t>(userId)))
     {
@@ -609,7 +609,7 @@
     }
     if (getChannelSessionSupport(chNum) == EChannelSessSupported::none)
     {
-        return ipmi::response(ccActionNotSupportedForChannel);
+        return ipmi::responseActionNotSupportedForChannel();
     }
     if (!ipmiUserIsValidUserId(static_cast<uint8_t>(userId)))
     {