X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/495c276d681a5b3f79d4b2af2ed36e8e5d9e993d..68ac8381cae336dda0cd718dd6fa43b677f5ef8d:/binipstuff.pas

diff --git a/binipstuff.pas b/binipstuff.pas
index 59d123b..70ac401 100755
--- a/binipstuff.pas
+++ b/binipstuff.pas
@@ -141,9 +141,12 @@ function comparebinip(const ip1,ip2:tbinip):boolean;
 procedure maskbits(var binip:tbinip;bits:integer);
 function comparebinipmask(ip1,ip2:tbinip;bits:integer):boolean;
 
+procedure addipsoffamily(var l:tbiniplist;const l2:tbiniplist;family:integer);
+
 {deprecated}
 function longip(s:string):longint;
 
+function needconverttov4(const ip:tbinip):boolean;
 procedure converttov4(var ip:tbinip);
 
 function inaddrvtobinip(inaddrv:tinetsockaddrv):tbinip;
@@ -499,18 +502,30 @@ begin
   result := comparebinip(ip1,ip2);
 end;
 
-{converts a binary IP to v4 if it is a v6 IP in the v4 range}
-procedure converttov4(var ip:tbinip);
+function needconverttov4(const ip:tbinip):boolean;
 begin
   {$ifdef ipv6}
   if ip.family = AF_INET6 then begin
     if (ip.ip6.u6_addr32[0] = 0) and (ip.ip6.u6_addr32[1] = 0) and
     (ip.ip6.u6_addr16[4] = 0) and (ip.ip6.u6_addr16[5] = $ffff) then begin
-      ip.family := AF_INET;
-      ip.ip := ip.ip6.s6_addr32[3];
+      result := true;
+      exit;
     end;
   end;
   {$endif}
+
+  result := false;
+end;
+
+{converts a binary IP to v4 if it is a v6 IP in the v4 range}
+procedure converttov4(var ip:tbinip);
+begin
+  {$ifdef ipv6}
+  if needconverttov4(ip) then begin
+    ip.family := AF_INET;
+    ip.ip := ip.ip6.s6_addr32[3];
+  end;
+  {$endif}
 end;
 
 {-----------biniplist stuff--------------------------------------------------}
@@ -565,7 +580,7 @@ end;
 
 procedure biniplist_addlist;
 begin
-  l := l + l2;
+  l := l + copy(l2,biniplist_prefixlen+1,maxlongint);
 end;
 
 function biniplist_tostr(const l:tbiniplist):string;
@@ -593,4 +608,16 @@ begin
   result := true;
 end;
 
+procedure addipsoffamily(var l:tbiniplist;const l2:tbiniplist;family:integer);
+var
+  a:integer;
+  biniptemp:tbinip;
+begin
+  for a := biniplist_getcount(l2)-1 downto 0 do begin
+    biniptemp := biniplist_get(l2,a);
+    if (biniptemp.family = family) then biniplist_add(l,biniptemp);
+  end;
+end;
+
+
 end.