blob: 6a3629eb268af911393f831d282122de6f309bff [file] [log] [blame]
Kamalkumar Patel4e69d252024-05-10 08:48:03 -05001#include "libpldm/pdr.h"
2
3#include "libpldmresponder/oem_handler.hpp"
4
5#include <nlohmann/json.hpp>
6#include <phosphor-logging/lg2.hpp>
7
8#include <filesystem>
9#include <fstream>
10#include <map>
11#include <string>
12#include <vector>
13
14PHOSPHOR_LOG2_USING;
15namespace pldm
16{
Kamalkumar Patel516122e2024-05-07 04:39:32 -050017using Json = nlohmann::json;
18namespace fs = std::filesystem;
19using ObjectPath = fs::path;
Kamalkumar Patel4e69d252024-05-10 08:48:03 -050020using EntityName = std::string;
21using EntityType = uint16_t;
Kamalkumar Patel4e69d252024-05-10 08:48:03 -050022using Entities = std::vector<pldm_entity_node*>;
23using EntityAssociations = std::vector<Entities>;
Kamalkumar Patel516122e2024-05-07 04:39:32 -050024using ObjectPathMaps = std::map<ObjectPath, pldm_entity_node*>;
25using EntityMaps = std::map<EntityType, EntityName>;
Kamalkumar Patel4e69d252024-05-10 08:48:03 -050026namespace hostbmc
27{
28namespace utils
29{
30
Kamalkumar Patel4e69d252024-05-10 08:48:03 -050031/** @brief Vector a entity name to pldm_entity from entity association tree
32 * @param[in] entityAssoc - Vector of associated pldm entities
33 * @param[in] entityTree - entity association tree
34 * @param[out] objPathMap - maps an object path to pldm_entity from the
35 * BMC's entity association tree
36 * @return
37 */
Kamalkumar Patel15ce5a12024-05-07 11:45:11 -050038void updateEntityAssociation(
39 const EntityAssociations& entityAssoc,
40 pldm_entity_association_tree* entityTree, ObjectPathMaps& objPathMap,
41 EntityMaps entityMaps,
42 pldm::responder::oem_platform::Handler* oemPlatformHandler);
Kamalkumar Patel516122e2024-05-07 04:39:32 -050043
44/** @brief Parsing entity to DBus string mapping from json file
45 *
46 * @param[in] filePath - JSON file path for parsing
47 *
48 * @return returns the entity to DBus string mapping object
49 */
50EntityMaps parseEntityMap(const fs::path& filePath);
Kamalkumar Patel4e69d252024-05-10 08:48:03 -050051
52} // namespace utils
53} // namespace hostbmc
54} // namespace pldm