mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-29 05:27:28 +01:00
* Add NetAddrIsPrivate function from Ondrej Pokorny
This commit is contained in:
parent
f43912a383
commit
00e3cdddce
@ -750,3 +750,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function NetAddrIsPrivate(const IP: in_addr): Boolean;
|
||||||
|
begin
|
||||||
|
NetAddrIsPrivate:=
|
||||||
|
// 10.0.0.0 – 10.255.255.255
|
||||||
|
(IP.s_bytes[1]=10)
|
||||||
|
// 172.16.0.0 – 172.31.255.255
|
||||||
|
or ((IP.s_bytes[1]=172) and (IP.s_bytes[2]>=16) and (IP.s_bytes[2]<=31))
|
||||||
|
// 192.168.0.0 – 192.168.255.255
|
||||||
|
or ((IP.s_bytes[1]=192) and (IP.s_bytes[2]=168));
|
||||||
|
end;
|
||||||
|
|||||||
@ -203,6 +203,9 @@ Function NetToHost (Net : Longint) : Longint; deprecated;
|
|||||||
Function ShortHostToNet(Host : Word) : Word; deprecated;
|
Function ShortHostToNet(Host : Word) : Word; deprecated;
|
||||||
Function ShortNetToHost(Net : Word) : Word; deprecated;
|
Function ShortNetToHost(Net : Word) : Word; deprecated;
|
||||||
|
|
||||||
|
function NetAddrIsPrivate(const IP: in_addr): Boolean;
|
||||||
|
|
||||||
|
|
||||||
// ipv6
|
// ipv6
|
||||||
function HostAddrToStr6(Entry : Tin6_addr) : AnsiString;
|
function HostAddrToStr6(Entry : Tin6_addr) : AnsiString;
|
||||||
function StrToHostAddr6(IP : AnsiString) : Tin6_addr; // not implemented?!?
|
function StrToHostAddr6(IP : AnsiString) : Tin6_addr; // not implemented?!?
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user