PEL: Receive a 'bad PEL' indication from host

If the code somehow sent the host a malformed PEL, it will
respond with the 'Ack PEL' PLDM command with a special value
that indicates this, and the PLDM daemon will relay it to this
daemon.

In this case, change the host transmission state to 'bad' so
it doesn't get sent again.  This should never happen as the
Repository class already validates PELs and removes bad ones,
though maybe the host and Repository have different ideas
about what constitutes a malformed PEL.

In the future, if event logging support is added to the PEL
code running inside the logging daemon, it may be a good
idea to create a new PEL for this case.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Id6f9fd37764bf5b5d09b4277a1e36b1f26b3e9a5
diff --git a/extensions/openpower-pels/host_notifier.cpp b/extensions/openpower-pels/host_notifier.cpp
index ca30340..2e132b9 100644
--- a/extensions/openpower-pels/host_notifier.cpp
+++ b/extensions/openpower-pels/host_notifier.cpp
@@ -419,4 +419,17 @@
     }
 }
 
+void HostNotifier::setBadPEL(uint32_t id)
+{
+    log<level::ERR>("PEL rejected by the host", entry("PEL_ID=0x%X", id));
+
+    auto sent = std::find(_sentPELs.begin(), _sentPELs.end(), id);
+    if (sent != _sentPELs.end())
+    {
+        _sentPELs.erase(sent);
+    }
+
+    _repo.setPELHostTransState(id, TransmissionState::badPEL);
+}
+
 } // namespace openpower::pels