blob: a1dfcf581f9d41e1f3d6cb46adb1de39e9ca6fb1 [file] [log] [blame]
Deepak Kodihalli4de4d002019-11-11 02:41:43 -06001#pragma once
2
3#include "instance_id.hpp"
4#include "xyz/openbmc_project/PLDM/Requester/server.hpp"
5
Deepak Kodihalli4de4d002019-11-11 02:41:43 -06006#include <sdbusplus/bus.hpp>
7#include <sdbusplus/server/object.hpp>
8
George Liu6492f522020-06-16 10:34:05 +08009#include <map>
10
Deepak Kodihalli4de4d002019-11-11 02:41:43 -060011namespace pldm
12{
13namespace dbus_api
14{
15
Patrick Williams84b790c2022-07-22 19:26:56 -050016using RequesterIntf = sdbusplus::server::object_t<
Deepak Kodihalli4de4d002019-11-11 02:41:43 -060017 sdbusplus::xyz::openbmc_project::PLDM::server::Requester>;
18
19/** @class Requester
20 * @brief OpenBMC PLDM.Requester implementation.
21 * @details A concrete implementation for the
22 * xyz.openbmc_project.PLDM.Requester DBus APIs.
23 */
24class Requester : public RequesterIntf
25{
26 public:
27 Requester() = delete;
28 Requester(const Requester&) = delete;
29 Requester& operator=(const Requester&) = delete;
30 Requester(Requester&&) = delete;
31 Requester& operator=(Requester&&) = delete;
32 virtual ~Requester() = default;
33
34 /** @brief Constructor to put object onto bus at a dbus path.
35 * @param[in] bus - Bus to attach to.
36 * @param[in] path - Path to attach at.
37 */
Patrick Williams84b790c2022-07-22 19:26:56 -050038 Requester(sdbusplus::bus_t& bus, const std::string& path) :
Deepak Kodihalli4de4d002019-11-11 02:41:43 -060039 RequesterIntf(bus, path.c_str()){};
40
41 /** @brief Implementation for RequesterIntf.GetInstanceId */
42 uint8_t getInstanceId(uint8_t eid) override;
43
44 /** @brief Mark an instance id as unused
45 * @param[in] eid - MCTP eid to which this instance id belongs
46 * @param[in] instanceId - PLDM instance id to be freed
47 * @note will throw std::out_of_range if instanceId > 31
48 */
49 void markFree(uint8_t eid, uint8_t instanceId)
50 {
51 ids[eid].markFree(instanceId);
52 }
53
54 private:
55 /** @brief EID to PLDM Instance ID map */
56 std::map<uint8_t, InstanceId> ids;
57};
58
59} // namespace dbus_api
60} // namespace pldm