blob: 114b5029f7453bbd1284aa289a572d0ab7784876 [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"
Matt Spinler35396c12019-04-05 11:46:57 -05004#include "types.hpp"
Andrew Geissler20679262019-02-11 20:20:40 -06005
Andrew Geissler3b025e62019-02-01 10:33:54 -06006#include <boost/container/flat_map.hpp>
Andrew Geissler82815da2019-02-04 12:19:41 -06007#include <boost/container/flat_set.hpp>
Matt Spinler8f876a52019-04-15 13:22:50 -05008#include <cassert>
Andrew Geissler3b025e62019-02-01 10:33:54 -06009#include <string>
10
Andrew Geissler82815da2019-02-04 12:19:41 -060011/** @brief Define white list and black list data structure */
12using WhiteBlackList = boost::container::flat_set<std::string>;
13
John Wangd0cf9422019-09-17 16:01:34 +080014/** @brief The associations definitions interface */
Matt Spinler8f876a52019-04-15 13:22:50 -050015constexpr const char* assocDefsInterface =
16 "xyz.openbmc_project.Association.Definitions";
17
John Wangd0cf9422019-09-17 16:01:34 +080018/** @brief The associations definitions property name */
19constexpr const char* assocDefsProperty = "Associations";
Andrew Geissler20679262019-02-11 20:20:40 -060020
Andrew Geissler70461892019-02-27 09:57:37 -060021/** @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 */
27using InterfacesAdded = std::vector<std::pair<
Patrick Williams2bb2d6b2020-05-13 17:59:02 -050028 std::string, std::vector<std::pair<
29 std::string, std::variant<std::vector<Association>>>>>>;
Andrew Geissler70461892019-02-27 09:57:37 -060030
Andrew Geissler3b025e62019-02-01 10:33:54 -060031/** @brief Get well known name of input unique name
32 *
33 * If user passes in well known name then that will be returned.
34 *
35 * @param[in] owners - Current list of owners
36 * @param[in] request - The name to look up
37 * @param[out] wellKnown - The well known name if found
38 *
39 * @return True if well known name is found, false otherwise
40 */
41bool getWellKnown(
42 const boost::container::flat_map<std::string, std::string>& owners,
Andrew Geissler82815da2019-02-04 12:19:41 -060043 const std::string& request, std::string& well_known);
44
45/** @brief Determine if dbus service is something to monitor
46 *
47 * mapper supports a whitelist and blacklist concept. If a whitelist is provided
48 * as input then only dbus objects matching that list is monitored. If a
49 * blacklist is provided then objects matching it will not be monitored.
50 *
51 * @param[in] processName - Dbus service name
52 * @param[in] whiteList - The white list
53 * @param[in] blackList - The black list
54 *
55 * @return True if input process_name should be monitored, false otherwise
56 */
57bool needToIntrospect(const std::string& processName,
58 const WhiteBlackList& whiteList,
59 const WhiteBlackList& blackList);
Andrew Geissler20679262019-02-11 20:20:40 -060060
61/** @brief Handle the removal of an existing name in objmgr data structures
62 *
63 * @param[in,out] nameOwners - Map of unique name to well known name
64 * @param[in] wellKnown - Well known name that has new owner
65 * @param[in] oldOwner - Old unique name
66 * @param[in,out] interfaceMap - Map of interfaces
Matt Spinlere2359fb2019-04-05 14:11:33 -050067 * @param[in,out] assocMaps - The association maps
Andrew Geissler20679262019-02-11 20:20:40 -060068 * @param[in,out] server - sdbus system object
69 *
70 */
71void processNameChangeDelete(
72 boost::container::flat_map<std::string, std::string>& nameOwners,
73 const std::string& wellKnown, const std::string& oldOwner,
Matt Spinlere2359fb2019-04-05 14:11:33 -050074 interface_map_type& interfaceMap, AssociationMaps& assocMaps,
Andrew Geissler20679262019-02-11 20:20:40 -060075 sdbusplus::asio::object_server& server);
Andrew Geissler70461892019-02-27 09:57:37 -060076
77/** @brief Handle an interfaces added signal
78 *
79 * @param[in,out] interfaceMap - Global map of interfaces
80 * @param[in] objPath - New path to process
81 * @param[in] interfacesAdded - New interfaces to process
82 * @param[in] wellKnown - Well known name that has new owner
Matt Spinlere2359fb2019-04-05 14:11:33 -050083 * @param[in,out] assocMaps - The association maps
Andrew Geissler70461892019-02-27 09:57:37 -060084 * @param[in,out] server - sdbus system object
85 *
86 */
87void processInterfaceAdded(interface_map_type& interfaceMap,
88 const sdbusplus::message::object_path& objPath,
89 const InterfacesAdded& intfAdded,
90 const std::string& wellKnown,
Matt Spinlere2359fb2019-04-05 14:11:33 -050091 AssociationMaps& assocMaps,
Andrew Geissler70461892019-02-27 09:57:37 -060092 sdbusplus::asio::object_server& server);