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