Add network static gateway configuration support
This commit enables static gateway configuration on EthernetInterface
Implements CreateStaticGateway method which creates a new d-bus object
with StaticGateway interface.
Tested By:
Run StaticGateway D-bus method and verified D-bus object and
configuration.
Delete StaticGateway object
Add static gateway
Delete static gateway
Change-Id: I3fbc6f85ede00b6c1949a0ac85f501037a69c831
Signed-off-by: Ravi Teja <raviteja28031990@gmail.com>
diff --git a/src/ethernet_interface.hpp b/src/ethernet_interface.hpp
index c7af241..3140528 100644
--- a/src/ethernet_interface.hpp
+++ b/src/ethernet_interface.hpp
@@ -2,9 +2,11 @@
#include "dhcp_configuration.hpp"
#include "ipaddress.hpp"
#include "neighbor.hpp"
+#include "static_gateway.hpp"
#include "types.hpp"
#include "xyz/openbmc_project/Network/IP/Create/server.hpp"
#include "xyz/openbmc_project/Network/Neighbor/CreateStatic/server.hpp"
+#include "xyz/openbmc_project/Network/StaticGateway/Create/server.hpp"
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/object.hpp>
@@ -14,6 +16,7 @@
#include <xyz/openbmc_project/Collection/DeleteAll/server.hpp>
#include <xyz/openbmc_project/Network/EthernetInterface/server.hpp>
#include <xyz/openbmc_project/Network/MACAddress/server.hpp>
+#include <xyz/openbmc_project/Network/StaticGateway/server.hpp>
#include <xyz/openbmc_project/Network/VLAN/server.hpp>
#include <xyz/openbmc_project/Object/Delete/server.hpp>
@@ -31,6 +34,7 @@
sdbusplus::xyz::openbmc_project::Network::server::MACAddress,
sdbusplus::xyz::openbmc_project::Network::IP::server::Create,
sdbusplus::xyz::openbmc_project::Network::Neighbor::server::CreateStatic,
+ sdbusplus::xyz::openbmc_project::Network::StaticGateway::server::Create,
sdbusplus::xyz::openbmc_project::Collection::server::DeleteAll>;
using VlanIfaces = sdbusplus::server::object_t<
@@ -45,6 +49,8 @@
sdbusplus::xyz::openbmc_project::Network::server::EthernetInterface;
using MacAddressIntf =
sdbusplus::xyz::openbmc_project::Network::server::MACAddress;
+using StaticGatewayIntf =
+ sdbusplus::xyz::openbmc_project::Network::server::StaticGateway;
using ServerList = std::vector<std::string>;
using ObjectPath = sdbusplus::message::object_path;
@@ -94,8 +100,13 @@
std::unordered_map<stdplus::InAnyAddr, std::unique_ptr<Neighbor>>
staticNeighbors;
+ /** @brief Persistent map of static route dbus objects and their names */
+ std::unordered_map<std::string, std::unique_ptr<StaticGateway>>
+ staticGateways;
+
void addAddr(const AddressInfo& info);
void addStaticNeigh(const NeighborInfo& info);
+ void addStaticGateway(const StaticGatewayInfo& info);
/** @brief Updates the interface information based on new InterfaceInfo */
void updateInfo(const InterfaceInfo& info, bool skipSignal = false);
@@ -123,6 +134,14 @@
*/
ObjectPath neighbor(std::string ipAddress, std::string macAddress) override;
+ /** @brief Function to create static route dbus object.
+ * @param[in] destination - Destination IP address.
+ * @param[in] gateway - Gateway
+ * @parma[in] prefixLength - Number of network bits.
+ */
+ ObjectPath staticGateway(std::string gateway,
+ IP::Protocol protocolType) override;
+
/** Set value of DHCPEnabled */
DHCPConf dhcpEnabled() const override;
DHCPConf dhcpEnabled(DHCPConf value) override;