1 #pragma once
2 #include "types.hpp"
3 
4 #include <sdbusplus/bus.hpp>
5 #include <sdbusplus/message/native_types.hpp>
6 #include <sdbusplus/server/object.hpp>
7 #include <stdplus/pinned.hpp>
8 #include <xyz/openbmc_project/Network/IP/server.hpp>
9 #include <xyz/openbmc_project/Network/StaticGateway/server.hpp>
10 #include <xyz/openbmc_project/Object/Delete/server.hpp>
11 
12 #include <string_view>
13 
14 namespace phosphor
15 {
16 namespace network
17 {
18 
19 using StaticGatewayIntf =
20     sdbusplus::xyz::openbmc_project::Network::server::StaticGateway;
21 
22 using StaticGatewayObj = sdbusplus::server::object_t<
23     StaticGatewayIntf, sdbusplus::xyz::openbmc_project::Object::server::Delete>;
24 
25 using IP = sdbusplus::xyz::openbmc_project::Network::server::IP;
26 
27 class EthernetInterface;
28 
29 /** @class StaticGateway
30  *  @brief OpenBMC network static gateway implementation.
31  *  @details A concrete implementation for the
32  *  xyz.openbmc_project.Network.StaticGateway dbus interface.
33  */
34 class StaticGateway : public StaticGatewayObj
35 {
36   public:
37     /** @brief Constructor to put object onto bus at a dbus path.
38      *  @param[in] bus - Bus to attach to.
39      *  @param[in] objRoot - Path to attach at.
40      *  @param[in] parent - Parent object.
41      *  @param[in] gateway - Gateway address.
42      */
43     StaticGateway(sdbusplus::bus_t& bus, std::string_view objRoot,
44                   stdplus::PinnedRef<EthernetInterface> parent,
45                   std::string gateway, IP::Protocol protocolType);
46 
47     /** @brief Delete this d-bus object.
48      */
49     void delete_() override;
50 
51     using StaticGatewayObj::gateway;
52     std::string gateway(std::string) override;
53     using StaticGatewayObj::protocolType;
54     IP::Protocol protocolType(IP::Protocol) override;
getObjPath() const55     inline const auto& getObjPath() const
56     {
57         return objPath;
58     }
59 
60   private:
61     /** @brief Parent Object. */
62     stdplus::PinnedRef<EthernetInterface> parent;
63 
64     /** @brief Dbus object path */
65     sdbusplus::message::object_path objPath;
66 
67     StaticGateway(sdbusplus::bus_t& bus,
68                   sdbusplus::message::object_path objPath,
69                   stdplus::PinnedRef<EthernetInterface> parent,
70                   std::string gateway, IP::Protocol protocolType);
71 };
72 
73 } // namespace network
74 } // namespace phosphor
75