ethernet_interface: Use string_umaps where sensible

Change-Id: Id30efb0d86e85828b5cd92d401b5bf6002f179ac
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/ethernet_interface.cpp b/src/ethernet_interface.cpp
index f65ebb0..7c1f187 100644
--- a/src/ethernet_interface.cpp
+++ b/src/ethernet_interface.cpp
@@ -3,11 +3,8 @@
 #include "ethernet_interface.hpp"
 
 #include "config_parser.hpp"
-#include "ipaddress.hpp"
-#include "neighbor.hpp"
 #include "network_manager.hpp"
 #include "util.hpp"
-#include "vlan_interface.hpp"
 
 #include <arpa/inet.h>
 #include <fmt/compile.h>
@@ -194,7 +191,7 @@
             addressType, address, addr.prefix, gateway, origin);
 
         this->addrs.insert_or_assign(
-            address, std::make_shared<phosphor::network::IPAddress>(
+            address, std::make_unique<IPAddress>(
                          bus, ipAddressObjectPath.c_str(), *this, addressType,
                          address, origin, addr.prefix, gateway));
     }
@@ -217,10 +214,9 @@
         std::string ip = toString(neighbor.address);
         std::string mac = mac_address::toString(*neighbor.mac);
         std::string objectPath = generateStaticNeighborObjectPath(ip, mac);
-        staticNeighbors.emplace(ip,
-                                std::make_shared<phosphor::network::Neighbor>(
-                                    bus, objectPath.c_str(), *this, ip, mac,
-                                    Neighbor::State::Permanent));
+        staticNeighbors.emplace(
+            ip, std::make_unique<Neighbor>(bus, objectPath.c_str(), *this, ip,
+                                           mac, Neighbor::State::Permanent));
     }
 }
 
@@ -282,10 +278,10 @@
 
     std::string objectPath =
         generateObjectPath(protType, ipaddress, prefixLength, gateway, origin);
-    this->addrs.insert_or_assign(ipaddress,
-                                 std::make_shared<phosphor::network::IPAddress>(
-                                     bus, objectPath.c_str(), *this, protType,
-                                     ipaddress, origin, prefixLength, gateway));
+    this->addrs.insert_or_assign(
+        ipaddress,
+        std::make_unique<IPAddress>(bus, objectPath.c_str(), *this, protType,
+                                    ipaddress, origin, prefixLength, gateway));
 
     writeConfigurationFile();
     manager.reloadConfigs();
@@ -313,10 +309,10 @@
 
     std::string objectPath =
         generateStaticNeighborObjectPath(ipAddress, macAddress);
-    staticNeighbors.emplace(ipAddress,
-                            std::make_shared<phosphor::network::Neighbor>(
-                                bus, objectPath.c_str(), *this, ipAddress,
-                                macAddress, Neighbor::State::Permanent));
+    staticNeighbors.emplace(
+        ipAddress,
+        std::make_unique<Neighbor>(bus, objectPath.c_str(), *this, ipAddress,
+                                   macAddress, Neighbor::State::Permanent));
 
     writeConfigurationFile();
     manager.reloadConfigs();
diff --git a/src/ethernet_interface.hpp b/src/ethernet_interface.hpp
index daedc50..f0931d7 100644
--- a/src/ethernet_interface.hpp
+++ b/src/ethernet_interface.hpp
@@ -1,9 +1,10 @@
 #pragma once
+#include "ipaddress.hpp"
+#include "neighbor.hpp"
 #include "types.hpp"
 #include "xyz/openbmc_project/Network/IP/Create/server.hpp"
 #include "xyz/openbmc_project/Network/Neighbor/CreateStatic/server.hpp"
 
-#include <map>
 #include <sdbusplus/bus.hpp>
 #include <sdbusplus/server/object.hpp>
 #include <string>
@@ -34,16 +35,12 @@
 using ServerList = std::vector<std::string>;
 using ObjectPath = sdbusplus::message::object_path;
 
-class Manager; // forward declaration of network manager.
+class Manager;
 
 class TestEthernetInterface;
 
 class VlanInterface;
 
-class IPAddress;
-
-class Neighbor;
-
 namespace config
 {
 class Parser;
@@ -59,10 +56,6 @@
 using InterfaceName = std::string;
 using InterfaceInfo =
     std::tuple<LinkSpeed, DuplexMode, Autoneg, LinkUp, NICEnabled, MTU>;
-using AddressMap = std::map<std::string, std::shared_ptr<IPAddress>>;
-using NeighborMap = std::map<std::string, std::shared_ptr<Neighbor>>;
-using VlanInterfaceMap =
-    std::map<InterfaceName, std::unique_ptr<VlanInterface>>;
 
 /** @class EthernetInterface
  *  @brief OpenBMC Ethernet Interface implementation.
@@ -146,7 +139,7 @@
     /* @brief Gets all the ip addresses.
      * @returns the list of ipAddress.
      */
-    const AddressMap& getAddresses() const
+    inline const auto& getAddresses() const
     {
         return addrs;
     }
@@ -154,7 +147,7 @@
     /* @brief Gets all the static neighbor entries.
      * @returns Static neighbor map.
      */
-    const NeighborMap& getStaticNeighbors() const
+    inline const auto& getStaticNeighbors() const
     {
         return staticNeighbors;
     }
@@ -320,13 +313,13 @@
     Manager& manager;
 
     /** @brief Persistent map of IPAddress dbus objects and their names */
-    AddressMap addrs;
+    string_umap<std::unique_ptr<IPAddress>> addrs;
 
     /** @brief Persistent map of Neighbor dbus objects and their names */
-    NeighborMap staticNeighbors;
+    string_umap<std::unique_ptr<Neighbor>> staticNeighbors;
 
     /** @brief Persistent map of VLAN interface dbus objects and their names */
-    VlanInterfaceMap vlanInterfaces;
+    string_umap<std::unique_ptr<VlanInterface>> vlanInterfaces;
 
     /** @brief Dbus object path */
     std::string objPath;