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 | } |
Manojkiran Eda | aa57fa5 | 2020-06-13 14:59:53 +0530 | [diff] [blame] | 38 | std::string IPAddress::address(std::string /*ipAddress*/) |
Ravi Teja | 2fd2f7d | 2019-06-06 03:27:55 -0500 | [diff] [blame] | 39 | { |
| 40 | elog<NotAllowed>(Reason("Property update is not allowed")); |
| 41 | } |
Manojkiran Eda | aa57fa5 | 2020-06-13 14:59:53 +0530 | [diff] [blame] | 42 | uint8_t IPAddress::prefixLength(uint8_t /*value*/) |
Ravi Teja | 2fd2f7d | 2019-06-06 03:27:55 -0500 | [diff] [blame] | 43 | { |
| 44 | elog<NotAllowed>(Reason("Property update is not allowed")); |
| 45 | } |
Manojkiran Eda | aa57fa5 | 2020-06-13 14:59:53 +0530 | [diff] [blame] | 46 | std::string IPAddress::gateway(std::string /*gateway*/) |
Ravi Teja | 2fd2f7d | 2019-06-06 03:27:55 -0500 | [diff] [blame] | 47 | { |
| 48 | elog<NotAllowed>(Reason("Property update is not allowed")); |
| 49 | } |
Manojkiran Eda | aa57fa5 | 2020-06-13 14:59:53 +0530 | [diff] [blame] | 50 | IP::Protocol IPAddress::type(IP::Protocol /*type*/) |
Ravi Teja | 2fd2f7d | 2019-06-06 03:27:55 -0500 | [diff] [blame] | 51 | { |
| 52 | elog<NotAllowed>(Reason("Property update is not allowed")); |
| 53 | } |
Manojkiran Eda | aa57fa5 | 2020-06-13 14:59:53 +0530 | [diff] [blame] | 54 | IP::AddressOrigin IPAddress::origin(IP::AddressOrigin /*origin*/) |
Ravi Teja | 2fd2f7d | 2019-06-06 03:27:55 -0500 | [diff] [blame] | 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 | { |
William A. Kennington III | 2dae969 | 2019-04-22 02:18:41 -0700 | [diff] [blame] | 60 | if (origin() != IP::AddressOrigin::Static) |
Nagaraju Goruganti | 66b974d | 2017-10-03 08:43:08 -0500 | [diff] [blame] | 61 | { |
William A. Kennington III | 2dae969 | 2019-04-22 02:18:41 -0700 | [diff] [blame] | 62 | log<level::ERR>("Tried to delete a non-static address"), |
| 63 | entry("ADDRESS=%s", address().c_str()), |
| 64 | entry("PREFIX=%" PRIu8, prefixLength()), |
Nagaraju Goruganti | 66b974d | 2017-10-03 08:43:08 -0500 | [diff] [blame] | 65 | entry("INTERFACE=%s", parent.interfaceName().c_str()); |
William A. Kennington III | 2dae969 | 2019-04-22 02:18:41 -0700 | [diff] [blame] | 66 | elog<InternalFailure>(); |
Nagaraju Goruganti | 66b974d | 2017-10-03 08:43:08 -0500 | [diff] [blame] | 67 | } |
| 68 | |
Ratan Gupta | 2eff84f | 2017-04-20 19:19:15 +0530 | [diff] [blame] | 69 | parent.deleteObject(address()); |
| 70 | } |
| 71 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 72 | } // namespace network |
| 73 | } // namespace phosphor |