diff options
author | Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com> | 2018-12-08 17:38:25 +0530 |
---|---|---|
committer | Vernon Mauery <vernon.mauery@linux.intel.com> | 2018-12-20 00:01:53 +0000 |
commit | 06df8765c586d03211177efd4aa095a5418dbf91 (patch) | |
tree | df9d13a1ae0429f251d0dcc13acbfd6e8062df08 | |
parent | f1d0e23b8f133d817896ce1cb2f288aefc61a81f (diff) | |
download | phosphor-host-ipmid-06df8765c586d03211177efd4aa095a5418dbf91.tar.gz phosphor-host-ipmid-06df8765c586d03211177efd4aa095a5418dbf91.zip |
User commands updated to handle channel request
User commands updated to handle channel request properly.
1. Self channel number 0xE will be converted properly as per
the interfaces
2. Will handle commands to set / get access for session based
channels only.
Unit-test:
Verfied get / set user access command works on self-channel
and session based channels accordingly. 0xCC will returned
for session-less channels
Change-Id: I91f610e5a70ba648a90191b7aad6ae09d4e0acdc
Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
-rw-r--r-- | user_channel/user_layer.cpp | 5 | ||||
-rw-r--r-- | user_channel/user_layer.hpp | 8 | ||||
-rw-r--r-- | user_channel/usercommands.cpp | 21 |
3 files changed, 9 insertions, 25 deletions
diff --git a/user_channel/user_layer.cpp b/user_channel/user_layer.cpp index 30aa12c..4dfed1f 100644 --- a/user_channel/user_layer.cpp +++ b/user_channel/user_layer.cpp @@ -62,11 +62,6 @@ bool ipmiUserIsValidUserId(const uint8_t userId) return UserAccess::isValidUserId(userId); } -bool ipmiUserIsValidChannel(const uint8_t chNum) -{ - return UserAccess::isValidChannel(chNum); -} - bool ipmiUserIsValidPrivilege(const uint8_t priv) { return UserAccess::isValidPrivilege(priv); diff --git a/user_channel/user_layer.hpp b/user_channel/user_layer.hpp index ce985df..7e8f185 100644 --- a/user_channel/user_layer.hpp +++ b/user_channel/user_layer.hpp @@ -101,14 +101,6 @@ ipmi_ret_t ipmiRenameUserEntryPassword(const std::string& userName, */ bool ipmiUserIsValidUserId(const uint8_t userId); -/** @brief determines valid channel - * - * @param[in] chNum- channel number - * - * @return true if valid, false otherwise - */ -bool ipmiUserIsValidChannel(const uint8_t chNum); - /** @brief determines valid privilege level * * @param[in] priv - privilege level diff --git a/user_channel/usercommands.cpp b/user_channel/usercommands.cpp index b0997d5..3bed8c5 100644 --- a/user_channel/usercommands.cpp +++ b/user_channel/usercommands.cpp @@ -17,6 +17,7 @@ #include "usercommands.hpp" #include "apphandler.hpp" +#include "channel_layer.hpp" #include "user_layer.hpp" #include <host-ipmid/ipmid-api.h> @@ -196,12 +197,11 @@ ipmi_ret_t ipmiSetUserAccess(ipmi_netfn_t netfn, ipmi_cmd_t cmd, log<level::DEBUG>("Set user access - Invalid Length"); return IPMI_CC_REQ_DATA_LEN_INVALID; } + uint8_t chNum = convertCurrentChannelNum(req->chNum); if (req->reserved1 != 0 || req->reserved2 != 0 || req->reserved3 != 0 || - req->sessLimit != 0 || - (!ipmiUserIsValidChannel(req->chNum) || - (!ipmiUserIsValidPrivilege(req->privilege)))) - // TODO: Need to check for session support and return invalid field in - // request + req->sessLimit != 0 || (!isValidChannel(chNum)) || + (!ipmiUserIsValidPrivilege(req->privilege)) || + (EChannelSessSupported::none == getChannelSessionSupport(chNum))) { log<level::DEBUG>("Set user access - Invalid field in request"); return IPMI_CC_INVALID_FIELD_REQUEST; @@ -211,8 +211,7 @@ ipmi_ret_t ipmiSetUserAccess(ipmi_netfn_t netfn, ipmi_cmd_t cmd, log<level::DEBUG>("Set user access - Parameter out of range"); return IPMI_CC_PARM_OUT_OF_RANGE; } - // TODO: Determine the Channel number 0xE (Self Channel number ?) - uint8_t chNum = req->chNum; + PrivAccess privAccess = {0}; if (req->bitsUpdate) { @@ -240,10 +239,10 @@ ipmi_ret_t ipmiGetUserAccess(ipmi_netfn_t netfn, ipmi_cmd_t cmd, log<level::DEBUG>("Get user access - Invalid Length"); return IPMI_CC_REQ_DATA_LEN_INVALID; } + uint8_t chNum = convertCurrentChannelNum(req->chNum); if (req->reserved1 != 0 || req->reserved2 != 0 || - (!ipmiUserIsValidChannel(req->chNum))) - // TODO: Need to check for session support and return invalid field in - // request + (!isValidChannel(chNum)) || + (EChannelSessSupported::none == getChannelSessionSupport(chNum))) { log<level::DEBUG>("Get user access - Invalid field in request"); return IPMI_CC_INVALID_FIELD_REQUEST; @@ -256,8 +255,6 @@ ipmi_ret_t ipmiGetUserAccess(ipmi_netfn_t netfn, ipmi_cmd_t cmd, uint8_t maxChUsers = 0, enabledUsers = 0, fixedUsers = 0; bool enabledState = false; - // TODO: Determine the Channel number 0xE (Self Channel number ?) - uint8_t chNum = req->chNum; GetUserAccessResp* resp = static_cast<GetUserAccessResp*>(response); std::fill(reinterpret_cast<uint8_t*>(resp), |