user_channel:Change fun ret&cmd cc as per New Std

Modified ipmi function return status code and
command completion codes as per new standard.

Tested:
verified using ipmitool commands.
1. create new user
Command : ipmitool user set name 5 user5
Response:                          //user created successfully
Command: ipmitool user set password 5 0penBmc\'  //set password
Response: Set User Password command successful (user 5)

2. Set password
Command :  ipmitool user set password 5 0penBmc\'
Response: Set User Password command successful (user 5)

3. set channel access
Command: ipmitool channel setaccess 1 5 callin=on ipmi=on link=on
            privilege=4
Response: Set User Access (channel 1 id 5) successful.

4. get channel access
Command:  ipmitool channel getaccess 1 5
Response:
Maximum User IDs     : 15
Enabled User IDs     : 5

User ID              : 5
User Name            : user5
Fixed Name           : No
Access Available     : call-in / callback
Link Authentication  : enabled
IPMI Messaging       : enabled
Privilege Level      : ADMINISTRATOR
Enable Status        : disabled

5. User list
Command: ipmitool user list 1
Response:
ID  Name             Callin  Link Auth  IPMI Msg   Channel Priv Limit
1   root             false   true       true       ADMINISTRATOR
2   putty_operator   true    true       true       OPERATOR
3   ipmi_admin       true    true       true       ADMINISTRATOR
4   user2            false   true       true       OPERATOR
5   user5            true    true       true       ADMINISTRATOR
6                    true    false      false      NO ACCESS
7                    true    false      false      NO ACCESS
8                    true    false      false      NO ACCESS
9                    true    false      false      NO ACCESS
10                   true    false      false      NO ACCESS
11                   true    false      false      NO ACCESS
12                   true    false      false      NO ACCESS
13                   true    false      false      NO ACCESS
14                   true    false      false      NO ACCESS
15                   true    false      false      NO ACCESS

Signed-off-by: jayaprakash Mutyala <mutyalax.jayaprakash@intel.com>
Signed-off-by: NITIN SHARMA <nitin1x.sharma@intel.com>
Change-Id: I5f2c32f50edc2de204ac361364e21a61a4bcf237
diff --git a/user_channel/user_mgmt.cpp b/user_channel/user_mgmt.cpp
index 102f990..c3517fd 100644
--- a/user_channel/user_mgmt.cpp
+++ b/user_channel/user_mgmt.cpp
@@ -713,26 +713,25 @@
     return true;
 }
 
-ipmi_ret_t UserAccess::setSpecialUserPassword(const std::string& userName,
-                                              const std::string& userPassword)
+Cc UserAccess::setSpecialUserPassword(const std::string& userName,
+                                      const std::string& userPassword)
 {
     if (pamUpdatePasswd(userName.c_str(), userPassword.c_str()) != PAM_SUCCESS)
     {
         log<level::DEBUG>("Failed to update password");
-        return IPMI_CC_UNSPECIFIED_ERROR;
+        return ccUnspecifiedError;
     }
-    return IPMI_CC_OK;
+    return ccSuccess;
 }
 
-ipmi_ret_t UserAccess::setUserPassword(const uint8_t userId,
-                                       const char* userPassword)
+Cc UserAccess::setUserPassword(const uint8_t userId, const char* userPassword)
 {
     std::string userName;
-    if (ipmiUserGetUserName(userId, userName) != ipmi::ccSuccess)
+    if (ipmiUserGetUserName(userId, userName) != ccSuccess)
     {
         log<level::DEBUG>("User Name not found",
                           entry("USER-ID=%d", (uint8_t)userId));
-        return ipmi::ccParmOutOfRange;
+        return ccParmOutOfRange;
     }
     std::string passwd;
     passwd.assign(reinterpret_cast<const char*>(userPassword), 0,
@@ -744,28 +743,28 @@
     {
         case PAM_SUCCESS:
         {
-            return ipmi::ccSuccess;
+            return ccSuccess;
         }
         case PAM_AUTHTOK_ERR:
         {
             log<level::DEBUG>("Bad authentication token");
-            return ipmi::ccInvalidFieldRequest;
+            return ccInvalidFieldRequest;
         }
         default:
         {
             log<level::DEBUG>("Failed to update password",
                               entry("USER-ID=%d", (uint8_t)userId));
-            return ipmi::ccUnspecifiedError;
+            return ccUnspecifiedError;
         }
     }
 }
 
-ipmi_ret_t UserAccess::setUserEnabledState(const uint8_t userId,
-                                           const bool& enabledState)
+Cc UserAccess::setUserEnabledState(const uint8_t userId,
+                                   const bool& enabledState)
 {
     if (!isValidUserId(userId))
     {
-        return IPMI_CC_PARM_OUT_OF_RANGE;
+        return ccParmOutOfRange;
     }
     boost::interprocess::scoped_lock<boost::interprocess::named_recursive_mutex>
         userLock{*userMutex};
@@ -776,7 +775,7 @@
     if (userName.empty())
     {
         log<level::DEBUG>("User name not set / invalid");
-        return IPMI_CC_UNSPECIFIED_ERROR;
+        return ccUnspecifiedError;
     }
     if (userInfo->userEnabled != enabledState)
     {
@@ -791,31 +790,31 @@
         catch (const std::exception& e)
         {
             log<level::DEBUG>("Write user data failed");
-            return IPMI_CC_UNSPECIFIED_ERROR;
+            return ccUnspecifiedError;
         }
     }
-    return IPMI_CC_OK;
+    return ccSuccess;
 }
 
-ipmi_ret_t UserAccess::setUserPayloadAccess(const uint8_t chNum,
-                                            const uint8_t operation,
-                                            const uint8_t userId,
-                                            const PayloadAccess& payloadAccess)
+Cc UserAccess::setUserPayloadAccess(const uint8_t chNum,
+                                    const uint8_t operation,
+                                    const uint8_t userId,
+                                    const PayloadAccess& payloadAccess)
 {
     constexpr uint8_t enable = 0x0;
     constexpr uint8_t disable = 0x1;
 
     if (!isValidChannel(chNum))
     {
-        return IPMI_CC_INVALID_FIELD_REQUEST;
+        return ccInvalidFieldRequest;
     }
     if (!isValidUserId(userId))
     {
-        return IPMI_CC_PARM_OUT_OF_RANGE;
+        return ccParmOutOfRange;
     }
     if (operation != enable && operation != disable)
     {
-        return IPMI_CC_INVALID_FIELD_REQUEST;
+        return ccInvalidFieldRequest;
     }
     // Check operation & payloadAccess if required.
     boost::interprocess::scoped_lock<boost::interprocess::named_recursive_mutex>
@@ -846,23 +845,22 @@
     catch (const std::exception& e)
     {
         log<level::ERR>("Write user data failed");
-        return IPMI_CC_UNSPECIFIED_ERROR;
+        return ccUnspecifiedError;
     }
-    return IPMI_CC_OK;
+    return ccSuccess;
 }
 
-ipmi_ret_t UserAccess::setUserPrivilegeAccess(const uint8_t userId,
-                                              const uint8_t chNum,
-                                              const UserPrivAccess& privAccess,
-                                              const bool& otherPrivUpdates)
+Cc UserAccess::setUserPrivilegeAccess(const uint8_t userId, const uint8_t chNum,
+                                      const UserPrivAccess& privAccess,
+                                      const bool& otherPrivUpdates)
 {
     if (!isValidChannel(chNum))
     {
-        return IPMI_CC_INVALID_FIELD_REQUEST;
+        return ccInvalidFieldRequest;
     }
     if (!isValidUserId(userId))
     {
-        return IPMI_CC_PARM_OUT_OF_RANGE;
+        return ccParmOutOfRange;
     }
     boost::interprocess::scoped_lock<boost::interprocess::named_recursive_mutex>
         userLock{*userMutex};
@@ -873,7 +871,7 @@
     if (userName.empty())
     {
         log<level::DEBUG>("User name not set / invalid");
-        return IPMI_CC_UNSPECIFIED_ERROR;
+        return ccUnspecifiedError;
     }
     std::string priv = convertToSystemPrivilege(
         static_cast<CommandPrivilege>(privAccess.privilege));
@@ -902,9 +900,9 @@
     catch (const std::exception& e)
     {
         log<level::DEBUG>("Write user data failed");
-        return IPMI_CC_UNSPECIFIED_ERROR;
+        return ccUnspecifiedError;
     }
-    return IPMI_CC_OK;
+    return ccSuccess;
 }
 
 uint8_t UserAccess::getUserId(const std::string& userName)
@@ -934,16 +932,16 @@
     return usrIndex;
 }
 
-ipmi_ret_t UserAccess::getUserName(const uint8_t userId, std::string& userName)
+Cc UserAccess::getUserName(const uint8_t userId, std::string& userName)
 {
     if (!isValidUserId(userId))
     {
-        return IPMI_CC_PARM_OUT_OF_RANGE;
+        return ccParmOutOfRange;
     }
     UserInfo* userInfo = getUserInfo(userId);
     userName.assign(reinterpret_cast<char*>(userInfo->userName), 0,
                     ipmiMaxUserName);
-    return IPMI_CC_OK;
+    return ccSuccess;
 }
 
 bool UserAccess::isIpmiInAvailableGroupList()
@@ -966,12 +964,11 @@
     return false;
 }
 
-ipmi_ret_t UserAccess::setUserName(const uint8_t userId,
-                                   const char* userNameInChar)
+Cc UserAccess::setUserName(const uint8_t userId, const char* userNameInChar)
 {
     if (!isValidUserId(userId))
     {
-        return IPMI_CC_PARM_OUT_OF_RANGE;
+        return ccParmOutOfRange;
     }
 
     boost::interprocess::scoped_lock<boost::interprocess::named_recursive_mutex>
@@ -983,7 +980,7 @@
     if (oldUser == newUser)
     {
         // requesting to set the same user name, return success.
-        return IPMI_CC_OK;
+        return ccSuccess;
     }
     bool validUser = isValidUserName(userNameInChar);
     UserInfo* userInfo = getUserInfo(userId);
@@ -1003,7 +1000,7 @@
             log<level::DEBUG>("Failed to excute method",
                               entry("METHOD=%s", deleteUserMethod),
                               entry("PATH=%s", userPath.c_str()));
-            return IPMI_CC_UNSPECIFIED_ERROR;
+            return ccUnspecifiedError;
         }
         deleteUserIndex(userId);
     }
@@ -1013,7 +1010,7 @@
         {
             if (!isIpmiInAvailableGroupList())
             {
-                return IPMI_CC_UNSPECIFIED_ERROR;
+                return ccUnspecifiedError;
             }
             // Create new user
             auto method = bus.new_method_call(
@@ -1027,7 +1024,7 @@
             log<level::DEBUG>("Failed to excute method",
                               entry("METHOD=%s", createUserMethod),
                               entry("PATH=%s", userMgrObjBasePath));
-            return IPMI_CC_UNSPECIFIED_ERROR;
+            return ccUnspecifiedError;
         }
         std::memcpy(userInfo->userName, userNameInChar, ipmiMaxUserName);
         userInfo->userInSystem = true;
@@ -1048,7 +1045,7 @@
             log<level::DEBUG>("Failed to excute method",
                               entry("METHOD=%s", renameUserMethod),
                               entry("PATH=%s", userMgrObjBasePath));
-            return IPMI_CC_UNSPECIFIED_ERROR;
+            return ccUnspecifiedError;
         }
         std::fill(static_cast<uint8_t*>(userInfo->userName),
                   static_cast<uint8_t*>(userInfo->userName) +
@@ -1060,7 +1057,7 @@
     }
     else if (!validUser)
     {
-        return IPMI_CC_INVALID_FIELD_REQUEST;
+        return ccInvalidFieldRequest;
     }
     try
     {
@@ -1069,9 +1066,9 @@
     catch (const std::exception& e)
     {
         log<level::DEBUG>("Write user data failed");
-        return IPMI_CC_UNSPECIFIED_ERROR;
+        return ccUnspecifiedError;
     }
-    return IPMI_CC_OK;
+    return ccSuccess;
 }
 
 static constexpr const char* jsonUserName = "user_name";