Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 1 | #include "config.h" |
| 2 | |
Ratan Gupta | 2eff84f | 2017-04-20 19:19:15 +0530 | [diff] [blame] | 3 | #include "ipaddress.hpp" |
Patrick Venture | 189d44e | 2018-07-09 12:30:59 -0700 | [diff] [blame] | 4 | |
Ratan Gupta | 2eff84f | 2017-04-20 19:19:15 +0530 | [diff] [blame] | 5 | #include "ethernet_interface.hpp" |
Nagaraju Goruganti | 66b974d | 2017-10-03 08:43:08 -0500 | [diff] [blame] | 6 | #include "util.hpp" |
Ratan Gupta | 2eff84f | 2017-04-20 19:19:15 +0530 | [diff] [blame] | 7 | |
Nagaraju Goruganti | 66b974d | 2017-10-03 08:43:08 -0500 | [diff] [blame] | 8 | #include <phosphor-logging/elog-errors.hpp> |
Patrick Venture | 189d44e | 2018-07-09 12:30:59 -0700 | [diff] [blame] | 9 | #include <phosphor-logging/log.hpp> |
| 10 | #include <xyz/openbmc_project/Common/error.hpp> |
Ratan Gupta | 2eff84f | 2017-04-20 19:19:15 +0530 | [diff] [blame] | 11 | namespace phosphor |
| 12 | { |
| 13 | namespace network |
| 14 | { |
| 15 | |
| 16 | using namespace phosphor::logging; |
Nagaraju Goruganti | 66b974d | 2017-10-03 08:43:08 -0500 | [diff] [blame] | 17 | using namespace sdbusplus::xyz::openbmc_project::Common::Error; |
Ravi Teja | 2fd2f7d | 2019-06-06 03:27:55 -0500 | [diff] [blame] | 18 | using NotAllowed = sdbusplus::xyz::openbmc_project::Common::Error::NotAllowed; |
| 19 | using Reason = xyz::openbmc_project::Common::NotAllowed::REASON; |
Ratan Gupta | 2eff84f | 2017-04-20 19:19:15 +0530 | [diff] [blame] | 20 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 21 | IPAddress::IPAddress(sdbusplus::bus::bus& bus, const char* objPath, |
| 22 | EthernetInterface& parent, IP::Protocol type, |
| 23 | const std::string& ipaddress, IP::AddressOrigin origin, |
| 24 | uint8_t prefixLength, const std::string& gateway) : |
| 25 | IPIfaces(bus, objPath, true), |
| 26 | parent(parent) |
Ratan Gupta | 2eff84f | 2017-04-20 19:19:15 +0530 | [diff] [blame] | 27 | { |
Ravi Teja | 2fd2f7d | 2019-06-06 03:27:55 -0500 | [diff] [blame] | 28 | |
| 29 | IP::address(ipaddress); |
| 30 | IP::prefixLength(prefixLength); |
| 31 | IP::gateway(gateway); |
| 32 | IP::type(type); |
| 33 | IP::origin(origin); |
Ratan Gupta | 29b0e43 | 2017-05-25 12:51:40 +0530 | [diff] [blame] | 34 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 35 | // Emit deferred signal. |
| 36 | emit_object_added(); |
Ratan Gupta | 2eff84f | 2017-04-20 19:19:15 +0530 | [diff] [blame] | 37 | } |
Ravi Teja | 2fd2f7d | 2019-06-06 03:27:55 -0500 | [diff] [blame] | 38 | std::string IPAddress::address(std::string ipAddress) |
| 39 | { |
| 40 | elog<NotAllowed>(Reason("Property update is not allowed")); |
| 41 | } |
| 42 | uint8_t IPAddress::prefixLength(uint8_t value) |
| 43 | { |
| 44 | elog<NotAllowed>(Reason("Property update is not allowed")); |
| 45 | } |
| 46 | std::string IPAddress::gateway(std::string gateway) |
| 47 | { |
| 48 | elog<NotAllowed>(Reason("Property update is not allowed")); |
| 49 | } |
| 50 | IP::Protocol IPAddress::type(IP::Protocol type) |
| 51 | { |
| 52 | elog<NotAllowed>(Reason("Property update is not allowed")); |
| 53 | } |
| 54 | IP::AddressOrigin IPAddress::origin(IP::AddressOrigin origin) |
| 55 | { |
| 56 | elog<NotAllowed>(Reason("Property update is not allowed")); |
| 57 | } |
Ratan Gupta | 2eff84f | 2017-04-20 19:19:15 +0530 | [diff] [blame] | 58 | void IPAddress::delete_() |
| 59 | { |
Nagaraju Goruganti | 66b974d | 2017-10-03 08:43:08 -0500 | [diff] [blame] | 60 | if (parent.dHCPEnabled()) |
| 61 | { |
| 62 | log<level::ERR>("DHCP enabled on the interface"), |
| 63 | entry("INTERFACE=%s", parent.interfaceName().c_str()); |
Ratan Gupta | 2003743 | 2017-11-08 16:35:22 +0530 | [diff] [blame] | 64 | return; |
Nagaraju Goruganti | 66b974d | 2017-10-03 08:43:08 -0500 | [diff] [blame] | 65 | } |
| 66 | |
Oskar Senft | ad21fc2 | 2018-07-26 16:32:23 -0400 | [diff] [blame] | 67 | #ifdef LINK_LOCAL_AUTOCONFIGURATION |
Nagaraju Goruganti | 66b974d | 2017-10-03 08:43:08 -0500 | [diff] [blame] | 68 | if (isLinkLocalIP(address())) |
| 69 | { |
| 70 | log<level::ERR>("Can not delete the LinkLocal address"), |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 71 | entry("INTERFACE=%s ADDRESS=%s", parent.interfaceName().c_str(), |
| 72 | address().c_str()); |
Ratan Gupta | 2003743 | 2017-11-08 16:35:22 +0530 | [diff] [blame] | 73 | return; |
Nagaraju Goruganti | 66b974d | 2017-10-03 08:43:08 -0500 | [diff] [blame] | 74 | } |
Oskar Senft | ad21fc2 | 2018-07-26 16:32:23 -0400 | [diff] [blame] | 75 | #endif |
Nagaraju Goruganti | 66b974d | 2017-10-03 08:43:08 -0500 | [diff] [blame] | 76 | |
Ratan Gupta | 2eff84f | 2017-04-20 19:19:15 +0530 | [diff] [blame] | 77 | parent.deleteObject(address()); |
| 78 | } |
| 79 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 80 | } // namespace network |
| 81 | } // namespace phosphor |