From 5ed395951d17f4f2616c21345cd6652779c8b300 Mon Sep 17 00:00:00 2001 From: Vernon Mauery Date: Tue, 14 May 2019 09:16:53 -0700 Subject: Update current channel mechanism to be usable by netipmid Getting the current channel is really just an if statement for the requested channel (check for 0x0e) to know if the device channel which is determined by -c by netipmid and by dbus names in host ipmid. Previously, an ipmi::Context was passed in, but netipmid does not use Context, it just has the channel number. So This change makes it so the the requested channel number and the device channel number are the arguments, which makes the same function usable in both netipmid and ipmid. Tested-by: run the get user access command to see that it uses the current channel. # remote connection over channel 1 ipmitool -I lanplus -H <> ... raw 6 0x44 0xe 1 0f 41 00 74 ipmitool -I lanplus -H <> ... raw 6 0x44 1 1 0f 41 00 74 # on bmc console (current channel does not use users) ipmitool raw 6 0x44 0xe 1 Unable to send RAW command (channel=0x0 netfn=0x6 lun=0x0 cmd=0x44 rsp=0xcc): Invalid data field in request # request info for channel 1 ipmitool raw 6 0x44 1 1 0f 41 00 74 Signed-off-by: Vernon Mauery Change-Id: Iadad6f93e47d031a6f4724a3db5161051c5b520a --- user_channel/channel_layer.hpp | 9 ++++----- user_channel/usercommands.cpp | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'user_channel') diff --git a/user_channel/channel_layer.hpp b/user_channel/channel_layer.hpp index 4308794..6dc9fe2 100644 --- a/user_channel/channel_layer.hpp +++ b/user_channel/channel_layer.hpp @@ -16,7 +16,6 @@ #pragma once #include -#include #include namespace ipmi @@ -281,17 +280,17 @@ ipmi_ret_t getChannelAccessData(const uint8_t chNum, /** @brief provides function to convert current channel number (0xE) * * @param[in] chNum - channel number as requested in commands. - * @param[in] ipmi::context - ipmi context ptr, which has more details + * @param[in] devChannel - channel number as provided by device (not 0xE) * * @return same channel number or proper channel number for current channel * number (0xE). */ -inline uint8_t convertCurrentChannelNum(const uint8_t chNum, - ipmi::Context::ptr ctx) +static inline uint8_t convertCurrentChannelNum(const uint8_t chNum, + const uint8_t devChannel) { if (chNum == currentChNum) { - return ctx->channel; + return devChannel; } return chNum; } diff --git a/user_channel/usercommands.cpp b/user_channel/usercommands.cpp index 489eeaf..5bdbbd3 100644 --- a/user_channel/usercommands.cpp +++ b/user_channel/usercommands.cpp @@ -130,7 +130,7 @@ ipmi::RspType<> ipmiSetUserAccess(ipmi::Context::ptr ctx, uint4_t channel, { uint8_t sessLimit = sessionLimit.value_or(0); uint8_t chNum = - convertCurrentChannelNum(static_cast(channel), ctx); + convertCurrentChannelNum(static_cast(channel), ctx->channel); if (reserved1 != 0 || reserved2 != 0 || sessLimit != 0 || (!isValidChannel(chNum)) || (!ipmiUserIsValidPrivilege(static_cast(privilege))) || @@ -199,7 +199,7 @@ ipmi::RspType(channel), ctx); + convertCurrentChannelNum(static_cast(channel), ctx->channel); if (reserved1 != 0 || reserved2 != 0 || (!isValidChannel(chNum)) || (EChannelSessSupported::none == getChannelSessionSupport(chNum))) { @@ -450,7 +450,7 @@ ipmi::RspType(chNum), ctx); + convertCurrentChannelNum(static_cast(chNum), ctx->channel); if (reserved1 || reserved2 || !isValidChannel(channel) || !isValidPrivLimit(static_cast(privLevel)) || -- cgit v1.2.1