| #ifndef RDE_MATCH_HANDLER_HPP |
| #define RDE_MATCH_HANDLER_HPP |
| |
| #include <sdbusplus/asio/connection.hpp> |
| #include <sdbusplus/asio/object_server.hpp> |
| #include <sdbusplus/asio/property.hpp> |
| #include <sdbusplus/bus.hpp> |
| #include <sdbusplus/server.hpp> |
| |
| #include <memory> |
| #include <unordered_map> |
| |
| class RdeMatchHandler |
| { |
| |
| public: |
| RdeMatchHandler(int socketFd); |
| ~RdeMatchHandler(); |
| |
| /** |
| * @brief Triggers RDE Matcher |
| */ |
| void triggerMatcher(); |
| |
| private: |
| int fd; |
| |
| std::unordered_map<std::string, int> deviceToNetIdMap; |
| |
| std::unordered_map<std::string, |
| std::shared_ptr<sdbusplus::asio::dbus_interface>> |
| deviceToDbusIntfMap; |
| |
| std::unordered_map<std::string, std::string> objectPathToDeviceIdMap; |
| |
| /** |
| * @brief Scans for existing USB devices in the Entity Manager that can be |
| * RDE Devices as soon as the RDE Daemon boots up |
| * |
| * @param[in] fd - Socket the MCTP is connected to (Required to setup the |
| * devices) |
| * @param[in] objectServer - Dbus obj server |
| * @param[in] prefixPath - Path to be searched for in EM tree |
| * @param[in] systemBus - Dbus system bus |
| */ |
| void scanForExistingDevices( |
| const int& fd, sdbusplus::asio::object_server& objectServer, |
| const std::string& prefixPath, |
| std::shared_ptr<sdbusplus::asio::connection>& systemBus); |
| |
| /** |
| * @brief Detects as soon as a new USB device is connected to the machine |
| * and sets up RDE |
| * |
| * @param[in] systemBus - Dbus system bus |
| * @param[in] objectServer - Dbus obj server |
| * @param[in] prefixPath - Path to be searched for in EM tree |
| * @param[in] fd - Socket the MCTP is connected to |
| * |
| * @return match_t pointer for the matcher |
| */ |
| std::unique_ptr<sdbusplus::bus::match_t> |
| handleMatchAdd(std::shared_ptr<sdbusplus::asio::connection>& systemBus, |
| sdbusplus::asio::object_server& objectServer, |
| const std::string& prefixPath, const int& fd); |
| |
| /** |
| * @brief Detects as soon as a new device is removed to the machine and |
| * tears down RDE |
| * |
| * @param[in] systemBus - Dbus system bus |
| * @param[in] objectServer - Dbus obj server |
| * @param[in] prefixPath - Path to be searched for in EM tree |
| * @param[in] fd - Socket the MCTP is connected to |
| * |
| * @return match_t pointer for the matcher |
| */ |
| std::unique_ptr<sdbusplus::bus::match_t> handleMatchRemove( |
| std::shared_ptr<sdbusplus::asio::connection>& systemBus, |
| sdbusplus::asio::object_server& objectServer); |
| |
| /** |
| * @brief Initiates PLDM and RDE Discovery on the device |
| * |
| * @param[in] fd - MCTP Socket |
| * @param[in] udevId - udevId of the USB device |
| * @param[in] netId - Network Id that would be used by USB device |
| * |
| * @return Status of discovery |
| */ |
| int initiateDiscovery(const int& fd, const std::string& udevId, |
| const int& netId); |
| |
| /** |
| * @brief: Sets up RDE, starting with MCTP setup to RDE Discovery |
| * |
| * @param[in] fd - MCTP Socket |
| * @param[in] objectServer - Dbus obj server |
| * @param[in] changedObject - Dbus object path defining that a new device is |
| * added |
| * @param[in] port - dev path location |
| * @param[in] udevId - udevId of the USB device |
| * @param[in] vendorId - Vendor id of the device |
| * @param[in] [prefixPath] - object path present in EM tree |
| * |
| * @return Status of the RDE setup |
| */ |
| int rdeSetup(const int& fd, sdbusplus::asio::object_server& objectServer, |
| const std::string& changedObject, const std::string& port, |
| const std::string& udevId, const std::string& vendorId, |
| const std::string& prefixPath); |
| }; |
| #endif // RDE_MATCH_HANDLER_HPP |