Skip to content

Commit

Permalink
COD : add fixes for status change
Browse files Browse the repository at this point in the history
Signed-off-by: Varsha Kaverappa <[email protected]>
  • Loading branch information
vkaverap authored and rfrandse committed Oct 5, 2021
1 parent 1fe10a1 commit 8ec6168
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 51 deletions.
2 changes: 1 addition & 1 deletion oem/ibm/libpldm/file_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ enum pldm_fileio_file_type {
#define PLDM_RW_FILE_BY_TYPE_RESP_BYTES 5
#define PLDM_FILE_ACK_REQ_BYTES 7
#define PLDM_FILE_ACK_RESP_BYTES 1
#define PLDM_FILE_ACK_WITH_META_DATA_REQ_BYTES 26
#define PLDM_FILE_ACK_WITH_META_DATA_REQ_BYTES 23
#define PLDM_FILE_ACK_WITH_META_DATA_RESP_BYTES 1

/** @struct pldm_read_write_file_memory_req
Expand Down
2 changes: 1 addition & 1 deletion oem/ibm/libpldmresponder/file_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ Response Handler::fileAckWithMetaData(const pldm_msg* request,
Response response(sizeof(pldm_msg_hdr) +
PLDM_FILE_ACK_WITH_META_DATA_RESP_BYTES);

if (payloadLength != PLDM_FILE_ACK_WITH_META_DATA_RESP_BYTES)
if (payloadLength != PLDM_FILE_ACK_WITH_META_DATA_REQ_BYTES)
{
return CmdHandler::ccOnlyResponse(request, PLDM_ERROR_INVALID_LENGTH);
}
Expand Down
19 changes: 14 additions & 5 deletions oem/ibm/libpldmresponder/file_io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ class Handler : public CmdHandler
return this->newFileAvailable(request,
payloadLength);
});
handlers.emplace(PLDM_FILE_ACK_WITH_META_DATA,
[this](const pldm_msg* request, size_t payloadLength) {
return this->fileAckWithMetaData(request,
payloadLength);
});

resDumpMatcher = std::make_unique<sdbusplus::bus::match::match>(
pldm::utils::DBusHandler::getBus(),
Expand Down Expand Up @@ -334,13 +339,17 @@ class Handler : public CmdHandler
{
pldm::utils::PropertyValue licStrVal{prop.second};
licenseStr = std::get<std::string>(licStrVal);
dbusToFileHandlers
.emplace_back(
std::make_unique<pldm::requester::oem_ibm::
DbusToFileHandler>(
hostSockFd, hostEid, dbusImplReqester, path,
handler))
->newLicFileAvailable(licenseStr);
break;
}
break;
}
dbusToFileHandlers
.emplace_back(std::make_unique<
pldm::requester::oem_ibm::DbusToFileHandler>(
hostSockFd, hostEid, dbusImplReqester, path, handler))
->newLicFileAvailable(licenseStr);
});
}

Expand Down
70 changes: 26 additions & 44 deletions oem/ibm/libpldmresponder/file_io_type_lic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,22 @@ int LicenseHandler::read(uint32_t offset, uint32_t& length, Response& response,

int LicenseHandler::fileAckWithMetaData(uint32_t metaDataValue)
{
constexpr auto codLicInterface = "com.ibm.License.LicenseManager";
constexpr auto codLicObjPath = "/com/ibm/license";
DBusMapping dbusMapping;
dbusMapping.objectPath = "/com/ibm/license";
dbusMapping.interface = "com.ibm.License.LicenseManager";
dbusMapping.propertyName = "LicenseActivationStatus";
dbusMapping.propertyType = "string";

Status status = static_cast<Status>(metaDataValue);

if (status == Status::InvalidLicense)
{
PropertyValue valueStatus{
"com.ibm.License.LicenseManager.Status.InvalidLicense"};
DBusMapping dbusMappingStatus{codLicObjPath, codLicInterface, "Status",
"string"};
pldm::utils::PropertyValue value =
"com.ibm.License.LicenseManager.Status.InvalidLicense";

try
{
pldm::utils::DBusHandler().setDbusProperty(dbusMappingStatus,
valueStatus);
pldm::utils::DBusHandler().setDbusProperty(dbusMapping, value);
}
catch (const std::exception& e)
{
Expand All @@ -182,15 +182,12 @@ int LicenseHandler::fileAckWithMetaData(uint32_t metaDataValue)
}
else if (status == Status::Activated)
{
PropertyValue valueStatus{
"com.ibm.License.LicenseManager.Status.Activated"};
DBusMapping dbusMappingStatus{codLicObjPath, codLicInterface, "Status",
"string"};
pldm::utils::PropertyValue value =
"com.ibm.License.LicenseManager.Status.Activated";

try
{
pldm::utils::DBusHandler().setDbusProperty(dbusMappingStatus,
valueStatus);
pldm::utils::DBusHandler().setDbusProperty(dbusMapping, value);
}
catch (const std::exception& e)
{
Expand All @@ -202,15 +199,12 @@ int LicenseHandler::fileAckWithMetaData(uint32_t metaDataValue)
}
else if (status == Status::Pending)
{
PropertyValue valueStatus{
"com.ibm.License.LicenseManager.Status.Pending"};
DBusMapping dbusMappingStatus{codLicObjPath, codLicInterface, "Status",
"string"};
pldm::utils::PropertyValue value =
"com.ibm.License.LicenseManager.Status.Pending";

try
{
pldm::utils::DBusHandler().setDbusProperty(dbusMappingStatus,
valueStatus);
pldm::utils::DBusHandler().setDbusProperty(dbusMapping, value);
}
catch (const std::exception& e)
{
Expand All @@ -222,15 +216,12 @@ int LicenseHandler::fileAckWithMetaData(uint32_t metaDataValue)
}
else if (status == Status::ActivationFailed)
{
PropertyValue valueStatus{
"com.ibm.License.LicenseManager.Status.ActivationFailed"};
DBusMapping dbusMappingStatus{codLicObjPath, codLicInterface, "Status",
"string"};
pldm::utils::PropertyValue value =
"com.ibm.License.LicenseManager.Status.ActivationFailed";

try
{
pldm::utils::DBusHandler().setDbusProperty(dbusMappingStatus,
valueStatus);
pldm::utils::DBusHandler().setDbusProperty(dbusMapping, value);
}
catch (const std::exception& e)
{
Expand All @@ -242,15 +233,12 @@ int LicenseHandler::fileAckWithMetaData(uint32_t metaDataValue)
}
else if (status == Status::IncorrectSystem)
{
PropertyValue valueStatus{
"com.ibm.License.LicenseManager.Status.IncorrectSystem"};
DBusMapping dbusMappingStatus{codLicObjPath, codLicInterface, "Status",
"string"};
pldm::utils::PropertyValue value =
"com.ibm.License.LicenseManager.Status.IncorrectSystem";

try
{
pldm::utils::DBusHandler().setDbusProperty(dbusMappingStatus,
valueStatus);
pldm::utils::DBusHandler().setDbusProperty(dbusMapping, value);
}
catch (const std::exception& e)
{
Expand All @@ -262,15 +250,12 @@ int LicenseHandler::fileAckWithMetaData(uint32_t metaDataValue)
}
else if (status == Status::InvalidHostState)
{
PropertyValue valueStatus{
"com.ibm.License.LicenseManager.Status.InvalidHostState"};
DBusMapping dbusMappingStatus{codLicObjPath, codLicInterface, "Status",
"string"};
pldm::utils::PropertyValue value =
"com.ibm.License.LicenseManager.Status.InvalidHostState";

try
{
pldm::utils::DBusHandler().setDbusProperty(dbusMappingStatus,
valueStatus);
pldm::utils::DBusHandler().setDbusProperty(dbusMapping, value);
}
catch (const std::exception& e)
{
Expand All @@ -282,15 +267,12 @@ int LicenseHandler::fileAckWithMetaData(uint32_t metaDataValue)
}
else if (status == Status::IncorrectSequence)
{
PropertyValue valueStatus{
"com.ibm.License.LicenseManager.Status.IncorrectSequence"};
DBusMapping dbusMappingStatus{codLicObjPath, codLicInterface, "Status",
"string"};
pldm::utils::PropertyValue value =
"com.ibm.License.LicenseManager.Status.IncorrectSequence";

try
{
pldm::utils::DBusHandler().setDbusProperty(dbusMappingStatus,
valueStatus);
pldm::utils::DBusHandler().setDbusProperty(dbusMapping, value);
}
catch (const std::exception& e)
{
Expand Down

0 comments on commit 8ec6168

Please sign in to comment.