blob: 7a0baef8ccf48ecc1ddf48efad74496423ffc1fc [file] [log] [blame]
Andrew Geissler3b025e62019-02-01 10:33:54 -06001#pragma once
2
Matt Spinler35396c12019-04-05 11:46:57 -05003#include "types.hpp"
Andrew Geissler20679262019-02-11 20:20:40 -06004
Andrew Geissler3b025e62019-02-01 10:33:54 -06005#include <boost/container/flat_map.hpp>
Brad Bishop23520882022-05-26 21:39:53 -04006
Matt Spinler8f876a52019-04-15 13:22:50 -05007#include <cassert>
Andrew Geissler3b025e62019-02-01 10:33:54 -06008#include <string>
9
John Wangd0cf9422019-09-17 16:01:34 +080010/** @brief The associations definitions interface */
Matt Spinler8f876a52019-04-15 13:22:50 -050011constexpr const char* assocDefsInterface =
12 "xyz.openbmc_project.Association.Definitions";
13
John Wangd0cf9422019-09-17 16:01:34 +080014/** @brief The associations definitions property name */
15constexpr const char* assocDefsProperty = "Associations";
Andrew Geissler20679262019-02-11 20:20:40 -060016
Andrew Geissler70461892019-02-27 09:57:37 -060017/** @brief InterfacesAdded represents the dbus data from the signal
18 *
19 * There are 2 pairs
20 * pair1: D-bus Interface,vector[pair2]
21 * pair2: D-bus Method,vector[Associations]
22 */
23using InterfacesAdded = std::vector<std::pair<
Patrick Williams2bb2d6b2020-05-13 17:59:02 -050024 std::string, std::vector<std::pair<
25 std::string, std::variant<std::vector<Association>>>>>>;
Andrew Geissler70461892019-02-27 09:57:37 -060026
Andrew Geissler3b025e62019-02-01 10:33:54 -060027/** @brief Get well known name of input unique name
28 *
29 * If user passes in well known name then that will be returned.
30 *
31 * @param[in] owners - Current list of owners
32 * @param[in] request - The name to look up
33 * @param[out] wellKnown - The well known name if found
34 *
35 * @return True if well known name is found, false otherwise
36 */
37bool getWellKnown(
38 const boost::container::flat_map<std::string, std::string>& owners,
Brad Bishopa098a372022-05-05 15:19:04 -040039 const std::string& request, std::string& wellKnown);
Andrew Geissler82815da2019-02-04 12:19:41 -060040
41/** @brief Determine if dbus service is something to monitor
42 *
Brad Bishop1e94e602022-06-02 19:47:53 -040043 * mapper does not monitor all DBus services. needToIntrospect determines
44 * whether or not a service is to be monitored.
Andrew Geissler82815da2019-02-04 12:19:41 -060045 *
46 * @param[in] processName - Dbus service name
Andrew Geissler82815da2019-02-04 12:19:41 -060047 *
Brad Bishopa098a372022-05-05 15:19:04 -040048 * @return True if input processName should be monitored, false otherwise
Andrew Geissler82815da2019-02-04 12:19:41 -060049 */
Brad Bishop1e94e602022-06-02 19:47:53 -040050bool needToIntrospect(const std::string& processName);
Andrew Geissler20679262019-02-11 20:20:40 -060051
52/** @brief Handle the removal of an existing name in objmgr data structures
53 *
Kallas, Pawel5b4357d2022-10-12 15:36:37 +020054 * @param[in] io - io context
Andrew Geissler20679262019-02-11 20:20:40 -060055 * @param[in,out] nameOwners - Map of unique name to well known name
56 * @param[in] wellKnown - Well known name that has new owner
57 * @param[in] oldOwner - Old unique name
58 * @param[in,out] interfaceMap - Map of interfaces
Matt Spinlere2359fb2019-04-05 14:11:33 -050059 * @param[in,out] assocMaps - The association maps
Andrew Geissler20679262019-02-11 20:20:40 -060060 * @param[in,out] server - sdbus system object
61 *
62 */
63void processNameChangeDelete(
Kallas, Pawel5b4357d2022-10-12 15:36:37 +020064 boost::asio::io_context& io,
Andrew Geissler20679262019-02-11 20:20:40 -060065 boost::container::flat_map<std::string, std::string>& nameOwners,
66 const std::string& wellKnown, const std::string& oldOwner,
Brad Bishopa098a372022-05-05 15:19:04 -040067 InterfaceMapType& interfaceMap, AssociationMaps& assocMaps,
Andrew Geissler20679262019-02-11 20:20:40 -060068 sdbusplus::asio::object_server& server);
Andrew Geissler70461892019-02-27 09:57:37 -060069
70/** @brief Handle an interfaces added signal
71 *
Kallas, Pawel5b4357d2022-10-12 15:36:37 +020072 * @param[in] io - io context
Andrew Geissler70461892019-02-27 09:57:37 -060073 * @param[in,out] interfaceMap - Global map of interfaces
74 * @param[in] objPath - New path to process
75 * @param[in] interfacesAdded - New interfaces to process
76 * @param[in] wellKnown - Well known name that has new owner
Matt Spinlere2359fb2019-04-05 14:11:33 -050077 * @param[in,out] assocMaps - The association maps
Andrew Geissler70461892019-02-27 09:57:37 -060078 * @param[in,out] server - sdbus system object
79 *
80 */
Patrick Williams9052ebd2024-08-16 15:22:16 -040081void processInterfaceAdded(
82 boost::asio::io_context& io, InterfaceMapType& interfaceMap,
83 const sdbusplus::message::object_path& objPath,
84 const InterfacesAdded& intfAdded, const std::string& wellKnown,
85 AssociationMaps& assocMaps, sdbusplus::asio::object_server& server);