Ratan Gupta | 3d3e4fc | 2017-07-25 13:38:19 +0530 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "types.hpp" |
| 4 | |
Ratan Gupta | 5978dd1 | 2017-07-25 13:47:13 +0530 | [diff] [blame] | 5 | #include "ethernet_interface.hpp" |
Ratan Gupta | 3d3e4fc | 2017-07-25 13:38:19 +0530 | [diff] [blame] | 6 | #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 Gupta | 3d3e4fc | 2017-07-25 13:38:19 +0530 | [diff] [blame] | 13 | |
| 14 | namespace phosphor |
| 15 | { |
| 16 | namespace network |
| 17 | { |
| 18 | |
| 19 | class EthernetInterface; |
| 20 | class Manager; |
| 21 | |
| 22 | |
Ratan Gupta | bc88629 | 2017-07-25 18:29:57 +0530 | [diff] [blame] | 23 | using DeleteIface = sdbusplus::xyz::openbmc_project::Object::server::Delete; |
Ratan Gupta | 3d3e4fc | 2017-07-25 13:38:19 +0530 | [diff] [blame] | 24 | using VlanIface = sdbusplus::xyz::openbmc_project::Network::server::VLAN; |
Ratan Gupta | 3d3e4fc | 2017-07-25 13:38:19 +0530 | [diff] [blame] | 25 | |
| 26 | /** @class VlanInterface |
| 27 | * @brief OpenBMC vlan Interface implementation. |
| 28 | * @details A concrete implementation for the vlan interface |
| 29 | */ |
Ratan Gupta | 26e87a0 | 2017-08-18 01:08:40 +0530 | [diff] [blame] | 30 | class VlanInterface : public VlanIface, |
| 31 | public DeleteIface, |
| 32 | public EthernetInterface |
Ratan Gupta | 3d3e4fc | 2017-07-25 13:38:19 +0530 | [diff] [blame] | 33 | { |
| 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 Gupta | bc88629 | 2017-07-25 18:29:57 +0530 | [diff] [blame] | 57 | /** @brief Delete this d-bus object. |
| 58 | */ |
| 59 | void delete_() override; |
| 60 | |
Ratan Gupta | 3d3e4fc | 2017-07-25 13:38:19 +0530 | [diff] [blame] | 61 | /** @brief writes the device configuration. |
| 62 | systemd reads this configuration file |
| 63 | and creates the vlan interface.*/ |
| 64 | void writeDeviceFile(); |
| 65 | |
Ratan Gupta | bd303b1 | 2017-08-18 17:10:07 +0530 | [diff] [blame] | 66 | /** @brief copy the mac address from the parent interface.*/ |
| 67 | void updateMacAddress() |
| 68 | { |
| 69 | MacAddressIntf::mACAddress(parentInterface.mACAddress()); |
| 70 | } |
| 71 | |
Ratan Gupta | 3d3e4fc | 2017-07-25 13:38:19 +0530 | [diff] [blame] | 72 | 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 |