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 | |
| 12 | namespace phosphor |
| 13 | { |
| 14 | namespace network |
| 15 | { |
| 16 | |
| 17 | using namespace phosphor::logging; |
Nagaraju Goruganti | 66b974d | 2017-10-03 08:43:08 -0500 | [diff] [blame] | 18 | using namespace sdbusplus::xyz::openbmc_project::Common::Error; |
Ratan Gupta | 2eff84f | 2017-04-20 19:19:15 +0530 | [diff] [blame] | 19 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 20 | IPAddress::IPAddress(sdbusplus::bus::bus& bus, const char* objPath, |
| 21 | EthernetInterface& parent, IP::Protocol type, |
| 22 | const std::string& ipaddress, IP::AddressOrigin origin, |
| 23 | uint8_t prefixLength, const std::string& gateway) : |
| 24 | IPIfaces(bus, objPath, true), |
| 25 | parent(parent) |
Ratan Gupta | 2eff84f | 2017-04-20 19:19:15 +0530 | [diff] [blame] | 26 | { |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 27 | this->address(ipaddress); |
| 28 | this->prefixLength(prefixLength); |
| 29 | this->gateway(gateway); |
| 30 | this->type(type); |
| 31 | this->origin(origin); |
Ratan Gupta | 29b0e43 | 2017-05-25 12:51:40 +0530 | [diff] [blame] | 32 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 33 | // Emit deferred signal. |
| 34 | emit_object_added(); |
Ratan Gupta | 2eff84f | 2017-04-20 19:19:15 +0530 | [diff] [blame] | 35 | } |
| 36 | |
Ratan Gupta | 2eff84f | 2017-04-20 19:19:15 +0530 | [diff] [blame] | 37 | void IPAddress::delete_() |
| 38 | { |
Nagaraju Goruganti | 66b974d | 2017-10-03 08:43:08 -0500 | [diff] [blame] | 39 | if (parent.dHCPEnabled()) |
| 40 | { |
| 41 | log<level::ERR>("DHCP enabled on the interface"), |
| 42 | entry("INTERFACE=%s", parent.interfaceName().c_str()); |
Ratan Gupta | 2003743 | 2017-11-08 16:35:22 +0530 | [diff] [blame] | 43 | return; |
Nagaraju Goruganti | 66b974d | 2017-10-03 08:43:08 -0500 | [diff] [blame] | 44 | } |
| 45 | |
Oskar Senft | ad21fc2 | 2018-07-26 16:32:23 -0400 | [diff] [blame] | 46 | #ifdef LINK_LOCAL_AUTOCONFIGURATION |
Nagaraju Goruganti | 66b974d | 2017-10-03 08:43:08 -0500 | [diff] [blame] | 47 | if (isLinkLocalIP(address())) |
| 48 | { |
| 49 | log<level::ERR>("Can not delete the LinkLocal address"), |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 50 | entry("INTERFACE=%s ADDRESS=%s", parent.interfaceName().c_str(), |
| 51 | address().c_str()); |
Ratan Gupta | 2003743 | 2017-11-08 16:35:22 +0530 | [diff] [blame] | 52 | return; |
Nagaraju Goruganti | 66b974d | 2017-10-03 08:43:08 -0500 | [diff] [blame] | 53 | } |
Oskar Senft | ad21fc2 | 2018-07-26 16:32:23 -0400 | [diff] [blame] | 54 | #endif |
Nagaraju Goruganti | 66b974d | 2017-10-03 08:43:08 -0500 | [diff] [blame] | 55 | |
Ratan Gupta | 2eff84f | 2017-04-20 19:19:15 +0530 | [diff] [blame] | 56 | parent.deleteObject(address()); |
| 57 | } |
| 58 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 59 | } // namespace network |
| 60 | } // namespace phosphor |