diff options
| author | Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com> | 2019-03-11 20:08:57 +0530 |
|---|---|---|
| committer | Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com> | 2019-03-12 14:34:35 +0530 |
| commit | 716d1efebef016a2bb1099d12e5b72e941063a58 (patch) | |
| tree | f84b3b9bbdea8cb21ecd304ea8ec2383153f83f5 | |
| parent | 7a4ea79501b85addf16e2c06ffc835708c5264ad (diff) | |
| download | phosphor-net-ipmid-716d1efebef016a2bb1099d12e5b72e941063a58.tar.gz phosphor-net-ipmid-716d1efebef016a2bb1099d12e5b72e941063a58.zip | |
Handle input - Get channel auth capabilities
Handle channel number input in Get Channel authentication
capabilities command. Validate input params, and return
data accordingly
Tested:
1. Verifid RMCP+ successful session establishement
2. ipmitool -I lanplus -H x.x.x.x -U root -P 0penBmc raw 6 0x38 1 4
with response
01 80 04 02 00 00 00 00
3. Verified negative tests like invalid length, invalid field,
invalid channel number (Sessionless)
Change-Id: Id8b4068b94ead281f00282fd709a3f7944887201
Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
| -rw-r--r-- | command/channel_auth.cpp | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/command/channel_auth.cpp b/command/channel_auth.cpp index 69b6d98..67ad8c7 100644 --- a/command/channel_auth.cpp +++ b/command/channel_auth.cpp @@ -2,6 +2,9 @@ #include <ipmid/api.h> +#include <user_channel/channel_layer.hpp> +#include <user_channel/user_layer.hpp> + namespace command { @@ -9,6 +12,23 @@ std::vector<uint8_t> GetChannelCapabilities(const std::vector<uint8_t>& inPayload, const message::Handler& handler) { + auto request = + reinterpret_cast<const GetChannelCapabilitiesReq*>(inPayload.data()); + if (inPayload.size() != sizeof(*request)) + { + std::vector<uint8_t> errorPayload{IPMI_CC_REQ_DATA_LEN_INVALID}; + return errorPayload; + } + uint8_t chNum = ipmi::convertCurrentChannelNum(request->channelNumber); + if (!ipmi::isValidChannel(chNum) || + (ipmi::EChannelSessSupported::none == + ipmi::getChannelSessionSupport(chNum)) || + !ipmi::isValidPrivLimit(request->reqMaxPrivLevel)) + { + std::vector<uint8_t> errorPayload{IPMI_CC_INVALID_FIELD_REQUEST}; + return errorPayload; + } + std::vector<uint8_t> outPayload(sizeof(GetChannelCapabilitiesResp)); auto response = reinterpret_cast<GetChannelCapabilitiesResp*>(outPayload.data()); @@ -16,8 +36,7 @@ std::vector<uint8_t> // A canned response, since there is no user and channel management. response->completionCode = IPMI_CC_OK; - // Channel Number 1 is arbitrarily applied to primary LAN channel; - response->channelNumber = 1; + response->channelNumber = chNum; response->ipmiVersion = 1; // IPMI v2.0 extended capabilities available. response->reserved1 = 0; @@ -31,7 +50,12 @@ std::vector<uint8_t> response->KGStatus = 0; // KG is set to default response->perMessageAuth = 0; // Per-message Authentication is enabled response->userAuth = 0; // User Level Authentication is enabled - response->nonNullUsers = 1; // Non-null usernames enabled + uint8_t maxChUsers = 0; + uint8_t enabledUsers = 0; + uint8_t fixedUsers = 0; + ipmi::ipmiUserGetAllCounts(maxChUsers, enabledUsers, fixedUsers); + + response->nonNullUsers = enabledUsers > 0 ? 1 : 0; // Non-null usernames response->nullUsers = 0; // Null usernames disabled response->anonymousLogin = 0; // Anonymous Login disabled |

