netipmid: use shared_ptr on session instead of shared_ptr+references

session objects were being created and held by shared_ptr objects and
then shared via reference. This is dangerous and sidesteps the whole
point of a shared_ptr, which is to share reference-counted ownership.
This replaces the usage with a shared_ptr, which shows shared ownership.

Change-Id: Ie22d812a6d260d606201eca6a9011e773c89e487
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/message_parsers.cpp b/message_parsers.cpp
index ddb9d01..d7074fa 100644
--- a/message_parsers.cpp
+++ b/message_parsers.cpp
@@ -55,7 +55,8 @@
 }
 
 std::vector<uint8_t> flatten(std::shared_ptr<Message> outMessage,
-                             SessionHeader authType, session::Session& session)
+                             SessionHeader authType,
+                             std::shared_ptr<session::Session> session)
 {
     // Call the flatten routine based on the header type
     switch (authType)
@@ -108,7 +109,7 @@
 }
 
 std::vector<uint8_t> flatten(std::shared_ptr<Message> outMessage,
-                             session::Session& session)
+                             std::shared_ptr<session::Session> session)
 {
     std::vector<uint8_t> packet(sizeof(SessionHeader_t));
 
@@ -191,7 +192,7 @@
 }
 
 std::vector<uint8_t> flatten(std::shared_ptr<Message> outMessage,
-                             session::Session& session)
+                             std::shared_ptr<session::Session> session)
 {
     std::vector<uint8_t> packet(sizeof(SessionHeader_t));
 
@@ -243,7 +244,8 @@
 namespace internal
 {
 
-void addSequenceNumber(std::vector<uint8_t>& packet, session::Session& session)
+void addSequenceNumber(std::vector<uint8_t>& packet,
+                       std::shared_ptr<session::Session> session)
 {
     SessionHeader_t* header = reinterpret_cast<SessionHeader_t*>(packet.data());
 
@@ -253,7 +255,7 @@
     }
     else
     {
-        auto seqNum = session.sequenceNums.increment();
+        auto seqNum = session->sequenceNums.increment();
         header->sessSeqNum = endian::to_ipmi(seqNum);
     }
 }