summaryrefslogtreecommitdiffstats
path: root/vlan_interface.hpp
blob: 3f273b7e3fecb7eaf9fdd14c216ce0088920cc5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#pragma once

#include "types.hpp"

#include "ethernet_interface.hpp"
#include "xyz/openbmc_project/Object/Delete/server.hpp"
#include "xyz/openbmc_project/Network/VLAN/server.hpp"

#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/object.hpp>

#include <string>

namespace phosphor
{
namespace network
{

class EthernetInterface;
class Manager;


using DeleteIface = sdbusplus::xyz::openbmc_project::Object::server::Delete;
using VlanIface = sdbusplus::xyz::openbmc_project::Network::server::VLAN;

/** @class VlanInterface
 *  @brief OpenBMC vlan Interface implementation.
 *  @details A concrete implementation for the vlan interface
 */
class VlanInterface : public VlanIface,
                      public DeleteIface,
                      public EthernetInterface
{
    public:
        VlanInterface() = delete;
        VlanInterface(const VlanInterface&) = delete;
        VlanInterface& operator=(const VlanInterface&) = delete;
        VlanInterface(VlanInterface&&) = delete;
        VlanInterface& operator=(VlanInterface&&) = delete;
        virtual ~VlanInterface() = default;

        /** @brief Constructor to put object onto bus at a dbus path.
         *  @param[in] bus - Bus to attach to.
         *  @param[in] objPath - Path to attach at.
         *  @param[in] dhcpEnabled - DHCP enable value.
         *  @param[in] vlanID - vlan identifier.
         *  @param[in] intf - ethernet interface object.
         *  @param[in] manager - network manager object.
         */
        VlanInterface(sdbusplus::bus::bus& bus,
                      const std::string& objPath,
                      bool dhcpEnabled,
                      uint32_t vlanID,
                      EthernetInterface& intf,
                      Manager& manager);

        /** @brief Delete this d-bus object.
         */
        void delete_() override;

        /** @brief writes the device configuration.
                   systemd reads this configuration file
                   and creates the vlan interface.*/
        void writeDeviceFile();

        /** @brief copy the mac address from the parent interface.*/
        void updateMacAddress()
        {
            MacAddressIntf::mACAddress(parentInterface.mACAddress());
        }

    private:

        /** @brief VLAN Identifier. */
        using VlanIface::id;

        EthernetInterface& parentInterface;

        friend class TestVlanInterface;
};

} // namespace network
} // namespace phosphor
OpenPOWER on IntegriCloud