#pragma once

#include <signal.h>
#include <sys/select.h>

#include <boost/beast/core/flat_static_buffer.hpp>
#include <boost/beast/http.hpp>
#include <boost/process.hpp>
#include <cstdio>
#include <cstdlib>

namespace crow
{
namespace obmc_dump
{

inline void handleDumpOffloadUrl(const crow::Request& req, crow::Response& res,
                                 const std::string& entryId);
inline void resetHandler();

// The max network block device buffer size is 128kb plus 16bytes
// for the message header
static constexpr auto nbdBufferSize = 131088;

/** class Handler
 *  handles data transfer between nbd-client and nbd-server.
 *  This handler invokes nbd-proxy and reads data from socket
 *  and writes on to nbd-client and vice-versa
 */
class Handler : public std::enable_shared_from_this<Handler>
{
  public:
    Handler(const std::string& media, boost::asio::io_context& ios,
            const std::string& entryID) :
        pipeOut(ios),
        pipeIn(ios), media(media), entryID(entryID), doingWrite(false),
        negotiationDone(false), writeonnbd(false),
        outputBuffer(std::make_unique<
                     boost::beast::flat_static_buffer<nbdBufferSize>>()),
        inputBuffer(
            std::make_unique<boost::beast::flat_static_buffer<nbdBufferSize>>())
    {
    }

    ~Handler()
    {
    }

    /**
     * @brief  Invokes InitiateOffload method of dump manager which
     *         directs pldm to start writing on the nbd device.
     *
     * @return void
     */
    void initiateOffloadOnNbdDevice()
    {
        crow::connections::systemBus->async_method_call(
            [this,
             self(shared_from_this())](const boost::system::error_code ec) {
                if (ec)
                {
                    BMCWEB_LOG_ERROR << "DBUS response error: " << ec;
                    resetBuffers();
                    resetHandler();
                    return;
                }
            },
            "xyz.openbmc_project.Dump.Manager",
            "/xyz/openbmc_project/dump/entry/" + entryID,
            "xyz.openbmc_project.Dump.Entry", "InitiateOffload", "/dev/nbd1");
    }

    /**
     * @brief  Kills nbd-proxy
     *
     * @return void
     */
    void doClose()
    {
        int rc = kill(proxy.id(), SIGTERM);
        if (rc)
        {
            return;
        }
        proxy.wait();
    }

    /**
     * @brief  Starts nbd-proxy
     *
     * @return void
     */
    void connect()
    {
        std::error_code ec;
        proxy = boost::process::child("/usr/sbin/nbd-proxy", media,
                                      boost::process::std_out > pipeOut,
                                      boost::process::std_in < pipeIn, ec);
        if (ec)
        {
            BMCWEB_LOG_ERROR << "Couldn't connect to nbd-proxy: "
                             << ec.message();
            resetHandler();
            return;
        }
        doRead();
    }

    /**
     * @brief  Wait for data on tcp socket from nbd-server.
     *
     * @return void
     */
    void waitForMessageOnSocket()
    {

        std::size_t bytes = inputBuffer->capacity() - inputBuffer->size();

        (*stream).async_read_some(
            inputBuffer->prepare(bytes),
            [this,
             self(shared_from_this())](const boost::system::error_code& ec,
                                       std::size_t bytes_transferred) {
                if (ec)
                {
                    BMCWEB_LOG_DEBUG << "Error while reading on socket";
                    doClose();
                    resetBuffers();
                    resetHandler();
                    return;
                }

                inputBuffer->commit(bytes_transferred);
                doWrite();
            });
    }

    /**
     * @brief  Writes data on input pipe of nbd-client.
     *
     * @return void
     */
    void doWrite()
    {

        if (doingWrite)
        {
            BMCWEB_LOG_DEBUG << "Already writing.  Bailing out";
            return;
        }

        if (inputBuffer->size() == 0)
        {
            BMCWEB_LOG_DEBUG << "inputBuffer empty.  Bailing out";
            return;
        }

        doingWrite = true;
        boost::asio::async_write(
            pipeIn, inputBuffer->data(),
            [this, self(shared_from_this())](const boost::beast::error_code& ec,
                                             std::size_t bytesWritten) {
                if (ec)
                {
                    BMCWEB_LOG_DEBUG << "VM socket port closed";
                    doClose();
                    resetBuffers();
                    resetHandler();
                    return;
                }

                doingWrite = false;

                if (negotiationDone == false)
                {
                    // "gDf" is NBD reply magic
                    std::string reply_magic("gDf");
                    std::string reply_string(
                        static_cast<char*>(inputBuffer->data().data()),
                        bytesWritten);
                    std::size_t found = reply_string.find(reply_magic);
                    if (found != std::string::npos)
                    {
                        negotiationDone = true;
                        writeonnbd = true;
                    }
                }

                inputBuffer->consume(bytesWritten);
                waitForMessageOnSocket();
                if (writeonnbd)
                {
                    // NBD Negotiation Complete!!!!. Notify Dump manager to
                    // start dumping the actual data over NBD device
                    initiateOffloadOnNbdDevice();
                    writeonnbd = false;
                }
            });
    }

    /**
     * @brief  Reads data on output pipe of nbd-client and write on
     *         tcp socket.
     *
     * @return void
     */
    void doRead()
    {
        std::size_t bytes = outputBuffer->capacity() - outputBuffer->size();

        pipeOut.async_read_some(
            outputBuffer->prepare(bytes),
            [this, self(shared_from_this())](
                const boost::system::error_code& ec, std::size_t bytesRead) {
                if (ec)
                {
                    BMCWEB_LOG_ERROR << "Couldn't read from VM port: " << ec;
                    doClose();
                    resetBuffers();
                    resetHandler();
                    return;
                }

                outputBuffer->commit(bytesRead);

                boost::asio::async_write(
                    *stream, outputBuffer->data(),
                    [this](const boost::system::error_code& ec,
                           std::size_t bytes_transferred) {
                        if (ec)
                        {
                            BMCWEB_LOG_DEBUG << "Error while writing on socket";
                            doClose();
                            resetBuffers();
                            resetHandler();
                            return;
                        }

                        outputBuffer->consume(bytes_transferred);
                        doRead();
                    });
            });
    }

    /**
     * @brief  Resets input and output buffers.
     * @return void
     */
    void resetBuffers()
    {
#if BOOST_VERSION >= 107000
        this->inputBuffer->clear();
        this->outputBuffer->clear();
#else
        this->inputBuffer->reset();
        this->outputBuffer->reset();
#endif
    }

    boost::process::async_pipe pipeOut;
    boost::process::async_pipe pipeIn;
    boost::process::child proxy;
    std::string media;
    std::string entryID;
    bool doingWrite;
    bool negotiationDone;
    bool writeonnbd;
    std::unique_ptr<boost::beast::flat_static_buffer<nbdBufferSize>>
        outputBuffer;
    std::unique_ptr<boost::beast::flat_static_buffer<nbdBufferSize>>
        inputBuffer;
    std::shared_ptr<crow::Request::Adaptor> stream;
};

static std::shared_ptr<Handler> handler;
inline void resetHandler()
{

    handler.reset();
}
inline void handleDumpOffloadUrl(const crow::Request& req, crow::Response& res,
                                 const std::string& entryId)
{

    // Run only one instance of Handler, one dump offload can happen at a time
    if (handler != nullptr)
    {
        BMCWEB_LOG_ERROR << "Handler already running";
        res.result(boost::beast::http::status::service_unavailable);
        res.jsonValue["Description"] = "Service is already being used";
        res.end();
        return;
    }

    const char* media = "1";
    boost::asio::io_context* io_con = req.ioService;

    handler = std::make_shared<Handler>(media, *io_con, entryId);
    handler->stream =
        std::make_shared<crow::Request::Adaptor>(std::move(req.socket()));
    handler->connect();
    handler->waitForMessageOnSocket();
}
} // namespace obmc_dump
} // namespace crow
