rodecomp/Source/Network/NIPAddr.cpp
ragnarok-clanker 55d37a7071 Maintenance: Forced resubmit of 17189, rebased on 7ea84b3b3 (main had added 25 more copies of the same lines, now converted too). Sha
Batch #17225 by ragnarok-clanker: forced by an admin (0 lower score(s), 1 changed function(s)); checked with 75 compiled unit(s), including every includer of Source/Utility/StdIntVectorCopy.h, Source/Utility/StdStringConcat.h, Source/Utility/StdStringCopy.h, Source/Utility/StdStringInsert.h, Source/Utility/StdStringMoveAssign.h, Source/Utility/StdStringVectorDestroy.h, Source/Utility/StdTraitsEqual.h, Source/Utility/StdTraitsFind.h, Source/Utility/StdWindowListEmplace.h.
2026-11-11 15:11:07 +00:00

60 lines
1.3 KiB
C++

#include <winsock2.h>
#include "Network/NIPAddr.h"
#include "Utility/StdStringCopy.h"
// INLINED
inline void NIPAddr::SetAddress(std::string text) {
this->address = inet_addr(text.c_str());
}
// OFFSET: 0x007349C0
// FUNCTION: fn_07599
NIPAddr::NIPAddr(std::string text) {
this->SetAddress(text);
}
// OFFSET: 0x00734BD0
// FUNCTION: fn_07601
NIPAddr::~NIPAddr() {
}
// OFFSET: 0x00734CE0
// FUNCTION: fn_07603
bool NIPAddr::IsPrivateAddress(std::uint32_t address) {
const std::uint32_t swapped = MAKELONG(MAKEWORD(HIBYTE(HIWORD(address)), LOBYTE(HIWORD(address))), MAKEWORD(HIBYTE(LOWORD(address)), LOBYTE(LOWORD(address))));
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;
}