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>
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 @@
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 @@
// 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 @@
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