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