Andrew Geissler | 3b025e6 | 2019-02-01 10:33:54 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Andrew Geissler | 2067926 | 2019-02-11 20:20:40 -0600 | [diff] [blame] | 3 | #include "associations.hpp" |
Matt Spinler | 35396c1 | 2019-04-05 11:46:57 -0500 | [diff] [blame] | 4 | #include "types.hpp" |
Andrew Geissler | 2067926 | 2019-02-11 20:20:40 -0600 | [diff] [blame] | 5 | |
Andrew Geissler | 3b025e6 | 2019-02-01 10:33:54 -0600 | [diff] [blame] | 6 | #include <boost/container/flat_map.hpp> |
Brad Bishop | 2352088 | 2022-05-26 21:39:53 -0400 | [diff] [blame] | 7 | |
Matt Spinler | 8f876a5 | 2019-04-15 13:22:50 -0500 | [diff] [blame] | 8 | #include <cassert> |
Andrew Geissler | 3b025e6 | 2019-02-01 10:33:54 -0600 | [diff] [blame] | 9 | #include <string> |
| 10 | |
John Wang | d0cf942 | 2019-09-17 16:01:34 +0800 | [diff] [blame] | 11 | /** @brief The associations definitions interface */ |
Matt Spinler | 8f876a5 | 2019-04-15 13:22:50 -0500 | [diff] [blame] | 12 | constexpr const char* assocDefsInterface = |
| 13 | "xyz.openbmc_project.Association.Definitions"; |
| 14 | |
John Wang | d0cf942 | 2019-09-17 16:01:34 +0800 | [diff] [blame] | 15 | /** @brief The associations definitions property name */ |
| 16 | constexpr const char* assocDefsProperty = "Associations"; |
Andrew Geissler | 2067926 | 2019-02-11 20:20:40 -0600 | [diff] [blame] | 17 | |
Andrew Geissler | 7046189 | 2019-02-27 09:57:37 -0600 | [diff] [blame] | 18 | /** @brief InterfacesAdded represents the dbus data from the signal |
| 19 | * |
| 20 | * There are 2 pairs |
| 21 | * pair1: D-bus Interface,vector[pair2] |
| 22 | * pair2: D-bus Method,vector[Associations] |
| 23 | */ |
| 24 | using InterfacesAdded = std::vector<std::pair< |
Patrick Williams | 2bb2d6b | 2020-05-13 17:59:02 -0500 | [diff] [blame] | 25 | std::string, std::vector<std::pair< |
| 26 | std::string, std::variant<std::vector<Association>>>>>>; |
Andrew Geissler | 7046189 | 2019-02-27 09:57:37 -0600 | [diff] [blame] | 27 | |
Andrew Geissler | 3b025e6 | 2019-02-01 10:33:54 -0600 | [diff] [blame] | 28 | /** @brief Get well known name of input unique name |
| 29 | * |
| 30 | * If user passes in well known name then that will be returned. |
| 31 | * |
| 32 | * @param[in] owners - Current list of owners |
| 33 | * @param[in] request - The name to look up |
| 34 | * @param[out] wellKnown - The well known name if found |
| 35 | * |
| 36 | * @return True if well known name is found, false otherwise |
| 37 | */ |
| 38 | bool getWellKnown( |
| 39 | const boost::container::flat_map<std::string, std::string>& owners, |
Brad Bishop | a098a37 | 2022-05-05 15:19:04 -0400 | [diff] [blame] | 40 | const std::string& request, std::string& wellKnown); |
Andrew Geissler | 82815da | 2019-02-04 12:19:41 -0600 | [diff] [blame] | 41 | |
| 42 | /** @brief Determine if dbus service is something to monitor |
| 43 | * |
Brad Bishop | 1e94e60 | 2022-06-02 19:47:53 -0400 | [diff] [blame] | 44 | * mapper does not monitor all DBus services. needToIntrospect determines |
| 45 | * whether or not a service is to be monitored. |
Andrew Geissler | 82815da | 2019-02-04 12:19:41 -0600 | [diff] [blame] | 46 | * |
| 47 | * @param[in] processName - Dbus service name |
Andrew Geissler | 82815da | 2019-02-04 12:19:41 -0600 | [diff] [blame] | 48 | * |
Brad Bishop | a098a37 | 2022-05-05 15:19:04 -0400 | [diff] [blame] | 49 | * @return True if input processName should be monitored, false otherwise |
Andrew Geissler | 82815da | 2019-02-04 12:19:41 -0600 | [diff] [blame] | 50 | */ |
Brad Bishop | 1e94e60 | 2022-06-02 19:47:53 -0400 | [diff] [blame] | 51 | bool needToIntrospect(const std::string& processName); |
Andrew Geissler | 2067926 | 2019-02-11 20:20:40 -0600 | [diff] [blame] | 52 | |
| 53 | /** @brief Handle the removal of an existing name in objmgr data structures |
| 54 | * |
Kallas, Pawel | 5b4357d | 2022-10-12 15:36:37 +0200 | [diff] [blame] | 55 | * @param[in] io - io context |
Andrew Geissler | 2067926 | 2019-02-11 20:20:40 -0600 | [diff] [blame] | 56 | * @param[in,out] nameOwners - Map of unique name to well known name |
| 57 | * @param[in] wellKnown - Well known name that has new owner |
| 58 | * @param[in] oldOwner - Old unique name |
| 59 | * @param[in,out] interfaceMap - Map of interfaces |
Matt Spinler | e2359fb | 2019-04-05 14:11:33 -0500 | [diff] [blame] | 60 | * @param[in,out] assocMaps - The association maps |
Andrew Geissler | 2067926 | 2019-02-11 20:20:40 -0600 | [diff] [blame] | 61 | * @param[in,out] server - sdbus system object |
| 62 | * |
| 63 | */ |
| 64 | void processNameChangeDelete( |
Kallas, Pawel | 5b4357d | 2022-10-12 15:36:37 +0200 | [diff] [blame] | 65 | boost::asio::io_context& io, |
Andrew Geissler | 2067926 | 2019-02-11 20:20:40 -0600 | [diff] [blame] | 66 | boost::container::flat_map<std::string, std::string>& nameOwners, |
| 67 | const std::string& wellKnown, const std::string& oldOwner, |
Brad Bishop | a098a37 | 2022-05-05 15:19:04 -0400 | [diff] [blame] | 68 | InterfaceMapType& interfaceMap, AssociationMaps& assocMaps, |
Andrew Geissler | 2067926 | 2019-02-11 20:20:40 -0600 | [diff] [blame] | 69 | sdbusplus::asio::object_server& server); |
Andrew Geissler | 7046189 | 2019-02-27 09:57:37 -0600 | [diff] [blame] | 70 | |
| 71 | /** @brief Handle an interfaces added signal |
| 72 | * |
Kallas, Pawel | 5b4357d | 2022-10-12 15:36:37 +0200 | [diff] [blame] | 73 | * @param[in] io - io context |
Andrew Geissler | 7046189 | 2019-02-27 09:57:37 -0600 | [diff] [blame] | 74 | * @param[in,out] interfaceMap - Global map of interfaces |
| 75 | * @param[in] objPath - New path to process |
| 76 | * @param[in] interfacesAdded - New interfaces to process |
| 77 | * @param[in] wellKnown - Well known name that has new owner |
Matt Spinler | e2359fb | 2019-04-05 14:11:33 -0500 | [diff] [blame] | 78 | * @param[in,out] assocMaps - The association maps |
Andrew Geissler | 7046189 | 2019-02-27 09:57:37 -0600 | [diff] [blame] | 79 | * @param[in,out] server - sdbus system object |
| 80 | * |
| 81 | */ |
Patrick Williams | 9052ebd | 2024-08-16 15:22:16 -0400 | [diff] [blame] | 82 | void processInterfaceAdded( |
| 83 | boost::asio::io_context& io, InterfaceMapType& interfaceMap, |
| 84 | const sdbusplus::message::object_path& objPath, |
| 85 | const InterfacesAdded& intfAdded, const std::string& wellKnown, |
| 86 | AssociationMaps& assocMaps, sdbusplus::asio::object_server& server); |