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