|  | #include "static_gateway.hpp" | 
|  |  | 
|  | #include "ethernet_interface.hpp" | 
|  | #include "network_manager.hpp" | 
|  |  | 
|  | #include <phosphor-logging/elog-errors.hpp> | 
|  | #include <phosphor-logging/elog.hpp> | 
|  | #include <xyz/openbmc_project/Common/error.hpp> | 
|  |  | 
|  | #include <string> | 
|  |  | 
|  | namespace phosphor | 
|  | { | 
|  | namespace network | 
|  | { | 
|  |  | 
|  | static auto makeObjPath(std::string_view root, std::string addr) | 
|  | { | 
|  | auto ret = sdbusplus::message::object_path(std::string(root)); | 
|  | ret /= addr; | 
|  | return ret; | 
|  | } | 
|  |  | 
|  | StaticGateway::StaticGateway(sdbusplus::bus_t& bus, std::string_view objRoot, | 
|  | stdplus::PinnedRef<EthernetInterface> parent, | 
|  | std::string gateway, IP::Protocol protocolType) : | 
|  | StaticGateway(bus, makeObjPath(objRoot, gateway), parent, gateway, | 
|  | protocolType) | 
|  | {} | 
|  |  | 
|  | StaticGateway::StaticGateway(sdbusplus::bus_t& bus, | 
|  | sdbusplus::message::object_path objPath, | 
|  | stdplus::PinnedRef<EthernetInterface> parent, | 
|  | std::string gateway, IP::Protocol protocolType) : | 
|  | StaticGatewayObj(bus, objPath.str.c_str(), | 
|  | StaticGatewayObj::action::defer_emit), | 
|  | parent(parent), objPath(std::move(objPath)) | 
|  | { | 
|  | StaticGatewayObj::gateway(gateway, true); | 
|  | StaticGatewayObj::protocolType(protocolType, true); | 
|  | emit_object_added(); | 
|  | } | 
|  |  | 
|  | void StaticGateway::delete_() | 
|  | { | 
|  | auto& staticGateways = parent.get().staticGateways; | 
|  | std::unique_ptr<StaticGateway> ptr; | 
|  | for (auto it = staticGateways.begin(); it != staticGateways.end(); ++it) | 
|  | { | 
|  | if (it->second.get() == this) | 
|  | { | 
|  | ptr = std::move(it->second); | 
|  | staticGateways.erase(it); | 
|  | break; | 
|  | } | 
|  | } | 
|  |  | 
|  | parent.get().writeConfigurationFile(); | 
|  | parent.get().manager.get().reloadConfigs(); | 
|  | } | 
|  |  | 
|  | using sdbusplus::xyz::openbmc_project::Common::Error::NotAllowed; | 
|  | using REASON = | 
|  | phosphor::logging::xyz::openbmc_project::Common::NotAllowed::REASON; | 
|  | using phosphor::logging::elog; | 
|  |  | 
|  | std::string StaticGateway::gateway(std::string /*gateway*/) | 
|  | { | 
|  | elog<NotAllowed>(REASON("Property update is not allowed")); | 
|  | } | 
|  |  | 
|  | IP::Protocol StaticGateway::protocolType(IP::Protocol /*protocolType*/) | 
|  | { | 
|  | elog<NotAllowed>(REASON("Property update is not allowed")); | 
|  | } | 
|  | } // namespace network | 
|  | } // namespace phosphor |