1a80a3af0SAndrew Geissler #pragma once 2a80a3af0SAndrew Geissler 335396c10SMatt Spinler #include "types.hpp" 4a80a3af0SAndrew Geissler 5*a098a37aSBrad Bishop constexpr const char* xyzAssociationInterface = 64511b33fSAndrew Geissler "xyz.openbmc_project.Association"; 74511b33fSAndrew Geissler 8a80a3af0SAndrew Geissler /** @brief Remove input association 9a80a3af0SAndrew Geissler * 10a80a3af0SAndrew Geissler * @param[in] sourcePath - Path of the object that contains the 11a80a3af0SAndrew Geissler * org.openbmc.Associations 12a80a3af0SAndrew Geissler * @param[in] owner - The Dbus service having its associations 13a80a3af0SAndrew Geissler * removed 14a80a3af0SAndrew Geissler * @param[in,out] server - sdbus system object 15e2359fb7SMatt Spinler * @param[in,out] assocMaps - The association maps 16a80a3af0SAndrew Geissler * 17e2359fb7SMatt Spinler * @return Void, server, assocMaps updated if needed 18a80a3af0SAndrew Geissler */ 19a80a3af0SAndrew Geissler void removeAssociation(const std::string& sourcePath, const std::string& owner, 20a80a3af0SAndrew Geissler sdbusplus::asio::object_server& server, 21e2359fb7SMatt Spinler AssociationMaps& assocMaps); 22ff5ce924SAndrew Geissler 23ff5ce924SAndrew Geissler /** @brief Remove input paths from endpoints of an association 24ff5ce924SAndrew Geissler * 25ff5ce924SAndrew Geissler * If the last endpoint was removed, then remove the whole 26ff5ce924SAndrew Geissler * association object, otherwise just set the property 27ff5ce924SAndrew Geissler * 28ff5ce924SAndrew Geissler * @param[in] objectServer - sdbus system object 29ff5ce924SAndrew Geissler * @param[in] assocPath - Path of the object that contains the 30ff5ce924SAndrew Geissler * org.openbmc.Associations 31ff5ce924SAndrew Geissler * @param[in] endpointsToRemove - Endpoints to remove 32e2359fb7SMatt Spinler * @param[in,out] assocMaps - The association maps 33ff5ce924SAndrew Geissler * 34e2359fb7SMatt Spinler * @return Void, objectServer and assocMaps updated if needed 35ff5ce924SAndrew Geissler */ 36ff5ce924SAndrew Geissler void removeAssociationEndpoints( 37ff5ce924SAndrew Geissler sdbusplus::asio::object_server& objectServer, const std::string& assocPath, 38ff5ce924SAndrew Geissler const boost::container::flat_set<std::string>& endpointsToRemove, 39e2359fb7SMatt Spinler AssociationMaps& assocMaps); 407f1c44dcSAndrew Geissler 417f1c44dcSAndrew Geissler /** @brief Check and remove any changed associations 427f1c44dcSAndrew Geissler * 437f1c44dcSAndrew Geissler * Based on the latest values of the org.openbmc.Associations.associations 447f1c44dcSAndrew Geissler * property, passed in via the newAssociations param, check if any of the 457f1c44dcSAndrew Geissler * paths in the xyz.openbmc_project.Association.endpoints D-Bus property 467f1c44dcSAndrew Geissler * for that association need to be removed. If the last path is removed 477f1c44dcSAndrew Geissler * from the endpoints property, remove that whole association object from 487f1c44dcSAndrew Geissler * D-Bus. 497f1c44dcSAndrew Geissler * 507f1c44dcSAndrew Geissler * @param[in] sourcePath - Path of the object that contains the 517f1c44dcSAndrew Geissler * org.openbmc.Associations 527f1c44dcSAndrew Geissler * @param[in] owner - The Dbus service having it's associatons 537f1c44dcSAndrew Geissler * changed 547f1c44dcSAndrew Geissler * @param[in] newAssociations - New associations to look at for change 557f1c44dcSAndrew Geissler * @param[in,out] objectServer - sdbus system object 56e2359fb7SMatt Spinler * @param[in,out] assocMaps - The association maps 577f1c44dcSAndrew Geissler * 58e2359fb7SMatt Spinler * @return Void, objectServer and assocMaps updated if needed 597f1c44dcSAndrew Geissler */ 607f1c44dcSAndrew Geissler void checkAssociationEndpointRemoves( 617f1c44dcSAndrew Geissler const std::string& sourcePath, const std::string& owner, 627f1c44dcSAndrew Geissler const AssociationPaths& newAssociations, 63e2359fb7SMatt Spinler sdbusplus::asio::object_server& objectServer, AssociationMaps& assocMaps); 644511b33fSAndrew Geissler 654511b33fSAndrew Geissler /** @brief Handle new or changed association interfaces 664511b33fSAndrew Geissler * 674511b33fSAndrew Geissler * Called when either a new org.openbmc.Associations interface was 684511b33fSAndrew Geissler * created, or the associations property on that interface changed 694511b33fSAndrew Geissler * 704511b33fSAndrew Geissler * @param[in,out] objectServer - sdbus system object 714511b33fSAndrew Geissler * @param[in] associations - New associations to look at for change 724511b33fSAndrew Geissler * @param[in] path - Path of the object that contains the 734511b33fSAndrew Geissler * org.openbmc.Associations 744511b33fSAndrew Geissler * @param[in] owner - The Dbus service having it's associatons 754511b33fSAndrew Geissler * changed 76e0b0e3a2SMatt Spinler * @param[in] interfaceMap - The full interface map 77e2359fb7SMatt Spinler * @param[in,out] assocMaps - The association maps 784511b33fSAndrew Geissler * 79e2359fb7SMatt Spinler * @return Void, objectServer and assocMaps updated if needed 804511b33fSAndrew Geissler */ 814511b33fSAndrew Geissler void associationChanged(sdbusplus::asio::object_server& objectServer, 824511b33fSAndrew Geissler const std::vector<Association>& associations, 834511b33fSAndrew Geissler const std::string& path, const std::string& owner, 84*a098a37aSBrad Bishop const InterfaceMapType& interfaceMap, 85e0b0e3a2SMatt Spinler AssociationMaps& assocMaps); 86e0b0e3a2SMatt Spinler 87e0b0e3a2SMatt Spinler /** @brief Add a pending associations entry 88e0b0e3a2SMatt Spinler * 89e0b0e3a2SMatt Spinler * Used when a client wants to create an association between 90e0b0e3a2SMatt Spinler * 2 D-Bus endpoint paths, but one of the paths doesn't exist. 91e0b0e3a2SMatt Spinler * When the path does show up in D-Bus, if there is a pending 92e0b0e3a2SMatt Spinler * association then the real association objects can be created. 93e0b0e3a2SMatt Spinler * 94e0b0e3a2SMatt Spinler * @param[in] objectPath - The D-Bus object path that should be an 95e0b0e3a2SMatt Spinler * association endpoint but doesn't exist 96e0b0e3a2SMatt Spinler * on D-Bus. 97e0b0e3a2SMatt Spinler * @param[in] type - The association type. Gets used in the final 98e0b0e3a2SMatt Spinler * association path of <objectPath>/<type>. 99e0b0e3a2SMatt Spinler * @param[in] endpointPath - The D-Bus path on the other side 100e0b0e3a2SMatt Spinler * of the association. This path exists. 101e0b0e3a2SMatt Spinler * @param[in] endpointType - The endpoint association type. Gets used 102e0b0e3a2SMatt Spinler * in the final association path of 103e0b0e3a2SMatt Spinler * <endpointPath>/<endpointType>. 104e0b0e3a2SMatt Spinler * @param[in] owner - The service name that owns the association. 105e0b0e3a2SMatt Spinler * @param[in,out] assocMaps - The association maps 106e0b0e3a2SMatt Spinler */ 107e0b0e3a2SMatt Spinler void addPendingAssociation(const std::string& objectPath, 108e0b0e3a2SMatt Spinler const std::string& type, 109e0b0e3a2SMatt Spinler const std::string& endpointPath, 110e0b0e3a2SMatt Spinler const std::string& endpointType, 111e0b0e3a2SMatt Spinler const std::string& owner, 112e2359fb7SMatt Spinler AssociationMaps& assocMaps); 113cb9bcdb1SMatt Spinler 114cb9bcdb1SMatt Spinler /** @brief Removes an endpoint from the pending associations map 115cb9bcdb1SMatt Spinler * 116cb9bcdb1SMatt Spinler * If the last endpoint is removed, removes the whole entry 117cb9bcdb1SMatt Spinler * 118cb9bcdb1SMatt Spinler * @param[in] endpointPath - the endpoint path to remove 119cb9bcdb1SMatt Spinler * @param[in,out] assocMaps - The association maps 120cb9bcdb1SMatt Spinler */ 121cb9bcdb1SMatt Spinler void removeFromPendingAssociations(const std::string& endpointPath, 122cb9bcdb1SMatt Spinler AssociationMaps& assocMaps); 12311401e2eSMatt Spinler 12411401e2eSMatt Spinler /** @brief Adds a single association D-Bus object (<path>/<type>) 12511401e2eSMatt Spinler * 12611401e2eSMatt Spinler * @param[in,out] server - sdbus system object 12711401e2eSMatt Spinler * @param[in] assocPath - The association D-Bus path 12811401e2eSMatt Spinler * @param[in] endpoint - The association's D-Bus endpoint path 12911401e2eSMatt Spinler * @param[in] owner - The owning D-Bus well known name 13011401e2eSMatt Spinler * @param[in] ownerPath - The D-Bus path hosting the Associations property 13111401e2eSMatt Spinler * @param[in,out] assocMaps - The association maps 13211401e2eSMatt Spinler */ 13311401e2eSMatt Spinler void addSingleAssociation(sdbusplus::asio::object_server& server, 13411401e2eSMatt Spinler const std::string& assocPath, 13511401e2eSMatt Spinler const std::string& endpoint, const std::string& owner, 13611401e2eSMatt Spinler const std::string& ownerPath, 13711401e2eSMatt Spinler AssociationMaps& assocMaps); 13811401e2eSMatt Spinler 13911401e2eSMatt Spinler /** @brief Create a real association out of a pending association 14011401e2eSMatt Spinler * if there is one for this path. 14111401e2eSMatt Spinler * 14211401e2eSMatt Spinler * If objectPath is now on D-Bus, and it is also in the pending associations 14311401e2eSMatt Spinler * map, create the 2 real association objects and remove its pending 14411401e2eSMatt Spinler * associations entry. Used when a new path shows up in D-Bus. 14511401e2eSMatt Spinler * 14611401e2eSMatt Spinler * @param[in] objectPath - the path to check 14711401e2eSMatt Spinler * @param[in] interfaceMap - The master interface map 14811401e2eSMatt Spinler * @param[in,out] assocMaps - The association maps 14911401e2eSMatt Spinler * @param[in,out] server - sdbus system object 15011401e2eSMatt Spinler */ 15111401e2eSMatt Spinler void checkIfPendingAssociation(const std::string& objectPath, 152*a098a37aSBrad Bishop const InterfaceMapType& interfaceMap, 15311401e2eSMatt Spinler AssociationMaps& assocMaps, 15411401e2eSMatt Spinler sdbusplus::asio::object_server& server); 1557f8fd1faSMatt Spinler 1567f8fd1faSMatt Spinler /** @brief Find all associations in the association owners map with the 1577f8fd1faSMatt Spinler * specified endpoint path. 1587f8fd1faSMatt Spinler * 1597f8fd1faSMatt Spinler * @param[in] endpointPath - the endpoint path to look for 1607f8fd1faSMatt Spinler * @param[in] assocMaps - The association maps 1617f8fd1faSMatt Spinler * @param[out] associationData - A vector of {owner, Association} tuples 1627f8fd1faSMatt Spinler * of all the associations with that endpoint. 1637f8fd1faSMatt Spinler */ 1647f8fd1faSMatt Spinler void findAssociations(const std::string& endpointPath, 1657f8fd1faSMatt Spinler AssociationMaps& assocMaps, 1667f8fd1faSMatt Spinler FindAssocResults& associationData); 1679c3d2859SMatt Spinler 1689c3d2859SMatt Spinler /** @brief If endpointPath is in an association, move that association 1699c3d2859SMatt Spinler * to pending and remove the association objects. 1709c3d2859SMatt Spinler * 1719c3d2859SMatt Spinler * Called when a path is going off of D-Bus. If this path is an 1729c3d2859SMatt Spinler * association endpoint (the path that owns the association is still 1739c3d2859SMatt Spinler * on D-Bus), then move the association it's involved in to pending. 1749c3d2859SMatt Spinler * 1759c3d2859SMatt Spinler * @param[in] endpointPath - the D-Bus endpoint path to check 1769c3d2859SMatt Spinler * @param[in,out] assocMaps - The association maps 1779c3d2859SMatt Spinler * @param[in,out] server - sdbus system object 1789c3d2859SMatt Spinler */ 1799c3d2859SMatt Spinler void moveAssociationToPending(const std::string& endpointPath, 1809c3d2859SMatt Spinler AssociationMaps& assocMaps, 1819c3d2859SMatt Spinler sdbusplus::asio::object_server& server); 182