blob: 9d27e302a161b43a22edca7cbc7d3f69206a3de9 [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;
19
Ratan Guptabc886292017-07-25 18:29:57 +053020using DeleteIface = sdbusplus::xyz::openbmc_project::Object::server::Delete;
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053021using VlanIface = sdbusplus::xyz::openbmc_project::Network::server::VLAN;
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053022
23/** @class VlanInterface
24 * @brief OpenBMC vlan Interface implementation.
25 * @details A concrete implementation for the vlan interface
26 */
William A. Kennington IIId298f932022-10-17 14:31:38 -070027class VlanInterface : public EthernetInterface,
Ratan Gupta26e87a02017-08-18 01:08:40 +053028 public DeleteIface,
William A. Kennington IIId298f932022-10-17 14:31:38 -070029 public VlanIface
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053030{
Gunnar Mills57d9c502018-09-14 14:42:34 -050031 public:
32 VlanInterface() = delete;
33 VlanInterface(const VlanInterface&) = delete;
34 VlanInterface& operator=(const VlanInterface&) = delete;
35 VlanInterface(VlanInterface&&) = delete;
36 VlanInterface& operator=(VlanInterface&&) = delete;
37 virtual ~VlanInterface() = default;
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053038
Gunnar Mills57d9c502018-09-14 14:42:34 -050039 /** @brief Constructor to put object onto bus at a dbus path.
40 * @param[in] bus - Bus to attach to.
William A. Kennington IIId298f932022-10-17 14:31:38 -070041 * @param[in] manager - network manager object.
42 * @param[in] info - Interface information.
43 * @param[in] objRoot - Path to attach at.
William A. Kennington IIIa520a392022-08-08 12:17:34 -070044 * @param[in] config - The parsed configuation file.
Gunnar Mills57d9c502018-09-14 14:42:34 -050045 * @param[in] vlanID - vlan identifier.
William A. Kennington IIId298f932022-10-17 14:31:38 -070046 * @param[in] parent - ethernet interface object.
47 * @param[in] emitSignal - true if the object added signal needs to be
48 * send.
49 * @param[in] enabled - Override the lookup of nicEnabled
Manojkiran Edaca8b91b2020-05-28 09:28:42 +053050 *
Manojkiran Edaca8b91b2020-05-28 09:28:42 +053051 * This constructor is called during loading the VLAN Interface
Gunnar Mills57d9c502018-09-14 14:42:34 -050052 */
William A. Kennington IIId298f932022-10-17 14:31:38 -070053 VlanInterface(sdbusplus::bus_t& bus, Manager& manager,
54 const InterfaceInfo& info, std::string_view objRoot,
55 const config::Parser& config, uint16_t vlanID,
56 EthernetInterface& parent, bool emitSignal = true,
57 std::optional<bool> enabled = std::nullopt);
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053058
Gunnar Mills57d9c502018-09-14 14:42:34 -050059 /** @brief Delete this d-bus object.
60 */
61 void delete_() override;
Ratan Guptabc886292017-07-25 18:29:57 +053062
William A. Kennington IIIa2145bf2019-04-19 13:15:56 -070063 /** @brief sets the MAC address.
64 * @param[in] value - MAC address which needs to be set on the system.
65 * @returns macAddress of the interface or throws an error.
66 */
Patrick Williams6aef7692021-05-01 06:39:41 -050067 std::string macAddress(std::string value) override;
William A. Kennington IIIa2145bf2019-04-19 13:15:56 -070068
Gunnar Mills57d9c502018-09-14 14:42:34 -050069 /** @brief writes the device configuration.
70 systemd reads this configuration file
71 and creates the vlan interface.*/
72 void writeDeviceFile();
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053073
Gunnar Mills57d9c502018-09-14 14:42:34 -050074 private:
75 /** @brief VLAN Identifier. */
76 using VlanIface::id;
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053077
Gunnar Mills57d9c502018-09-14 14:42:34 -050078 EthernetInterface& parentInterface;
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053079
Gunnar Mills57d9c502018-09-14 14:42:34 -050080 friend class TestVlanInterface;
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053081};
82
83} // namespace network
84} // namespace phosphor