1 #pragma once
2 
3 #include <cstdint>
4 #include <string>
5 #include <vector>
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);
39 
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 
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 
56 } // namespace utils
57 } // namespace responder
58 } // namespace pldm
59