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