blob: 5830feeafef417f08a3dfe96a37f543d5d8df07a [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
Pavithra Barithayacee5ecc2025-09-17 16:31:31 +053016constexpr uint32_t BMC_PDR_START_RANGE = 0x00000000;
17constexpr uint32_t BMC_PDR_END_RANGE = 0x00FFFFFF;
18
Ravi Tejace1c96f2020-10-05 23:13:01 -050019/** @brief Setup UNIX socket
20 * This function creates listening socket in non-blocking mode and allows only
21 * one socket connection. returns accepted socket after accepting connection
22 * from peer.
23 *
24 * @param[in] socketInterface - unix socket path
25 * @return on success returns accepted socket fd
26 * on failure returns -1
27 */
28int setupUnixSocket(const std::string& socketInterface);
29
30/** @brief Write data on UNIX socket
31 * This function writes given data to a non-blocking socket.
32 * Irrespective of block size, this function make sure of writing given data
33 * on unix socket.
34 *
35 * @param[in] sock - unix socket
36 * @param[in] buf - data buffer
37 * @param[in] blockSize - size of data to write
Manojkiran Eda2576aec2024-06-17 12:05:17 +053038 * @return on success returns 0
Ravi Tejace1c96f2020-10-05 23:13:01 -050039 * on failure returns -1
40
41 */
42int writeToUnixSocket(const int sock, const char* buf,
43 const uint64_t blockSize);
Sagar Srinivas3687e2b2023-04-10 05:08:28 -050044
Sampa Misra245fc6f2021-08-12 10:30:34 -050045/** @brief checks if given FRU is IBM specific
46 *
47 * @param[in] objPath - FRU object path
48 *
49 * @return bool - true if IBM specific FRU
50 */
51bool checkIfIBMFru(const std::string& objPath);
52
Pavithra Barithaya9e0e8262024-04-15 09:12:16 -050053/** @brief finds the ports under an adapter
54 *
55 * @param[in] adapterObjPath - D-Bus object path for the adapter
56 *
57 * @return std::vector<std::string> - port object paths
58 */
59std::vector<std::string> findPortObjects(const std::string& adapterObjPath);
60
Ravi Tejace1c96f2020-10-05 23:13:01 -050061} // namespace utils
Kamalkumar Pateleb43d6c2024-05-01 06:11:31 -050062
63namespace oem_ibm_utils
64{
65
66class Handler : public oem_utils::Handler
67{
68 public:
69 Handler(const pldm::utils::DBusHandler* dBusIntf) :
70 oem_utils::Handler(dBusIntf), dBusIntf(dBusIntf)
71 {}
72
73 /** @brief Collecting core count data and setting to Dbus properties
74 *
75 * @param[in] associations - the data of entity association
76 * @param[in] entityMaps - the mapping of entity to DBus string
77 *
78 */
Patrick Williams366507c2025-02-03 14:28:01 -050079 virtual int setCoreCount(
80 const pldm::utils::EntityAssociations& associations,
81 const pldm::utils::EntityMaps entityMaps);
Kamalkumar Pateleb43d6c2024-05-01 06:11:31 -050082
83 virtual ~Handler() = default;
84
85 protected:
86 const pldm::utils::DBusHandler* dBusIntf;
87};
88
89} // namespace oem_ibm_utils
Ravi Tejace1c96f2020-10-05 23:13:01 -050090} // namespace responder
91} // namespace pldm