blob: 8ef6e485d70d7ae368fe373a793567d9fc2a8dab [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 Geissler3b025e62019-02-01 10:33:54 -060026/** @brief Get well known name of input unique name
27 *
28 * If user passes in well known name then that will be returned.
29 *
30 * @param[in] owners - Current list of owners
31 * @param[in] request - The name to look up
32 * @param[out] wellKnown - The well known name if found
33 *
34 * @return True if well known name is found, false otherwise
35 */
36bool getWellKnown(
37 const boost::container::flat_map<std::string, std::string>& owners,
Andrew Geissler82815da2019-02-04 12:19:41 -060038 const std::string& request, std::string& well_known);
39
40/** @brief Determine if dbus service is something to monitor
41 *
42 * mapper supports a whitelist and blacklist concept. If a whitelist is provided
43 * as input then only dbus objects matching that list is monitored. If a
44 * blacklist is provided then objects matching it will not be monitored.
45 *
46 * @param[in] processName - Dbus service name
47 * @param[in] whiteList - The white list
48 * @param[in] blackList - The black list
49 *
50 * @return True if input process_name should be monitored, false otherwise
51 */
52bool needToIntrospect(const std::string& processName,
53 const WhiteBlackList& whiteList,
54 const WhiteBlackList& blackList);
Andrew Geissler20679262019-02-11 20:20:40 -060055
56/** @brief Handle the removal of an existing name in objmgr data structures
57 *
58 * @param[in,out] nameOwners - Map of unique name to well known name
59 * @param[in] wellKnown - Well known name that has new owner
60 * @param[in] oldOwner - Old unique name
61 * @param[in,out] interfaceMap - Map of interfaces
62 * @param[in,out] assocOwners - Owners of associations
63 * @param[in,out] assocInterfaces - Associations endpoints
64 * @param[in,out] server - sdbus system object
65 *
66 */
67void processNameChangeDelete(
68 boost::container::flat_map<std::string, std::string>& nameOwners,
69 const std::string& wellKnown, const std::string& oldOwner,
70 interface_map_type& interfaceMap, AssociationOwnersType& assocOwners,
71 AssociationInterfaces& assocInterfaces,
72 sdbusplus::asio::object_server& server);