blob: 2d8baaa13c9bd9fc4b7360550f23a6992e0b9d92 [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>
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053010#include <string>
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] dhcpEnabled - DHCP enable value.
45 * @param[in] vlanID - vlan identifier.
46 * @param[in] intf - ethernet interface object.
47 * @param[in] manager - network manager object.
Manojkiran Edaca8b91b2020-05-28 09:28:42 +053048 *
Manojkiran Edaca8b91b2020-05-28 09:28:42 +053049 * This constructor is called during loading the VLAN Interface
Gunnar Mills57d9c502018-09-14 14:42:34 -050050 */
Patrick Williamsc38b0712022-07-22 19:26:54 -050051 VlanInterface(sdbusplus::bus_t& bus, const std::string& objPath,
William A. Kennington IIIa520a392022-08-08 12:17:34 -070052 const config::Parser& config, DHCPConf dhcpEnabled,
53 bool nicEnabled, uint32_t vlanID, EthernetInterface& intf,
54 Manager& parent);
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053055
Gunnar Mills57d9c502018-09-14 14:42:34 -050056 /** @brief Delete this d-bus object.
57 */
58 void delete_() override;
Ratan Guptabc886292017-07-25 18:29:57 +053059
William A. Kennington IIIa2145bf2019-04-19 13:15:56 -070060 /** @brief sets the MAC address.
61 * @param[in] value - MAC address which needs to be set on the system.
62 * @returns macAddress of the interface or throws an error.
63 */
Patrick Williams6aef7692021-05-01 06:39:41 -050064 std::string macAddress(std::string value) override;
William A. Kennington IIIa2145bf2019-04-19 13:15:56 -070065
Gunnar Mills57d9c502018-09-14 14:42:34 -050066 /** @brief writes the device configuration.
67 systemd reads this configuration file
68 and creates the vlan interface.*/
69 void writeDeviceFile();
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053070
Gunnar Mills57d9c502018-09-14 14:42:34 -050071 private:
72 /** @brief VLAN Identifier. */
73 using VlanIface::id;
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053074
Gunnar Mills57d9c502018-09-14 14:42:34 -050075 EthernetInterface& parentInterface;
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053076
Gunnar Mills57d9c502018-09-14 14:42:34 -050077 friend class TestVlanInterface;
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053078};
79
80} // namespace network
81} // namespace phosphor