Refactor: Handler expands TID parameter
Adding tid as a parameter to each handler so that the handler
can know the message sent from which device
Tested:
- Unit Tests passed.
Change-Id: Ida37bf61146d2f59ea11ebc7bf009f7837ed496d
Signed-off-by: Delphine CC Chiu <Delphine_CC_Chiu@wiwynn.com>
diff --git a/libpldmresponder/base.hpp b/libpldmresponder/base.hpp
index 1bd88f8..544e913 100644
--- a/libpldmresponder/base.hpp
+++ b/libpldmresponder/base.hpp
@@ -30,20 +30,24 @@
instanceIdDb(instanceIdDb), event(event),
oemPlatformHandler(oemPlatformHandler), handler(handler)
{
- handlers.emplace(PLDM_GET_PLDM_TYPES,
- [this](const pldm_msg* request, size_t payloadLength) {
+ handlers.emplace(
+ PLDM_GET_PLDM_TYPES,
+ [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
return this->getPLDMTypes(request, payloadLength);
});
- handlers.emplace(PLDM_GET_PLDM_COMMANDS,
- [this](const pldm_msg* request, size_t payloadLength) {
+ handlers.emplace(
+ PLDM_GET_PLDM_COMMANDS,
+ [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
return this->getPLDMCommands(request, payloadLength);
});
- handlers.emplace(PLDM_GET_PLDM_VERSION,
- [this](const pldm_msg* request, size_t payloadLength) {
+ handlers.emplace(
+ PLDM_GET_PLDM_VERSION,
+ [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
return this->getPLDMVersion(request, payloadLength);
});
- handlers.emplace(PLDM_GET_TID,
- [this](const pldm_msg* request, size_t payloadLength) {
+ handlers.emplace(
+ PLDM_GET_TID,
+ [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
return this->getTID(request, payloadLength);
});
}
diff --git a/libpldmresponder/bios.cpp b/libpldmresponder/bios.cpp
index 986e74a..6687901 100644
--- a/libpldmresponder/bios.cpp
+++ b/libpldmresponder/bios.cpp
@@ -78,29 +78,35 @@
biosConfig.removeTables();
biosConfig.buildTables();
- handlers.emplace(PLDM_SET_DATE_TIME,
- [this](const pldm_msg* request, size_t payloadLength) {
+ handlers.emplace(
+ PLDM_SET_DATE_TIME,
+ [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
return this->setDateTime(request, payloadLength);
});
- handlers.emplace(PLDM_GET_DATE_TIME,
- [this](const pldm_msg* request, size_t payloadLength) {
+ handlers.emplace(
+ PLDM_GET_DATE_TIME,
+ [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
return this->getDateTime(request, payloadLength);
});
- handlers.emplace(PLDM_GET_BIOS_TABLE,
- [this](const pldm_msg* request, size_t payloadLength) {
+ handlers.emplace(
+ PLDM_GET_BIOS_TABLE,
+ [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
return this->getBIOSTable(request, payloadLength);
});
- handlers.emplace(PLDM_SET_BIOS_TABLE,
- [this](const pldm_msg* request, size_t payloadLength) {
+ handlers.emplace(
+ PLDM_SET_BIOS_TABLE,
+ [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
return this->setBIOSTable(request, payloadLength);
});
- handlers.emplace(PLDM_GET_BIOS_ATTRIBUTE_CURRENT_VALUE_BY_HANDLE,
- [this](const pldm_msg* request, size_t payloadLength) {
+ handlers.emplace(
+ PLDM_GET_BIOS_ATTRIBUTE_CURRENT_VALUE_BY_HANDLE,
+ [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
return this->getBIOSAttributeCurrentValueByHandle(request,
payloadLength);
});
- handlers.emplace(PLDM_SET_BIOS_ATTRIBUTE_CURRENT_VALUE,
- [this](const pldm_msg* request, size_t payloadLength) {
+ handlers.emplace(
+ PLDM_SET_BIOS_ATTRIBUTE_CURRENT_VALUE,
+ [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
return this->setBIOSAttributeCurrentValue(request, payloadLength);
});
}
diff --git a/libpldmresponder/fru.hpp b/libpldmresponder/fru.hpp
index b986836..78a1a3e 100644
--- a/libpldmresponder/fru.hpp
+++ b/libpldmresponder/fru.hpp
@@ -232,17 +232,19 @@
pldm_entity_association_tree* bmcEntityTree) :
impl(configPath, fruMasterJsonPath, pdrRepo, entityTree, bmcEntityTree)
{
- handlers.emplace(PLDM_GET_FRU_RECORD_TABLE_METADATA,
- [this](const pldm_msg* request, size_t payloadLength) {
+ handlers.emplace(
+ PLDM_GET_FRU_RECORD_TABLE_METADATA,
+ [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
return this->getFRURecordTableMetadata(request, payloadLength);
});
-
- handlers.emplace(PLDM_GET_FRU_RECORD_TABLE,
- [this](const pldm_msg* request, size_t payloadLength) {
+ handlers.emplace(
+ PLDM_GET_FRU_RECORD_TABLE,
+ [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
return this->getFRURecordTable(request, payloadLength);
});
- handlers.emplace(PLDM_GET_FRU_RECORD_BY_OPTION,
- [this](const pldm_msg* request, size_t payloadLength) {
+ handlers.emplace(
+ PLDM_GET_FRU_RECORD_BY_OPTION,
+ [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
return this->getFRURecordByOption(request, payloadLength);
});
}
diff --git a/libpldmresponder/platform.hpp b/libpldmresponder/platform.hpp
index 8df9625..eb01e5f 100644
--- a/libpldmresponder/platform.hpp
+++ b/libpldmresponder/platform.hpp
@@ -69,28 +69,34 @@
pdrCreated = true;
}
- handlers.emplace(PLDM_GET_PDR,
- [this](const pldm_msg* request, size_t payloadLength) {
+ handlers.emplace(
+ PLDM_GET_PDR,
+ [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
return this->getPDR(request, payloadLength);
});
- handlers.emplace(PLDM_SET_NUMERIC_EFFECTER_VALUE,
- [this](const pldm_msg* request, size_t payloadLength) {
+ handlers.emplace(
+ PLDM_SET_NUMERIC_EFFECTER_VALUE,
+ [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
return this->setNumericEffecterValue(request, payloadLength);
});
- handlers.emplace(PLDM_GET_NUMERIC_EFFECTER_VALUE,
- [this](const pldm_msg* request, size_t payloadLength) {
+ handlers.emplace(
+ PLDM_GET_NUMERIC_EFFECTER_VALUE,
+ [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
return this->getNumericEffecterValue(request, payloadLength);
});
- handlers.emplace(PLDM_SET_STATE_EFFECTER_STATES,
- [this](const pldm_msg* request, size_t payloadLength) {
+ handlers.emplace(
+ PLDM_SET_STATE_EFFECTER_STATES,
+ [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
return this->setStateEffecterStates(request, payloadLength);
});
- handlers.emplace(PLDM_PLATFORM_EVENT_MESSAGE,
- [this](const pldm_msg* request, size_t payloadLength) {
+ handlers.emplace(
+ PLDM_PLATFORM_EVENT_MESSAGE,
+ [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
return this->platformEventMessage(request, payloadLength);
});
- handlers.emplace(PLDM_GET_STATE_SENSOR_READINGS,
- [this](const pldm_msg* request, size_t payloadLength) {
+ handlers.emplace(
+ PLDM_GET_STATE_SENSOR_READINGS,
+ [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
return this->getStateSensorReadings(request, payloadLength);
});