blob: 9a68ca9cfcad7e6d4866f886edf59b8eb73997b4 [file] [log] [blame]
#include "pdr.hpp"
namespace pldm
{
namespace responder
{
namespace pdr_utils
{
pldm_pdr* Repo::getPdr() const
{
return repo;
}
RecordHandle Repo::addRecord(const PdrEntry& pdrEntry)
{
return pldm_pdr_add(repo, pdrEntry.data, pdrEntry.size,
pdrEntry.handle.recordHandle);
}
const pldm_pdr_record* Repo::getFirstRecord(PdrEntry& pdrEntry)
{
constexpr uint32_t firstNum = 0;
uint8_t* pdrData = nullptr;
auto record =
pldm_pdr_find_record(getPdr(), firstNum, &pdrData, &pdrEntry.size,
&pdrEntry.handle.nextRecordHandle);
if (record)
{
pdrEntry.data = pdrData;
}
return record;
}
const pldm_pdr_record* Repo::getNextRecord(const pldm_pdr_record* currRecord,
PdrEntry& pdrEntry)
{
uint8_t* pdrData = nullptr;
auto record =
pldm_pdr_get_next_record(getPdr(), currRecord, &pdrData, &pdrEntry.size,
&pdrEntry.handle.nextRecordHandle);
if (record)
{
pdrEntry.data = pdrData;
}
return record;
}
uint32_t Repo::getRecordHandle(const pldm_pdr_record* record) const
{
return pldm_pdr_get_record_handle(getPdr(), record);
}
uint32_t Repo::getRecordCount()
{
return pldm_pdr_get_record_count(getPdr());
}
bool Repo::empty()
{
return !getRecordCount();
}
} // namespace pdr_utils
} // namespace responder
} // namespace pldm