treewide: Cleanup unused includes

Change-Id: Ied2a0d97d2c31dc2b370452768a7f41d9ecf07f3
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/dhcp_configuration.cpp b/src/dhcp_configuration.cpp
index 53d4e91..6c96206 100644
--- a/src/dhcp_configuration.cpp
+++ b/src/dhcp_configuration.cpp
@@ -2,6 +2,7 @@
 
 #include "config_parser.hpp"
 #include "network_manager.hpp"
+#include "util.hpp"
 
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/log.hpp>
diff --git a/src/dhcp_configuration.hpp b/src/dhcp_configuration.hpp
index 8174ec7..19a8888 100644
--- a/src/dhcp_configuration.hpp
+++ b/src/dhcp_configuration.hpp
@@ -1,7 +1,4 @@
 #pragma once
-
-#include "config_parser.hpp"
-
 #include <sdbusplus/bus.hpp>
 #include <sdbusplus/server/object.hpp>
 #include <string>
diff --git a/src/dns_updater.cpp b/src/dns_updater.cpp
index bf29fff..22693f8 100644
--- a/src/dns_updater.cpp
+++ b/src/dns_updater.cpp
@@ -1,5 +1,3 @@
-#include "config.h"
-
 #include "dns_updater.hpp"
 
 #include <fstream>
diff --git a/src/ethernet_interface.cpp b/src/ethernet_interface.cpp
index 6f078e3..1c77f8d 100644
--- a/src/ethernet_interface.cpp
+++ b/src/ethernet_interface.cpp
@@ -6,7 +6,7 @@
 #include "ipaddress.hpp"
 #include "neighbor.hpp"
 #include "network_manager.hpp"
-#include "types.hpp"
+#include "util.hpp"
 #include "vlan_interface.hpp"
 
 #include <arpa/inet.h>
@@ -457,8 +457,8 @@
 
     // delete the vlan network file
     std::error_code ec;
-    fs::remove(networkFile, ec);
-    fs::remove(deviceFile, ec);
+    std::filesystem::remove(networkFile, ec);
+    std::filesystem::remove(deviceFile, ec);
 
     // TODO  systemd doesn't delete the virtual network interface
     // even after deleting all the related configuartion.
@@ -962,14 +962,6 @@
 
 void EthernetInterface::writeConfigurationFile()
 {
-    // write all the static ip address in the systemd-network conf file
-
-    using namespace std::string_literals;
-    namespace fs = std::filesystem;
-
-    // if there is vlan interafce then write the configuration file
-    // for vlan also.
-
     for (const auto& intf : vlanInterfaces)
     {
         intf.second->writeConfigurationFile();
diff --git a/src/ethernet_interface.hpp b/src/ethernet_interface.hpp
index e81a108..daedc50 100644
--- a/src/ethernet_interface.hpp
+++ b/src/ethernet_interface.hpp
@@ -1,15 +1,13 @@
 #pragma once
-
-#include "config_parser.hpp"
 #include "types.hpp"
-#include "util.hpp"
 #include "xyz/openbmc_project/Network/IP/Create/server.hpp"
 #include "xyz/openbmc_project/Network/Neighbor/CreateStatic/server.hpp"
 
-#include <filesystem>
+#include <map>
 #include <sdbusplus/bus.hpp>
 #include <sdbusplus/server/object.hpp>
 #include <string>
+#include <vector>
 #include <xyz/openbmc_project/Collection/DeleteAll/server.hpp>
 #include <xyz/openbmc_project/Network/EthernetInterface/server.hpp>
 #include <xyz/openbmc_project/Network/MACAddress/server.hpp>
@@ -36,8 +34,6 @@
 using ServerList = std::vector<std::string>;
 using ObjectPath = sdbusplus::message::object_path;
 
-namespace fs = std::filesystem;
-
 class Manager; // forward declaration of network manager.
 
 class TestEthernetInterface;
@@ -48,6 +44,11 @@
 
 class Neighbor;
 
+namespace config
+{
+class Parser;
+}
+
 using LinkSpeed = uint16_t;
 using DuplexMode = uint8_t;
 using Autoneg = uint8_t;
diff --git a/src/ipaddress.cpp b/src/ipaddress.cpp
index becb5b3..ac9c0b0 100644
--- a/src/ipaddress.cpp
+++ b/src/ipaddress.cpp
@@ -1,5 +1,3 @@
-#include "config.h"
-
 #include "ipaddress.hpp"
 
 #include "ethernet_interface.hpp"
diff --git a/src/neighbor.cpp b/src/neighbor.cpp
index 579a5a8..f68dd90 100644
--- a/src/neighbor.cpp
+++ b/src/neighbor.cpp
@@ -1,5 +1,3 @@
-#include "config.h"
-
 #include "neighbor.hpp"
 
 #include "ethernet_interface.hpp"
diff --git a/src/network_manager_main.cpp b/src/network_manager_main.cpp
index fa4efe5..6a9c740 100644
--- a/src/network_manager_main.cpp
+++ b/src/network_manager_main.cpp
@@ -3,6 +3,9 @@
 #include "network_manager.hpp"
 #include "rtnetlink_server.hpp"
 #include "types.hpp"
+#ifdef SYNC_MAC_FROM_INVENTORY
+#include "util.hpp"
+#endif
 
 #include <linux/netlink.h>
 
diff --git a/src/system_configuration.cpp b/src/system_configuration.cpp
index e1bbf2e..a302ace 100644
--- a/src/system_configuration.cpp
+++ b/src/system_configuration.cpp
@@ -1,5 +1,3 @@
-#include "config.h"
-
 #include "system_configuration.hpp"
 
 #include <phosphor-logging/elog-errors.hpp>
diff --git a/src/types.hpp b/src/types.hpp
index e0d768d..e14cac4 100644
--- a/src/types.hpp
+++ b/src/types.hpp
@@ -5,12 +5,9 @@
 #include <systemd/sd-event.h>
 
 #include <chrono>
-#include <cstddef>
-#include <functional>
 #include <memory>
 #include <sdeventplus/clock.hpp>
 #include <sdeventplus/utility/timer.hpp>
-#include <set>
 #include <string>
 #include <variant>
 
@@ -52,13 +49,10 @@
 };
 using EventPtr = std::unique_ptr<sd_event, EventDeleter>;
 
-template <typename T>
-using UniquePtr = std::unique_ptr<T, std::function<void(T*)>>;
-
 // Byte representations for common address types in network byte order
 using InAddrAny = std::variant<struct in_addr, struct in6_addr>;
 
-using InterfaceList = std::set<IntfName>;
+using InterfaceList = std::vector<IntfName>;
 
 using Timer = sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>;
 
diff --git a/src/util.cpp b/src/util.cpp
index c5543f0..fb59348 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -16,7 +16,6 @@
 #include <cctype>
 #include <cstdlib>
 #include <cstring>
-#include <filesystem>
 #include <fstream>
 #include <list>
 #ifdef SYNC_MAC_FROM_INVENTORY
@@ -37,7 +36,6 @@
 
 using namespace phosphor::logging;
 using namespace sdbusplus::xyz::openbmc_project::Common::Error;
-namespace fs = std::filesystem;
 
 namespace internal
 {
@@ -110,9 +108,10 @@
 }
 
 /** @brief Parse the comma separated interface names */
-std::set<std::string_view> parseInterfaces(std::string_view interfaces)
+std::unordered_set<std::string_view>
+    parseInterfaces(std::string_view interfaces)
 {
-    std::set<std::string_view> result;
+    std::unordered_set<std::string_view> result;
     while (true)
     {
         auto sep = interfaces.find(',');
@@ -139,7 +138,7 @@
 }
 
 /** @brief Get the ignored interfaces */
-const std::set<std::string_view>& getIgnoredInterfaces()
+const std::unordered_set<std::string_view>& getIgnoredInterfaces()
 {
     static auto ignoredInterfaces = parseInterfaces(getIgnoredInterfacesEnv());
     return ignoredInterfaces;
@@ -294,7 +293,7 @@
         {
             continue;
         }
-        interfaces.emplace(ifa->ifa_name);
+        interfaces.emplace_back(ifa->ifa_name);
     }
     return interfaces;
 }
diff --git a/src/util.hpp b/src/util.hpp
index cc7ab03..5705eda 100644
--- a/src/util.hpp
+++ b/src/util.hpp
@@ -1,8 +1,5 @@
 #pragma once
-
-#include "config.h"
-
-#include "ethernet_interface.hpp"
+#include "config_parser.hpp"
 #include "types.hpp"
 
 #include <netinet/ether.h>
@@ -14,6 +11,7 @@
 #include <sdbusplus/bus.hpp>
 #include <string>
 #include <string_view>
+#include <unordered_set>
 #include <xyz/openbmc_project/Network/EthernetInterface/server.hpp>
 
 namespace phosphor
@@ -157,10 +155,11 @@
 std::string_view getIgnoredInterfacesEnv();
 
 /** @brief Parse the comma separated interface names */
-std::set<std::string_view> parseInterfaces(std::string_view interfaces);
+std::unordered_set<std::string_view>
+    parseInterfaces(std::string_view interfaces);
 
 /** @brief Get the ignored interfaces */
-const std::set<std::string_view>& getIgnoredInterfaces();
+const std::unordered_set<std::string_view>& getIgnoredInterfaces();
 
 } // namespace internal
 
diff --git a/src/vlan_interface.cpp b/src/vlan_interface.cpp
index 129cbf7..67074f0 100644
--- a/src/vlan_interface.cpp
+++ b/src/vlan_interface.cpp
@@ -1,5 +1,3 @@
-#include "config.h"
-
 #include "vlan_interface.hpp"
 
 #include "config_parser.hpp"
diff --git a/test/mock_network_manager.hpp b/test/mock_network_manager.hpp
index fde3bbd..337af88 100644
--- a/test/mock_network_manager.hpp
+++ b/test/mock_network_manager.hpp
@@ -1,6 +1,7 @@
 #pragma once
 #include "mock_ethernet_interface.hpp"
 #include "network_manager.hpp"
+#include "util.hpp"
 
 #include <gmock/gmock.h>
 
diff --git a/test/test_util.cpp b/test/test_util.cpp
index 4a50a26..dbf0a27 100644
--- a/test/test_util.cpp
+++ b/test/test_util.cpp
@@ -230,7 +230,7 @@
 TEST(IgnoredInterfaces, NotEmpty)
 {
     using ::testing::ContainerEq;
-    std::set<std::string_view> expected = {"eth0"};
+    std::unordered_set<std::string_view> expected = {"eth0"};
     auto ret = internal::parseInterfaces("eth0");
     EXPECT_THAT(ret, ContainerEq(expected));