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