Add convert current channel number function
Support for convert current channel number based on
ipmi::Context is added.
Tested:
Verified by updating the channel number manually and function
returns correctly. For correct value another gerrit patch is needed
which will advertise proper channel from which the command
originated.
Change-Id: Id17d87b6a945b0264c8f14348a50bc2c087d187e
Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
diff --git a/user_channel/channel_layer.hpp b/user_channel/channel_layer.hpp
index 5c82fba..b86d6bf 100644
--- a/user_channel/channel_layer.hpp
+++ b/user_channel/channel_layer.hpp
@@ -16,6 +16,8 @@
#pragma once
#include <ipmid/api.h>
+#include <ipmid/api.hpp>
+#include <ipmid/message.hpp>
#include <string>
namespace ipmi
@@ -261,6 +263,24 @@
/** @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
+ *
+ * @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)
+{
+ if (chNum == currentChNum)
+ {
+ return ctx->channel;
+ }
+ return chNum;
+}
+
+/** @brief provides function to convert current channel number (0xE)
+ *
+ * @param[in] chNum - channel number as requested in commands.
*
* @return same channel number or proper channel number for current channel
* number (0xE).