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