blob: 953a01bb64be18d133d0e867a1f3b1271bed523b [file] [log] [blame]
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +05301#pragma once
2
Ratan Gupta5978dd12017-07-25 13:47:13 +05303#include "ethernet_interface.hpp"
Patrick Venture189d44e2018-07-09 12:30:59 -07004#include "types.hpp"
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +05305#include "xyz/openbmc_project/Network/VLAN/server.hpp"
6
7#include <sdbusplus/bus.hpp>
8#include <sdbusplus/server/object.hpp>
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +05309#include <string>
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 */
Ratan Gupta26e87a02017-08-18 01:08:40 +053027class VlanInterface : public VlanIface,
28 public DeleteIface,
29 public EthernetInterface
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.
41 * @param[in] objPath - Path to attach at.
42 * @param[in] dhcpEnabled - DHCP enable value.
43 * @param[in] vlanID - vlan identifier.
44 * @param[in] intf - ethernet interface object.
45 * @param[in] manager - network manager object.
Manojkiran Edaca8b91b2020-05-28 09:28:42 +053046 *
Manojkiran Edaca8b91b2020-05-28 09:28:42 +053047 * This constructor is called during loading the VLAN Interface
Gunnar Mills57d9c502018-09-14 14:42:34 -050048 */
Patrick Williamsc38b0712022-07-22 19:26:54 -050049 VlanInterface(sdbusplus::bus_t& bus, const std::string& objPath,
Johnathan Mantey817012a2020-01-30 15:07:39 -080050 DHCPConf dhcpEnabled, bool nicEnabled, uint32_t vlanID,
51 EthernetInterface& intf, Manager& parent);
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053052
Gunnar Mills57d9c502018-09-14 14:42:34 -050053 /** @brief Delete this d-bus object.
54 */
55 void delete_() override;
Ratan Guptabc886292017-07-25 18:29:57 +053056
William A. Kennington IIIa2145bf2019-04-19 13:15:56 -070057 /** @brief sets the MAC address.
58 * @param[in] value - MAC address which needs to be set on the system.
59 * @returns macAddress of the interface or throws an error.
60 */
Patrick Williams6aef7692021-05-01 06:39:41 -050061 std::string macAddress(std::string value) override;
William A. Kennington IIIa2145bf2019-04-19 13:15:56 -070062
Gunnar Mills57d9c502018-09-14 14:42:34 -050063 /** @brief writes the device configuration.
64 systemd reads this configuration file
65 and creates the vlan interface.*/
66 void writeDeviceFile();
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053067
Gunnar Mills57d9c502018-09-14 14:42:34 -050068 private:
69 /** @brief VLAN Identifier. */
70 using VlanIface::id;
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053071
Gunnar Mills57d9c502018-09-14 14:42:34 -050072 EthernetInterface& parentInterface;
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053073
Gunnar Mills57d9c502018-09-14 14:42:34 -050074 friend class TestVlanInterface;
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053075};
76
77} // namespace network
78} // namespace phosphor