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