ipmid: Handler should automatically handle OEM / Group
We shouldn't require the user to handle these. They are a detail purely
at the message layer and weren't provided to handlers in the past.
Change-Id: I1796eb887c86dfbd66d9c784a99dbae675ceb774
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/ipmid-new.cpp b/ipmid-new.cpp
index 97c6e79..5eec4d1 100644
--- a/ipmid-new.cpp
+++ b/ipmid-new.cpp
@@ -276,16 +276,12 @@
{
return errorResponse(request, ccReqDataLenInvalid);
}
- // The handler will need to unpack group as well; we just need it for lookup
- request->payload.reset();
auto group = static_cast<Group>(bytes);
message::Response::ptr response =
executeIpmiCommandCommon(groupHandlerMap, group, request);
- // if the handler should add the group; executeIpmiCommandCommon does not
- if (response->cc != ccSuccess && response->payload.size() == 0)
- {
- response->pack(bytes);
- }
+ ipmi::message::Payload prefix;
+ prefix.pack(bytes);
+ response->prepend(prefix);
return response;
}
@@ -297,15 +293,12 @@
{
return errorResponse(request, ccReqDataLenInvalid);
}
- request->payload.reset();
auto iana = static_cast<Iana>(bytes);
message::Response::ptr response =
executeIpmiCommandCommon(oemHandlerMap, iana, request);
- // if the handler should add the iana; executeIpmiCommandCommon does not
- if (response->cc != ccSuccess && response->payload.size() == 0)
- {
- response->pack(bytes);
- }
+ ipmi::message::Payload prefix;
+ prefix.pack(bytes);
+ response->prepend(prefix);
return response;
}