blob: ac7549f9a1f9a403764ccc7e634a67ec216a8d42 [file] [log] [blame]
Ravi Tejace1c96f2020-10-05 23:13:01 -05001#pragma once
2
Andrew Jefferyda4b13c2023-04-28 12:56:20 +09303#include <cstdint>
Ravi Tejace1c96f2020-10-05 23:13:01 -05004#include <string>
Pavithra Barithaya9e0e8262024-04-15 09:12:16 -05005#include <vector>
Ravi Tejace1c96f2020-10-05 23:13:01 -05006
7namespace pldm
8{
9namespace responder
10{
11namespace 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 */
23int 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 */
37int writeToUnixSocket(const int sock, const char* buf,
38 const uint64_t blockSize);
Sagar Srinivas3687e2b2023-04-10 05:08:28 -050039
Sampa Misra245fc6f2021-08-12 10:30:34 -050040/** @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 */
46bool checkIfIBMFru(const std::string& objPath);
47
Pavithra Barithaya9e0e8262024-04-15 09:12:16 -050048/** @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 */
54std::vector<std::string> findPortObjects(const std::string& adapterObjPath);
55
Ravi Tejace1c96f2020-10-05 23:13:01 -050056} // namespace utils
57} // namespace responder
58} // namespace pldm