#include "util.hpp"

#include <arpa/inet.h>
#include <netinet/in.h>

#include <cstddef>
#include <xyz/openbmc_project/Common/error.hpp>

#include <gtest/gtest.h>

namespace phosphor
{
namespace network
{

using InternalFailure =
    sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
class TestUtil : public testing::Test
{
  public:
    TestUtil()
    {
        // Empty
    }
};

TEST_F(TestUtil, ToHex)
{
    EXPECT_EQ('E', mac_address::internal::toHex(std::byte(0xfe)));
    EXPECT_EQ('A', mac_address::internal::toHex(std::byte(10)));
    EXPECT_EQ('4', mac_address::internal::toHex(std::byte(4)));
}

TEST_F(TestUtil, MacFromBuf)
{
    std::string tooSmall(1, 'a');
    std::string tooLarge(24, 'a');
    std::string buf{'\x00', '\xde', '\xad', '\x00', '\xbe', '\xef'};

    MacAddr mac = mac_address::fromBuf(buf);
    EXPECT_EQ(0, memcmp(buf.data(), mac.data(), buf.size()));

    EXPECT_THROW(mac_address::fromBuf(tooSmall), std::runtime_error);
    EXPECT_THROW(mac_address::fromBuf(tooLarge), std::runtime_error);
}

TEST_F(TestUtil, MacToString)
{
    MacAddr mac1{
        std::byte(0x00), std::byte(0xDE), std::byte(0xAD),
        std::byte(0x00), std::byte(0xBE), std::byte(0xEF),
    };
    EXPECT_EQ("00:DE:AD:00:BE:EF", mac_address::toString(mac1));
    MacAddr mac2{
        std::byte(0x70), std::byte(0xFF), std::byte(0x84),
        std::byte(0x09), std::byte(0x35), std::byte(0x09),
    };
    EXPECT_EQ("70:FF:84:09:35:09", mac_address::toString(mac2));
}

TEST_F(TestUtil, AddrFromBuf)
{
    std::string tooSmall(1, 'a');
    std::string tooLarge(24, 'a');

    struct in_addr ip1;
    EXPECT_EQ(1, inet_pton(AF_INET, "192.168.10.1", &ip1));
    std::string_view buf1(reinterpret_cast<char*>(&ip1), sizeof(ip1));
    InAddrAny res1 = addrFromBuf(AF_INET, buf1);
    EXPECT_EQ(0, memcmp(&ip1, &std::get<struct in_addr>(res1), sizeof(ip1)));
    EXPECT_THROW(addrFromBuf(AF_INET, tooSmall), std::runtime_error);
    EXPECT_THROW(addrFromBuf(AF_INET, tooLarge), std::runtime_error);
    EXPECT_THROW(addrFromBuf(AF_UNSPEC, buf1), std::runtime_error);

    struct in6_addr ip2;
    EXPECT_EQ(1, inet_pton(AF_INET6, "fdd8:b5ad:9d93:94ee::2:1", &ip2));
    std::string_view buf2(reinterpret_cast<char*>(&ip2), sizeof(ip2));
    InAddrAny res2 = addrFromBuf(AF_INET6, buf2);
    EXPECT_EQ(0, memcmp(&ip2, &std::get<struct in6_addr>(res2), sizeof(ip2)));
    EXPECT_THROW(addrFromBuf(AF_INET6, tooSmall), std::runtime_error);
    EXPECT_THROW(addrFromBuf(AF_INET6, tooLarge), std::runtime_error);
    EXPECT_THROW(addrFromBuf(AF_UNSPEC, buf2), std::runtime_error);
}

TEST_F(TestUtil, IpToString)
{
    struct in_addr ip1;
    EXPECT_EQ(1, inet_pton(AF_INET, "192.168.10.1", &ip1));
    EXPECT_EQ("192.168.10.1", toString(InAddrAny(ip1)));

    struct in6_addr ip2;
    EXPECT_EQ(1, inet_pton(AF_INET6, "fdd8:b5ad:9d93:94ee::2:1", &ip2));
    EXPECT_EQ("fdd8:b5ad:9d93:94ee::2:1", toString(InAddrAny(ip2)));

    InAddrAny ip3;
    try
    {
        struct E
        {
            operator struct in6_addr()
            {
                throw 1;
            }
        };
        ip3.emplace<struct in6_addr>(E());
        EXPECT_TRUE(false);
    }
    catch (...)
    {
    }
    EXPECT_THROW(toString(ip3), std::runtime_error);
}

TEST_F(TestUtil, IpValidation)
{
    std::string ipaddress = "0.0.0.0";
    EXPECT_EQ(true, isValidIP(AF_INET, ipaddress));

    ipaddress = "9.3.185.83";
    EXPECT_EQ(true, isValidIP(AF_INET, ipaddress));

    ipaddress = "9.3.185.a";
    EXPECT_EQ(false, isValidIP(AF_INET, ipaddress));

    ipaddress = "9.3.a.83";
    EXPECT_EQ(false, isValidIP(AF_INET, ipaddress));

    ipaddress = "x.x.x.x";
    EXPECT_EQ(false, isValidIP(AF_INET, ipaddress));

    ipaddress = "0:0:0:0:0:0:0:0";
    EXPECT_EQ(true, isValidIP(AF_INET6, ipaddress));

    ipaddress = "1:0:0:0:0:0:0:8";
    EXPECT_EQ(true, isValidIP(AF_INET6, ipaddress));

    ipaddress = "1::8";
    EXPECT_EQ(true, isValidIP(AF_INET6, ipaddress));

    ipaddress = "0:0:0:0:0:FFFF:204.152.189.116";
    EXPECT_EQ(true, isValidIP(AF_INET6, ipaddress));

    ipaddress = "::ffff:204.152.189.116";
    EXPECT_EQ(true, isValidIP(AF_INET6, ipaddress));

    ipaddress = "a:0:0:0:0:FFFF:204.152.189.116";
    EXPECT_EQ(true, isValidIP(AF_INET6, ipaddress));

    ipaddress = "1::8";
    EXPECT_EQ(true, isValidIP(AF_INET6, ipaddress));
}

TEST_F(TestUtil, PrefixValidation)
{
    uint8_t prefixLength = 1;
    EXPECT_EQ(true, isValidPrefix(AF_INET, prefixLength));

    prefixLength = 32;
    EXPECT_EQ(true, isValidPrefix(AF_INET, prefixLength));

    prefixLength = 0;
    EXPECT_EQ(false, isValidPrefix(AF_INET, prefixLength));

    prefixLength = 33;
    EXPECT_EQ(false, isValidPrefix(AF_INET, prefixLength));

    prefixLength = 33;
    EXPECT_EQ(true, isValidPrefix(AF_INET6, prefixLength));

    prefixLength = 65;
    EXPECT_EQ(false, isValidPrefix(AF_INET, prefixLength));
}

TEST_F(TestUtil, MacValidation)
{
    std::string macaddress = "00:00:00:00:00:00";
    EXPECT_EQ(false, phosphor::network::mac_address::validate(macaddress));

    macaddress = "F6:C6:E6:6:B0:D3";
    EXPECT_EQ(true, phosphor::network::mac_address::validate(macaddress));

    macaddress = "F6:C6:E6:06:B0:D3";
    EXPECT_EQ(true, phosphor::network::mac_address::validate(macaddress));

    macaddress = "hh:HH:HH:hh:HH:yy";
    EXPECT_EQ(false, phosphor::network::mac_address::validate(macaddress));

    macaddress = "hhh:GGG:iii:jjj:kkk:lll";
    EXPECT_EQ(false, phosphor::network::mac_address::validate(macaddress));
}

TEST_F(TestUtil, ConvertV4MasktoPrefix)
{
    std::string mask = "255.255.255.0";
    uint8_t prefix = toCidr(AF_INET, mask);
    EXPECT_EQ(prefix, 24);

    mask = "255.255.0.0";
    prefix = toCidr(AF_INET, mask);
    EXPECT_EQ(prefix, 16);

    mask = "255.0.0.0";
    prefix = toCidr(AF_INET, mask);
    EXPECT_EQ(prefix, 8);

    mask = "255.224.0.0";
    prefix = toCidr(AF_INET, mask);
    EXPECT_EQ(prefix, 11);

    // Invalid Mask
    mask = "255.0.255.0";
    prefix = toCidr(AF_INET, mask);
    EXPECT_EQ(prefix, 0);
}

TEST_F(TestUtil, convertV6MasktoPrefix)
{
    std::string mask = "ffff:ffff::";
    uint8_t prefix = toCidr(AF_INET6, mask);
    EXPECT_EQ(prefix, 32);

    mask = "ffff:ffff:ffff::";
    prefix = toCidr(AF_INET6, mask);
    EXPECT_EQ(prefix, 48);

    mask = "ffff:ffff:fc00::";
    prefix = toCidr(AF_INET6, mask);
    EXPECT_EQ(prefix, 38);

    // Invalid Mask
    mask = "ffff:0fff::";
    prefix = toCidr(AF_INET6, mask);
    EXPECT_EQ(prefix, 0);
}

TEST_F(TestUtil, isLinkLocaladdress)
{
    std::string ipaddress = "fe80:fec0::";
    EXPECT_TRUE(isLinkLocalIP(ipaddress));

    ipaddress = "2000:fe80:789::";
    EXPECT_FALSE(isLinkLocalIP(ipaddress));

    ipaddress = "2000:fe80::";
    EXPECT_FALSE(isLinkLocalIP(ipaddress));

    ipaddress = "169.254.3.3";
    EXPECT_TRUE(isLinkLocalIP(ipaddress));

    ipaddress = "3.169.254.3";
    EXPECT_FALSE(isLinkLocalIP(ipaddress));

    ipaddress = "3.3.169.254";
    EXPECT_FALSE(isLinkLocalIP(ipaddress));
}

TEST_F(TestUtil, convertPrefixToMask)
{
    std::string mask = toMask(AF_INET, 24);
    EXPECT_EQ(mask, "255.255.255.0");

    mask = toMask(AF_INET, 8);
    EXPECT_EQ(mask, "255.0.0.0");

    mask = toMask(AF_INET, 27);
    EXPECT_EQ(mask, "255.255.255.224");
}

TEST_F(TestUtil, getNetworkAddress)
{
    std::string address = getNetworkID(AF_INET, "9.3.23.251", 24);
    EXPECT_EQ("9.3.23.0", address);

    address = getNetworkID(AF_INET, "9.3.23.251", 25);
    EXPECT_EQ("9.3.23.128", address);

    address = getNetworkID(AF_INET6, "2001:db8:abcd:dd12::0", 64);
    EXPECT_EQ("2001:db8:abcd:dd12::", address);

    EXPECT_THROW(getNetworkID(AF_INET, "a.b.c.d", 25), InternalFailure);

    EXPECT_THROW(getNetworkID(AF_INET6, "2001:db8:gghh:dd12::0", 64),
                 InternalFailure);

    address = getNetworkID(AF_INET6, "fe80::201:6cff:fe80:228", 64);
    EXPECT_EQ("fe80::", address);
}

} // namespace network
} // namespace phosphor
