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