system_queries: Get Interface Info from netlink

This reduces all of the interface information probing down to a single
netlink request for all the label + mac information needed to build an
ethernet interface.

If we ever plumb the ethernet stats into dbus, we can get that
information with this same netlink code.

Change-Id: Ied8a73639dcd74bcfecda392905638573ab7970f
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/system_queries.hpp b/src/system_queries.hpp
index 3182cd6..3bbb021 100644
--- a/src/system_queries.hpp
+++ b/src/system_queries.hpp
@@ -1,17 +1,20 @@
 #pragma once
 #include "types.hpp"
 
-#include <netinet/ether.h>
+#include <net/ethernet.h>
 
 #include <cstdint>
 #include <optional>
 #include <stdplus/zstring.hpp>
 #include <stdplus/zstring_view.hpp>
+#include <string>
 #include <string_view>
+#include <vector>
+
+struct nlmsghdr;
 
 namespace phosphor::network::system
 {
-
 struct EthInfo
 {
     bool autoneg;
@@ -21,19 +24,39 @@
 
 bool intfIsRunning(std::string_view ifname);
 
-unsigned intfIndex(stdplus::const_zstring ifname);
-
-std::optional<ether_addr> getMAC(stdplus::zstring_view ifname);
-
 std::optional<unsigned> getMTU(stdplus::zstring_view ifname);
 
 void setMTU(std::string_view ifname, unsigned mtu);
 
 void setNICUp(std::string_view ifname, bool up);
 
+/** @class InterfaceInfo
+ *  @brief Information about interfaces from the kernel
+ */
+struct InterfaceInfo
+{
+    unsigned idx;
+    unsigned flags;
+    std::optional<std::string> name = std::nullopt;
+    std::optional<ether_addr> mac = std::nullopt;
+    std::optional<unsigned> mtu = std::nullopt;
+
+    constexpr bool operator==(const InterfaceInfo& rhs) const noexcept
+    {
+        return idx == rhs.idx && flags == rhs.flags && name == rhs.name &&
+               mac == rhs.mac && mtu == rhs.mtu;
+    }
+};
+
+namespace detail
+{
+InterfaceInfo parseInterface(const nlmsghdr& hdr, std::string_view msg);
+bool validateNewInterface(const InterfaceInfo& info);
+} // namespace detail
+
 /** @brief Get all the interfaces from the system.
  *  @returns list of interface names.
  */
-string_uset getInterfaces();
+std::vector<InterfaceInfo> getInterfaces();
 
 } // namespace phosphor::network::system