Implement create interface for ipaddress

Change-Id: Ia4598c27c11667dafb70a8af58871661b7042d0f
Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
diff --git a/ethernet_interface.hpp b/ethernet_interface.hpp
index 71a3003..ab69a78 100644
--- a/ethernet_interface.hpp
+++ b/ethernet_interface.hpp
@@ -1,6 +1,10 @@
 #pragma once
 
+#include "ipaddress.hpp"
+#include "types.hpp"
+
 #include "xyz/openbmc_project/Network/EthernetInterface/server.hpp"
+#include "xyz/openbmc_project/Network/IP/Create/server.hpp"
 
 #include <sdbusplus/bus.hpp>
 #include <sdbusplus/server/object.hpp>
@@ -11,17 +15,14 @@
 {
 namespace network
 {
-namespace details
-{
 
-template <typename T>
-using ServerObject = typename sdbusplus::server::object::object<T>;
+using Ifaces =
+    sdbusplus::server::object::object<
+        sdbusplus::xyz::openbmc_project::Network::server::EthernetInterface,
+        sdbusplus::xyz::openbmc_project::Network::IP::server::Create>;
 
-using EthernetIface =
-    sdbusplus::server::object::object <
-    sdbusplus::xyz::openbmc_project::Network::server::EthernetInterface >;
+using IP = sdbusplus::xyz::openbmc_project::Network::server::IP;
 
-} // namespace details
 
 using LinkSpeed = uint16_t;
 using DuplexMode = uint8_t;
@@ -34,7 +35,7 @@
  *  @details A concrete implementation for the
  *  xyz.openbmc_project.Network.EthernetInterface DBus API.
  */
-class EthernetInterface : public details::EthernetIface
+class EthernetInterface : public Ifaces
 {
     public:
         EthernetInterface() = delete;
@@ -52,7 +53,20 @@
          */
         EthernetInterface(sdbusplus::bus::bus& bus,
                           const std::string& objPath,
-                          bool dhcpEnabled);
+                          bool dhcpEnabled,
+                          const AddrList& addrs);
+
+        /** @brief Function to create ipaddress dbus object.
+         *  @param[in] addressType - Type of ip address.
+         *  @param[in] ipaddress- IP adress.
+         *  @param[in] prefixLength - Length of prefix.
+         *  @param[in] gateway - Gateway ip address.
+         */
+
+        void iP(IP::Protocol addressType,
+                std::string ipaddress,
+                uint8_t prefixLength,
+                std::string gateway) override;
 
         /** @brief delete the dbus object of the given ipaddress.
          */
@@ -74,6 +88,28 @@
 
         std::string getMACAddress() const;
 
+        /** @brief construct the ip address dbus object path.
+         *  @param[in] addressType - Type of ip address.
+         *  @return path of the address object.
+         */
+
+        std::string getAddressObjectPath(IP::Protocol addressType) const;
+
+        /** @brief get the ipadress count for a specific type on this interface.
+         *  @param[in] addressType - Type of ip address.
+         *  @return count of ipaddreses for the incoming type.
+         */
+
+        size_t getAddressCount(IP::Protocol addressType) const;
+
+
+        /** @brief Persistent sdbusplus DBus bus connection. */
+        sdbusplus::bus::bus& bus;
+
+        /** @brief Persistent map of IPAddress dbus objects and their names */
+        std::map<std::string, std::unique_ptr<IPAddress>> addrs;
+
+
 };
 
 } // namespace network