blob: e1feda7d039b6083c4bb33e66a6bbb3155d8b175 [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
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{
32 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;
39
40 /** @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.
43 * @param[in] dhcpEnabled - DHCP enable value.
44 * @param[in] vlanID - vlan identifier.
45 * @param[in] intf - ethernet interface object.
46 * @param[in] manager - network manager object.
47 */
48 VlanInterface(sdbusplus::bus::bus& bus,
49 const std::string& objPath,
50 bool dhcpEnabled,
51 uint32_t vlanID,
52 EthernetInterface& intf,
53 Manager& manager);
54
Ratan Guptabc886292017-07-25 18:29:57 +053055 /** @brief Delete this d-bus object.
56 */
57 void delete_() override;
58
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053059 /** @brief writes the device configuration.
60 systemd reads this configuration file
61 and creates the vlan interface.*/
62 void writeDeviceFile();
63
Ratan Guptabd303b12017-08-18 17:10:07 +053064 /** @brief copy the mac address from the parent interface.*/
65 void updateMacAddress()
66 {
67 MacAddressIntf::mACAddress(parentInterface.mACAddress());
68 }
69
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053070 private:
71
72 /** @brief VLAN Identifier. */
73 using VlanIface::id;
74
75 EthernetInterface& parentInterface;
76
77 friend class TestVlanInterface;
78};
79
80} // namespace network
81} // namespace phosphor