summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFeist, James <james.feist@linux.intel.com>2017-10-26 15:06:13 -0700
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2017-11-06 14:39:28 +0000
commitbd45aae1db0643570ebad03f8d2a39e5cac53c8d (patch)
treea6714ec352774b2ef7a364785a37ba40d49ffcef
parent541aee76cf4a6d182c864f62298579eb155f414b (diff)
downloadphosphor-net-ipmid-bd45aae1db0643570ebad03f8d2a39e5cac53c8d.tar.gz
phosphor-net-ipmid-bd45aae1db0643570ebad03f8d2a39e5cac53c8d.zip
Small fixes for net ipmi handler
Host ipmid handler will not re-register commands, so make the net handler follow this by skipping later registrations. Also pass size of command to handlers for length checks to work. Host ipmi handler passes this parameter correctly. Change-Id: I8eb1d645eff405b91e471433085025b6835f0bd2 Signed-off-by: Feist, James <james.feist@linux.intel.com>
-rw-r--r--command_table.cpp13
-rw-r--r--command_table.hpp4
2 files changed, 13 insertions, 4 deletions
diff --git a/command_table.cpp b/command_table.cpp
index f0a8f17..7a6e2df 100644
--- a/command_table.cpp
+++ b/command_table.cpp
@@ -12,10 +12,19 @@ namespace command
void Table::registerCommand(CommandID inCommand, std::unique_ptr<Entry>&& entry)
{
+ auto& command = commandTable[inCommand.command];
+
+ if (command)
+ {
+ std::cout << "I> Already Registered, Skipping " << std::hex
+ << inCommand.command << "\n";
+ return;
+ }
+
std::cout << "I> Registering Command" << std::hex
<< inCommand.command << "\n";
- commandTable[inCommand.command] = std::move(entry);
+ command = std::move(entry);
}
std::vector<uint8_t> Table::executeCommand(uint32_t inCommand,
@@ -82,7 +91,7 @@ std::vector<uint8_t> ProviderIpmidEntry::executeCommand(
const message::Handler& handler)
{
std::vector<uint8_t> response(message::parser::MAX_PAYLOAD_SIZE - 1);
- size_t respSize {};
+ size_t respSize = commandData.size();
ipmi_ret_t ipmiRC = functor(0, 0,
reinterpret_cast<void*>(commandData.data()),
diff --git a/command_table.hpp b/command_table.hpp
index 62738c8..7d2fe13 100644
--- a/command_table.hpp
+++ b/command_table.hpp
@@ -269,8 +269,8 @@ class Table
*
* @return: None
*
- * @note Registering an already registered command will overwrite the
- * existing entry with the new one.
+ * @note: Duplicate registrations will be rejected.
+ *
*/
void registerCommand(CommandID inCommand,
std::unique_ptr<Entry>&& entry);
OpenPOWER on IntegriCloud