blob: d5ed2b4d9b55d8c7e40299684c6d69c298dcbc74 [file] [log] [blame]
Andrew Geissler3b025e62019-02-01 10:33:54 -06001#pragma once
2
Andrew Geissler20679262019-02-11 20:20:40 -06003#include "associations.hpp"
4
Andrew Geissler3b025e62019-02-01 10:33:54 -06005#include <boost/container/flat_map.hpp>
Andrew Geissler82815da2019-02-04 12:19:41 -06006#include <boost/container/flat_set.hpp>
Andrew Geissler3b025e62019-02-01 10:33:54 -06007#include <string>
8
Andrew Geissler82815da2019-02-04 12:19:41 -06009/** @brief Define white list and black list data structure */
10using WhiteBlackList = boost::container::flat_set<std::string>;
11
Andrew Geissler20679262019-02-11 20:20:40 -060012/** @brief Dbus interface which contains org.openbmc Associations */
13constexpr 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 */
22using 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 Geissler70461892019-02-27 09:57:37 -060026/** @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 */
32using InterfacesAdded = std::vector<std::pair<
33 std::string,
34 std::vector<std::pair<
35 std::string, sdbusplus::message::variant<std::vector<Association>>>>>>;
36
Andrew Geissler3b025e62019-02-01 10:33:54 -060037/** @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 */
47bool getWellKnown(
48 const boost::container::flat_map<std::string, std::string>& owners,
Andrew Geissler82815da2019-02-04 12:19:41 -060049 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 */
63bool needToIntrospect(const std::string& processName,
64 const WhiteBlackList& whiteList,
65 const WhiteBlackList& blackList);
Andrew Geissler20679262019-02-11 20:20:40 -060066
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 */
78void 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 Geissler70461892019-02-27 09:57:37 -060084
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 */
96void 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);