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/test/test_ethernet_interface.cpp b/test/test_ethernet_interface.cpp
index 72579f3..146fb20 100644
--- a/test/test_ethernet_interface.cpp
+++ b/test/test_ethernet_interface.cpp
@@ -54,6 +54,12 @@
         return interface.ip(addressType, ipaddress, subnetMask, "");
     }
 
+    auto createStaticGatewayObject(const std::string& gateway,
+                                   IP::Protocol protocol)
+    {
+        return interface.staticGateway(gateway, protocol);
+    }
+
     void setNtpServers()
     {
         ServerList ntpServers = {"10.1.1.1", "10.2.2.2", "10.3.3.3"};
@@ -253,5 +259,47 @@
     set_test(DHCPConf::both, /*dhcp4=*/true, /*dhcp6=*/true, /*ra=*/true);
 }
 
+TEST_F(TestEthernetInterface, AddStaticGateway)
+{
+    createStaticGatewayObject("10.10.10.1", IP::Protocol::IPv4);
+    EXPECT_THAT(interface.staticGateways,
+                UnorderedElementsAre(Key(std::string("10.10.10.1"))));
+}
+
+TEST_F(TestEthernetInterface, AddMultipleStaticGateways)
+{
+    createStaticGatewayObject("10.10.10.1", IP::Protocol::IPv4);
+    createStaticGatewayObject("10.20.30.1", IP::Protocol::IPv4);
+    EXPECT_THAT(interface.staticGateways,
+                UnorderedElementsAre(Key(std::string("10.10.10.1")),
+                                     Key(std::string("10.20.30.1"))));
+}
+
+TEST_F(TestEthernetInterface, DeleteStaticGateway)
+{
+    createStaticGatewayObject("10.10.10.1", IP::Protocol::IPv4);
+    createStaticGatewayObject("10.20.30.1", IP::Protocol::IPv4);
+
+    interface.staticGateways.at(std::string("10.10.10.1"))->delete_();
+    interface.staticGateways.at(std::string("10.20.30.1"))->delete_();
+    EXPECT_EQ(interface.staticGateways.empty(), true);
+}
+
+TEST_F(TestEthernetInterface, AddIPv6StaticGateway)
+{
+    createStaticGatewayObject("2002:903:15f:325::1", IP::Protocol::IPv6);
+    EXPECT_THAT(interface.staticGateways,
+                UnorderedElementsAre(Key(std::string("2002:903:15f:325::1"))));
+}
+
+TEST_F(TestEthernetInterface, AddMultipleIPv6StaticGateways)
+{
+    createStaticGatewayObject("2003:903:15f:325::1", IP::Protocol::IPv6);
+    createStaticGatewayObject("2004:903:15f:325::1", IP::Protocol::IPv6);
+    EXPECT_THAT(interface.staticGateways,
+                UnorderedElementsAre(Key(std::string("2003:903:15f:325::1")),
+                                     Key(std::string("2004:903:15f:325::1"))));
+}
+
 } // namespace network
 } // namespace phosphor