1 #include "hyp_ethernet_interface.hpp" 2 3 namespace phosphor 4 { 5 namespace network 6 { 7 8 using namespace phosphor::logging; 9 using namespace sdbusplus::xyz::openbmc_project::Common::Error; 10 using Argument = xyz::openbmc_project::Common::InvalidArgument; 11 12 biosTableType HypEthInterface::getBiosAttrsMap() 13 { 14 return manager.getBIOSTableAttrs(); 15 } 16 17 bool HypEthInterface::ipv6AcceptRA(bool value) 18 { 19 auto currValue = ipv6AcceptRA(); 20 if (currValue != value) 21 { 22 HypEthernetIntf::ipv6AcceptRA(value); 23 } 24 return value; 25 } 26 27 bool HypEthInterface::dhcp4(bool value) 28 { 29 auto currValue = dhcp4(); 30 if (currValue != value) 31 { 32 HypEthernetIntf::dhcp4(value); 33 } 34 return value; 35 } 36 37 bool HypEthInterface::dhcp6(bool value) 38 { 39 auto currValue = dhcp6(); 40 if (currValue != value) 41 { 42 HypEthernetIntf::dhcp6(value); 43 } 44 return value; 45 } 46 47 bool HypEthInterface::dhcpIsEnabled(HypIP::Protocol family) 48 { 49 switch (family) 50 { 51 case HypIP::Protocol::IPv6: 52 return dhcp6(); 53 case HypIP::Protocol::IPv4: 54 return dhcp4(); 55 } 56 throw std::logic_error("Unreachable"); 57 } 58 59 HypEthInterface::DHCPConf HypEthInterface::dhcpEnabled(DHCPConf value) 60 { 61 auto old4 = HypEthernetIntf::dhcp4(); 62 auto new4 = HypEthernetIntf::dhcp4(value == DHCPConf::v4 || 63 value == DHCPConf::v4v6stateless || 64 value == DHCPConf::both); 65 auto old6 = HypEthernetIntf::dhcp6(); 66 auto new6 = HypEthernetIntf::dhcp6(value == DHCPConf::v6 || 67 value == DHCPConf::both); 68 auto oldra = HypEthernetIntf::ipv6AcceptRA(); 69 auto newra = HypEthernetIntf::ipv6AcceptRA( 70 value == DHCPConf::v6stateless || value == DHCPConf::v4v6stateless || 71 value == DHCPConf::v6 || value == DHCPConf::both); 72 73 if (old4 != new4 || old6 != new6 || oldra != newra) 74 { 75 HypEthernetIntf::dhcpEnabled(value); 76 } 77 return value; 78 } 79 80 HypEthInterface::DHCPConf HypEthInterface::dhcpEnabled() const 81 { 82 if (dhcp6()) 83 { 84 return dhcp4() ? DHCPConf::both : DHCPConf::v6; 85 } 86 else if (dhcp4()) 87 { 88 return ipv6AcceptRA() ? DHCPConf::v4v6stateless : DHCPConf::v4; 89 } 90 return ipv6AcceptRA() ? DHCPConf::v6stateless : DHCPConf::none; 91 } 92 93 } // namespace network 94 } // namespace phosphor 95