ipaddress: Parse from netlink

This improves on the old code for enumerating IP addresses by allowing
the application of filtering rules prior to listing out the IPs. The
netlink interface provides the information in a more direct form with
less superfluous enumeration of data about the address.

This will be required to determine deprecated / dynamic addresses from
static ones with IPv6.

Change-Id: I8ff2408b58921a82fd556d8ed08c203171c88035
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/ipaddress.hpp b/src/ipaddress.hpp
index b78b677..b46d64e 100644
--- a/src/ipaddress.hpp
+++ b/src/ipaddress.hpp
@@ -1,8 +1,15 @@
 #pragma once
+#include "types.hpp"
 
+#include <linux/netlink.h>
+
+#include <cstdint>
+#include <optional>
 #include <sdbusplus/bus.hpp>
 #include <sdbusplus/server/object.hpp>
 #include <string>
+#include <string_view>
+#include <vector>
 #include <xyz/openbmc_project/Network/IP/server.hpp>
 #include <xyz/openbmc_project/Object/Delete/server.hpp>
 
@@ -19,6 +26,30 @@
 
 class EthernetInterface;
 
+/* @class AddressFilter
+ */
+struct AddressFilter
+{
+    unsigned interface = 0;
+    std::optional<uint8_t> scope;
+};
+
+/** @class AddressInfo
+ *  @brief Information about a addresses from the kernel
+ */
+struct AddressInfo
+{
+    unsigned interface;
+    InAddrAny address;
+    uint8_t prefix;
+    uint8_t scope;
+    uint32_t flags;
+};
+
+/** @brief Returns a list of the current system neighbor table
+ */
+std::vector<AddressInfo> getCurrentAddresses(const AddressFilter& filter);
+
 /** @class IPAddress
  *  @brief OpenBMC IPAddress implementation.
  *  @details A concrete implementation for the
@@ -71,5 +102,12 @@
     EthernetInterface& parent;
 };
 
+namespace detail
+{
+
+void parseAddress(const AddressFilter& filter, const nlmsghdr& hdr,
+                  std::string_view msg, std::vector<AddressInfo>& addresses);
+
+} // namespace detail
 } // namespace network
 } // namespace phosphor