Patrick Venture | 189d44e | 2018-07-09 12:30:59 -0700 | [diff] [blame] | 1 | #include "vlan_interface.hpp" |
| 2 | |
William A. Kennington III | 9c9f1b7 | 2022-08-18 17:55:29 -0700 | [diff] [blame] | 3 | #include "config_parser.hpp" |
Ratan Gupta | 3d3e4fc | 2017-07-25 13:38:19 +0530 | [diff] [blame] | 4 | #include "ethernet_interface.hpp" |
Ratan Gupta | 3d3e4fc | 2017-07-25 13:38:19 +0530 | [diff] [blame] | 5 | #include "network_manager.hpp" |
| 6 | |
Patrick Venture | 189d44e | 2018-07-09 12:30:59 -0700 | [diff] [blame] | 7 | #include <phosphor-logging/elog-errors.hpp> |
| 8 | #include <phosphor-logging/log.hpp> |
| 9 | #include <string> |
| 10 | #include <xyz/openbmc_project/Common/error.hpp> |
Ratan Gupta | 3d3e4fc | 2017-07-25 13:38:19 +0530 | [diff] [blame] | 11 | |
| 12 | namespace phosphor |
| 13 | { |
| 14 | namespace network |
| 15 | { |
| 16 | |
| 17 | using namespace phosphor::logging; |
| 18 | using namespace sdbusplus::xyz::openbmc_project::Common::Error; |
| 19 | |
William A. Kennington III | d298f93 | 2022-10-17 14:31:38 -0700 | [diff] [blame^] | 20 | VlanInterface::VlanInterface(sdbusplus::bus_t& bus, Manager& manager, |
| 21 | const InterfaceInfo& info, |
| 22 | std::string_view objRoot, |
| 23 | const config::Parser& config, uint16_t vlanID, |
| 24 | EthernetInterface& parent, bool emitSignal, |
| 25 | std::optional<bool> enabled) : |
| 26 | EthernetInterface(bus, manager, info, objRoot, config, emitSignal, enabled), |
| 27 | DeleteIface(bus, objPath.c_str()), VlanIface(bus, objPath.c_str()), |
| 28 | parentInterface(parent) |
Manojkiran Eda | ca8b91b | 2020-05-28 09:28:42 +0530 | [diff] [blame] | 29 | { |
| 30 | id(vlanID); |
Manojkiran Eda | ca8b91b | 2020-05-28 09:28:42 +0530 | [diff] [blame] | 31 | emit_object_added(); |
| 32 | } |
| 33 | |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 34 | std::string VlanInterface::macAddress(std::string) |
William A. Kennington III | a2145bf | 2019-04-19 13:15:56 -0700 | [diff] [blame] | 35 | { |
| 36 | log<level::ERR>("Tried to set MAC address on VLAN"); |
| 37 | elog<InternalFailure>(); |
| 38 | } |
| 39 | |
Ratan Gupta | 3d3e4fc | 2017-07-25 13:38:19 +0530 | [diff] [blame] | 40 | void VlanInterface::writeDeviceFile() |
| 41 | { |
William A. Kennington III | 9c9f1b7 | 2022-08-18 17:55:29 -0700 | [diff] [blame] | 42 | config::Parser config; |
| 43 | auto& netdev = config.map["NetDev"].emplace_back(); |
| 44 | netdev["Name"].emplace_back(EthernetInterface::interfaceName()); |
| 45 | netdev["Kind"].emplace_back("vlan"); |
| 46 | config.map["VLAN"].emplace_back()["Id"].emplace_back(std::to_string(id())); |
| 47 | config.writeFile(config::pathForIntfDev( |
| 48 | manager.getConfDir(), EthernetInterface::interfaceName())); |
Ratan Gupta | 3d3e4fc | 2017-07-25 13:38:19 +0530 | [diff] [blame] | 49 | } |
| 50 | |
Ratan Gupta | bc88629 | 2017-07-25 18:29:57 +0530 | [diff] [blame] | 51 | void VlanInterface::delete_() |
| 52 | { |
| 53 | parentInterface.deleteVLANObject(EthernetInterface::interfaceName()); |
| 54 | } |
| 55 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 56 | } // namespace network |
| 57 | } // namespace phosphor |