Ratan Gupta | 05eb109 | 2017-04-14 16:33:53 +0530 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "ethernet_interface.hpp" |
Ratan Gupta | ef85eb9 | 2017-06-15 08:57:54 +0530 | [diff] [blame] | 4 | #include "system_configuration.hpp" |
Ratan Gupta | d16f88c | 2017-07-11 17:47:57 +0530 | [diff] [blame] | 5 | #include "dhcp_configuration.hpp" |
| 6 | #include <xyz/openbmc_project/Network/VLAN/Create/server.hpp> |
Michael Tritz | 29f2fd6 | 2017-05-22 15:27:26 -0500 | [diff] [blame] | 7 | #include <xyz/openbmc_project/Common/FactoryReset/server.hpp> |
Ratan Gupta | 05eb109 | 2017-04-14 16:33:53 +0530 | [diff] [blame] | 8 | #include <sdbusplus/bus.hpp> |
| 9 | |
| 10 | #include <list> |
Ratan Gupta | 6811f82 | 2017-04-14 16:34:56 +0530 | [diff] [blame] | 11 | #include <memory> |
Ratan Gupta | 05eb109 | 2017-04-14 16:33:53 +0530 | [diff] [blame] | 12 | #include <string> |
| 13 | #include <vector> |
Ratan Gupta | ef85eb9 | 2017-06-15 08:57:54 +0530 | [diff] [blame] | 14 | #include <experimental/filesystem> |
Ratan Gupta | 05eb109 | 2017-04-14 16:33:53 +0530 | [diff] [blame] | 15 | |
| 16 | namespace phosphor |
| 17 | { |
| 18 | namespace network |
| 19 | { |
| 20 | |
Ratan Gupta | ef85eb9 | 2017-06-15 08:57:54 +0530 | [diff] [blame] | 21 | namespace fs = std::experimental::filesystem; |
Ratan Gupta | 05eb109 | 2017-04-14 16:33:53 +0530 | [diff] [blame] | 22 | namespace details |
| 23 | { |
| 24 | |
Michael Tritz | 29f2fd6 | 2017-05-22 15:27:26 -0500 | [diff] [blame] | 25 | template <typename T, typename U> |
| 26 | using ServerObject = typename sdbusplus::server::object::object<T, U>; |
Ratan Gupta | 05eb109 | 2017-04-14 16:33:53 +0530 | [diff] [blame] | 27 | |
Michael Tritz | 29f2fd6 | 2017-05-22 15:27:26 -0500 | [diff] [blame] | 28 | using VLANCreateIface = details::ServerObject< |
| 29 | sdbusplus::xyz::openbmc_project::Network::VLAN::server::Create, |
| 30 | sdbusplus::xyz::openbmc_project::Common::server::FactoryReset>; |
Ratan Gupta | 05eb109 | 2017-04-14 16:33:53 +0530 | [diff] [blame] | 31 | |
Ratan Gupta | 05eb109 | 2017-04-14 16:33:53 +0530 | [diff] [blame] | 32 | } // namespace details |
| 33 | |
Ratan Gupta | 8ab1792 | 2017-05-25 13:07:05 +0530 | [diff] [blame] | 34 | class TestNetworkManager; //forward declaration |
| 35 | |
Ratan Gupta | 05eb109 | 2017-04-14 16:33:53 +0530 | [diff] [blame] | 36 | /** @class Manager |
| 37 | * @brief OpenBMC network manager implementation. |
| 38 | */ |
| 39 | class Manager : public details::VLANCreateIface |
| 40 | { |
| 41 | public: |
| 42 | Manager() = delete; |
| 43 | Manager(const Manager&) = delete; |
| 44 | Manager& operator=(const Manager&) = delete; |
| 45 | Manager(Manager&&) = delete; |
| 46 | Manager& operator=(Manager&&) = delete; |
| 47 | virtual ~Manager() = default; |
| 48 | |
| 49 | /** @brief Constructor to put object onto bus at a dbus path. |
| 50 | * @param[in] bus - Bus to attach to. |
| 51 | * @param[in] objPath - Path to attach at. |
| 52 | */ |
| 53 | Manager(sdbusplus::bus::bus& bus, const char* objPath); |
| 54 | |
Ratan Gupta | 82549cc | 2017-04-21 08:45:23 +0530 | [diff] [blame] | 55 | void vLAN(IntfName interfaceName, uint16_t id) override; |
Ratan Gupta | 05eb109 | 2017-04-14 16:33:53 +0530 | [diff] [blame] | 56 | |
Ratan Gupta | 4f1c18b | 2017-05-25 12:59:35 +0530 | [diff] [blame] | 57 | /** @brief write the network conf file with the in-memory objects. |
| 58 | */ |
| 59 | void writeToConfigurationFile(); |
| 60 | |
Ratan Gupta | 29b0e43 | 2017-05-25 12:51:40 +0530 | [diff] [blame] | 61 | /** @brief Fetch the interface and the ipaddress details |
| 62 | * from the system and create the ethernet interraces |
| 63 | * dbus object. |
| 64 | */ |
| 65 | void createInterfaces(); |
| 66 | |
Ratan Gupta | ef85eb9 | 2017-06-15 08:57:54 +0530 | [diff] [blame] | 67 | /** @brief create child interface object and the system conf object. |
Ratan Gupta | fc2c724 | 2017-05-29 08:46:06 +0530 | [diff] [blame] | 68 | */ |
Ratan Gupta | ef85eb9 | 2017-06-15 08:57:54 +0530 | [diff] [blame] | 69 | void createChildObjects(); |
| 70 | |
| 71 | /** @brief sets the network conf directory. |
| 72 | * @param[in] dirName - Absolute path of the directory. |
| 73 | */ |
| 74 | void setConfDir(const fs::path& dir); |
| 75 | |
Ratan Gupta | 05eb109 | 2017-04-14 16:33:53 +0530 | [diff] [blame] | 76 | private: |
Ratan Gupta | 05eb109 | 2017-04-14 16:33:53 +0530 | [diff] [blame] | 77 | |
Ratan Gupta | 70c7e5b | 2017-07-12 11:41:55 +0530 | [diff] [blame] | 78 | /** @brief write the dhcp section **/ |
| 79 | void writeDHCPSection(std::fstream& stream); |
| 80 | |
Ratan Gupta | 29b0e43 | 2017-05-25 12:51:40 +0530 | [diff] [blame] | 81 | /** @brief Persistent sdbusplus DBus bus connection. */ |
| 82 | sdbusplus::bus::bus& bus; |
| 83 | |
Ratan Gupta | 05eb109 | 2017-04-14 16:33:53 +0530 | [diff] [blame] | 84 | /** @brief Persistent map of EthernetInterface dbus objects and their names */ |
Ratan Gupta | 82549cc | 2017-04-21 08:45:23 +0530 | [diff] [blame] | 85 | std::map<IntfName, std::unique_ptr<EthernetInterface>> interfaces; |
Ratan Gupta | 05eb109 | 2017-04-14 16:33:53 +0530 | [diff] [blame] | 86 | |
Michael Tritz | 29f2fd6 | 2017-05-22 15:27:26 -0500 | [diff] [blame] | 87 | /** @brief BMC network reset - resets network configuration for BMC. */ |
| 88 | void reset() override; |
| 89 | |
Ratan Gupta | 34f96d6 | 2017-06-15 09:16:22 +0530 | [diff] [blame] | 90 | /** @brief read the DHCP value from the configuration file |
| 91 | * @param[in] intf - Interface name. |
| 92 | */ |
| 93 | bool getDHCPValue(const std::string& intf); |
| 94 | |
Ratan Gupta | 29b0e43 | 2017-05-25 12:51:40 +0530 | [diff] [blame] | 95 | /** @brief Path of Object. */ |
| 96 | std::string objectPath; |
| 97 | |
Ratan Gupta | ef85eb9 | 2017-06-15 08:57:54 +0530 | [diff] [blame] | 98 | /** @brief pointer to system conf object. */ |
| 99 | std::unique_ptr<SystemConfiguration> systemConf = nullptr; |
| 100 | |
Ratan Gupta | d16f88c | 2017-07-11 17:47:57 +0530 | [diff] [blame] | 101 | /** @brief pointer to dhcp conf object. */ |
| 102 | std::unique_ptr<dhcp::Configuration> dhcpConf = nullptr; |
| 103 | |
Ratan Gupta | ef85eb9 | 2017-06-15 08:57:54 +0530 | [diff] [blame] | 104 | /** @brief Network Configuration directory. */ |
| 105 | fs::path confDir; |
| 106 | |
Ratan Gupta | 8ab1792 | 2017-05-25 13:07:05 +0530 | [diff] [blame] | 107 | friend class TestNetworkManager; |
| 108 | |
Ratan Gupta | 05eb109 | 2017-04-14 16:33:53 +0530 | [diff] [blame] | 109 | }; |
| 110 | |
| 111 | } // namespace network |
| 112 | } // namespace phosphor |