netipmid: move sol console sockets to asio

Rewrite the SOL console sockets use boost::asio. This reduces code size
and ties better into the main asio io loop.

Change-Id: Ia79b9aa3fa3c7ce1ddd9b609b032160a88394f8c
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/sol/sol_manager.hpp b/sol/sol_manager.hpp
index 5a0c18c..5d96890 100644
--- a/sol/sol_manager.hpp
+++ b/sol/sol_manager.hpp
@@ -4,6 +4,8 @@
 #include "session.hpp"
 #include "sol_context.hpp"
 
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/local/stream_protocol.hpp>
 #include <map>
 #include <memory>
 
@@ -23,32 +25,6 @@
 
 using Instance = uint8_t;
 
-/** @struct CustomFD
- *
- *  RAII wrapper for file descriptor.
- */
-struct CustomFD
-{
-    CustomFD(const CustomFD&) = delete;
-    CustomFD& operator=(const CustomFD&) = delete;
-    CustomFD(CustomFD&&) = delete;
-    CustomFD& operator=(CustomFD&&) = delete;
-
-    CustomFD(int fd) : fd(fd)
-    {
-    }
-
-    ~CustomFD();
-
-    int operator()() const
-    {
-        return fd;
-    }
-
-  private:
-    int fd = -1;
-};
-
 using namespace std::chrono_literals;
 
 /** @class Manager
@@ -65,13 +41,20 @@
      */
     using SOLPayloadMap = std::map<Instance, std::unique_ptr<Context>>;
 
-    Manager() = default;
+    Manager() = delete;
     ~Manager() = default;
     Manager(const Manager&) = delete;
     Manager& operator=(const Manager&) = delete;
     Manager(Manager&&) = default;
     Manager& operator=(Manager&&) = default;
 
+    Manager(std::shared_ptr<boost::asio::io_context> io) : io(io)
+    {
+    }
+
+    /** @brief io context to add events to */
+    std::shared_ptr<boost::asio::io_context> io;
+
     /** @brief Host Console Buffer. */
     ConsoleData dataBuffer;
 
@@ -180,6 +163,12 @@
      */
     uint8_t channel = 1;
 
+    /** @brief Add host console I/O event source to the event loop.  */
+    void startHostConsole();
+
+    /** @brief Remove host console I/O event source. */
+    void stopHostConsole();
+
     /** @brief Start a SOL payload instance.
      *
      *  Starting a payload instance involves creating the context object,
@@ -263,11 +252,15 @@
   private:
     SOLPayloadMap payloadMap;
 
-    /** @brief File descriptor for the host console. */
-    std::unique_ptr<CustomFD> consoleFD = nullptr;
+    /** @brief Local stream socket for the host console. */
+    std::unique_ptr<boost::asio::local::stream_protocol::socket> consoleSocket =
+        nullptr;
 
     /** @brief Initialize the host console file descriptor. */
-    void initHostConsoleFd();
+    void initConsoleSocket();
+
+    /** @brief Handle incoming console data on the console socket */
+    void consoleInputHandler();
 };
 
 } // namespace sol