X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/f04d9ac0ffbe96ead372b84dad0786daba7f5ed7..85ef2ce64f0cc31a063fccea69fdcc7281d51548:/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--------------------------------------------------}