blob: 7cdb61d14e5cdbbd47dc00218be55b1e02403edb [file] [log] [blame]
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +05301#pragma once
2
William A. Kennington IIIa520a392022-08-08 12:17:34 -07003#include "config_parser.hpp"
Ratan Gupta5978dd12017-07-25 13:47:13 +05304#include "ethernet_interface.hpp"
Patrick Venture189d44e2018-07-09 12:30:59 -07005#include "types.hpp"
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +05306#include "xyz/openbmc_project/Network/VLAN/server.hpp"
7
8#include <sdbusplus/bus.hpp>
9#include <sdbusplus/server/object.hpp>
Patrick Venture189d44e2018-07-09 12:30:59 -070010#include <xyz/openbmc_project/Object/Delete/server.hpp>
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053011
12namespace phosphor
13{
14namespace network
15{
16
17class EthernetInterface;
18class Manager;
William A. Kennington IIIfd862be2022-10-09 18:40:55 -070019namespace system
20{
21struct InterfaceInfo;
22}
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053023
Ratan Guptabc886292017-07-25 18:29:57 +053024using DeleteIface = sdbusplus::xyz::openbmc_project::Object::server::Delete;
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053025using VlanIface = sdbusplus::xyz::openbmc_project::Network::server::VLAN;
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053026
27/** @class VlanInterface
28 * @brief OpenBMC vlan Interface implementation.
29 * @details A concrete implementation for the vlan interface
30 */
William A. Kennington IIId298f932022-10-17 14:31:38 -070031class VlanInterface : public EthernetInterface,
Ratan Gupta26e87a02017-08-18 01:08:40 +053032 public DeleteIface,
William A. Kennington IIId298f932022-10-17 14:31:38 -070033 public VlanIface
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053034{
Gunnar Mills57d9c502018-09-14 14:42:34 -050035 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 Gupta3d3e4fc2017-07-25 13:38:19 +053042
Gunnar Mills57d9c502018-09-14 14:42:34 -050043 /** @brief Constructor to put object onto bus at a dbus path.
44 * @param[in] bus - Bus to attach to.
William A. Kennington IIId298f932022-10-17 14:31:38 -070045 * @param[in] manager - network manager object.
46 * @param[in] info - Interface information.
47 * @param[in] objRoot - Path to attach at.
William A. Kennington IIIa520a392022-08-08 12:17:34 -070048 * @param[in] config - The parsed configuation file.
Gunnar Mills57d9c502018-09-14 14:42:34 -050049 * @param[in] vlanID - vlan identifier.
William A. Kennington IIId298f932022-10-17 14:31:38 -070050 * @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 Edaca8b91b2020-05-28 09:28:42 +053054 *
Manojkiran Edaca8b91b2020-05-28 09:28:42 +053055 * This constructor is called during loading the VLAN Interface
Gunnar Mills57d9c502018-09-14 14:42:34 -050056 */
William A. Kennington IIId298f932022-10-17 14:31:38 -070057 VlanInterface(sdbusplus::bus_t& bus, Manager& manager,
William A. Kennington IIIfd862be2022-10-09 18:40:55 -070058 const system::InterfaceInfo& info, std::string_view objRoot,
William A. Kennington IIId298f932022-10-17 14:31:38 -070059 const config::Parser& config, uint16_t vlanID,
60 EthernetInterface& parent, bool emitSignal = true,
61 std::optional<bool> enabled = std::nullopt);
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053062
Gunnar Mills57d9c502018-09-14 14:42:34 -050063 /** @brief Delete this d-bus object.
64 */
65 void delete_() override;
Ratan Guptabc886292017-07-25 18:29:57 +053066
William A. Kennington IIIa2145bf2019-04-19 13:15:56 -070067 /** @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 Williams6aef7692021-05-01 06:39:41 -050071 std::string macAddress(std::string value) override;
William A. Kennington IIIa2145bf2019-04-19 13:15:56 -070072
Gunnar Mills57d9c502018-09-14 14:42:34 -050073 /** @brief writes the device configuration.
74 systemd reads this configuration file
75 and creates the vlan interface.*/
76 void writeDeviceFile();
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053077
Gunnar Mills57d9c502018-09-14 14:42:34 -050078 private:
79 /** @brief VLAN Identifier. */
80 using VlanIface::id;
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053081
Gunnar Mills57d9c502018-09-14 14:42:34 -050082 EthernetInterface& parentInterface;
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053083
Gunnar Mills57d9c502018-09-14 14:42:34 -050084 friend class TestVlanInterface;
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053085};
86
87} // namespace network
88} // namespace phosphor