X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/d53fe26eaac895d1e7a0ba2b2b8965cf77932de8..f292b938e3856ed9fb8fb45bb96d72fab1ed494f:/binipstuff.pas diff --git a/binipstuff.pas b/binipstuff.pas index a1433fc..8411cd3 100755 --- a/binipstuff.pas +++ b/binipstuff.pas @@ -86,12 +86,18 @@ type - {$ifdef ipv6} + {$ifdef ipv6} {$ifdef ver1_0} cuint16=word; cuint32=dword; sa_family_t=word; - + TInetSockAddr6 = packed record + sin6_family: word; + sin6_port: word; + sin6_flowinfo: uint32; + sin6_addr: tin6_addr; + sin6_scope_id: uint32; + end; {$endif} {$endif} TinetSockAddrv = packed record @@ -146,6 +152,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,26 +508,41 @@ 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--------------------------------------------------} const biniplist_prefix='bipl'#0; - biniplist_prefixlen=length(biniplist_prefix); - + //fpc 1.0.x doesn't seem to like use of length function in a constant + //definition + //biniplist_prefixlen=length(biniplist_prefix); + biniplist_prefixlen=5; + function biniplist_new:tbiniplist; begin result := biniplist_prefix;