Ratan Gupta | 8c83493 | 2017-04-14 16:30:24 +0530 | [diff] [blame] | 1 | #pragma once |
William A. Kennington III | 9a20a6e | 2022-10-05 13:41:12 -0700 | [diff] [blame] | 2 | #include "ipaddress.hpp" |
| 3 | #include "neighbor.hpp" |
Ratan Gupta | 82549cc | 2017-04-21 08:45:23 +0530 | [diff] [blame] | 4 | #include "types.hpp" |
Ratan Gupta | 82549cc | 2017-04-21 08:45:23 +0530 | [diff] [blame] | 5 | #include "xyz/openbmc_project/Network/IP/Create/server.hpp" |
William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 6 | #include "xyz/openbmc_project/Network/Neighbor/CreateStatic/server.hpp" |
Ratan Gupta | 8c83493 | 2017-04-14 16:30:24 +0530 | [diff] [blame] | 7 | |
William A. Kennington III | d298f93 | 2022-10-17 14:31:38 -0700 | [diff] [blame] | 8 | #include <optional> |
Ratan Gupta | 8c83493 | 2017-04-14 16:30:24 +0530 | [diff] [blame] | 9 | #include <sdbusplus/bus.hpp> |
| 10 | #include <sdbusplus/server/object.hpp> |
William A. Kennington III | be3bd2f | 2022-10-11 14:11:27 -0700 | [diff] [blame] | 11 | #include <stdplus/zstring_view.hpp> |
Ratan Gupta | 8c83493 | 2017-04-14 16:30:24 +0530 | [diff] [blame] | 12 | #include <string> |
William A. Kennington III | 95530ec | 2022-08-19 01:44:39 -0700 | [diff] [blame] | 13 | #include <vector> |
Patrick Venture | 189d44e | 2018-07-09 12:30:59 -0700 | [diff] [blame] | 14 | #include <xyz/openbmc_project/Collection/DeleteAll/server.hpp> |
| 15 | #include <xyz/openbmc_project/Network/EthernetInterface/server.hpp> |
| 16 | #include <xyz/openbmc_project/Network/MACAddress/server.hpp> |
Ratan Gupta | 8c83493 | 2017-04-14 16:30:24 +0530 | [diff] [blame] | 17 | |
| 18 | namespace phosphor |
| 19 | { |
| 20 | namespace network |
| 21 | { |
Ratan Gupta | 8c83493 | 2017-04-14 16:30:24 +0530 | [diff] [blame] | 22 | |
Patrick Williams | c38b071 | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 23 | using Ifaces = sdbusplus::server::object_t< |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 24 | sdbusplus::xyz::openbmc_project::Network::server::EthernetInterface, |
| 25 | sdbusplus::xyz::openbmc_project::Network::server::MACAddress, |
| 26 | sdbusplus::xyz::openbmc_project::Network::IP::server::Create, |
William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 27 | sdbusplus::xyz::openbmc_project::Network::Neighbor::server::CreateStatic, |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 28 | sdbusplus::xyz::openbmc_project::Collection::server::DeleteAll>; |
Ratan Gupta | 8c83493 | 2017-04-14 16:30:24 +0530 | [diff] [blame] | 29 | |
Ratan Gupta | 82549cc | 2017-04-21 08:45:23 +0530 | [diff] [blame] | 30 | using IP = sdbusplus::xyz::openbmc_project::Network::server::IP; |
Ratan Gupta | 87c1398 | 2017-06-15 09:27:27 +0530 | [diff] [blame] | 31 | |
| 32 | using EthernetInterfaceIntf = |
| 33 | sdbusplus::xyz::openbmc_project::Network::server::EthernetInterface; |
Ratan Gupta | bd303b1 | 2017-08-18 17:10:07 +0530 | [diff] [blame] | 34 | using MacAddressIntf = |
| 35 | sdbusplus::xyz::openbmc_project::Network::server::MACAddress; |
Ratan Gupta | 87c1398 | 2017-06-15 09:27:27 +0530 | [diff] [blame] | 36 | |
Ratan Gupta | 497c0c9 | 2017-08-22 19:15:59 +0530 | [diff] [blame] | 37 | using ServerList = std::vector<std::string>; |
raviteja-b | ce37956 | 2019-03-28 05:59:36 -0500 | [diff] [blame] | 38 | using ObjectPath = sdbusplus::message::object_path; |
Ratan Gupta | 497c0c9 | 2017-08-22 19:15:59 +0530 | [diff] [blame] | 39 | |
William A. Kennington III | 9a20a6e | 2022-10-05 13:41:12 -0700 | [diff] [blame] | 40 | class Manager; |
Ratan Gupta | 8c83493 | 2017-04-14 16:30:24 +0530 | [diff] [blame] | 41 | |
Ratan Gupta | 47722dc | 2017-05-26 18:32:23 +0530 | [diff] [blame] | 42 | class TestEthernetInterface; |
| 43 | |
Ratan Gupta | 5978dd1 | 2017-07-25 13:47:13 +0530 | [diff] [blame] | 44 | class VlanInterface; |
| 45 | |
William A. Kennington III | 95530ec | 2022-08-19 01:44:39 -0700 | [diff] [blame] | 46 | namespace config |
| 47 | { |
| 48 | class Parser; |
| 49 | } |
William A. Kennington III | fd862be | 2022-10-09 18:40:55 -0700 | [diff] [blame] | 50 | namespace system |
William A. Kennington III | d298f93 | 2022-10-17 14:31:38 -0700 | [diff] [blame] | 51 | { |
William A. Kennington III | fd862be | 2022-10-09 18:40:55 -0700 | [diff] [blame] | 52 | struct InterfaceInfo; |
William A. Kennington III | d298f93 | 2022-10-17 14:31:38 -0700 | [diff] [blame] | 53 | }; |
| 54 | |
Ratan Gupta | 8c83493 | 2017-04-14 16:30:24 +0530 | [diff] [blame] | 55 | /** @class EthernetInterface |
| 56 | * @brief OpenBMC Ethernet Interface implementation. |
| 57 | * @details A concrete implementation for the |
| 58 | * xyz.openbmc_project.Network.EthernetInterface DBus API. |
| 59 | */ |
Ratan Gupta | 82549cc | 2017-04-21 08:45:23 +0530 | [diff] [blame] | 60 | class EthernetInterface : public Ifaces |
Ratan Gupta | 8c83493 | 2017-04-14 16:30:24 +0530 | [diff] [blame] | 61 | { |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 62 | public: |
| 63 | EthernetInterface() = delete; |
| 64 | EthernetInterface(const EthernetInterface&) = delete; |
| 65 | EthernetInterface& operator=(const EthernetInterface&) = delete; |
| 66 | EthernetInterface(EthernetInterface&&) = delete; |
| 67 | EthernetInterface& operator=(EthernetInterface&&) = delete; |
| 68 | virtual ~EthernetInterface() = default; |
Ratan Gupta | 8c83493 | 2017-04-14 16:30:24 +0530 | [diff] [blame] | 69 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 70 | /** @brief Constructor to put object onto bus at a dbus path. |
| 71 | * @param[in] bus - Bus to attach to. |
William A. Kennington III | d298f93 | 2022-10-17 14:31:38 -0700 | [diff] [blame] | 72 | * @param[in] manager - parent object. |
| 73 | * @param[in] info - Interface information. |
| 74 | * @param[in] objRoot - Path to attach at. |
William A. Kennington III | a520a39 | 2022-08-08 12:17:34 -0700 | [diff] [blame] | 75 | * @param[in] config - The parsed configuation file. |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 76 | * @param[in] emitSignal - true if the object added signal needs to be |
| 77 | * send. |
William A. Kennington III | 26275a3 | 2021-07-13 20:32:42 -0700 | [diff] [blame] | 78 | * @param[in] enabled - Override the lookup of nicEnabled |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 79 | */ |
William A. Kennington III | d298f93 | 2022-10-17 14:31:38 -0700 | [diff] [blame] | 80 | EthernetInterface(sdbusplus::bus_t& bus, Manager& manager, |
William A. Kennington III | fd862be | 2022-10-09 18:40:55 -0700 | [diff] [blame] | 81 | const system::InterfaceInfo& info, |
| 82 | std::string_view objRoot, const config::Parser& config, |
| 83 | bool emitSignal = true, |
William A. Kennington III | 26275a3 | 2021-07-13 20:32:42 -0700 | [diff] [blame] | 84 | std::optional<bool> enabled = std::nullopt); |
Ratan Gupta | 82549cc | 2017-04-21 08:45:23 +0530 | [diff] [blame] | 85 | |
William A. Kennington III | d298f93 | 2022-10-17 14:31:38 -0700 | [diff] [blame] | 86 | /** @brief Updates the interface information based on new InterfaceInfo */ |
William A. Kennington III | fd862be | 2022-10-09 18:40:55 -0700 | [diff] [blame] | 87 | void updateInfo(const system::InterfaceInfo& info); |
William A. Kennington III | d298f93 | 2022-10-17 14:31:38 -0700 | [diff] [blame] | 88 | |
Asmitha Karunanithi | 003b8b7 | 2022-01-06 04:17:59 -0600 | [diff] [blame] | 89 | /** @brief Function used to load the ntpservers |
| 90 | */ |
| 91 | void loadNTPServers(const config::Parser& config); |
| 92 | |
Manojkiran Eda | acd6dd5 | 2019-10-15 15:00:51 +0530 | [diff] [blame] | 93 | /** @brief Function used to load the nameservers. |
| 94 | */ |
William A. Kennington III | a520a39 | 2022-08-08 12:17:34 -0700 | [diff] [blame] | 95 | void loadNameServers(const config::Parser& config); |
Manojkiran Eda | acd6dd5 | 2019-10-15 15:00:51 +0530 | [diff] [blame] | 96 | |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 97 | /** @brief Function to create ipAddress dbus object. |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 98 | * @param[in] addressType - Type of ip address. |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 99 | * @param[in] ipAddress- IP address. |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 100 | * @param[in] prefixLength - Length of prefix. |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 101 | */ |
Ratan Gupta | 82549cc | 2017-04-21 08:45:23 +0530 | [diff] [blame] | 102 | |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 103 | ObjectPath ip(IP::Protocol addressType, std::string ipAddress, |
William A. Kennington III | e25f8b4 | 2022-10-11 14:43:28 -0700 | [diff] [blame] | 104 | uint8_t prefixLength, std::string) override; |
Ratan Gupta | 8c83493 | 2017-04-14 16:30:24 +0530 | [diff] [blame] | 105 | |
William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 106 | /** @brief Function to create static neighbor dbus object. |
| 107 | * @param[in] ipAddress - IP address. |
| 108 | * @param[in] macAddress - Low level MAC address. |
| 109 | */ |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 110 | ObjectPath neighbor(std::string ipAddress, std::string macAddress) override; |
William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 111 | |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 112 | /* @brief delete the dbus object of the given ipAddress. |
| 113 | * @param[in] ipAddress - IP address. |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 114 | */ |
William A. Kennington III | be3bd2f | 2022-10-11 14:11:27 -0700 | [diff] [blame] | 115 | void deleteObject(std::string_view ipAddress); |
Ratan Gupta | 8c83493 | 2017-04-14 16:30:24 +0530 | [diff] [blame] | 116 | |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 117 | /* @brief delete the dbus object of the given ipAddress. |
| 118 | * @param[in] ipAddress - IP address. |
William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 119 | */ |
William A. Kennington III | be3bd2f | 2022-10-11 14:11:27 -0700 | [diff] [blame] | 120 | void deleteStaticNeighborObject(std::string_view ipAddress); |
William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 121 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 122 | /* @brief delete the vlan dbus object of the given interface. |
| 123 | * Also deletes the device file and the network file. |
| 124 | * @param[in] interface - VLAN Interface. |
| 125 | */ |
William A. Kennington III | be3bd2f | 2022-10-11 14:11:27 -0700 | [diff] [blame] | 126 | void deleteVLANObject(stdplus::zstring_view interface); |
Ratan Gupta | bc88629 | 2017-07-25 18:29:57 +0530 | [diff] [blame] | 127 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 128 | /* @brief creates the dbus object(IPaddres) given in the address list. |
| 129 | * @param[in] addrs - address list for which dbus objects needs |
| 130 | * to create. |
| 131 | */ |
| 132 | void createIPAddressObjects(); |
Ratan Gupta | 29b0e43 | 2017-05-25 12:51:40 +0530 | [diff] [blame] | 133 | |
William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 134 | /* @brief creates the dbus object(Neighbor) given in the neighbor list. |
| 135 | */ |
| 136 | void createStaticNeighborObjects(); |
| 137 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 138 | /* @brief Gets all the ip addresses. |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 139 | * @returns the list of ipAddress. |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 140 | */ |
William A. Kennington III | 9a20a6e | 2022-10-05 13:41:12 -0700 | [diff] [blame] | 141 | inline const auto& getAddresses() const |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 142 | { |
| 143 | return addrs; |
| 144 | } |
Ratan Gupta | 8c83493 | 2017-04-14 16:30:24 +0530 | [diff] [blame] | 145 | |
William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 146 | /* @brief Gets all the static neighbor entries. |
| 147 | * @returns Static neighbor map. |
| 148 | */ |
William A. Kennington III | 9a20a6e | 2022-10-05 13:41:12 -0700 | [diff] [blame] | 149 | inline const auto& getStaticNeighbors() const |
William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 150 | { |
| 151 | return staticNeighbors; |
| 152 | } |
| 153 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 154 | /** Set value of DHCPEnabled */ |
William A. Kennington III | 8060c0d | 2022-08-18 19:19:34 -0700 | [diff] [blame] | 155 | DHCPConf dhcpEnabled() const override; |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 156 | DHCPConf dhcpEnabled(DHCPConf value) override; |
William A. Kennington III | 8060c0d | 2022-08-18 19:19:34 -0700 | [diff] [blame] | 157 | using EthernetInterfaceIntf::dhcp4; |
| 158 | bool dhcp4(bool value) override; |
| 159 | using EthernetInterfaceIntf::dhcp6; |
| 160 | bool dhcp6(bool value) override; |
Ratan Gupta | 87c1398 | 2017-06-15 09:27:27 +0530 | [diff] [blame] | 161 | |
Johnathan Mantey | faa72e5 | 2020-01-08 10:38:58 -0800 | [diff] [blame] | 162 | /** Retrieve Link State */ |
| 163 | bool linkUp() const override; |
| 164 | |
Tejas Patil | 2c0fc56 | 2021-08-03 19:13:46 +0530 | [diff] [blame] | 165 | /** Retrieve MTU Size */ |
| 166 | size_t mtu() const override; |
| 167 | |
| 168 | /** Set size of MTU */ |
| 169 | size_t mtu(size_t value) override; |
| 170 | |
Johnathan Mantey | d0679f9 | 2019-10-29 16:20:28 -0700 | [diff] [blame] | 171 | /** Set value of NICEnabled */ |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 172 | bool nicEnabled(bool value) override; |
Johnathan Mantey | d0679f9 | 2019-10-29 16:20:28 -0700 | [diff] [blame] | 173 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 174 | /** @brief sets the MAC address. |
| 175 | * @param[in] value - MAC address which needs to be set on the system. |
| 176 | * @returns macAddress of the interface or throws an error. |
| 177 | */ |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 178 | std::string macAddress(std::string value) override; |
Ratan Gupta | bd303b1 | 2017-08-18 17:10:07 +0530 | [diff] [blame] | 179 | |
Johnathan Mantey | 5b023f5 | 2019-06-24 16:06:37 -0700 | [diff] [blame] | 180 | /** @brief check conf file for Router Advertisements |
| 181 | * |
| 182 | */ |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 183 | bool ipv6AcceptRA(bool value) override; |
William A. Kennington III | 8060c0d | 2022-08-18 19:19:34 -0700 | [diff] [blame] | 184 | using EthernetInterfaceIntf::ipv6AcceptRA; |
Johnathan Mantey | 5b023f5 | 2019-06-24 16:06:37 -0700 | [diff] [blame] | 185 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 186 | /** @brief sets the NTP servers. |
| 187 | * @param[in] value - vector of NTP servers. |
| 188 | */ |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 189 | ServerList ntpServers(ServerList value) override; |
Ratan Gupta | 497c0c9 | 2017-08-22 19:15:59 +0530 | [diff] [blame] | 190 | |
Asmitha Karunanithi | 003b8b7 | 2022-01-06 04:17:59 -0600 | [diff] [blame] | 191 | /** @brief sets the static NTP servers. |
| 192 | * @param[in] value - vector of NTP servers. |
| 193 | */ |
| 194 | ServerList staticNTPServers(ServerList value) override; |
| 195 | |
Manojkiran Eda | acd6dd5 | 2019-10-15 15:00:51 +0530 | [diff] [blame] | 196 | /** @brief sets the Static DNS/nameservers. |
| 197 | * @param[in] value - vector of DNS servers. |
| 198 | */ |
| 199 | |
| 200 | ServerList staticNameServers(ServerList value) override; |
| 201 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 202 | /** @brief create Vlan interface. |
| 203 | * @param[in] id- VLAN identifier. |
| 204 | */ |
William A. Kennington III | d298f93 | 2022-10-17 14:31:38 -0700 | [diff] [blame] | 205 | ObjectPath createVLAN(uint16_t id); |
Ratan Gupta | 5978dd1 | 2017-07-25 13:47:13 +0530 | [diff] [blame] | 206 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 207 | /** @brief load the vlan info from the system |
| 208 | * and creates the ip address dbus objects. |
| 209 | * @param[in] vlanID- VLAN identifier. |
| 210 | */ |
William A. Kennington III | fd862be | 2022-10-09 18:40:55 -0700 | [diff] [blame] | 211 | void loadVLAN(std::string_view objRoot, uint16_t vlanID, |
| 212 | system::InterfaceInfo&& info); |
Ratan Gupta | 92bc2fe | 2017-07-26 22:40:21 +0530 | [diff] [blame] | 213 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 214 | /** @brief write the network conf file with the in-memory objects. |
| 215 | */ |
| 216 | void writeConfigurationFile(); |
Ratan Gupta | 2b10653 | 2017-07-25 16:05:02 +0530 | [diff] [blame] | 217 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 218 | /** @brief delete all dbus objects. |
| 219 | */ |
| 220 | void deleteAll(); |
Ratan Gupta | e9c9b81 | 2017-09-22 17:15:37 +0530 | [diff] [blame] | 221 | |
Ravi Teja | a5a0944 | 2020-07-17 00:57:33 -0500 | [diff] [blame] | 222 | /** @brief set the default v4 gateway of the interface. |
| 223 | * @param[in] gateway - default v4 gateway of the interface. |
| 224 | */ |
| 225 | std::string defaultGateway(std::string gateway) override; |
| 226 | |
| 227 | /** @brief set the default v6 gateway of the interface. |
| 228 | * @param[in] gateway - default v6 gateway of the interface. |
| 229 | */ |
| 230 | std::string defaultGateway6(std::string gateway) override; |
| 231 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 232 | using EthernetInterfaceIntf::interfaceName; |
Johnathan Mantey | faa72e5 | 2020-01-08 10:38:58 -0800 | [diff] [blame] | 233 | using EthernetInterfaceIntf::linkUp; |
Tejas Patil | 2c0fc56 | 2021-08-03 19:13:46 +0530 | [diff] [blame] | 234 | using EthernetInterfaceIntf::mtu; |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 235 | using EthernetInterfaceIntf::nicEnabled; |
| 236 | using MacAddressIntf::macAddress; |
Ratan Gupta | 5978dd1 | 2017-07-25 13:47:13 +0530 | [diff] [blame] | 237 | |
Ravi Teja | a5a0944 | 2020-07-17 00:57:33 -0500 | [diff] [blame] | 238 | using EthernetInterfaceIntf::defaultGateway; |
| 239 | using EthernetInterfaceIntf::defaultGateway6; |
Ratan Gupta | 6dec390f | 2017-08-20 15:28:12 +0530 | [diff] [blame] | 240 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 241 | protected: |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 242 | /* @brief delete the vlan interface from system. |
| 243 | * @param[in] interface - vlan Interface. |
| 244 | */ |
William A. Kennington III | be3bd2f | 2022-10-11 14:11:27 -0700 | [diff] [blame] | 245 | void deleteVLANFromSystem(stdplus::zstring_view interface); |
Ratan Gupta | e9c9b81 | 2017-09-22 17:15:37 +0530 | [diff] [blame] | 246 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 247 | /** @brief construct the ip address dbus object path. |
| 248 | * @param[in] addressType - Type of ip address. |
Patrick Williams | 6aef769 | 2021-05-01 06:39:41 -0500 | [diff] [blame] | 249 | * @param[in] ipAddress - IP address. |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 250 | * @param[in] prefixLength - Length of prefix. |
Lei YU | 3402757 | 2021-08-11 15:23:52 +0800 | [diff] [blame] | 251 | * @param[in] origin - The origin entry of the IP::Address |
Ratan Gupta | 65e5abe | 2017-05-23 13:20:44 +0530 | [diff] [blame] | 252 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 253 | * @return path of the address object. |
| 254 | */ |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 255 | std::string generateObjectPath(IP::Protocol addressType, |
William A. Kennington III | be3bd2f | 2022-10-11 14:11:27 -0700 | [diff] [blame] | 256 | std::string_view ipAddress, |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 257 | uint8_t prefixLength, |
Lei YU | 3402757 | 2021-08-11 15:23:52 +0800 | [diff] [blame] | 258 | IP::AddressOrigin origin) const; |
Ratan Gupta | 82549cc | 2017-04-21 08:45:23 +0530 | [diff] [blame] | 259 | |
William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 260 | std::string |
William A. Kennington III | be3bd2f | 2022-10-11 14:11:27 -0700 | [diff] [blame] | 261 | generateStaticNeighborObjectPath(std::string_view ipAddress, |
| 262 | std::string_view macAddress) const; |
William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 263 | |
Asmitha Karunanithi | 003b8b7 | 2022-01-06 04:17:59 -0600 | [diff] [blame] | 264 | /** @brief get the NTP server list from the timsyncd dbus obj |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 265 | * |
| 266 | */ |
Asmitha Karunanithi | 003b8b7 | 2022-01-06 04:17:59 -0600 | [diff] [blame] | 267 | virtual ServerList getNTPServerFromTimeSyncd(); |
Ratan Gupta | 497c0c9 | 2017-08-22 19:15:59 +0530 | [diff] [blame] | 268 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 269 | /** @brief get the name server details from the network conf |
| 270 | * |
| 271 | */ |
Manojkiran Eda | acd6dd5 | 2019-10-15 15:00:51 +0530 | [diff] [blame] | 272 | virtual ServerList getNameServerFromResolvd(); |
Ratan Gupta | 6dec390f | 2017-08-20 15:28:12 +0530 | [diff] [blame] | 273 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 274 | /** @brief Persistent sdbusplus DBus bus connection. */ |
Patrick Williams | c38b071 | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 275 | sdbusplus::bus_t& bus; |
Ratan Gupta | 82549cc | 2017-04-21 08:45:23 +0530 | [diff] [blame] | 276 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 277 | /** @brief Network Manager object. */ |
| 278 | Manager& manager; |
Ratan Gupta | 4f1c18b | 2017-05-25 12:59:35 +0530 | [diff] [blame] | 279 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 280 | /** @brief Persistent map of IPAddress dbus objects and their names */ |
William A. Kennington III | 9a20a6e | 2022-10-05 13:41:12 -0700 | [diff] [blame] | 281 | string_umap<std::unique_ptr<IPAddress>> addrs; |
Ratan Gupta | 82549cc | 2017-04-21 08:45:23 +0530 | [diff] [blame] | 282 | |
William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 283 | /** @brief Persistent map of Neighbor dbus objects and their names */ |
William A. Kennington III | 9a20a6e | 2022-10-05 13:41:12 -0700 | [diff] [blame] | 284 | string_umap<std::unique_ptr<Neighbor>> staticNeighbors; |
William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 285 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 286 | /** @brief Persistent map of VLAN interface dbus objects and their names */ |
William A. Kennington III | 9a20a6e | 2022-10-05 13:41:12 -0700 | [diff] [blame] | 287 | string_umap<std::unique_ptr<VlanInterface>> vlanInterfaces; |
Ratan Gupta | 5978dd1 | 2017-07-25 13:47:13 +0530 | [diff] [blame] | 288 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 289 | /** @brief Dbus object path */ |
| 290 | std::string objPath; |
Ratan Gupta | 47722dc | 2017-05-26 18:32:23 +0530 | [diff] [blame] | 291 | |
William A. Kennington III | 2e09d27 | 2022-10-14 17:15:00 -0700 | [diff] [blame] | 292 | /** @brief Interface index */ |
| 293 | unsigned ifIdx; |
| 294 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 295 | friend class TestEthernetInterface; |
Johnathan Mantey | 817012a | 2020-01-30 15:07:39 -0800 | [diff] [blame] | 296 | |
| 297 | private: |
William A. Kennington III | d298f93 | 2022-10-17 14:31:38 -0700 | [diff] [blame] | 298 | EthernetInterface(sdbusplus::bus_t& bus, Manager& manager, |
William A. Kennington III | fd862be | 2022-10-09 18:40:55 -0700 | [diff] [blame] | 299 | const system::InterfaceInfo& info, std::string&& objPath, |
William A. Kennington III | d298f93 | 2022-10-17 14:31:38 -0700 | [diff] [blame] | 300 | const config::Parser& config, bool emitSignal, |
| 301 | std::optional<bool> enabled); |
| 302 | |
Johnathan Mantey | 817012a | 2020-01-30 15:07:39 -0800 | [diff] [blame] | 303 | /** @brief Determines if DHCP is active for the IP::Protocol supplied. |
| 304 | * @param[in] protocol - Either IPv4 or IPv6 |
Johnathan Mantey | 817012a | 2020-01-30 15:07:39 -0800 | [diff] [blame] | 305 | * @returns true/false value if DHCP is active for the input protocol |
| 306 | */ |
William A. Kennington III | 24957b9 | 2021-12-03 13:59:19 -0800 | [diff] [blame] | 307 | bool dhcpIsEnabled(IP::Protocol protocol); |
Johnathan Mantey | 817012a | 2020-01-30 15:07:39 -0800 | [diff] [blame] | 308 | |
Johnathan Mantey | 817012a | 2020-01-30 15:07:39 -0800 | [diff] [blame] | 309 | /** @brief Determines if the address is manually assigned |
| 310 | * @param[in] origin - The origin entry of the IP::Address |
| 311 | * @returns true/false value if the address is static |
| 312 | */ |
| 313 | bool originIsManuallyAssigned(IP::AddressOrigin origin); |
William A. Kennington III | 26275a3 | 2021-07-13 20:32:42 -0700 | [diff] [blame] | 314 | |
| 315 | /** @brief Determines if the NIC is enabled in systemd |
| 316 | * @returns true/false value if the NIC is enabled |
| 317 | */ |
| 318 | bool queryNicEnabled() const; |
William A. Kennington III | a520a39 | 2022-08-08 12:17:34 -0700 | [diff] [blame] | 319 | |
William A. Kennington III | d298f93 | 2022-10-17 14:31:38 -0700 | [diff] [blame] | 320 | std::string vlanIntfName(uint16_t id) const; |
Ratan Gupta | 8c83493 | 2017-04-14 16:30:24 +0530 | [diff] [blame] | 321 | }; |
| 322 | |
| 323 | } // namespace network |
| 324 | } // namespace phosphor |