#include "endian.hpp"
#include "slp.hpp"
#include "slp_meta.hpp"

#include <string.h>

#include <algorithm>
#include <string>

namespace slp
{

namespace parser
{

namespace internal
{

std::tuple<int, Message> parseHeader(const buffer& buff)
{
    /*  0                   1                   2                   3
        0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |    Version    |  Function-ID  |            Length             |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       | Length, contd.|O|F|R|       reserved          |Next Ext Offset|
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |  Next Extension Offset, contd.|              XID              |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |      Language Tag Length      |         Language Tag          \
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */

    Message req{};
    int rc = slp::SUCCESS;

    std::copy_n(buff.data(), slp::header::SIZE_VERSION, &req.header.version);

    std::copy_n(buff.data() + slp::header::OFFSET_FUNCTION,
                slp::header::SIZE_VERSION, &req.header.functionID);

    std::copy_n(buff.data() + slp::header::OFFSET_LENGTH,
                slp::header::SIZE_LENGTH, req.header.length.data());

    std::copy_n(buff.data() + slp::header::OFFSET_FLAGS,
                slp::header::SIZE_FLAGS, (uint8_t*)&req.header.flags);

    req.header.flags = endian::from_network(req.header.flags);
    std::copy_n(buff.data() + slp::header::OFFSET_EXT, slp::header::SIZE_EXT,
                req.header.extOffset.data());

    std::copy_n(buff.data() + slp::header::OFFSET_XID, slp::header::SIZE_XID,
                (uint8_t*)&req.header.xid);

    req.header.xid = endian::from_network(req.header.xid);

    uint16_t langtagLen;

    std::copy_n(buff.data() + slp::header::OFFSET_LANG_LEN,
                slp::header::SIZE_LANG, (uint8_t*)&langtagLen);

    langtagLen = endian::from_network(langtagLen);

    req.header.langtag.insert(
        0, (const char*)buff.data() + slp::header::OFFSET_LANG, langtagLen);

    /* check for the validity of the function */
    if (req.header.functionID <
            static_cast<uint8_t>(slp::FunctionType::SRVRQST) ||
        req.header.functionID > static_cast<uint8_t>(slp::FunctionType::SAADV))
    {
        rc = static_cast<int>(slp::Error::PARSE_ERROR);
    }

    return std::make_tuple(rc, std::move(req));
}

int parseSrvTypeRqst(const buffer& buff, Message& req)
{
    /*  0                   1                   2                   3
        0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |        length of PRList       |        <PRList> String        \
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |   length of Naming Authority  |   <Naming Authority String>   \
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |     length of <scope-list>    |      <scope-list> String      \
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */

    /* Enforce SLPv2 service type request size limits. */
    if (buff.size() < slp::request::MIN_SRVTYPE_LEN)
    {
        return (int)slp::Error::PARSE_ERROR;
    }

    /* Parse the PRList. */
    uint16_t prListLen;
    std::copy_n(buff.data() + slp::request::OFFSET_PR_LEN,
                slp::request::SIZE_PRLIST, (uint8_t*)&prListLen);

    prListLen = endian::from_network(prListLen);

    req.body.srvtyperqst.prList.insert(
        0, (const char*)buff.data() + slp::request::OFFSET_PR, prListLen);

    uint8_t pos = slp::request::OFFSET_PR + prListLen;

    /* Parse the Naming Authority. */
    uint16_t namingAuthLen;
    std::copy_n(buff.data() + pos, slp::request::SIZE_NAMING,
                (uint8_t*)&namingAuthLen);

    pos += slp::request::SIZE_NAMING;

    namingAuthLen = endian::from_network(namingAuthLen);

    if (namingAuthLen == 0 || namingAuthLen == 0xffff)
    {
        req.body.srvtyperqst.namingAuth = "";
    }
    else
    {
        req.body.srvtyperqst.namingAuth.insert(
            0, (const char*)buff.data() + pos, namingAuthLen);
    }

    pos += namingAuthLen;

    /* Parse the <scope-list>. */
    uint16_t scopeListLen;
    std::copy_n(buff.data() + pos, slp::request::SIZE_SCOPE,
                (uint8_t*)&scopeListLen);

    pos += slp::request::SIZE_SCOPE;

    scopeListLen = endian::from_network(scopeListLen);

    req.body.srvtyperqst.scopeList.insert(0, (const char*)buff.data() + pos,
                                          scopeListLen);

    return slp::SUCCESS;
}

int parseSrvRqst(const buffer& buff, Message& req)
{
    /*  0                   1                   2                   3
        0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |      length of <PRList>       |        <PRList> String        \
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |   length of <service-type>    |    <service-type> String      \
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |    length of <scope-list>     |     <scope-list> String       \
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |  length of predicate string   |  Service Request <predicate>  \
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |  length of <SLP SPI> string   |       <SLP SPI> String        \
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */

    /* Enforce v2 service request size limits. */
    if (buff.size() < slp::request::MIN_SRV_LEN)
    {
        return (int)slp::Error::PARSE_ERROR;
    }

    /* 1) Parse the PRList. */
    uint16_t prListLen;
    std::copy_n(buff.data() + slp::request::OFFSET_PR_LEN,
                slp::request::SIZE_PRLIST, (uint8_t*)&prListLen);

    auto pos = slp::request::OFFSET_PR_LEN + slp::request::SIZE_PRLIST;

    prListLen = endian::from_network(prListLen);

    req.body.srvrqst.prList.insert(0, (const char*)buff.data() + pos,
                                   prListLen);

    pos += prListLen;

    /* 2) Parse the <service-type> string. */
    uint16_t srvTypeLen;
    std::copy_n(buff.data() + pos, slp::request::SIZE_SERVICE_TYPE,
                (uint8_t*)&srvTypeLen);

    srvTypeLen = endian::from_network(srvTypeLen);

    pos += slp::request::SIZE_SERVICE_TYPE;

    req.body.srvrqst.srvType.insert(0, (const char*)buff.data() + pos,
                                    srvTypeLen);

    pos += srvTypeLen;

    /* 3) Parse the <scope-list> string. */
    uint16_t scopeListLen;
    std::copy_n(buff.data() + pos, slp::request::SIZE_SCOPE,
                (uint8_t*)&scopeListLen);

    scopeListLen = endian::from_network(scopeListLen);

    pos += slp::request::SIZE_SCOPE;

    req.body.srvrqst.scopeList.insert(0, (const char*)buff.data() + pos,
                                      scopeListLen);

    pos += scopeListLen;

    /* 4) Parse the <predicate> string. */
    uint16_t predicateLen;
    std::copy_n(buff.data() + pos, slp::request::SIZE_PREDICATE,
                (uint8_t*)&predicateLen);

    predicateLen = endian::from_network(predicateLen);
    pos += slp::request::SIZE_PREDICATE;

    req.body.srvrqst.predicate.insert(0, (const char*)buff.data() + pos,
                                      predicateLen);

    pos += predicateLen;

    /* 5) Parse the <SLP SPI> string. */
    uint16_t spistrLen;
    std::copy_n(buff.data() + pos, slp::request::SIZE_SLPI,
                (uint8_t*)&spistrLen);

    spistrLen = endian::from_network(spistrLen);
    pos += slp::request::SIZE_SLPI;

    req.body.srvrqst.spistr.insert(0, (const char*)buff.data() + pos,
                                   spistrLen);

    return slp::SUCCESS;
}
} // namespace internal

std::tuple<int, Message> parseBuffer(const buffer& buff)
{
    Message req;
    int rc = slp::SUCCESS;
    /* parse the header first */
    std::tie(rc, req) = internal::parseHeader(buff);
    if (!rc)
    {
        /* switch on the function id to parse the body */
        switch (req.header.functionID)
        {
            case (uint8_t)slp::FunctionType::SRVTYPERQST:
                rc = internal::parseSrvTypeRqst(buff, req);
                break;
            case (uint8_t)slp::FunctionType::SRVRQST:
                rc = internal::parseSrvRqst(buff, req);
                break;
            default:
                rc = (int)slp::Error::MSG_NOT_SUPPORTED;
        }
    }
    return std::make_tuple(rc, std::move(req));
}
} // namespace parser
} // namespace slp
