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_util.hpp b/src/ncsi_util.hpp
index dfa39e5..da45a38 100644
--- a/src/ncsi_util.hpp
+++ b/src/ncsi_util.hpp
@@ -12,19 +12,24 @@
 constexpr auto DEFAULT_VALUE = -1;
 constexpr auto NONE = 0;
 
+struct Interface
+{
+    int ifindex;
+};
+
 /* @brief  This function will ask underlying NCSI driver
  *         to send an OEM command (command type 0x50) with
  *         the specified payload as the OEM data.
  *         This function talks with the NCSI driver over
  *         netlink messages.
- * @param[in] ifindex - Interface Index.
+ * @param[in] interface - Interface
  * @param[in] package - NCSI Package.
  * @param[in] channel - Channel number with in the package.
  * @param[in] opcode  - NCSI Send Command sub-operation
  * @param[in] payload - OEM data to send.
  * @returns 0 on success and negative value for failure.
  */
-int sendOemCommand(int ifindex, int package, int channel, int opcode,
+int sendOemCommand(Interface& interface, int package, int channel, int opcode,
                    std::span<const unsigned char> payload);
 
 /* @brief  This function will ask underlying NCSI driver
@@ -32,31 +37,31 @@
  *         combination as the preferred choice.
  *         This function talks with the NCSI driver over
  *         netlink messages.
- * @param[in] ifindex - Interface Index.
+ * @param[in] interface - Interface
  * @param[in] package - NCSI Package.
  * @param[in] channel - Channel number with in the package.
  * @returns 0 on success and negative value for failure.
  */
-int setChannel(int ifindex, int package, int channel);
+int setChannel(Interface& interface, int package, int channel);
 
 /* @brief  This function will ask underlying NCSI driver
  *         to clear any preferred setting from the given
  *         interface.
  *         This function talks with the NCSI driver over
  *         netlink messages.
- * @param[in] ifindex - Interface Index.
+ * @param[in] interface - Interface
  * @returns 0 on success and negative value for failure.
  */
-int clearInterface(int ifindex);
+int clearInterface(Interface& interface);
 
 /* @brief  This function is used to dump all the info
  *         of the package and the channels underlying
  *         the package.
- * @param[in] ifindex - Interface Index.
+ * @param[in] interface - Interface
  * @param[in] package - NCSI Package.
  * @returns 0 on success and negative value for failure.
  */
-int getInfo(int ifindex, int package);
+int getInfo(Interface& interface, int package);
 
 /* @brief  This function assigns a mask controlling responses to AEN from a
  * package.
@@ -64,7 +69,7 @@
  * @param[in] mask - A 32-bit mask integer
  * @returns 0 on success and negative value for failure.
  */
-int setPackageMask(int ifindex, unsigned int mask);
+int setPackageMask(Interface& interface, unsigned int mask);
 
 /* @brief  This function sets the AEN mask for the channels inside the selected
  * package.
@@ -73,7 +78,7 @@
  * @param[in] mask - A 32-bit mask integer
  * @returns 0 on success and negative value for failure.
  */
-int setChannelMask(int ifindex, int package, unsigned int mask);
+int setChannelMask(Interface& interface, int package, unsigned int mask);
 
 } // namespace ncsi
 } // namespace network