#include "types.hpp"
#include "utils.hpp"

#include <ipmid/api.hpp>

#include <regex>

namespace ipmi
{
namespace iei
{
namespace firmware_version
{

void registerIEIFirmwareVersionFunctions() __attribute__((constructor));

static constexpr auto versionInterface = "xyz.openbmc_project.Software.Version";

std::string getBMCVersionValue(ipmi::Context::ptr ctx,
                               const std::string& objPath,
                               const std::string& interface)
{
    std::string value{};
    auto cc = iei::getDbusProperty(ctx, objPath, interface, "Version", value);
    if (cc)
    {
        return "";
    }

    const std::regex patternId("v[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}");
    std::smatch result;
    if (!std::regex_search(value, result, patternId))
    {
        return "";
    }
    std::string versionStr = result[0];
    return versionStr.substr(1);
}

std::string getFWVersionValue(ipmi::Context::ptr ctx,
                              const std::string& objPath,
                              const std::string& interface)
{
    std::string value{};
    auto cc = iei::getDbusProperty(ctx, objPath, interface, "Version", value);
    if (cc)
    {
        return "";
    }
    return value;
}

enum FirmwareType : uint8_t
{
    BMC = 0x01,
    BIOS = 0x03,
};

RspType<std::string> ipmiIEIGetFWVersion(ipmi::Context::ptr ctx,
                                         uint8_t fwIndex,
                                         uint8_t /* devIndex */)
{
    std::string fwPath{};
    std::string value{};

    switch (fwIndex)
    {
        case BMC:
        {
            fwPath = "/xyz/openbmc_project/software/bmc_active";
            value = getBMCVersionValue(ctx, fwPath, versionInterface);
            break;
        }
        case BIOS:
        {
            fwPath = "/xyz/openbmc_project/software/bios_active";
            value = getFWVersionValue(ctx, fwPath, versionInterface);
            break;
        }
        default:
            return ipmi::responseParmOutOfRange();
    }

    return ipmi::responseSuccess(value);
}

void registerIEIFirmwareVersionFunctions()
{
    ipmi::registerHandler(prioOemBase, netFnIEI, cmdGetFWVersion,
                          ipmi::Privilege::User, ipmiIEIGetFWVersion);
}

} // namespace firmware_version
} // namespace iei
} // namespace ipmi
