Ravi Teja | ce1c96f | 2020-10-05 23:13:01 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Andrew Jeffery | da4b13c | 2023-04-28 12:56:20 +0930 | [diff] [blame] | 3 | #include <cstdint> |
Ravi Teja | ce1c96f | 2020-10-05 23:13:01 -0500 | [diff] [blame] | 4 | #include <string> |
Pavithra Barithaya | 9e0e826 | 2024-04-15 09:12:16 -0500 | [diff] [blame] | 5 | #include <vector> |
Ravi Teja | ce1c96f | 2020-10-05 23:13:01 -0500 | [diff] [blame] | 6 | |
| 7 | namespace pldm |
| 8 | { |
| 9 | namespace responder |
| 10 | { |
| 11 | namespace utils |
| 12 | { |
| 13 | |
| 14 | /** @brief Setup UNIX socket |
| 15 | * This function creates listening socket in non-blocking mode and allows only |
| 16 | * one socket connection. returns accepted socket after accepting connection |
| 17 | * from peer. |
| 18 | * |
| 19 | * @param[in] socketInterface - unix socket path |
| 20 | * @return on success returns accepted socket fd |
| 21 | * on failure returns -1 |
| 22 | */ |
| 23 | int setupUnixSocket(const std::string& socketInterface); |
| 24 | |
| 25 | /** @brief Write data on UNIX socket |
| 26 | * This function writes given data to a non-blocking socket. |
| 27 | * Irrespective of block size, this function make sure of writing given data |
| 28 | * on unix socket. |
| 29 | * |
| 30 | * @param[in] sock - unix socket |
| 31 | * @param[in] buf - data buffer |
| 32 | * @param[in] blockSize - size of data to write |
| 33 | * @return on success retruns 0 |
| 34 | * on failure returns -1 |
| 35 | |
| 36 | */ |
| 37 | int writeToUnixSocket(const int sock, const char* buf, |
| 38 | const uint64_t blockSize); |
Sagar Srinivas | 3687e2b | 2023-04-10 05:08:28 -0500 | [diff] [blame] | 39 | |
Sampa Misra | 245fc6f | 2021-08-12 10:30:34 -0500 | [diff] [blame] | 40 | /** @brief checks if given FRU is IBM specific |
| 41 | * |
| 42 | * @param[in] objPath - FRU object path |
| 43 | * |
| 44 | * @return bool - true if IBM specific FRU |
| 45 | */ |
| 46 | bool checkIfIBMFru(const std::string& objPath); |
| 47 | |
Pavithra Barithaya | 9e0e826 | 2024-04-15 09:12:16 -0500 | [diff] [blame] | 48 | /** @brief finds the ports under an adapter |
| 49 | * |
| 50 | * @param[in] adapterObjPath - D-Bus object path for the adapter |
| 51 | * |
| 52 | * @return std::vector<std::string> - port object paths |
| 53 | */ |
| 54 | std::vector<std::string> findPortObjects(const std::string& adapterObjPath); |
| 55 | |
Ravi Teja | ce1c96f | 2020-10-05 23:13:01 -0500 | [diff] [blame] | 56 | } // namespace utils |
| 57 | } // namespace responder |
| 58 | } // namespace pldm |