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" |
| 4 | |
Andrew Geissler | 3b025e6 | 2019-02-01 10:33:54 -0600 | [diff] [blame] | 5 | #include <boost/container/flat_map.hpp> |
Andrew Geissler | 82815da | 2019-02-04 12:19:41 -0600 | [diff] [blame] | 6 | #include <boost/container/flat_set.hpp> |
Andrew Geissler | 3b025e6 | 2019-02-01 10:33:54 -0600 | [diff] [blame] | 7 | #include <string> |
| 8 | |
Andrew Geissler | 82815da | 2019-02-04 12:19:41 -0600 | [diff] [blame] | 9 | /** @brief Define white list and black list data structure */ |
| 10 | using WhiteBlackList = boost::container::flat_set<std::string>; |
| 11 | |
Andrew Geissler | 2067926 | 2019-02-11 20:20:40 -0600 | [diff] [blame] | 12 | /** @brief Dbus interface which contains org.openbmc Associations */ |
| 13 | constexpr const char* ASSOCIATIONS_INTERFACE = "org.openbmc.Associations"; |
| 14 | |
| 15 | /** @brief interface_map_type is the underlying datastructure the mapper uses. |
| 16 | * |
| 17 | * The 3 levels of map are |
| 18 | * object paths |
| 19 | * connection names |
| 20 | * interface names |
| 21 | */ |
| 22 | using interface_map_type = boost::container::flat_map< |
| 23 | std::string, boost::container::flat_map< |
| 24 | std::string, boost::container::flat_set<std::string>>>; |
| 25 | |
Andrew Geissler | 7046189 | 2019-02-27 09:57:37 -0600 | [diff] [blame] | 26 | /** @brief InterfacesAdded represents the dbus data from the signal |
| 27 | * |
| 28 | * There are 2 pairs |
| 29 | * pair1: D-bus Interface,vector[pair2] |
| 30 | * pair2: D-bus Method,vector[Associations] |
| 31 | */ |
| 32 | using InterfacesAdded = std::vector<std::pair< |
| 33 | std::string, |
| 34 | std::vector<std::pair< |
| 35 | std::string, sdbusplus::message::variant<std::vector<Association>>>>>>; |
| 36 | |
Andrew Geissler | 3b025e6 | 2019-02-01 10:33:54 -0600 | [diff] [blame] | 37 | /** @brief Get well known name of input unique name |
| 38 | * |
| 39 | * If user passes in well known name then that will be returned. |
| 40 | * |
| 41 | * @param[in] owners - Current list of owners |
| 42 | * @param[in] request - The name to look up |
| 43 | * @param[out] wellKnown - The well known name if found |
| 44 | * |
| 45 | * @return True if well known name is found, false otherwise |
| 46 | */ |
| 47 | bool getWellKnown( |
| 48 | const boost::container::flat_map<std::string, std::string>& owners, |
Andrew Geissler | 82815da | 2019-02-04 12:19:41 -0600 | [diff] [blame] | 49 | const std::string& request, std::string& well_known); |
| 50 | |
| 51 | /** @brief Determine if dbus service is something to monitor |
| 52 | * |
| 53 | * mapper supports a whitelist and blacklist concept. If a whitelist is provided |
| 54 | * as input then only dbus objects matching that list is monitored. If a |
| 55 | * blacklist is provided then objects matching it will not be monitored. |
| 56 | * |
| 57 | * @param[in] processName - Dbus service name |
| 58 | * @param[in] whiteList - The white list |
| 59 | * @param[in] blackList - The black list |
| 60 | * |
| 61 | * @return True if input process_name should be monitored, false otherwise |
| 62 | */ |
| 63 | bool needToIntrospect(const std::string& processName, |
| 64 | const WhiteBlackList& whiteList, |
| 65 | const WhiteBlackList& blackList); |
Andrew Geissler | 2067926 | 2019-02-11 20:20:40 -0600 | [diff] [blame] | 66 | |
| 67 | /** @brief Handle the removal of an existing name in objmgr data structures |
| 68 | * |
| 69 | * @param[in,out] nameOwners - Map of unique name to well known name |
| 70 | * @param[in] wellKnown - Well known name that has new owner |
| 71 | * @param[in] oldOwner - Old unique name |
| 72 | * @param[in,out] interfaceMap - Map of interfaces |
| 73 | * @param[in,out] assocOwners - Owners of associations |
| 74 | * @param[in,out] assocInterfaces - Associations endpoints |
| 75 | * @param[in,out] server - sdbus system object |
| 76 | * |
| 77 | */ |
| 78 | void processNameChangeDelete( |
| 79 | boost::container::flat_map<std::string, std::string>& nameOwners, |
| 80 | const std::string& wellKnown, const std::string& oldOwner, |
| 81 | interface_map_type& interfaceMap, AssociationOwnersType& assocOwners, |
| 82 | AssociationInterfaces& assocInterfaces, |
| 83 | sdbusplus::asio::object_server& server); |
Andrew Geissler | 7046189 | 2019-02-27 09:57:37 -0600 | [diff] [blame] | 84 | |
| 85 | /** @brief Handle an interfaces added signal |
| 86 | * |
| 87 | * @param[in,out] interfaceMap - Global map of interfaces |
| 88 | * @param[in] objPath - New path to process |
| 89 | * @param[in] interfacesAdded - New interfaces to process |
| 90 | * @param[in] wellKnown - Well known name that has new owner |
| 91 | * @param[in,out] assocOwners - Owners of associations |
| 92 | * @param[in,out] assocInterfaces - Associations endpoints |
| 93 | * @param[in,out] server - sdbus system object |
| 94 | * |
| 95 | */ |
| 96 | void processInterfaceAdded(interface_map_type& interfaceMap, |
| 97 | const sdbusplus::message::object_path& objPath, |
| 98 | const InterfacesAdded& intfAdded, |
| 99 | const std::string& wellKnown, |
| 100 | AssociationOwnersType& assocOwners, |
| 101 | AssociationInterfaces& assocInterfaces, |
| 102 | sdbusplus::asio::object_server& server); |