Check host state before attempting OCC communication

HBRT sends a PLDM message to occ-control when the OCCs go active. If the
system is powered down close to that time, there is a window where the
PLDM message could get sent even when the host is no longer running.
This commit will confirm the host is actually running when the message
is received; if not, the OCC communication willl not be allowed.

Change-Id: Ia209a5893e8294f1b10bcb143bc59831205223ab
Signed-off-by: Chris Cain <cjcain@us.ibm.com>
diff --git a/pldm.cpp b/pldm.cpp
index 687e3b4..fb2c245 100644
--- a/pldm.cpp
+++ b/pldm.cpp
@@ -159,13 +159,14 @@
         if (sensorEntry != sensorToOCCInstance.end())
         {
             const uint8_t instance = sensorEntry->second;
+            bool isRunning = false;
             if (eventState ==
                 static_cast<EventState>(
                     PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS_IN_SERVICE))
             {
                 log<level::INFO>(
                     fmt::format("PLDM: OCC{} is RUNNING", instance).c_str());
-                callBack(sensorEntry->second, true);
+                isRunning = true;
             }
             else if (eventState ==
                      static_cast<EventState>(
@@ -174,7 +175,6 @@
                 log<level::INFO>(
                     fmt::format("PLDM: OCC{} has now STOPPED", instance)
                         .c_str());
-                callBack(instance, false);
             }
             else if (eventState ==
                      static_cast<EventState>(
@@ -188,8 +188,6 @@
 
                 // Setting safe mode true
                 safeModeCallBack(true);
-
-                callBack(instance, false);
             }
             else
             {
@@ -198,6 +196,14 @@
                                 eventState, instance)
                         .c_str());
             }
+
+            if (!open_power::occ::utils::isHostRunning())
+            {
+                log<level::INFO>("PLDM: HOST is not running");
+                isRunning = false;
+            }
+            callBack(instance, isRunning);
+
             return;
         }
     }