1 #pragma once
2 
3 #include "libpldmresponder/oem_handler.hpp"
4 
5 #include <cstdint>
6 #include <string>
7 #include <vector>
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
35  *  @return   on success returns  0
36  *            on failure returns -1
37 
38  */
39 int writeToUnixSocket(const int sock, const char* buf,
40                       const uint64_t blockSize);
41 
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 
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 
58 } // namespace utils
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
87 } // namespace responder
88 } // namespace pldm
89