1 #include <ipmid/api.hpp>
2 #include <sdbusplus/asio/connection.hpp>
3 
4 #include <memory>
5 
6 namespace
7 {
8 
9 std::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  */
19 std::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 }
34