blob: 3f273b7e3fecb7eaf9fdd14c216ce0088920cc5c [file] [log] [blame]
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +05301#pragma once
2
3#include "types.hpp"
4
Ratan Gupta5978dd12017-07-25 13:47:13 +05305#include "ethernet_interface.hpp"
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +05306#include "xyz/openbmc_project/Object/Delete/server.hpp"
7#include "xyz/openbmc_project/Network/VLAN/server.hpp"
8
9#include <sdbusplus/bus.hpp>
10#include <sdbusplus/server/object.hpp>
11
12#include <string>
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053013
14namespace phosphor
15{
16namespace network
17{
18
19class EthernetInterface;
20class Manager;
21
22
Ratan Guptabc886292017-07-25 18:29:57 +053023using DeleteIface = sdbusplus::xyz::openbmc_project::Object::server::Delete;
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053024using VlanIface = sdbusplus::xyz::openbmc_project::Network::server::VLAN;
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053025
26/** @class VlanInterface
27 * @brief OpenBMC vlan Interface implementation.
28 * @details A concrete implementation for the vlan interface
29 */
Ratan Gupta26e87a02017-08-18 01:08:40 +053030class VlanInterface : public VlanIface,
31 public DeleteIface,
32 public EthernetInterface
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053033{
34 public:
35 VlanInterface() = delete;
36 VlanInterface(const VlanInterface&) = delete;
37 VlanInterface& operator=(const VlanInterface&) = delete;
38 VlanInterface(VlanInterface&&) = delete;
39 VlanInterface& operator=(VlanInterface&&) = delete;
40 virtual ~VlanInterface() = default;
41
42 /** @brief Constructor to put object onto bus at a dbus path.
43 * @param[in] bus - Bus to attach to.
44 * @param[in] objPath - Path to attach at.
45 * @param[in] dhcpEnabled - DHCP enable value.
46 * @param[in] vlanID - vlan identifier.
47 * @param[in] intf - ethernet interface object.
48 * @param[in] manager - network manager object.
49 */
50 VlanInterface(sdbusplus::bus::bus& bus,
51 const std::string& objPath,
52 bool dhcpEnabled,
53 uint32_t vlanID,
54 EthernetInterface& intf,
55 Manager& manager);
56
Ratan Guptabc886292017-07-25 18:29:57 +053057 /** @brief Delete this d-bus object.
58 */
59 void delete_() override;
60
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053061 /** @brief writes the device configuration.
62 systemd reads this configuration file
63 and creates the vlan interface.*/
64 void writeDeviceFile();
65
Ratan Guptabd303b12017-08-18 17:10:07 +053066 /** @brief copy the mac address from the parent interface.*/
67 void updateMacAddress()
68 {
69 MacAddressIntf::mACAddress(parentInterface.mACAddress());
70 }
71
Ratan Gupta3d3e4fc2017-07-25 13:38:19 +053072 private:
73
74 /** @brief VLAN Identifier. */
75 using VlanIface::id;
76
77 EthernetInterface& parentInterface;
78
79 friend class TestVlanInterface;
80};
81
82} // namespace network
83} // namespace phosphor