blob: 4e849f572d26a4e0360a25144c12bddda325d3ac [file] [log] [blame]
Ravi Tejace1c96f2020-10-05 23:13:01 -05001#pragma once
2
Kamalkumar Pateleb43d6c2024-05-01 06:11:31 -05003#include "libpldmresponder/oem_handler.hpp"
4
Andrew Jefferyda4b13c2023-04-28 12:56:20 +09305#include <cstdint>
Ravi Tejace1c96f2020-10-05 23:13:01 -05006#include <string>
Pavithra Barithaya9e0e8262024-04-15 09:12:16 -05007#include <vector>
Ravi Tejace1c96f2020-10-05 23:13:01 -05008
9namespace pldm
10{
11namespace responder
12{
13namespace 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 */
25int 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 Eda2576aec2024-06-17 12:05:17 +053035 * @return on success returns 0
Ravi Tejace1c96f2020-10-05 23:13:01 -050036 * on failure returns -1
37
38 */
39int writeToUnixSocket(const int sock, const char* buf,
40 const uint64_t blockSize);
Sagar Srinivas3687e2b2023-04-10 05:08:28 -050041
Sampa Misra245fc6f2021-08-12 10:30:34 -050042/** @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 */
48bool checkIfIBMFru(const std::string& objPath);
49
Pavithra Barithaya9e0e8262024-04-15 09:12:16 -050050/** @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 */
56std::vector<std::string> findPortObjects(const std::string& adapterObjPath);
57
Ravi Tejace1c96f2020-10-05 23:13:01 -050058} // namespace utils
Kamalkumar Pateleb43d6c2024-05-01 06:11:31 -050059
60namespace oem_ibm_utils
61{
62
63class 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 Tejace1c96f2020-10-05 23:13:01 -050087} // namespace responder
88} // namespace pldm