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