blob: 15577ec54291606c32e69c79b752ca8a142b5026 [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>
Brad Bishop23520882022-05-26 21:39:53 -04007
Matt Spinler8f876a52019-04-15 13:22:50 -05008#include <cassert>
Andrew Geissler3b025e62019-02-01 10:33:54 -06009#include <string>
10
John Wangd0cf9422019-09-17 16:01:34 +080011/** @brief The associations definitions interface */
Matt Spinler8f876a52019-04-15 13:22:50 -050012constexpr const char* assocDefsInterface =
13 "xyz.openbmc_project.Association.Definitions";
14
John Wangd0cf9422019-09-17 16:01:34 +080015/** @brief The associations definitions property name */
16constexpr const char* assocDefsProperty = "Associations";
Andrew Geissler20679262019-02-11 20:20:40 -060017
Andrew Geissler70461892019-02-27 09:57:37 -060018/** @brief InterfacesAdded represents the dbus data from the signal
19 *
20 * There are 2 pairs
21 * pair1: D-bus Interface,vector[pair2]
22 * pair2: D-bus Method,vector[Associations]
23 */
24using InterfacesAdded = std::vector<std::pair<
Patrick Williams2bb2d6b2020-05-13 17:59:02 -050025 std::string, std::vector<std::pair<
26 std::string, std::variant<std::vector<Association>>>>>>;
Andrew Geissler70461892019-02-27 09:57:37 -060027
Andrew Geissler3b025e62019-02-01 10:33:54 -060028/** @brief Get well known name of input unique name
29 *
30 * If user passes in well known name then that will be returned.
31 *
32 * @param[in] owners - Current list of owners
33 * @param[in] request - The name to look up
34 * @param[out] wellKnown - The well known name if found
35 *
36 * @return True if well known name is found, false otherwise
37 */
38bool getWellKnown(
39 const boost::container::flat_map<std::string, std::string>& owners,
Brad Bishopa098a372022-05-05 15:19:04 -040040 const std::string& request, std::string& wellKnown);
Andrew Geissler82815da2019-02-04 12:19:41 -060041
42/** @brief Determine if dbus service is something to monitor
43 *
Brad Bishop1e94e602022-06-02 19:47:53 -040044 * mapper does not monitor all DBus services. needToIntrospect determines
45 * whether or not a service is to be monitored.
Andrew Geissler82815da2019-02-04 12:19:41 -060046 *
47 * @param[in] processName - Dbus service name
Andrew Geissler82815da2019-02-04 12:19:41 -060048 *
Brad Bishopa098a372022-05-05 15:19:04 -040049 * @return True if input processName should be monitored, false otherwise
Andrew Geissler82815da2019-02-04 12:19:41 -060050 */
Brad Bishop1e94e602022-06-02 19:47:53 -040051bool needToIntrospect(const std::string& processName);
Andrew Geissler20679262019-02-11 20:20:40 -060052
53/** @brief Handle the removal of an existing name in objmgr data structures
54 *
Kallas, Pawel5b4357d2022-10-12 15:36:37 +020055 * @param[in] io - io context
Andrew Geissler20679262019-02-11 20:20:40 -060056 * @param[in,out] nameOwners - Map of unique name to well known name
57 * @param[in] wellKnown - Well known name that has new owner
58 * @param[in] oldOwner - Old unique name
59 * @param[in,out] interfaceMap - Map of interfaces
Matt Spinlere2359fb2019-04-05 14:11:33 -050060 * @param[in,out] assocMaps - The association maps
Andrew Geissler20679262019-02-11 20:20:40 -060061 * @param[in,out] server - sdbus system object
62 *
63 */
64void processNameChangeDelete(
Kallas, Pawel5b4357d2022-10-12 15:36:37 +020065 boost::asio::io_context& io,
Andrew Geissler20679262019-02-11 20:20:40 -060066 boost::container::flat_map<std::string, std::string>& nameOwners,
67 const std::string& wellKnown, const std::string& oldOwner,
Brad Bishopa098a372022-05-05 15:19:04 -040068 InterfaceMapType& interfaceMap, AssociationMaps& assocMaps,
Andrew Geissler20679262019-02-11 20:20:40 -060069 sdbusplus::asio::object_server& server);
Andrew Geissler70461892019-02-27 09:57:37 -060070
71/** @brief Handle an interfaces added signal
72 *
Kallas, Pawel5b4357d2022-10-12 15:36:37 +020073 * @param[in] io - io context
Andrew Geissler70461892019-02-27 09:57:37 -060074 * @param[in,out] interfaceMap - Global map of interfaces
75 * @param[in] objPath - New path to process
76 * @param[in] interfacesAdded - New interfaces to process
77 * @param[in] wellKnown - Well known name that has new owner
Matt Spinlere2359fb2019-04-05 14:11:33 -050078 * @param[in,out] assocMaps - The association maps
Andrew Geissler70461892019-02-27 09:57:37 -060079 * @param[in,out] server - sdbus system object
80 *
81 */
Patrick Williams9052ebd2024-08-16 15:22:16 -040082void processInterfaceAdded(
83 boost::asio::io_context& io, InterfaceMapType& interfaceMap,
84 const sdbusplus::message::object_path& objPath,
85 const InterfacesAdded& intfAdded, const std::string& wellKnown,
86 AssociationMaps& assocMaps, sdbusplus::asio::object_server& server);