13b025e69SAndrew Geissler #pragma once
23b025e69SAndrew Geissler 
32067926aSAndrew Geissler #include "associations.hpp"
435396c10SMatt Spinler #include "types.hpp"
52067926aSAndrew Geissler 
63b025e69SAndrew Geissler #include <boost/container/flat_map.hpp>
782815dacSAndrew Geissler #include <boost/container/flat_set.hpp>
82352088eSBrad Bishop 
98f876a5aSMatt Spinler #include <cassert>
103b025e69SAndrew Geissler #include <string>
113b025e69SAndrew Geissler 
12*f944a450SBrad Bishop /** @brief Define allow list and deny list data structure */
13*f944a450SBrad Bishop using AllowDenyList = boost::container::flat_set<std::string>;
1482815dacSAndrew Geissler 
15d0cf9428SJohn Wang /** @brief The associations definitions interface */
168f876a5aSMatt Spinler constexpr const char* assocDefsInterface =
178f876a5aSMatt Spinler     "xyz.openbmc_project.Association.Definitions";
188f876a5aSMatt Spinler 
19d0cf9428SJohn Wang /** @brief The associations definitions property name */
20d0cf9428SJohn Wang constexpr const char* assocDefsProperty = "Associations";
212067926aSAndrew Geissler 
2270461896SAndrew Geissler /** @brief InterfacesAdded represents the dbus data from the signal
2370461896SAndrew Geissler  *
2470461896SAndrew Geissler  * There are 2 pairs
2570461896SAndrew Geissler  * pair1: D-bus Interface,vector[pair2]
2670461896SAndrew Geissler  * pair2: D-bus Method,vector[Associations]
2770461896SAndrew Geissler  */
2870461896SAndrew Geissler using InterfacesAdded = std::vector<std::pair<
292bb2d6baSPatrick Williams     std::string, std::vector<std::pair<
302bb2d6baSPatrick Williams                      std::string, std::variant<std::vector<Association>>>>>>;
3170461896SAndrew Geissler 
323b025e69SAndrew Geissler /** @brief Get well known name of input unique name
333b025e69SAndrew Geissler  *
343b025e69SAndrew Geissler  * If user passes in well known name then that will be returned.
353b025e69SAndrew Geissler  *
363b025e69SAndrew Geissler  * @param[in] owners       - Current list of owners
373b025e69SAndrew Geissler  * @param[in] request      - The name to look up
383b025e69SAndrew Geissler  * @param[out] wellKnown   - The well known name if found
393b025e69SAndrew Geissler  *
403b025e69SAndrew Geissler  * @return True if well known name is found, false otherwise
413b025e69SAndrew Geissler  */
423b025e69SAndrew Geissler bool getWellKnown(
433b025e69SAndrew Geissler     const boost::container::flat_map<std::string, std::string>& owners,
4482815dacSAndrew Geissler     const std::string& request, std::string& well_known);
4582815dacSAndrew Geissler 
4682815dacSAndrew Geissler /** @brief Determine if dbus service is something to monitor
4782815dacSAndrew Geissler  *
48*f944a450SBrad Bishop  * mapper supports an allowlist and denylist concept. If an allowlist is
49*f944a450SBrad Bishop  * provided as input then only dbus objects matching that list is monitored. If
50*f944a450SBrad Bishop  * a denylist is provided then objects matching it will not be monitored.
5182815dacSAndrew Geissler  *
5282815dacSAndrew Geissler  * @param[in] processName   - Dbus service name
53*f944a450SBrad Bishop  * @param[in] allowList     - The allow list
54*f944a450SBrad Bishop  * @param[in] denyList      - The deny list
5582815dacSAndrew Geissler  *
5682815dacSAndrew Geissler  * @return True if input process_name should be monitored, false otherwise
5782815dacSAndrew Geissler  */
5882815dacSAndrew Geissler bool needToIntrospect(const std::string& processName,
59*f944a450SBrad Bishop                       const AllowDenyList& allowList,
60*f944a450SBrad Bishop                       const AllowDenyList& denyList);
612067926aSAndrew Geissler 
622067926aSAndrew Geissler /** @brief Handle the removal of an existing name in objmgr data structures
632067926aSAndrew Geissler  *
642067926aSAndrew Geissler  * @param[in,out] nameOwners      - Map of unique name to well known name
652067926aSAndrew Geissler  * @param[in]     wellKnown       - Well known name that has new owner
662067926aSAndrew Geissler  * @param[in]     oldOwner        - Old unique name
672067926aSAndrew Geissler  * @param[in,out] interfaceMap    - Map of interfaces
68e2359fb7SMatt Spinler  * @param[in,out] assocMaps       - The association maps
692067926aSAndrew Geissler  * @param[in,out] server          - sdbus system object
702067926aSAndrew Geissler  *
712067926aSAndrew Geissler  */
722067926aSAndrew Geissler void processNameChangeDelete(
732067926aSAndrew Geissler     boost::container::flat_map<std::string, std::string>& nameOwners,
742067926aSAndrew Geissler     const std::string& wellKnown, const std::string& oldOwner,
75e2359fb7SMatt Spinler     interface_map_type& interfaceMap, AssociationMaps& assocMaps,
762067926aSAndrew Geissler     sdbusplus::asio::object_server& server);
7770461896SAndrew Geissler 
7870461896SAndrew Geissler /** @brief Handle an interfaces added signal
7970461896SAndrew Geissler  *
8070461896SAndrew Geissler  * @param[in,out] interfaceMap    - Global map of interfaces
8170461896SAndrew Geissler  * @param[in]     objPath         - New path to process
8270461896SAndrew Geissler  * @param[in]     interfacesAdded - New interfaces to process
8370461896SAndrew Geissler  * @param[in]     wellKnown       - Well known name that has new owner
84e2359fb7SMatt Spinler  * @param[in,out] assocMaps       - The association maps
8570461896SAndrew Geissler  * @param[in,out] server          - sdbus system object
8670461896SAndrew Geissler  *
8770461896SAndrew Geissler  */
8870461896SAndrew Geissler void processInterfaceAdded(interface_map_type& interfaceMap,
8970461896SAndrew Geissler                            const sdbusplus::message::object_path& objPath,
9070461896SAndrew Geissler                            const InterfacesAdded& intfAdded,
9170461896SAndrew Geissler                            const std::string& wellKnown,
92e2359fb7SMatt Spinler                            AssociationMaps& assocMaps,
9370461896SAndrew Geissler                            sdbusplus::asio::object_server& server);
94