util: Remove unused isValidIP
Change-Id: Iea90c03f8d13cde03c1ffbab9108879f12d17224
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/util.cpp b/src/util.cpp
index 1feab81..03d7398 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -5,7 +5,6 @@
#include "config_parser.hpp"
#include "types.hpp"
-#include <arpa/inet.h>
#include <fmt/compile.h>
#include <fmt/format.h>
#include <sys/wait.h>
@@ -158,17 +157,6 @@
[=]<int f>() -> InAddrAny { return addrFromBuf<f>(buf); }, family);
}
-bool isValidIP(int family, stdplus::const_zstring address) noexcept
-{
- unsigned char buf[sizeof(struct in6_addr)];
- return inet_pton(family, address.c_str(), buf) > 0;
-}
-
-bool isValidIP(stdplus::const_zstring address) noexcept
-{
- return isValidIP(AF_INET, address) || isValidIP(AF_INET6, address);
-}
-
void deleteInterface(stdplus::const_zstring intf)
{
pid_t pid = fork();
diff --git a/src/util.hpp b/src/util.hpp
index 47351a5..93b2925 100644
--- a/src/util.hpp
+++ b/src/util.hpp
@@ -82,14 +82,6 @@
typename FamilyTraits<family>::addr addrFromBuf(std::string_view buf);
InAddrAny addrFromBuf(int family, std::string_view buf);
-/* @brief checks that the given ip address valid or not.
- * @param[in] family - IP address family(AF_INET/AF_INET6).
- * @param[in] address - IP address.
- * @returns true if it is valid otherwise false.
- */
-bool isValidIP(int family, stdplus::const_zstring address) noexcept;
-bool isValidIP(stdplus::const_zstring address) noexcept;
-
/** @brief Delete the given interface.
* @param[in] intf - interface name.
*/
diff --git a/test/test_util.cpp b/test/test_util.cpp
index 84d6f1b..3978b1e 100644
--- a/test/test_util.cpp
+++ b/test/test_util.cpp
@@ -56,36 +56,6 @@
EXPECT_THROW(addrFromBuf(AF_UNSPEC, buf2), std::invalid_argument);
}
-TEST_F(TestUtil, IpValidation)
-{
- EXPECT_TRUE(isValidIP(AF_INET, "0.0.0.0"));
- EXPECT_TRUE(isValidIP("0.0.0.0"));
-
- EXPECT_TRUE(isValidIP(AF_INET, "9.3.185.83"));
-
- EXPECT_FALSE(isValidIP(AF_INET, "9.3.185.a"));
- EXPECT_FALSE(isValidIP("9.3.185.a"));
-
- EXPECT_FALSE(isValidIP(AF_INET, "9.3.a.83"));
-
- EXPECT_FALSE(isValidIP(AF_INET, "x.x.x.x"));
-
- EXPECT_TRUE(isValidIP(AF_INET6, "0:0:0:0:0:0:0:0"));
- EXPECT_TRUE(isValidIP("0:0:0:0:0:0:0:0"));
-
- EXPECT_TRUE(isValidIP(AF_INET6, "1:0:0:0:0:0:0:8"));
-
- EXPECT_TRUE(isValidIP(AF_INET6, "1::8"));
-
- EXPECT_TRUE(isValidIP(AF_INET6, "0:0:0:0:0:FFFF:204.152.189.116"));
-
- EXPECT_TRUE(isValidIP(AF_INET6, "::ffff:204.152.189.116"));
-
- EXPECT_TRUE(isValidIP(AF_INET6, "a:0:0:0:0:FFFF:204.152.189.116"));
-
- EXPECT_TRUE(isValidIP(AF_INET6, "1::8"));
-}
-
TEST_F(TestUtil, InterfaceToUbootEthAddr)
{
EXPECT_EQ(std::nullopt, interfaceToUbootEthAddr("et"));