X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/9763940f8849e5c807566157829a1e6d2c9172ee..4e72d8df4cde72eb1e62da6e0331af4b7f3e4c6a:/binipstuff.pas?ds=inline

diff --git a/binipstuff.pas b/binipstuff.pas
index d622029..489c2a2 100644
--- a/binipstuff.pas
+++ b/binipstuff.pas
@@ -166,6 +166,10 @@ function inaddrvtobinip(inaddrv:tinetsockaddrv):tbinip;
 function makeinaddrv(addr:tbinip;port:ansistring;var inaddr:tinetsockaddrv):integer;
 function inaddrsize(inaddr:tinetsockaddrv):integer;
 
+function getbinipbitlength(const ip:tbinip):integer;
+function getipstrbitlength(const ip:thostname):integer;
+function getfamilybitlength(family:integer):integer;
+
 implementation
 
 uses sysutils;
@@ -555,8 +559,8 @@ begin
   {$ifdef ipv6}
     if ip.family = AF_INET then begin
       ip.family := AF_INET6;
-      ip.ip6.s6_addr32[3] := ip.ip; 
-      ip.ip6.u6_addr32[0] := 0; 
+      ip.ip6.s6_addr32[3] := ip.ip;
+      ip.ip6.u6_addr32[0] := 0;
       ip.ip6.u6_addr32[1] := 0;
       ip.ip6.u6_addr16[4] := 0;
       ip.ip6.u6_addr16[5] := $ffff;
@@ -660,5 +664,26 @@ begin
   end;
 end;
 
+function getfamilybitlength(family:integer):integer;
+begin
+  {$ifdef ipv6}
+  if family = AF_INET6 then result := 128 else
+  {$endif}
+  if family = AF_INET then result := 32
+  else result := 0;
+end;
+
+function getbinipbitlength(const ip:tbinip):integer;
+begin
+  result := getfamilybitlength(ip.family);
+end;
+
+function getipstrbitlength(const ip:thostname):integer;
+var
+  biniptemp:tbinip;
+begin
+  ipstrtobin(ip,biniptemp);
+  result := getbinipbitlength(biniptemp);
+end;
 
 end.