blob: d17cacd95d81bb08f8e089e1077bd3a62eaa7efc [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>
Brad Bishop23520882022-05-26 21:39:53 -04008
Matt Spinler8f876a52019-04-15 13:22:50 -05009#include <cassert>
Andrew Geissler3b025e62019-02-01 10:33:54 -060010#include <string>
11
Brad Bishopf944a452022-05-05 15:06:46 -040012/** @brief Define allow list and deny list data structure */
13using AllowDenyList = boost::container::flat_set<std::string>;
Andrew Geissler82815da2019-02-04 12:19:41 -060014
John Wangd0cf9422019-09-17 16:01:34 +080015/** @brief The associations definitions interface */
Matt Spinler8f876a52019-04-15 13:22:50 -050016constexpr const char* assocDefsInterface =
17 "xyz.openbmc_project.Association.Definitions";
18
John Wangd0cf9422019-09-17 16:01:34 +080019/** @brief The associations definitions property name */
20constexpr const char* assocDefsProperty = "Associations";
Andrew Geissler20679262019-02-11 20:20:40 -060021
Andrew Geissler70461892019-02-27 09:57:37 -060022/** @brief InterfacesAdded represents the dbus data from the signal
23 *
24 * There are 2 pairs
25 * pair1: D-bus Interface,vector[pair2]
26 * pair2: D-bus Method,vector[Associations]
27 */
28using InterfacesAdded = std::vector<std::pair<
Patrick Williams2bb2d6b2020-05-13 17:59:02 -050029 std::string, std::vector<std::pair<
30 std::string, std::variant<std::vector<Association>>>>>>;
Andrew Geissler70461892019-02-27 09:57:37 -060031
Andrew Geissler3b025e62019-02-01 10:33:54 -060032/** @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 */
42bool getWellKnown(
43 const boost::container::flat_map<std::string, std::string>& owners,
Brad Bishopa098a372022-05-05 15:19:04 -040044 const std::string& request, std::string& wellKnown);
Andrew Geissler82815da2019-02-04 12:19:41 -060045
46/** @brief Determine if dbus service is something to monitor
47 *
Brad Bishopd5542322022-06-02 19:56:23 -040048 * mapper supports an allowlist concept. If an allowlist is provided as input
49 * then only dbus objects matching that list is monitored.
Andrew Geissler82815da2019-02-04 12:19:41 -060050 *
51 * @param[in] processName - Dbus service name
Brad Bishopf944a452022-05-05 15:06:46 -040052 * @param[in] allowList - The allow list
Andrew Geissler82815da2019-02-04 12:19:41 -060053 *
Brad Bishopa098a372022-05-05 15:19:04 -040054 * @return True if input processName should be monitored, false otherwise
Andrew Geissler82815da2019-02-04 12:19:41 -060055 */
56bool needToIntrospect(const std::string& processName,
Brad Bishopd5542322022-06-02 19:56:23 -040057 const AllowDenyList& allowList);
Andrew Geissler20679262019-02-11 20:20:40 -060058
59/** @brief Handle the removal of an existing name in objmgr data structures
60 *
61 * @param[in,out] nameOwners - Map of unique name to well known name
62 * @param[in] wellKnown - Well known name that has new owner
63 * @param[in] oldOwner - Old unique name
64 * @param[in,out] interfaceMap - Map of interfaces
Matt Spinlere2359fb2019-04-05 14:11:33 -050065 * @param[in,out] assocMaps - The association maps
Andrew Geissler20679262019-02-11 20:20:40 -060066 * @param[in,out] server - sdbus system object
67 *
68 */
69void processNameChangeDelete(
70 boost::container::flat_map<std::string, std::string>& nameOwners,
71 const std::string& wellKnown, const std::string& oldOwner,
Brad Bishopa098a372022-05-05 15:19:04 -040072 InterfaceMapType& interfaceMap, AssociationMaps& assocMaps,
Andrew Geissler20679262019-02-11 20:20:40 -060073 sdbusplus::asio::object_server& server);
Andrew Geissler70461892019-02-27 09:57:37 -060074
75/** @brief Handle an interfaces added signal
76 *
77 * @param[in,out] interfaceMap - Global map of interfaces
78 * @param[in] objPath - New path to process
79 * @param[in] interfacesAdded - New interfaces to process
80 * @param[in] wellKnown - Well known name that has new owner
Matt Spinlere2359fb2019-04-05 14:11:33 -050081 * @param[in,out] assocMaps - The association maps
Andrew Geissler70461892019-02-27 09:57:37 -060082 * @param[in,out] server - sdbus system object
83 *
84 */
Brad Bishopa098a372022-05-05 15:19:04 -040085void processInterfaceAdded(InterfaceMapType& interfaceMap,
Andrew Geissler70461892019-02-27 09:57:37 -060086 const sdbusplus::message::object_path& objPath,
87 const InterfacesAdded& intfAdded,
88 const std::string& wellKnown,
Matt Spinlere2359fb2019-04-05 14:11:33 -050089 AssociationMaps& assocMaps,
Andrew Geissler70461892019-02-27 09:57:37 -060090 sdbusplus::asio::object_server& server);