blob: bc5a1c8cc09533114ef95e163f8750102f8e2adc [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>
William A. Kennington IIIbe3bd2f2022-10-11 14:11:27 -070010#include <stdplus/zstring.hpp>
Patrick Venture189d44e2018-07-09 12:30:59 -070011#include <xyz/openbmc_project/Object/Delete/server.hpp>
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053012
13namespace phosphor
14{
15namespace network
16{
17
18class EthernetInterface;
19class Manager;
20
Ratan Guptabc886292017-07-25 18:29:57 +053021using DeleteIface = sdbusplus::xyz::openbmc_project::Object::server::Delete;
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053022using VlanIface = sdbusplus::xyz::openbmc_project::Network::server::VLAN;
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053023
24/** @class VlanInterface
25 * @brief OpenBMC vlan Interface implementation.
26 * @details A concrete implementation for the vlan interface
27 */
Ratan Gupta26e87a02017-08-18 01:08:40 +053028class VlanInterface : public VlanIface,
29 public DeleteIface,
30 public EthernetInterface
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053031{
Gunnar Mills57d9c502018-09-14 14:42:34 -050032 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 Gupta3d3e4fc2017-07-25 13:38:19 +053039
Gunnar Mills57d9c502018-09-14 14:42:34 -050040 /** @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 IIIa520a392022-08-08 12:17:34 -070043 * @param[in] config - The parsed configuation file.
Gunnar Mills57d9c502018-09-14 14:42:34 -050044 * @param[in] vlanID - vlan identifier.
45 * @param[in] intf - ethernet interface object.
46 * @param[in] manager - network manager object.
Manojkiran Edaca8b91b2020-05-28 09:28:42 +053047 *
Manojkiran Edaca8b91b2020-05-28 09:28:42 +053048 * This constructor is called during loading the VLAN Interface
Gunnar Mills57d9c502018-09-14 14:42:34 -050049 */
William A. Kennington IIIbe3bd2f2022-10-11 14:11:27 -070050 VlanInterface(sdbusplus::bus_t& bus, stdplus::const_zstring objPath,
William A. Kennington III0caf2212022-08-18 18:15:51 -070051 const config::Parser& config, bool nicEnabled,
52 uint32_t vlanID, EthernetInterface& intf, Manager& parent);
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053053
Gunnar Mills57d9c502018-09-14 14:42:34 -050054 /** @brief Delete this d-bus object.
55 */
56 void delete_() override;
Ratan Guptabc886292017-07-25 18:29:57 +053057
William A. Kennington IIIa2145bf2019-04-19 13:15:56 -070058 /** @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 Williams6aef7692021-05-01 06:39:41 -050062 std::string macAddress(std::string value) override;
William A. Kennington IIIa2145bf2019-04-19 13:15:56 -070063
Gunnar Mills57d9c502018-09-14 14:42:34 -050064 /** @brief writes the device configuration.
65 systemd reads this configuration file
66 and creates the vlan interface.*/
67 void writeDeviceFile();
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053068
Gunnar Mills57d9c502018-09-14 14:42:34 -050069 private:
70 /** @brief VLAN Identifier. */
71 using VlanIface::id;
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053072
Gunnar Mills57d9c502018-09-14 14:42:34 -050073 EthernetInterface& parentInterface;
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053074
Gunnar Mills57d9c502018-09-14 14:42:34 -050075 friend class TestVlanInterface;
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053076};
77
78} // namespace network
79} // namespace phosphor