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