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