William A. Kennington III | 0850579 | 2019-01-30 16:00:04 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "types.hpp" |
| 4 | #include "util.hpp" |
| 5 | |
| 6 | #include <netinet/in.h> |
| 7 | |
| 8 | #include <optional> |
| 9 | #include <sdbusplus/bus.hpp> |
| 10 | #include <sdbusplus/server/object.hpp> |
| 11 | #include <string> |
| 12 | #include <vector> |
| 13 | #include <xyz/openbmc_project/Network/Neighbor/server.hpp> |
| 14 | #include <xyz/openbmc_project/Object/Delete/server.hpp> |
| 15 | |
| 16 | namespace phosphor |
| 17 | { |
| 18 | namespace network |
| 19 | { |
| 20 | |
| 21 | using NeighborIntf = sdbusplus::xyz::openbmc_project::Network::server::Neighbor; |
| 22 | |
| 23 | using NeighborObj = sdbusplus::server::object::object< |
| 24 | NeighborIntf, sdbusplus::xyz::openbmc_project::Object::server::Delete>; |
| 25 | |
| 26 | class EthernetInterface; |
| 27 | |
| 28 | /** @class NeighborInfo |
| 29 | * @brief Information about a neighbor from the kernel |
| 30 | */ |
| 31 | struct NeighborInfo |
| 32 | { |
| 33 | std::string interface; |
| 34 | InAddrAny address; |
| 35 | std::optional<MacAddr> mac; |
| 36 | bool permanent; |
| 37 | }; |
| 38 | |
| 39 | /** @brief Returns a list of the current system neighbor table |
| 40 | */ |
| 41 | std::vector<NeighborInfo> getCurrentNeighbors(); |
| 42 | |
| 43 | /** @class Neighbor |
| 44 | * @brief OpenBMC network neighbor implementation. |
| 45 | * @details A concrete implementation for the |
| 46 | * xyz.openbmc_project.Network.Neighbor dbus interface. |
| 47 | */ |
| 48 | class Neighbor : public NeighborObj |
| 49 | { |
| 50 | public: |
| 51 | using State = NeighborIntf::State; |
| 52 | |
| 53 | Neighbor() = delete; |
| 54 | Neighbor(const Neighbor&) = delete; |
| 55 | Neighbor& operator=(const Neighbor&) = delete; |
| 56 | Neighbor(Neighbor&&) = delete; |
| 57 | Neighbor& operator=(Neighbor&&) = delete; |
| 58 | virtual ~Neighbor() = default; |
| 59 | |
| 60 | /** @brief Constructor to put object onto bus at a dbus path. |
| 61 | * @param[in] bus - Bus to attach to. |
| 62 | * @param[in] objPath - Path to attach at. |
| 63 | * @param[in] parent - Parent object. |
| 64 | * @param[in] ipAddress - IP address. |
| 65 | * @param[in] macAddress - Low level MAC address. |
| 66 | * @param[in] state - The state of the neighbor entry. |
| 67 | */ |
| 68 | Neighbor(sdbusplus::bus::bus& bus, const char* objPath, |
| 69 | EthernetInterface& parent, const std::string& ipAddress, |
| 70 | const std::string& macAddress, State state); |
| 71 | |
| 72 | /** @brief Delete this d-bus object. |
| 73 | */ |
| 74 | void delete_() override; |
| 75 | |
| 76 | private: |
| 77 | /** @brief Parent Object. */ |
| 78 | EthernetInterface& parent; |
| 79 | }; |
| 80 | |
| 81 | } // namespace network |
| 82 | } // namespace phosphor |