X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/d53fe26eaac895d1e7a0ba2b2b8965cf77932de8..7dc251cf8ed990dd285b5fa5818c3a247e07d95c:/binipstuff.pas

diff --git a/binipstuff.pas b/binipstuff.pas
index a1433fc..70ac401 100755
--- a/binipstuff.pas
+++ b/binipstuff.pas
@@ -146,6 +146,7 @@ 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;
@@ -501,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--------------------------------------------------}