Set the current interface number based on the channel name
Now that netipmid is launched with -c <channel_name>, it is possible
to look up the channel number for the 'current channel' 0x0e for
commands that get handled for session init/fini. This is needed for
tools that request channel access info for the current channel.
Tested-by: run ipmitool to establish a session, using -vvvvv
see that the get channel auth command returns the correct
channel ID.
In this config, eth0 is channel 3 and eth1 is channel 1.
As is evident by the highlighted <0X> byte in each of the
returned responses, the value of the current channel byte
went from a hard-coded value 03 to a value that changed with
the current channel.
Before:
ipmitool -H <ip of eth0> ... mc info
...
>> sending packet (23 bytes)
06 00 ff 07 00 00 00 00 00 00 00 00 00 09 20 18
c8 81 00 38 0e 04 35
<< received packet (31 bytes)
06 00 ff 07 00 00 00 00 00 00 00 00 00 10 81 1c
63 20 00 38 00<03>80 04 02 00 00 00 00 1f 00
ipmitool -H <ip of eth1> ... mc info
...
>> sending packet (23 bytes)
06 00 ff 07 00 00 00 00 00 00 00 00 00 09 20 18
c8 81 00 38 0e 04 35
<< received packet (31 bytes)
06 00 ff 07 00 00 00 00 00 00 00 00 00 10 81 1c
63 20 00 38 00<03>80 04 02 00 00 00 00 1f 00
After:
ipmitool -H <ip of eth0> ... mc info
...
>> sending packet (23 bytes)
06 00 ff 07 00 00 00 00 00 00 00 00 00 09 20 18
c8 81 00 38 8e 04 b5
<< received packet (31 bytes)
06 00 ff 07 00 00 00 00 00 00 00 00 00 10 81 1c
63 20 00 38 00<03>80 04 02 00 00 00 00 1f 00
ipmitool -H <ip of eth1> ... mc info
...
>> sending packet (23 bytes)
06 00 ff 07 00 00 00 00 00 00 00 00 00 09 20 18
c8 81 00 38 8e 04 b5
<< received packet (31 bytes)
06 00 ff 07 00 00 00 00 00 00 00 00 00 10 81 1c
63 20 00 38 00<01>80 04 02 00 00 00 00 21 00
Change-Id: I743260a6924606b9ad3eeb8b49bda424dc0ba3d7
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/main.cpp b/main.cpp
index d26e032..880244b 100644
--- a/main.cpp
+++ b/main.cpp
@@ -20,6 +20,7 @@
#include <phosphor-logging/log.hpp>
#include <sdbusplus/asio/connection.hpp>
#include <tuple>
+#include <user_channel/channel_layer.hpp>
using namespace phosphor::logging;
@@ -54,9 +55,24 @@
return sdbusp;
}
+static EInterfaceIndex currentInterfaceIndex = interfaceUnknown;
+static void setInterfaceIndex(const std::string& channel)
+{
+ try
+ {
+ currentInterfaceIndex =
+ static_cast<EInterfaceIndex>(ipmi::getChannelByName(channel));
+ }
+ catch (const std::exception& e)
+ {
+ log<level::ERR>("Requested channel name is not a valid channel name",
+ entry("ERROR=%s", e.what()),
+ entry("CHANNEL=%s", channel.c_str()));
+ }
+}
EInterfaceIndex getInterfaceIndex(void)
{
- return interfaceLAN1;
+ return currentInterfaceIndex;
}
int main(int argc, char* argv[])
@@ -78,9 +94,14 @@
entry("ERROR=%s", strerror(-rc)));
return rc;
}
-
sdbusp = std::make_shared<sdbusplus::asio::connection>(*io, bus);
+ ipmi::ipmiChannelInit();
+ if (channel.size())
+ {
+ setInterfaceIndex(channel);
+ }
+
// Register callback to update cache for a GUID change and cache the GUID
command::registerGUIDChangeCallback();
cache::guid = command::getSystemGUID();