Vernon Mauery | 20ff333 | 2019-03-01 16:52:25 -0800 | [diff] [blame] | 1 | #include <ipmid/api.hpp> |
| 2 | #include <memory> |
| 3 | #include <sdbusplus/asio/connection.hpp> |
| 4 | |
| 5 | namespace |
| 6 | { |
| 7 | |
| 8 | std::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 | */ |
| 18 | std::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 | } |