Ratan Gupta | 3d3e4fc | 2017-07-25 13:38:19 +0530 | [diff] [blame] | 1 | #pragma once |
| 2 | |
William A. Kennington III | a520a39 | 2022-08-08 12:17:34 -0700 | [diff] [blame] | 3 | #include "config_parser.hpp" |
Ratan Gupta | 5978dd1 | 2017-07-25 13:47:13 +0530 | [diff] [blame] | 4 | #include "ethernet_interface.hpp" |
Patrick Venture | 189d44e | 2018-07-09 12:30:59 -0700 | [diff] [blame] | 5 | #include "types.hpp" |
Ratan Gupta | 3d3e4fc | 2017-07-25 13:38:19 +0530 | [diff] [blame] | 6 | #include "xyz/openbmc_project/Network/VLAN/server.hpp" |
| 7 | |
| 8 | #include <sdbusplus/bus.hpp> |
| 9 | #include <sdbusplus/server/object.hpp> |
Patrick Venture | 189d44e | 2018-07-09 12:30:59 -0700 | [diff] [blame] | 10 | #include <xyz/openbmc_project/Object/Delete/server.hpp> |
Ratan Gupta | 3d3e4fc | 2017-07-25 13:38:19 +0530 | [diff] [blame] | 11 | |
| 12 | namespace phosphor |
| 13 | { |
| 14 | namespace network |
| 15 | { |
| 16 | |
| 17 | class EthernetInterface; |
| 18 | class Manager; |
William A. Kennington III | fd862be | 2022-10-09 18:40:55 -0700 | [diff] [blame] | 19 | namespace system |
| 20 | { |
| 21 | struct InterfaceInfo; |
| 22 | } |
Ratan Gupta | 3d3e4fc | 2017-07-25 13:38:19 +0530 | [diff] [blame] | 23 | |
Ratan Gupta | bc88629 | 2017-07-25 18:29:57 +0530 | [diff] [blame] | 24 | using DeleteIface = sdbusplus::xyz::openbmc_project::Object::server::Delete; |
Ratan Gupta | 3d3e4fc | 2017-07-25 13:38:19 +0530 | [diff] [blame] | 25 | using VlanIface = sdbusplus::xyz::openbmc_project::Network::server::VLAN; |
Ratan Gupta | 3d3e4fc | 2017-07-25 13:38:19 +0530 | [diff] [blame] | 26 | |
| 27 | /** @class VlanInterface |
| 28 | * @brief OpenBMC vlan Interface implementation. |
| 29 | * @details A concrete implementation for the vlan interface |
| 30 | */ |
William A. Kennington III | d298f93 | 2022-10-17 14:31:38 -0700 | [diff] [blame] | 31 | class VlanInterface : public EthernetInterface, |
Ratan Gupta | 26e87a0 | 2017-08-18 01:08:40 +0530 | [diff] [blame] | 32 | public DeleteIface, |
William A. Kennington III | d298f93 | 2022-10-17 14:31:38 -0700 | [diff] [blame] | 33 | public VlanIface |
Ratan Gupta | 3d3e4fc | 2017-07-25 13:38:19 +0530 | [diff] [blame] | 34 | { |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 35 | public: |
| 36 | VlanInterface() = delete; |
| 37 | VlanInterface(const VlanInterface&) = delete; |
| 38 | VlanInterface& operator=(const VlanInterface&) = delete; |
| 39 | VlanInterface(VlanInterface&&) = delete; |
| 40 | VlanInterface& operator=(VlanInterface&&) = delete; |
| 41 | virtual ~VlanInterface() = default; |
Ratan Gupta | 3d3e4fc | 2017-07-25 13:38:19 +0530 | [diff] [blame] | 42 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 43 | /** @brief Constructor to put object onto bus at a dbus path. |
| 44 | * @param[in] bus - Bus to attach to. |
William A. Kennington III | d298f93 | 2022-10-17 14:31:38 -0700 | [diff] [blame] | 45 | * @param[in] manager - network manager object. |
| 46 | * @param[in] info - Interface information. |
| 47 | * @param[in] objRoot - Path to attach at. |
William A. Kennington III | a520a39 | 2022-08-08 12:17:34 -0700 | [diff] [blame] | 48 | * @param[in] config - The parsed configuation file. |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 49 | * @param[in] vlanID - vlan identifier. |
William A. Kennington III | d298f93 | 2022-10-17 14:31:38 -0700 | [diff] [blame] | 50 | * @param[in] parent - ethernet interface object. |
| 51 | * @param[in] emitSignal - true if the object added signal needs to be |
| 52 | * send. |
| 53 | * @param[in] enabled - Override the lookup of nicEnabled |
Manojkiran Eda | ca8b91b | 2020-05-28 09:28:42 +0530 | [diff] [blame] | 54 | * |
Manojkiran Eda | ca8b91b | 2020-05-28 09:28:42 +0530 | [diff] [blame] | 55 | * This constructor is called during loading the VLAN Interface |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 56 | */ |
William A. Kennington III | d298f93 | 2022-10-17 14:31:38 -0700 | [diff] [blame] | 57 | VlanInterface(sdbusplus::bus_t& bus, Manager& manager, |
William A. Kennington III | fd862be | 2022-10-09 18:40:55 -0700 | [diff] [blame] | 58 | const system::InterfaceInfo& info, std::string_view objRoot, |
William A. Kennington III | d298f93 | 2022-10-17 14:31:38 -0700 | [diff] [blame] | 59 | const config::Parser& config, uint16_t vlanID, |
| 60 | EthernetInterface& parent, bool emitSignal = true, |
| 61 | std::optional<bool> enabled = std::nullopt); |
Ratan Gupta | 3d3e4fc | 2017-07-25 13:38:19 +0530 | [diff] [blame] | 62 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 63 | /** @brief Delete this d-bus object. |
| 64 | */ |
| 65 | void delete_() override; |
Ratan Gupta | bc88629 | 2017-07-25 18:29:57 +0530 | [diff] [blame] | 66 | |
William A. Kennington III | a2145bf | 2019-04-19 13:15:56 -0700 | [diff] [blame] | 67 | /** @brief sets the MAC address. |
| 68 | * @param[in] value - MAC address which needs to be set on the system. |
| 69 | * @returns macAddress of the interface or throws an error. |
| 70 | */ |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 71 | std::string macAddress(std::string value) override; |
William A. Kennington III | a2145bf | 2019-04-19 13:15:56 -0700 | [diff] [blame] | 72 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 73 | /** @brief writes the device configuration. |
| 74 | systemd reads this configuration file |
| 75 | and creates the vlan interface.*/ |
| 76 | void writeDeviceFile(); |
Ratan Gupta | 3d3e4fc | 2017-07-25 13:38:19 +0530 | [diff] [blame] | 77 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 78 | private: |
| 79 | /** @brief VLAN Identifier. */ |
| 80 | using VlanIface::id; |
Ratan Gupta | 3d3e4fc | 2017-07-25 13:38:19 +0530 | [diff] [blame] | 81 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 82 | EthernetInterface& parentInterface; |
Ratan Gupta | 3d3e4fc | 2017-07-25 13:38:19 +0530 | [diff] [blame] | 83 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 84 | friend class TestVlanInterface; |
Ratan Gupta | 3d3e4fc | 2017-07-25 13:38:19 +0530 | [diff] [blame] | 85 | }; |
| 86 | |
| 87 | } // namespace network |
| 88 | } // namespace phosphor |