Fix minor issues in Get OEM Device Info
Minor fixes in get OEM device information command
- As per spec, Byte 2 and Byte 3 are valid only if
Byte 1 is selected as BIOS. So corrected the code
to make Byte 2 and Byte 3 as optional and checking
as per spec.
- Corrected the ME object path which is resulting in
command failure.
Tested:
Get OEM device information command works fine for all
BIOS, Management controller and SDR as specified in spec.
Change-Id: If5a5edbaf0464b7253fba2ef9fa0595878c12062
Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>
diff --git a/src/oemcommands.cpp b/src/oemcommands.cpp
index a5dea03..e531a8c 100644
--- a/src/oemcommands.cpp
+++ b/src/oemcommands.cpp
@@ -336,18 +336,18 @@
std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
std::string service =
getService(*dbus, "xyz.openbmc_project.Software.Version",
- "/xyz/openbmc_project/me_version");
+ "/xyz/openbmc_project/software/me");
Value variant =
- getDbusProperty(*dbus, service, "/xyz/openbmc_project/me_version",
+ getDbusProperty(*dbus, service, "/xyz/openbmc_project/software/me",
"xyz.openbmc_project.Software.Version", "Version");
- std::string& meString = std::get<std::string>(variant);
+ std::string& meVersion = std::get<std::string>(variant);
// get ME major number
std::regex pattern1("(\\d+?).(\\d+?).(\\d+?).(\\d+?).(\\d+?)");
constexpr size_t matchedPhosphor = 6;
std::smatch results;
- if (std::regex_match(meString, results, pattern1))
+ if (std::regex_match(meVersion, results, pattern1))
{
if (results.size() == matchedPhosphor)
{
@@ -369,14 +369,9 @@
std::array<uint8_t, 2>, std::array<uint8_t, 2>,
std::array<uint8_t, 2>, std::array<uint8_t, 2>>,
std::tuple<uint8_t, std::array<uint8_t, 2>>>>
- ipmiOEMGetDeviceInfo(uint8_t entityType, uint8_t countToRead,
- uint8_t offset)
+ ipmiOEMGetDeviceInfo(uint8_t entityType, std::optional<uint8_t> countToRead,
+ std::optional<uint8_t> offset)
{
- if (countToRead == 0)
- {
- return ipmi::responseReqDataLenInvalid();
- }
-
if (entityType > static_cast<uint8_t>(OEMDevEntityType::sdrVer))
{
return ipmi::responseInvalidFieldRequest();
@@ -387,6 +382,12 @@
{
case OEMDevEntityType::biosId:
{
+ // Byte 2&3, Only used with selecting BIOS
+ if (!countToRead || !offset)
+ {
+ return ipmi::responseReqDataLenInvalid();
+ }
+
std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
std::string service =
getService(*dbus, biosVersionIntf, biosObjPath);
@@ -396,23 +397,23 @@
getDbusProperty(*dbus, service, biosObjPath,
biosVersionIntf, biosVersionProp);
std::string& idString = std::get<std::string>(variant);
- if (offset >= idString.size())
+ if (*offset >= idString.size())
{
return ipmi::responseParmOutOfRange();
}
size_t length = 0;
- if (countToRead > (idString.size() - offset))
+ if (*countToRead > (idString.size() - *offset))
{
- length = idString.size() - offset;
+ length = idString.size() - *offset;
}
else
{
- length = countToRead;
+ length = *countToRead;
}
std::string readBuf = {0};
readBuf.resize(length);
- std::copy_n(idString.begin() + offset, length,
+ std::copy_n(idString.begin() + *offset, length,
(readBuf.begin()));
return ipmi::responseSuccess(readBuf);
}
@@ -425,6 +426,12 @@
case OEMDevEntityType::devVer:
{
+ // Byte 2&3, Only used with selecting BIOS
+ if (countToRead || offset)
+ {
+ return ipmi::responseReqDataLenInvalid();
+ }
+
constexpr const size_t verLen = 2;
constexpr const size_t verTotalLen = 10;
std::array<uint8_t, verLen> bmcBuf = {0xff, 0xff};
@@ -449,6 +456,12 @@
case OEMDevEntityType::sdrVer:
{
+ // Byte 2&3, Only used with selecting BIOS
+ if (countToRead || offset)
+ {
+ return ipmi::responseReqDataLenInvalid();
+ }
+
constexpr const size_t sdrLen = 2;
std::array<uint8_t, sdrLen> readBuf = {0x01, 0x0};
return ipmi::responseSuccess(