diff options
author | Ratan Gupta <ratagupt@in.ibm.com> | 2017-07-25 13:38:19 +0530 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2017-08-13 11:32:24 +0000 |
commit | 3d3e4fcbb1c7b09376e04b6203d1803d2cae60b1 (patch) | |
tree | c299808359e6adcf733bd90a8f369b273f21590c /vlan_interface.cpp | |
parent | eaefe587ad3df702bf201ae921e46b556352ed6d (diff) | |
download | phosphor-networkd-3d3e4fcbb1c7b09376e04b6203d1803d2cae60b1.tar.gz phosphor-networkd-3d3e4fcbb1c7b09376e04b6203d1803d2cae60b1.zip |
Implement the Vlan Interface
Change-Id: I6085868ba4e30bb9e1c6f6d9895a40ebff82804f
Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
Diffstat (limited to 'vlan_interface.cpp')
-rw-r--r-- | vlan_interface.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/vlan_interface.cpp b/vlan_interface.cpp new file mode 100644 index 0000000..f4224d4 --- /dev/null +++ b/vlan_interface.cpp @@ -0,0 +1,68 @@ +#include "config.h" +#include "ethernet_interface.hpp" +#include "vlan_interface.hpp" +#include "network_manager.hpp" + +#include <phosphor-logging/log.hpp> +#include "xyz/openbmc_project/Common/error.hpp" +#include <phosphor-logging/elog-errors.hpp> + +#include <string> +#include <algorithm> +#include <fstream> +#include <experimental/filesystem> + +namespace phosphor +{ +namespace network +{ + +using namespace phosphor::logging; +using namespace sdbusplus::xyz::openbmc_project::Common::Error; + +VlanInterface::VlanInterface(sdbusplus::bus::bus& bus, + const std::string& objPath, + bool dhcpEnabled, + uint32_t vlanID, + EthernetInterface& intf, + Manager& parent ) : + VlanIntfObject(bus, objPath.c_str(), true), + EthernetInterface(bus, objPath, dhcpEnabled, parent, false), + parentInterface(intf) +{ + id(vlanID); + VlanIface::interfaceName(EthernetInterface::interfaceName()); + + VlanIntfObject::emit_object_added(); +} + +void VlanInterface::writeDeviceFile() +{ + using namespace std::string_literals; + fs::path confPath = manager.getConfDir(); + std::string fileName = EthernetInterface::interfaceName() + ".netdev"s; + confPath /= fileName; + std::fstream stream; + try + { + stream.open(confPath.c_str(), std::fstream::out); + } + catch (std::ios_base::failure& e) + { + log<level::ERR>("Unable to open the VLAN device file", + entry("FILE=%s", confPath.c_str()), + entry("ERROR=%s", e.what())); + elog<InternalFailure>(); + + } + + stream << "[" << "NetDev" << "]\n"; + stream << "Name=" << EthernetInterface::interfaceName() << "\n"; + stream << "Kind=vlan" << "\n"; + stream << "[VLAN]" << "\n"; + stream << "Id=" << id() << "\n"; + stream.close(); +} + +}//namespace network +}//namespace phosphor |