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