Ravi Teja | ce1c96f | 2020-10-05 23:13:01 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Kamalkumar Patel | eb43d6c | 2024-05-01 06:11:31 -0500 | [diff] [blame] | 3 | #include "libpldmresponder/oem_handler.hpp" |
| 4 | |
Andrew Jeffery | da4b13c | 2023-04-28 12:56:20 +0930 | [diff] [blame] | 5 | #include <cstdint> |
Ravi Teja | ce1c96f | 2020-10-05 23:13:01 -0500 | [diff] [blame] | 6 | #include <string> |
Pavithra Barithaya | 9e0e826 | 2024-04-15 09:12:16 -0500 | [diff] [blame] | 7 | #include <vector> |
Ravi Teja | ce1c96f | 2020-10-05 23:13:01 -0500 | [diff] [blame] | 8 | |
| 9 | namespace pldm |
| 10 | { |
| 11 | namespace responder |
| 12 | { |
| 13 | namespace utils |
| 14 | { |
| 15 | |
| 16 | /** @brief Setup UNIX socket |
| 17 | * This function creates listening socket in non-blocking mode and allows only |
| 18 | * one socket connection. returns accepted socket after accepting connection |
| 19 | * from peer. |
| 20 | * |
| 21 | * @param[in] socketInterface - unix socket path |
| 22 | * @return on success returns accepted socket fd |
| 23 | * on failure returns -1 |
| 24 | */ |
| 25 | int setupUnixSocket(const std::string& socketInterface); |
| 26 | |
| 27 | /** @brief Write data on UNIX socket |
| 28 | * This function writes given data to a non-blocking socket. |
| 29 | * Irrespective of block size, this function make sure of writing given data |
| 30 | * on unix socket. |
| 31 | * |
| 32 | * @param[in] sock - unix socket |
| 33 | * @param[in] buf - data buffer |
| 34 | * @param[in] blockSize - size of data to write |
Manojkiran Eda | 2576aec | 2024-06-17 12:05:17 +0530 | [diff] [blame] | 35 | * @return on success returns 0 |
Ravi Teja | ce1c96f | 2020-10-05 23:13:01 -0500 | [diff] [blame] | 36 | * on failure returns -1 |
| 37 | |
| 38 | */ |
| 39 | int writeToUnixSocket(const int sock, const char* buf, |
| 40 | const uint64_t blockSize); |
Sagar Srinivas | 3687e2b | 2023-04-10 05:08:28 -0500 | [diff] [blame] | 41 | |
Sampa Misra | 245fc6f | 2021-08-12 10:30:34 -0500 | [diff] [blame] | 42 | /** @brief checks if given FRU is IBM specific |
| 43 | * |
| 44 | * @param[in] objPath - FRU object path |
| 45 | * |
| 46 | * @return bool - true if IBM specific FRU |
| 47 | */ |
| 48 | bool checkIfIBMFru(const std::string& objPath); |
| 49 | |
Pavithra Barithaya | 9e0e826 | 2024-04-15 09:12:16 -0500 | [diff] [blame] | 50 | /** @brief finds the ports under an adapter |
| 51 | * |
| 52 | * @param[in] adapterObjPath - D-Bus object path for the adapter |
| 53 | * |
| 54 | * @return std::vector<std::string> - port object paths |
| 55 | */ |
| 56 | std::vector<std::string> findPortObjects(const std::string& adapterObjPath); |
| 57 | |
Ravi Teja | ce1c96f | 2020-10-05 23:13:01 -0500 | [diff] [blame] | 58 | } // namespace utils |
Kamalkumar Patel | eb43d6c | 2024-05-01 06:11:31 -0500 | [diff] [blame] | 59 | |
| 60 | namespace oem_ibm_utils |
| 61 | { |
| 62 | |
| 63 | class Handler : public oem_utils::Handler |
| 64 | { |
| 65 | public: |
| 66 | Handler(const pldm::utils::DBusHandler* dBusIntf) : |
| 67 | oem_utils::Handler(dBusIntf), dBusIntf(dBusIntf) |
| 68 | {} |
| 69 | |
| 70 | /** @brief Collecting core count data and setting to Dbus properties |
| 71 | * |
| 72 | * @param[in] associations - the data of entity association |
| 73 | * @param[in] entityMaps - the mapping of entity to DBus string |
| 74 | * |
| 75 | */ |
| 76 | virtual int |
| 77 | setCoreCount(const pldm::utils::EntityAssociations& associations, |
| 78 | const pldm::utils::EntityMaps entityMaps); |
| 79 | |
| 80 | virtual ~Handler() = default; |
| 81 | |
| 82 | protected: |
| 83 | const pldm::utils::DBusHandler* dBusIntf; |
| 84 | }; |
| 85 | |
| 86 | } // namespace oem_ibm_utils |
Ravi Teja | ce1c96f | 2020-10-05 23:13:01 -0500 | [diff] [blame] | 87 | } // namespace responder |
| 88 | } // namespace pldm |