Add support for Get SOL configuration parameters command.

Change-Id: I711cbcd66caea7939d7604551ea4d80a1576244e
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
diff --git a/command/sol_cmds.cpp b/command/sol_cmds.cpp
index f18bc8b..f475c03 100644
--- a/command/sol_cmds.cpp
+++ b/command/sol_cmds.cpp
@@ -153,6 +153,92 @@
     return outPayload;
 }
 
+std::vector<uint8_t> getConfParams(const std::vector<uint8_t>& inPayload,
+                                   const message::Handler& handler)
+{
+    std::vector<uint8_t> outPayload(sizeof(GetConfParamsResponse));
+    auto request = reinterpret_cast<const GetConfParamsRequest*>
+                   (inPayload.data());
+    auto response = reinterpret_cast<GetConfParamsResponse*>
+                    (outPayload.data());
+    response->completionCode = IPMI_CC_OK;
+    response->paramRev = parameterRevision;
+
+    if (request->getParamRev)
+    {
+        return outPayload;
+    }
+
+    switch (static_cast<Parameter>(request->paramSelector))
+    {
+        case Parameter::PROGRESS:
+        {
+            outPayload.push_back(std::get<sol::Manager&>
+                    (singletonPool).progress);
+            break;
+        }
+        case Parameter::ENABLE:
+        {
+            outPayload.push_back(std::get<sol::Manager&>
+                    (singletonPool).enable);
+            break;
+        }
+        case Parameter::AUTHENTICATION:
+        {
+            Auth value {0};
+
+            value.encrypt = std::get<sol::Manager&>(singletonPool).forceEncrypt;
+            value.auth = std::get<sol::Manager&>(singletonPool).forceAuth;
+            value.privilege  = static_cast<uint8_t>(std::get<sol::Manager&>
+                    (singletonPool).solMinPrivilege);
+            auto buffer = reinterpret_cast<const uint8_t *>(&value);
+
+            std::copy_n(buffer, sizeof(value), std::back_inserter(outPayload));
+            break;
+        }
+        case Parameter::ACCUMULATE:
+        {
+            Accumulate value {0};
+
+            value.interval = std::get<sol::Manager&>(singletonPool)
+                            .accumulateInterval.count()/sol::accIntervalFactor;
+            value.threshold = std::get<sol::Manager&>
+                            (singletonPool).sendThreshold;
+            auto buffer = reinterpret_cast<const uint8_t *>(&value);
+
+            std::copy_n(buffer, sizeof(value), std::back_inserter(outPayload));
+            break;
+        }
+        case Parameter::RETRY:
+        {
+            Retry value {0};
+
+            value.count = std::get<sol::Manager&>(singletonPool).retryCount;
+            value.interval = std::get<sol::Manager&>(singletonPool)
+                    .retryInterval.count()/sol::retryIntervalFactor;
+            auto buffer = reinterpret_cast<const uint8_t *>(&value);
+
+            std::copy_n(buffer, sizeof(value), std::back_inserter(outPayload));
+            break;
+        }
+        case Parameter::PORT:
+        {
+            auto port = endian::to_ipmi<uint16_t>(IPMI_STD_PORT);
+            auto buffer = reinterpret_cast<const uint8_t *>(&port);
+
+            std::copy_n(buffer, sizeof(port), std::back_inserter(outPayload));
+            break;
+        }
+        case Parameter::NVBITRATE:
+        case Parameter::VBITRATE:
+        case Parameter::CHANNEL:
+        default:
+            response->completionCode = ipmiCCParamNotSupported;
+    }
+
+    return outPayload;
+}
+
 } // namespace command
 
 } // namespace sol
diff --git a/command/sol_cmds.hpp b/command/sol_cmds.hpp
index 2336f02..cc19323 100644
--- a/command/sol_cmds.hpp
+++ b/command/sol_cmds.hpp
@@ -186,6 +186,49 @@
 std::vector<uint8_t> setConfParams(const std::vector<uint8_t>& inPayload,
                                    const message::Handler& handler);
 
+/** @struct GetConfParamsRequest
+ *
+ *  IPMI payload for Get SOL configuration parameters command request.
+ */
+struct GetConfParamsRequest
+{
+#if BYTE_ORDER == LITTLE_ENDIAN
+    uint8_t channelNum : 4;         //!< Channel number.
+    uint8_t reserved : 3;           //!< Reserved.
+    uint8_t getParamRev : 1;        //!< Get parameter or Get parameter revision
+#endif
+
+#if BYTE_ORDER == BIG_ENDIAN
+    uint8_t getParamRev : 1;        //!< Get parameter or Get parameter revision
+    uint8_t reserved : 3;           //!< Reserved.
+    uint8_t channelNum : 4;         //!< Channel number.
+#endif
+
+    uint8_t paramSelector;          //!< Parameter selector.
+    uint8_t setSelector;            //!< Set selector.
+    uint8_t blockSelector;          //!< Block selector.
+} __attribute__((packed));
+
+/** @struct GetConfParamsResponse
+ *
+ *  IPMI payload for Get SOL configuration parameters command response.
+ */
+struct GetConfParamsResponse
+{
+    uint8_t completionCode;          //!< Completion code.
+    uint8_t paramRev;                //!< Parameter revision.
+} __attribute__((packed));
+
+/** @brief Get SOL configuration parameters command.
+ *
+ *  @param[in] inPayload - Request data for the command.
+ *  @param[in] handler - Reference to the message handler.
+ *
+ *  @return Response data for the command.
+ */
+std::vector<uint8_t> getConfParams(const std::vector<uint8_t>& inPayload,
+                                   const message::Handler& handler);
+
 } // namespace command
 
 } // namespace sol