ncsi: Create Interface type to wrap a network interface instance
Define an interface as a new type, just containing the ifindex
currently.
This will allow future Interface implementations that don't interact
directly with a local Linux network interface.
Tested: "get info" (--info) and "send OEM command" (--oem-payload)
operations tested against kernel NCSI layer, to a test NC-SI device.
Change-Id: If0471ac3fa41e08bb916e9279d4fe5b668860b03
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
diff --git a/src/ncsi_netlink_main.cpp b/src/ncsi_netlink_main.cpp
index 6657c60..3ac42bd 100644
--- a/src/ncsi_netlink_main.cpp
+++ b/src/ncsi_netlink_main.cpp
@@ -56,6 +56,8 @@
argv);
}
+ Interface interface{indexInt};
+
// Parse out package argument.
auto package = (options)["package"];
try
@@ -137,7 +139,7 @@
}
return ncsi::sendOemCommand(
- indexInt, packageInt, channelInt, operationInt,
+ interface, packageInt, channelInt, operationInt,
std::span<const unsigned char>(payload.begin(), payload.end()));
}
else if ((options)["set"] == "true")
@@ -147,15 +149,15 @@
{
exitWithError("Package not specified.", argv);
}
- return ncsi::setChannel(indexInt, packageInt, channelInt);
+ return ncsi::setChannel(interface, packageInt, channelInt);
}
else if ((options)["info"] == "true")
{
- return ncsi::getInfo(indexInt, packageInt);
+ return ncsi::getInfo(interface, packageInt);
}
else if ((options)["clear"] == "true")
{
- return ncsi::clearInterface(indexInt);
+ return ncsi::clearInterface(interface);
}
else if (!(options)["pmask"].empty())
{
@@ -173,7 +175,7 @@
{
exitWithError("Package mask value is not valid", argv);
}
- return ncsi::setPackageMask(indexInt, mask);
+ return ncsi::setPackageMask(interface, mask);
}
else if (!(options)["cmask"].empty())
{
@@ -195,7 +197,7 @@
{
exitWithError("Channel mask value is not valid", argv);
}
- return ncsi::setChannelMask(indexInt, packageInt, mask);
+ return ncsi::setChannelMask(interface, packageInt, mask);
}
else
{