From e99b978f195d345be4346fc8564e200714e96a77 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Mon, 26 Oct 2026 22:53:01 +0000 Subject: [PATCH] Decompile 3 functions in Source/Utility/NIPAddr.cpp, Source/Utility/NIPAddr.h Batch #853 by ragnarok-clanker: 0 byte-identical, 3 confirmed by peer review. - fn_07599 NIPAddr::NIPAddr: logic confirmed by peer review - fn_07601 NIPAddr::~NIPAddr: logic confirmed by peer review - fn_07603 NIPAddr::IsPrivateAddress: logic confirmed by peer review Reviewed-by: ragnarok-clanker Adds to the build: Source/Utility/NIPAddr.cpp --- Source/Utility/NIPAddr.cpp | 51 ++++++++++++++++++++++++++++++++++++++ Source/Utility/NIPAddr.h | 20 +++++++++++++++ compile.json | 1 + 3 files changed, 72 insertions(+) create mode 100644 Source/Utility/NIPAddr.cpp create mode 100644 Source/Utility/NIPAddr.h diff --git a/Source/Utility/NIPAddr.cpp b/Source/Utility/NIPAddr.cpp new file mode 100644 index 0000000..1c49b99 --- /dev/null +++ b/Source/Utility/NIPAddr.cpp @@ -0,0 +1,51 @@ +#include + +#include "Utility/NIPAddr.h" + +// FUNCTION: fn_07599 +NIPAddr::NIPAddr(std::string text) { + std::string copy(text); + this->address = inet_addr(copy.c_str()); +} + +// FUNCTION: fn_07601 +NIPAddr::~NIPAddr() { +} + +// FUNCTION: fn_07603 +bool NIPAddr::IsPrivateAddress(std::uint32_t address) { + const std::uint32_t swapped = (address >> 24) | ((address >> 8) & 0x0000FF00u) | ((address << 8) & 0x00FF0000u) | (address << 24); + std::uint32_t lower; + std::uint32_t upper; + { + NIPAddr first(std::string("10.0.0.0")); + lower = first.address; + } + { + NIPAddr last(std::string("10.255.255.255")); + upper = last.address; + } + if (swapped >= lower && swapped <= upper) { + return true; + } + { + NIPAddr first(std::string("172.16.0.0")); + lower = first.address; + } + { + NIPAddr last(std::string("172.31.255.255")); + upper = last.address; + } + if (swapped >= lower && swapped <= upper) { + return true; + } + { + NIPAddr first(std::string("192.168.0.0")); + lower = first.address; + } + { + NIPAddr last(std::string("192.168.255.255")); + upper = last.address; + } + return swapped >= lower && swapped <= upper; +} diff --git a/Source/Utility/NIPAddr.h b/Source/Utility/NIPAddr.h new file mode 100644 index 0000000..9cb2f80 --- /dev/null +++ b/Source/Utility/NIPAddr.h @@ -0,0 +1,20 @@ +#ifndef RAGNAROK_SOURCE_UTILITY_NIPADDR_H +#define RAGNAROK_SOURCE_UTILITY_NIPADDR_H + +#include +#include + +class NIPAddr { +public: + explicit NIPAddr(std::string text); + virtual ~NIPAddr(); + static bool IsPrivateAddress(std::uint32_t address); + + /* 0004 */ std::uint32_t address; +}; + +#if defined(_WIN32) && !defined(_WIN64) +static_assert(sizeof(NIPAddr) == 8); +#endif + +#endif diff --git a/compile.json b/compile.json index eb8a633..e4fb121 100644 --- a/compile.json +++ b/compile.json @@ -601,6 +601,7 @@ "Source/Utility/Math/ClientAngles.cpp": 0, "Source/Utility/Math/RadialGrid.cpp": 0, "Source/Utility/Math/RayTriangle.cpp": 0, + "Source/Utility/NIPAddr.cpp": 0, "Source/Utility/ProcessSecurity.cpp": 0, "Source/Utility/Text/Base64.cpp": 0, "Source/Utility/Text/FormatString.cpp": 0,