message_parsers: Use local session instance

In message_parsers, it was calling `getSession()` in a few functions,
which is not necessary because the caller already has the session
instance.

Add the `session` as the argument of the functions so that it does not
need to call `getSession()` again.

This also fixes the issue that the session is removed in the session
manager and throws in `getSession()`, see details in the previous commit.

Tested: No logic changes, verify build is OK, and ipmi lanplus commands
       are working OK.

Signed-off-by: Lei YU <yulei.sh@bytedance.com>
Change-Id: Ibaf38ce86cad9f421a672aeb4304246aa9aa1e49
diff --git a/message_parsers.hpp b/message_parsers.hpp
index b26f9a3..a992e0a 100644
--- a/message_parsers.hpp
+++ b/message_parsers.hpp
@@ -178,6 +178,7 @@
  *        session header
  *
  * @param[in] outMessage - IPMI message to be flattened
+ * @param[in] session - session handle
  *
  * @return IPMI packet on success
  */
@@ -203,11 +204,13 @@
  * @param[in] packet - Incoming IPMI packet
  * @param[in] message - IPMI Message populated from the incoming packet
  * @param[in] payloadLen - Length of the IPMI payload
+ * @param[in] session - session handle
  *
  */
 bool verifyPacketIntegrity(const std::vector<uint8_t>& packet,
                            const std::shared_ptr<Message> message,
-                           size_t payloadLen);
+                           size_t payloadLen,
+                           const std::shared_ptr<session::Session>& session);
 
 /**
  * @brief Add Integrity data to the outgoing IPMI packet
@@ -217,8 +220,8 @@
  * @param[in] payloadLen - Length of the IPMI payload
  */
 void addIntegrityData(std::vector<uint8_t>& packet,
-                      const std::shared_ptr<Message> message,
-                      size_t payloadLen);
+                      const std::shared_ptr<Message> message, size_t payloadLen,
+                      const std::shared_ptr<session::Session>& session);
 
 /**
  * @brief Decrypt the encrypted payload in the incoming IPMI packet
@@ -226,21 +229,26 @@
  * @param[in] packet - Incoming IPMI packet
  * @param[in] message - IPMI Message populated from the incoming packet
  * @param[in] payloadLen - Length of encrypted IPMI payload
+ * @param[in] session - session handle
  *
  * @return on successful completion, return the plain text payload
  */
-std::vector<uint8_t> decryptPayload(const std::vector<uint8_t>& packet,
-                                    const std::shared_ptr<Message> message,
-                                    size_t payloadLen);
+std::vector<uint8_t>
+    decryptPayload(const std::vector<uint8_t>& packet,
+                   const std::shared_ptr<Message> message, size_t payloadLen,
+                   const std::shared_ptr<session::Session>& session);
 
 /**
  * @brief Encrypt the plain text payload for the outgoing IPMI packet
  *
  * @param[in] message - IPMI Message populated for the outgoing packet
+ * @param[in] session - session handle
  *
  * @return on successful completion, return the encrypted payload
  */
-std::vector<uint8_t> encryptPayload(std::shared_ptr<Message> message);
+std::vector<uint8_t>
+    encryptPayload(std::shared_ptr<Message> message,
+                   const std::shared_ptr<session::Session>& session);
 
 } // namespace internal