Use consistent error code in biosconfigcommands.

biosconfigcommands is checking for IsSystemInterface and
getPostCompleted to throw error for OOB IPMI commands.
But the error code was inconsistent.

Fix added to make error code consistent.
If not IsSystemInterface, error code is ipmi::responseCommandNotAvailable
If getPostCompleted, error code is ipmi::ipmiCCNotSupportedInCurrentState

Tested:
By sending following OOB BIOS commands:
1) Set Payload (0xD5), for type payload type 0.
2) Set BIOS Password Hash info (D7).
3) Set BIOS Feature Capability (D3).
4) Get BIOS Feature Capability (D4).

And verified that after post complete, correct error was thrown.

Signed-off-by: Arun Lal K M <arun.lal@intel.com>
Change-Id: Ie0e1337e4be74a0f5ebb9576ccdff4072fc51bf1
diff --git a/src/biosconfigcommands.cpp b/src/biosconfigcommands.cpp
index 8792e9b..a40c978 100644
--- a/src/biosconfigcommands.cpp
+++ b/src/biosconfigcommands.cpp
@@ -682,23 +682,26 @@
                                   uint8_t BIOSCapabilties, uint8_t reserved1,
                                   uint8_t reserved2, uint8_t reserved3)
 {
-    if (!getPostCompleted() && IsSystemInterface(ctx))
+    if (!IsSystemInterface(ctx))
     {
-        if (reserved1 != 0 || reserved2 != 0 || reserved3 != 0)
-        {
-            return ipmi::responseInvalidFieldRequest();
-        }
-
-        gNVOOBdata.mBIOSCapabilities.OOBCapability = BIOSCapabilties;
-        gNVOOBdata.mIsBIOSCapInitDone = true;
-
-        flushNVOOBdata();
-        return ipmi::responseSuccess();
+        return ipmi::responseCommandNotAvailable();
     }
-    else
+
+    if (getPostCompleted())
     {
         return ipmi::response(ipmiCCNotSupportedInCurrentState);
     }
+
+    if (reserved1 != 0 || reserved2 != 0 || reserved3 != 0)
+    {
+        return ipmi::responseInvalidFieldRequest();
+    }
+
+    gNVOOBdata.mBIOSCapabilities.OOBCapability = BIOSCapabilties;
+    gNVOOBdata.mIsBIOSCapInitDone = true;
+
+    flushNVOOBdata();
+    return ipmi::responseSuccess();
 }
 
 ipmi::RspType<uint8_t, uint8_t, uint8_t, uint8_t>
@@ -736,10 +739,15 @@
     // We should support this Payload type 0 command only in KCS Interface
     if (payloadType == static_cast<uint8_t>(ipmi::PType::IntelXMLType0))
     {
-        if (!IsSystemInterface(ctx) || getPostCompleted())
+        if (!IsSystemInterface(ctx))
         {
             return ipmi::responseCommandNotAvailable();
         }
+
+        if (getPostCompleted())
+        {
+            return ipmi::response(ipmiCCNotSupportedInCurrentState);
+        }
     }
 
     switch (static_cast<PTState>(paramSel))
@@ -1156,72 +1164,60 @@
     nlohmann::json data = nullptr;
 
     // We should support this command only in KCS Interface
-    if (!IsSystemInterface(ctx))
-    {
-        return ipmi::responseCommandNotAvailable();
-    }
-
-    // We should not support this command after System Booted - After Exit Boot
-    // service called
-    if (!getPostCompleted())
-    {
-        std::string HashFilePath = "/var/lib/bios-settings-manager/seedData";
-
-        std::ifstream devIdFile(HashFilePath);
-        if (devIdFile.is_open())
-        {
-
-            try
-            {
-                data = nlohmann::json::parse(devIdFile, nullptr, false);
-            }
-            catch (const nlohmann::json::parse_error& e)
-            {
-                return ipmi::responseResponseError();
-            }
-
-            if (data.is_discarded())
-            {
-                return ipmi::responseResponseError();
-            }
-
-            std::array<uint8_t, maxHashSize> newAdminHash;
-            std::array<uint8_t, maxSeedSize> seed;
-
-            uint8_t flag = 0;
-            uint8_t adminPwdChangedFlag = 0;
-            if (!data.is_discarded())
-            {
-
-                adminPwdChangedFlag = data["IsAdminPwdChanged"];
-                newAdminHash = data["AdminPwdHash"];
-                seed = data["Seed"];
-            }
-
-            auto status = getResetBIOSSettings(flag);
-            if (status)
-            {
-                return ipmi::responseResponseError();
-            }
-            if (adminPwdChangedFlag)
-            {
-                flag |= adminPasswordChanged;
-            }
-
-            std::copy(std::begin(newAdminHash), std::end(newAdminHash),
-                      std::begin(newAdminHash));
-
-            return ipmi::responseSuccess(seed, flag, newAdminHash);
-        }
-        else
-        {
-            return ipmi::responseResponseError();
-        }
-    }
-    else
+    if (getPostCompleted())
     {
         return ipmi::response(ipmiCCNotSupportedInCurrentState);
     }
+
+    std::string HashFilePath = "/var/lib/bios-settings-manager/seedData";
+
+    std::ifstream devIdFile(HashFilePath);
+    if (!devIdFile.is_open())
+    {
+        return ipmi::responseResponseError();
+    }
+
+    try
+    {
+        data = nlohmann::json::parse(devIdFile, nullptr, false);
+    }
+    catch (const nlohmann::json::parse_error& e)
+    {
+        return ipmi::responseResponseError();
+    }
+
+    if (data.is_discarded())
+    {
+        return ipmi::responseResponseError();
+    }
+
+    std::array<uint8_t, maxHashSize> newAdminHash;
+    std::array<uint8_t, maxSeedSize> seed;
+
+    uint8_t flag = 0;
+    uint8_t adminPwdChangedFlag = 0;
+    if (!data.is_discarded())
+    {
+
+        adminPwdChangedFlag = data["IsAdminPwdChanged"];
+        newAdminHash = data["AdminPwdHash"];
+        seed = data["Seed"];
+    }
+
+    auto status = getResetBIOSSettings(flag);
+    if (status)
+    {
+        return ipmi::responseResponseError();
+    }
+    if (adminPwdChangedFlag)
+    {
+        flag |= adminPasswordChanged;
+    }
+
+    std::copy(std::begin(newAdminHash), std::end(newAdminHash),
+              std::begin(newAdminHash));
+
+    return ipmi::responseSuccess(seed, flag, newAdminHash);
 }
 
 static void registerBIOSConfigFunctions(void)