Ed Tanous | 40e9b92 | 2024-09-10 13:50:16 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | // SPDX-FileCopyrightText: Copyright OpenBMC Authors |
| 3 | // SPDX-FileCopyrightText: Copyright 2018 Intel Corporation |
James Feist | 5b4aa86 | 2018-08-16 14:07:01 -0700 | [diff] [blame] | 4 | #pragma once |
| 5 | |
Ed Tanous | 95c6307 | 2024-03-26 13:19:52 -0700 | [diff] [blame] | 6 | #include "boost_formatters.hpp" |
Nan Zhou | 80d37e7 | 2022-06-21 17:46:14 +0000 | [diff] [blame] | 7 | #include "dbus_singleton.hpp" |
Ed Tanous | 863c1c2 | 2022-02-21 21:33:06 -0800 | [diff] [blame] | 8 | #include "logging.hpp" |
Nan Zhou | 80d37e7 | 2022-06-21 17:46:14 +0000 | [diff] [blame] | 9 | |
Ed Tanous | 478b7ad | 2024-07-15 19:11:54 -0700 | [diff] [blame] | 10 | #include <boost/system/error_code.hpp> |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 11 | #include <sdbusplus/asio/connection.hpp> |
George Liu | a4eb761 | 2023-02-11 15:49:46 +0800 | [diff] [blame] | 12 | #include <sdbusplus/asio/property.hpp> |
Nan Zhou | d5c80ad | 2022-07-11 01:16:31 +0000 | [diff] [blame] | 13 | #include <sdbusplus/message/native_types.hpp> |
James Feist | 5b4aa86 | 2018-08-16 14:07:01 -0700 | [diff] [blame] | 14 | |
Nan Zhou | 80d37e7 | 2022-06-21 17:46:14 +0000 | [diff] [blame] | 15 | #include <array> |
Nan Zhou | d5c80ad | 2022-07-11 01:16:31 +0000 | [diff] [blame] | 16 | #include <cstddef> |
| 17 | #include <cstdint> |
Manojkiran Eda | 17a897d | 2020-09-12 15:31:58 +0530 | [diff] [blame] | 18 | #include <filesystem> |
George Liu | 2138483 | 2022-11-09 11:21:15 +0800 | [diff] [blame] | 19 | #include <functional> |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 20 | #include <regex> |
George Liu | 2138483 | 2022-11-09 11:21:15 +0800 | [diff] [blame] | 21 | #include <span> |
Nan Zhou | 80d37e7 | 2022-06-21 17:46:14 +0000 | [diff] [blame] | 22 | #include <string> |
George Liu | 7a1dbc4 | 2022-12-07 16:03:22 +0800 | [diff] [blame] | 23 | #include <string_view> |
Nan Zhou | 80d37e7 | 2022-06-21 17:46:14 +0000 | [diff] [blame] | 24 | #include <tuple> |
Nan Zhou | d5c80ad | 2022-07-11 01:16:31 +0000 | [diff] [blame] | 25 | #include <utility> |
Ed Tanous | 4068129 | 2022-02-22 10:11:43 -0800 | [diff] [blame] | 26 | #include <variant> |
Nan Zhou | 80d37e7 | 2022-06-21 17:46:14 +0000 | [diff] [blame] | 27 | #include <vector> |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 28 | |
James Feist | 5b4aa86 | 2018-08-16 14:07:01 -0700 | [diff] [blame] | 29 | namespace dbus |
| 30 | { |
| 31 | |
| 32 | namespace utility |
| 33 | { |
| 34 | |
Ed Tanous | d1a6481 | 2021-12-13 12:14:05 -0800 | [diff] [blame] | 35 | // clang-format off |
Ed Tanous | 4068129 | 2022-02-22 10:11:43 -0800 | [diff] [blame] | 36 | using DbusVariantType = std::variant< |
Ed Tanous | d1a6481 | 2021-12-13 12:14:05 -0800 | [diff] [blame] | 37 | std::vector<std::tuple<std::string, std::string, std::string>>, |
| 38 | std::vector<std::string>, |
| 39 | std::vector<double>, |
| 40 | std::string, |
| 41 | int64_t, |
| 42 | uint64_t, |
| 43 | double, |
| 44 | int32_t, |
| 45 | uint32_t, |
| 46 | int16_t, |
| 47 | uint16_t, |
| 48 | uint8_t, |
| 49 | bool, |
Ed Tanous | d1a6481 | 2021-12-13 12:14:05 -0800 | [diff] [blame] | 50 | std::vector<uint32_t>, |
| 51 | std::vector<uint16_t>, |
| 52 | sdbusplus::message::object_path, |
Krzysztof Grobelny | 479e899 | 2021-06-17 13:37:57 +0000 | [diff] [blame] | 53 | std::tuple<uint64_t, std::vector<std::tuple<std::string, double, uint64_t>>>, |
Szymon Dompke | f19ab44 | 2022-03-07 14:28:06 +0100 | [diff] [blame] | 54 | std::vector<sdbusplus::message::object_path>, |
Ed Tanous | d1a6481 | 2021-12-13 12:14:05 -0800 | [diff] [blame] | 55 | std::vector<std::tuple<std::string, std::string>>, |
| 56 | std::vector<std::tuple<uint32_t, std::vector<uint32_t>>>, |
| 57 | std::vector<std::tuple<uint32_t, size_t>>, |
Krzysztof Grobelny | 479e899 | 2021-06-17 13:37:57 +0000 | [diff] [blame] | 58 | std::vector<std::tuple< |
| 59 | std::vector<std::tuple<sdbusplus::message::object_path, std::string>>, |
Ed Tanous | e364803 | 2024-10-16 18:06:39 -0700 | [diff] [blame] | 60 | std::string, std::string, uint64_t>>, |
| 61 | std::vector<std::pair<sdbusplus::message::object_path, std::string>>, |
Ed Tanous | 58c7148 | 2024-10-19 14:35:07 -0700 | [diff] [blame] | 62 | std::vector<std::tuple<std::string, uint64_t, std::string, double>>, |
| 63 | std::vector<std::tuple<std::string, std::string, uint64_t, std::string>> |
Ed Tanous | d1a6481 | 2021-12-13 12:14:05 -0800 | [diff] [blame] | 64 | >; |
James Feist | 5b4aa86 | 2018-08-16 14:07:01 -0700 | [diff] [blame] | 65 | |
Ed Tanous | d1a6481 | 2021-12-13 12:14:05 -0800 | [diff] [blame] | 66 | // clang-format on |
Ed Tanous | 711ac7a | 2021-12-20 09:34:41 -0800 | [diff] [blame] | 67 | using DBusPropertiesMap = std::vector<std::pair<std::string, DbusVariantType>>; |
Michael Shen | 80f79a4 | 2023-08-24 13:41:53 +0000 | [diff] [blame] | 68 | using DBusInterfacesMap = |
| 69 | std::vector<std::pair<std::string, DBusPropertiesMap>>; |
Zbigniew Kurzynski | 755a33c | 2020-02-28 14:06:37 +0100 | [diff] [blame] | 70 | using ManagedObjectType = |
Michael Shen | 80f79a4 | 2023-08-24 13:41:53 +0000 | [diff] [blame] | 71 | std::vector<std::pair<sdbusplus::message::object_path, DBusInterfacesMap>>; |
James Feist | 5b4aa86 | 2018-08-16 14:07:01 -0700 | [diff] [blame] | 72 | |
Shantappa Teekappanavar | 5df6eda | 2022-01-18 12:29:28 -0600 | [diff] [blame] | 73 | // Map of service name to list of interfaces |
| 74 | using MapperServiceMap = |
| 75 | std::vector<std::pair<std::string, std::vector<std::string>>>; |
| 76 | |
| 77 | // Map of object paths to MapperServiceMaps |
| 78 | using MapperGetSubTreeResponse = |
| 79 | std::vector<std::pair<std::string, MapperServiceMap>>; |
| 80 | |
Ed Tanous | b9d36b4 | 2022-02-26 21:42:46 -0800 | [diff] [blame] | 81 | using MapperGetObject = |
| 82 | std::vector<std::pair<std::string, std::vector<std::string>>>; |
| 83 | |
| 84 | using MapperGetAncestorsResponse = std::vector< |
| 85 | std::pair<std::string, |
| 86 | std::vector<std::pair<std::string, std::vector<std::string>>>>>; |
| 87 | |
| 88 | using MapperGetSubTreePathsResponse = std::vector<std::string>; |
| 89 | |
George Liu | a4eb761 | 2023-02-11 15:49:46 +0800 | [diff] [blame] | 90 | using MapperEndPoints = std::vector<std::string>; |
| 91 | |
James Feist | 5b4aa86 | 2018-08-16 14:07:01 -0700 | [diff] [blame] | 92 | inline void escapePathForDbus(std::string& path) |
| 93 | { |
Ed Tanous | 4b24274 | 2023-05-11 09:51:51 -0700 | [diff] [blame] | 94 | const static std::regex reg("[^A-Za-z0-9_/]"); |
James Feist | 5b4aa86 | 2018-08-16 14:07:01 -0700 | [diff] [blame] | 95 | std::regex_replace(path.begin(), path.begin(), path.end(), reg, "_"); |
| 96 | } |
| 97 | |
Ed Tanous | 863c1c2 | 2022-02-21 21:33:06 -0800 | [diff] [blame] | 98 | inline void logError(const boost::system::error_code& ec) |
| 99 | { |
| 100 | if (ec) |
| 101 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 102 | BMCWEB_LOG_ERROR("DBus error: {}, cannot call method", ec); |
Ed Tanous | 863c1c2 | 2022-02-21 21:33:06 -0800 | [diff] [blame] | 103 | } |
| 104 | } |
| 105 | |
James Feist | 5b4aa86 | 2018-08-16 14:07:01 -0700 | [diff] [blame] | 106 | // gets the string N strings deep into a path |
| 107 | // i.e. /0th/1st/2nd/3rd |
| 108 | inline bool getNthStringFromPath(const std::string& path, int index, |
| 109 | std::string& result) |
| 110 | { |
Manojkiran Eda | 17a897d | 2020-09-12 15:31:58 +0530 | [diff] [blame] | 111 | if (index < 0) |
James Feist | 5b4aa86 | 2018-08-16 14:07:01 -0700 | [diff] [blame] | 112 | { |
Manojkiran Eda | 17a897d | 2020-09-12 15:31:58 +0530 | [diff] [blame] | 113 | return false; |
| 114 | } |
| 115 | |
| 116 | std::filesystem::path p1(path); |
| 117 | int count = -1; |
Patrick Williams | 89492a1 | 2023-05-10 07:51:34 -0500 | [diff] [blame] | 118 | for (const auto& element : p1) |
Manojkiran Eda | 17a897d | 2020-09-12 15:31:58 +0530 | [diff] [blame] | 119 | { |
| 120 | if (element.has_filename()) |
James Feist | 5b4aa86 | 2018-08-16 14:07:01 -0700 | [diff] [blame] | 121 | { |
Manojkiran Eda | 17a897d | 2020-09-12 15:31:58 +0530 | [diff] [blame] | 122 | ++count; |
James Feist | 5b4aa86 | 2018-08-16 14:07:01 -0700 | [diff] [blame] | 123 | if (count == index) |
| 124 | { |
Manojkiran Eda | 17a897d | 2020-09-12 15:31:58 +0530 | [diff] [blame] | 125 | result = element.stem().string(); |
James Feist | 5b4aa86 | 2018-08-16 14:07:01 -0700 | [diff] [blame] | 126 | break; |
| 127 | } |
| 128 | } |
| 129 | } |
Ed Tanous | dcf2ebc | 2022-01-25 10:07:45 -0800 | [diff] [blame] | 130 | return count >= index; |
James Feist | 5b4aa86 | 2018-08-16 14:07:01 -0700 | [diff] [blame] | 131 | } |
| 132 | |
Ed Tanous | deae6a7 | 2024-11-11 21:58:57 -0800 | [diff] [blame] | 133 | inline void |
| 134 | getAllProperties(const std::string& service, const std::string& objectPath, |
| 135 | const std::string& interface, |
| 136 | std::function<void(const boost::system::error_code&, |
| 137 | const DBusPropertiesMap&)>&& callback) |
| 138 | { |
| 139 | sdbusplus::asio::getAllProperties(*crow::connections::systemBus, service, |
| 140 | objectPath, interface, |
| 141 | std::move(callback)); |
| 142 | } |
| 143 | |
| 144 | template <typename PropertyType> |
| 145 | inline void getProperty( |
| 146 | const std::string& service, const std::string& objectPath, |
| 147 | const std::string& interface, const std::string& propertyName, |
| 148 | std::function<void(const boost::system::error_code&, const PropertyType&)>&& |
| 149 | callback) |
| 150 | { |
| 151 | sdbusplus::asio::getProperty<PropertyType>( |
| 152 | *crow::connections::systemBus, service, objectPath, interface, |
| 153 | propertyName, std::move(callback)); |
| 154 | } |
| 155 | |
| 156 | template <typename PropertyType> |
| 157 | inline void getProperty( |
| 158 | sdbusplus::asio::connection& /*conn*/, const std::string& service, |
| 159 | const std::string& objectPath, const std::string& interface, |
| 160 | const std::string& propertyName, |
| 161 | std::function<void(const boost::system::error_code&, const PropertyType&)>&& |
| 162 | callback) |
| 163 | { |
| 164 | getProperty(service, objectPath, interface, propertyName, |
| 165 | std::move(callback)); |
| 166 | } |
| 167 | |
| 168 | inline void getAllProperties( |
| 169 | sdbusplus::asio::connection& /*conn*/, const std::string& service, |
| 170 | const std::string& objectPath, const std::string& interface, |
| 171 | std::function<void(const boost::system::error_code&, |
| 172 | const DBusPropertiesMap&)>&& callback) |
| 173 | { |
| 174 | getAllProperties(service, objectPath, interface, std::move(callback)); |
| 175 | } |
| 176 | |
Ed Tanous | d35c241 | 2024-11-18 04:45:30 -0800 | [diff] [blame] | 177 | inline void checkDbusPathExists(const std::string& path, |
| 178 | std::function<void(bool)>&& callback) |
Ratan Gupta | 22c3371 | 2019-05-03 21:50:28 +0530 | [diff] [blame] | 179 | { |
Ratan Gupta | 22c3371 | 2019-05-03 21:50:28 +0530 | [diff] [blame] | 180 | crow::connections::systemBus->async_method_call( |
Ed Tanous | d35c241 | 2024-11-18 04:45:30 -0800 | [diff] [blame] | 181 | [callback = std::move(callback)](const boost::system::error_code& ec, |
| 182 | const MapperGetObject& objectNames) { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 183 | callback(!ec && !objectNames.empty()); |
| 184 | }, |
Ratan Gupta | 22c3371 | 2019-05-03 21:50:28 +0530 | [diff] [blame] | 185 | "xyz.openbmc_project.ObjectMapper", |
| 186 | "/xyz/openbmc_project/object_mapper", |
| 187 | "xyz.openbmc_project.ObjectMapper", "GetObject", path, |
| 188 | std::array<std::string, 0>()); |
| 189 | } |
| 190 | |
George Liu | 2138483 | 2022-11-09 11:21:15 +0800 | [diff] [blame] | 191 | inline void |
George Liu | e99073f | 2022-12-09 11:06:16 +0800 | [diff] [blame] | 192 | getSubTree(const std::string& path, int32_t depth, |
| 193 | std::span<const std::string_view> interfaces, |
George Liu | 2138483 | 2022-11-09 11:21:15 +0800 | [diff] [blame] | 194 | std::function<void(const boost::system::error_code&, |
| 195 | const MapperGetSubTreeResponse&)>&& callback) |
| 196 | { |
| 197 | crow::connections::systemBus->async_method_call( |
| 198 | [callback{std::move(callback)}]( |
Ed Tanous | 5e7e2dc | 2023-02-16 10:37:01 -0800 | [diff] [blame] | 199 | const boost::system::error_code& ec, |
George Liu | 2138483 | 2022-11-09 11:21:15 +0800 | [diff] [blame] | 200 | const MapperGetSubTreeResponse& subtree) { callback(ec, subtree); }, |
| 201 | "xyz.openbmc_project.ObjectMapper", |
| 202 | "/xyz/openbmc_project/object_mapper", |
George Liu | e99073f | 2022-12-09 11:06:16 +0800 | [diff] [blame] | 203 | "xyz.openbmc_project.ObjectMapper", "GetSubTree", path, depth, |
| 204 | interfaces); |
George Liu | 2138483 | 2022-11-09 11:21:15 +0800 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | inline void getSubTreePaths( |
George Liu | 7a1dbc4 | 2022-12-07 16:03:22 +0800 | [diff] [blame] | 208 | const std::string& path, int32_t depth, |
| 209 | std::span<const std::string_view> interfaces, |
George Liu | 2138483 | 2022-11-09 11:21:15 +0800 | [diff] [blame] | 210 | std::function<void(const boost::system::error_code&, |
| 211 | const MapperGetSubTreePathsResponse&)>&& callback) |
| 212 | { |
| 213 | crow::connections::systemBus->async_method_call( |
| 214 | [callback{std::move(callback)}]( |
Ed Tanous | 5e7e2dc | 2023-02-16 10:37:01 -0800 | [diff] [blame] | 215 | const boost::system::error_code& ec, |
George Liu | 2138483 | 2022-11-09 11:21:15 +0800 | [diff] [blame] | 216 | const MapperGetSubTreePathsResponse& subtreePaths) { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 217 | callback(ec, subtreePaths); |
| 218 | }, |
George Liu | 2138483 | 2022-11-09 11:21:15 +0800 | [diff] [blame] | 219 | "xyz.openbmc_project.ObjectMapper", |
| 220 | "/xyz/openbmc_project/object_mapper", |
George Liu | 7a1dbc4 | 2022-12-07 16:03:22 +0800 | [diff] [blame] | 221 | "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths", path, depth, |
George Liu | 2138483 | 2022-11-09 11:21:15 +0800 | [diff] [blame] | 222 | interfaces); |
| 223 | } |
| 224 | |
Willy Tu | 8d01836 | 2023-04-14 09:14:16 -0700 | [diff] [blame] | 225 | inline void getAssociatedSubTree( |
| 226 | const sdbusplus::message::object_path& associatedPath, |
| 227 | const sdbusplus::message::object_path& path, int32_t depth, |
| 228 | std::span<const std::string_view> interfaces, |
| 229 | std::function<void(const boost::system::error_code&, |
| 230 | const MapperGetSubTreeResponse&)>&& callback) |
| 231 | { |
| 232 | crow::connections::systemBus->async_method_call( |
| 233 | [callback{std::move(callback)}]( |
| 234 | const boost::system::error_code& ec, |
| 235 | const MapperGetSubTreeResponse& subtree) { callback(ec, subtree); }, |
| 236 | "xyz.openbmc_project.ObjectMapper", |
| 237 | "/xyz/openbmc_project/object_mapper", |
| 238 | "xyz.openbmc_project.ObjectMapper", "GetAssociatedSubTree", |
| 239 | associatedPath, path, depth, interfaces); |
| 240 | } |
| 241 | |
| 242 | inline void getAssociatedSubTreePaths( |
| 243 | const sdbusplus::message::object_path& associatedPath, |
| 244 | const sdbusplus::message::object_path& path, int32_t depth, |
| 245 | std::span<const std::string_view> interfaces, |
| 246 | std::function<void(const boost::system::error_code&, |
| 247 | const MapperGetSubTreePathsResponse&)>&& callback) |
| 248 | { |
| 249 | crow::connections::systemBus->async_method_call( |
| 250 | [callback{std::move(callback)}]( |
| 251 | const boost::system::error_code& ec, |
| 252 | const MapperGetSubTreePathsResponse& subtreePaths) { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 253 | callback(ec, subtreePaths); |
| 254 | }, |
Willy Tu | 8d01836 | 2023-04-14 09:14:16 -0700 | [diff] [blame] | 255 | "xyz.openbmc_project.ObjectMapper", |
| 256 | "/xyz/openbmc_project/object_mapper", |
| 257 | "xyz.openbmc_project.ObjectMapper", "GetAssociatedSubTreePaths", |
| 258 | associatedPath, path, depth, interfaces); |
| 259 | } |
| 260 | |
Lakshmi Yadlapati | 64d8e80 | 2024-06-26 17:41:19 -0500 | [diff] [blame] | 261 | inline void getAssociatedSubTreeById( |
| 262 | const std::string& id, const std::string& path, |
| 263 | std::span<const std::string_view> subtreeInterfaces, |
| 264 | std::string_view association, |
| 265 | std::span<const std::string_view> endpointInterfaces, |
| 266 | std::function<void(const boost::system::error_code&, |
| 267 | const MapperGetSubTreeResponse&)>&& callback) |
| 268 | { |
| 269 | crow::connections::systemBus->async_method_call( |
| 270 | [callback{std::move(callback)}]( |
| 271 | const boost::system::error_code& ec, |
| 272 | const MapperGetSubTreeResponse& subtree) { callback(ec, subtree); }, |
| 273 | "xyz.openbmc_project.ObjectMapper", |
| 274 | "/xyz/openbmc_project/object_mapper", |
| 275 | "xyz.openbmc_project.ObjectMapper", "GetAssociatedSubTreeById", id, |
| 276 | path, subtreeInterfaces, association, endpointInterfaces); |
| 277 | } |
| 278 | |
| 279 | inline void getAssociatedSubTreePathsById( |
| 280 | const std::string& id, const std::string& path, |
| 281 | std::span<const std::string_view> subtreeInterfaces, |
| 282 | std::string_view association, |
| 283 | std::span<const std::string_view> endpointInterfaces, |
| 284 | std::function<void(const boost::system::error_code&, |
| 285 | const MapperGetSubTreePathsResponse&)>&& callback) |
| 286 | { |
| 287 | crow::connections::systemBus->async_method_call( |
| 288 | [callback{std::move(callback)}]( |
| 289 | const boost::system::error_code& ec, |
| 290 | const MapperGetSubTreePathsResponse& subtreePaths) { |
| 291 | callback(ec, subtreePaths); |
| 292 | }, |
| 293 | "xyz.openbmc_project.ObjectMapper", |
| 294 | "/xyz/openbmc_project/object_mapper", |
| 295 | "xyz.openbmc_project.ObjectMapper", "GetAssociatedSubTreePathsById", id, |
| 296 | path, subtreeInterfaces, association, endpointInterfaces); |
| 297 | } |
| 298 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 299 | inline void getDbusObject( |
| 300 | const std::string& path, std::span<const std::string_view> interfaces, |
| 301 | std::function<void(const boost::system::error_code&, |
| 302 | const MapperGetObject&)>&& callback) |
George Liu | 2b73119 | 2023-01-11 16:27:13 +0800 | [diff] [blame] | 303 | { |
| 304 | crow::connections::systemBus->async_method_call( |
| 305 | [callback{std::move(callback)}](const boost::system::error_code& ec, |
| 306 | const MapperGetObject& object) { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 307 | callback(ec, object); |
| 308 | }, |
George Liu | 2b73119 | 2023-01-11 16:27:13 +0800 | [diff] [blame] | 309 | "xyz.openbmc_project.ObjectMapper", |
| 310 | "/xyz/openbmc_project/object_mapper", |
| 311 | "xyz.openbmc_project.ObjectMapper", "GetObject", path, interfaces); |
| 312 | } |
| 313 | |
George Liu | a4eb761 | 2023-02-11 15:49:46 +0800 | [diff] [blame] | 314 | inline void getAssociationEndPoints( |
| 315 | const std::string& path, |
| 316 | std::function<void(const boost::system::error_code&, |
| 317 | const MapperEndPoints&)>&& callback) |
| 318 | { |
Ed Tanous | deae6a7 | 2024-11-11 21:58:57 -0800 | [diff] [blame] | 319 | getProperty<MapperEndPoints>("xyz.openbmc_project.ObjectMapper", path, |
| 320 | "xyz.openbmc_project.Association", "endpoints", |
| 321 | std::move(callback)); |
George Liu | a4eb761 | 2023-02-11 15:49:46 +0800 | [diff] [blame] | 322 | } |
| 323 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 324 | inline void getManagedObjects( |
| 325 | const std::string& service, const sdbusplus::message::object_path& path, |
| 326 | std::function<void(const boost::system::error_code&, |
| 327 | const ManagedObjectType&)>&& callback) |
George Liu | f5892d0 | 2023-03-01 10:37:08 +0800 | [diff] [blame] | 328 | { |
| 329 | crow::connections::systemBus->async_method_call( |
| 330 | [callback{std::move(callback)}](const boost::system::error_code& ec, |
| 331 | const ManagedObjectType& objects) { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 332 | callback(ec, objects); |
| 333 | }, |
George Liu | f5892d0 | 2023-03-01 10:37:08 +0800 | [diff] [blame] | 334 | service, path, "org.freedesktop.DBus.ObjectManager", |
| 335 | "GetManagedObjects"); |
| 336 | } |
| 337 | |
James Feist | 5b4aa86 | 2018-08-16 14:07:01 -0700 | [diff] [blame] | 338 | } // namespace utility |
| 339 | } // namespace dbus |