{$include lcoreconfig.inc}\r
\r
uses\r
-{$ifndef win32}\r
+{$ifndef mswindows}\r
sockets,\r
{$endif}\r
pgtypes;\r
\r
-{$ifdef cpu386}{$define i386}{$endif}\r
-{$ifdef i386}{$define ENDIAN_LITTLE}{$endif}\r
+\r
+{$include pgtypes.inc}\r
\r
{$include uint32.inc}\r
\r
const\r
hexchars:array[0..15] of ansichar='0123456789abcdef';\r
- {$ifdef win32}\r
+ {$ifdef mswindows}\r
AF_INET=2;\r
AF_INET6=23;\r
{$else}\r
type\r
{$ifdef ipv6}\r
\r
- {$ifdef win32}\r
+ {$ifdef mswindows}\r
{$define want_Tin6_addr}\r
{$endif}\r
{$ifdef ver1_0}\r
{$endif}\r
end;\r
\r
- {$ifdef win32}\r
+ {$ifdef mswindows}\r
TInetSockAddr = packed Record\r
family:Word;\r
port :Word;\r
function makeinaddrv(addr:tbinip;port:ansistring;var inaddr:tinetsockaddrv):integer;\r
function inaddrsize(inaddr:tinetsockaddrv):integer;\r
\r
+function getbinipbitlength(const ip:tbinip):integer;\r
+function getipstrbitlength(const ip:thostname):integer;\r
+function getfamilybitlength(family:integer):integer;\r
+\r
implementation\r
\r
uses sysutils;\r
\r
- implementation does not depend on other ipv6 code such as the tin6_addr type,\r
the parameter can also be untyped.\r
-- it is host endian neutral - binary format is aways network order\r
+- it is host endian neutral - binary format is always network order\r
- it supports compression of zeroes\r
- it supports ::ffff:192.168.12.34 style addresses\r
- they are made to do the Right Thing, more efficient implementations are possible\r
end;\r
end;\r
\r
- {run length atleast 2 0 words}\r
+ {run length at least 2 0 words}\r
if (runlength = 1) then begin\r
runlength := 0;\r
runbegin := 0;\r
{$ifdef ipv6}\r
if ip.family = AF_INET then begin\r
ip.family := AF_INET6;\r
- ip.ip6.s6_addr32[3] := ip.ip; \r
- ip.ip6.u6_addr32[0] := 0; \r
+ ip.ip6.s6_addr32[3] := ip.ip;\r
+ ip.ip6.u6_addr32[0] := 0;\r
ip.ip6.u6_addr32[1] := 0;\r
ip.ip6.u6_addr16[4] := 0;\r
ip.ip6.u6_addr16[5] := $ffff;\r
end;\r
end;\r
\r
+function getfamilybitlength(family:integer):integer;\r
+begin\r
+ {$ifdef ipv6}\r
+ if family = AF_INET6 then result := 128 else\r
+ {$endif}\r
+ if family = AF_INET then result := 32\r
+ else result := 0;\r
+end;\r
+\r
+function getbinipbitlength(const ip:tbinip):integer;\r
+begin\r
+ result := getfamilybitlength(ip.family);\r
+end;\r
+\r
+function getipstrbitlength(const ip:thostname):integer;\r
+var\r
+ biniptemp:tbinip;\r
+begin\r
+ ipstrtobin(ip,biniptemp);\r
+ result := getbinipbitlength(biniptemp);\r
+end;\r
\r
end.\r