blob: a9a4e186778ec14e01c3dca40c2f98c373686a76 [file] [log] [blame]
Vernon Mauery20ff3332019-03-01 16:52:25 -08001#include <ipmid/api.hpp>
Vernon Mauery20ff3332019-03-01 16:52:25 -08002#include <sdbusplus/asio/connection.hpp>
3
Patrick Williamsfbc6c9d2023-05-10 07:50:16 -05004#include <memory>
5
Vernon Mauery20ff3332019-03-01 16:52:25 -08006namespace
7{
8
9std::unique_ptr<sdbusplus::asio::connection> sdbusp;
10
11} // namespace
12
13/**
14 * @brief ipmid_get_sdbus_plus_handler is used by some ipmi providers
15 *
16 * @return: a reference to a unique pointer of the systemd connection
17 * managed by the systemintfcmds code
18 */
19std::unique_ptr<sdbusplus::asio::connection>& ipmid_get_sdbus_plus_handler()
20{
21 if (!sdbusp)
22 {
23 // Create a new sdbus connection so it can have a well-known name
24 sd_bus* bus = nullptr;
25 sd_bus_open_system(&bus);
26 if (bus)
27 {
28 sdbusp = std::make_unique<sdbusplus::asio::connection>(
29 *getIoContext(), bus);
30 }
31 }
32 return sdbusp;
33}