1 #pragma once 2 3 #include "hyp_network_manager.hpp" 4 #include "xyz/openbmc_project/Network/IP/Create/server.hpp" 5 6 #include <phosphor-logging/elog-errors.hpp> 7 #include <phosphor-logging/elog.hpp> 8 #include <phosphor-logging/log.hpp> 9 #include <sdbusplus/bus.hpp> 10 #include <xyz/openbmc_project/Common/error.hpp> 11 #include <xyz/openbmc_project/Network/EthernetInterface/server.hpp> 12 #include <xyz/openbmc_project/Network/IP/server.hpp> 13 14 namespace phosphor 15 { 16 namespace network 17 { 18 19 class HypNetworkMgr; // forward declaration of hypervisor network manager. 20 21 using namespace phosphor::logging; 22 using HypIP = sdbusplus::xyz::openbmc_project::Network::server::IP; 23 24 using CreateIface = sdbusplus::server::object_t< 25 sdbusplus::xyz::openbmc_project::Network::server::EthernetInterface, 26 sdbusplus::xyz::openbmc_project::Network::IP::server::Create>; 27 28 using biosTableType = std::map<std::string, std::variant<int64_t, std::string>>; 29 30 using HypEthernetIntf = 31 sdbusplus::xyz::openbmc_project::Network::server::EthernetInterface; 32 33 using ObjectPath = sdbusplus::message::object_path; 34 35 static std::shared_ptr<sdbusplus::bus::match_t> matchBIOSAttrUpdate; 36 37 /** @class HypEthernetInterface 38 * @brief Hypervisor Ethernet Interface implementation. 39 */ 40 class HypEthInterface : public CreateIface 41 { 42 public: 43 HypEthInterface() = delete; 44 HypEthInterface(const HypEthInterface&) = delete; 45 HypEthInterface& operator=(const HypEthInterface&) = delete; 46 HypEthInterface(HypEthInterface&&) = delete; 47 HypEthInterface& operator=(HypEthInterface&&) = delete; 48 virtual ~HypEthInterface() = default; 49 50 /** @brief Constructor to put object onto bus at a dbus path. 51 * @param[in] bus - Bus to attach to. 52 * @param[in] path - Path to attach at. 53 * @param[in] parent - parent object. 54 */ 55 HypEthInterface(sdbusplus::bus_t& bus, const char* path, 56 std::string_view intfName, HypNetworkMgr& parent) : 57 CreateIface(bus, path, CreateIface::action::defer_emit), 58 bus(bus), objectPath(path), manager(parent) 59 { 60 HypEthernetIntf::interfaceName(intfName.data(), true); 61 emit_object_added(); 62 }; 63 64 /** @brief Function to create ipAddress dbus object. 65 * @param[in] addressType - Type of ip address. 66 * @param[in] ipAddress- IP address. 67 * @param[in] prefixLength - Length of prefix. 68 * @param[in] gateway - Gateway ip address. 69 */ 70 71 ObjectPath ip(HypIP::Protocol /*addressType*/, std::string /*ipAddress*/, 72 uint8_t /*prefixLength*/, std::string /*gateway*/) override 73 { 74 return std::string(); 75 }; 76 77 /* @brief Function that returns parent's bios attrs map 78 */ 79 biosTableType getBiosAttrsMap(); 80 81 /* @brief Returns the dhcp enabled property 82 * @param[in] protocol - ipv4/ipv6 83 * @return bool - true if dhcpEnabled 84 */ 85 bool isDHCPEnabled(HypIP::Protocol protocol); 86 87 /** Set value of DHCPEnabled */ 88 HypEthernetIntf::DHCPConf dhcpEnabled() const override; 89 HypEthernetIntf::DHCPConf dhcpEnabled(DHCPConf value) override; 90 using HypEthernetIntf::dhcp4; 91 bool dhcp4(bool value) override; 92 using HypEthernetIntf::dhcp6; 93 bool dhcp6(bool value) override; 94 95 /** @brief check conf file for Router Advertisements 96 * 97 */ 98 bool ipv6AcceptRA(bool value) override; 99 using HypEthernetIntf::ipv6AcceptRA; 100 101 using HypEthernetIntf::interfaceName; 102 103 protected: 104 /** @brief sdbusplus DBus bus connection. */ 105 sdbusplus::bus_t& bus; 106 107 /** @brief object path */ 108 std::string objectPath; 109 110 /** @brief Parent of this object */ 111 HypNetworkMgr& manager; 112 113 private: 114 /** @brief Determines if DHCP is active for the IP::Protocol supplied. 115 * @param[in] protocol - Either IPv4 or IPv6 116 * @returns true/false value if DHCP is active for the input protocol 117 */ 118 bool dhcpIsEnabled(HypIP::Protocol protocol); 119 }; 120 121 } // namespace network 122 } // namespace phosphor 123