{$include lcoreconfig.inc}\r
\r
{$ifndef win32}\r
-{$ifdef ipv6}\r
uses sockets;\r
{$endif}\r
-{$endif}\r
\r
{$ifdef fpc}\r
{$mode delphi}\r
\r
const\r
hexchars:array[0..15] of char='0123456789abcdef';\r
- AF_INET=2;\r
{$ifdef win32}\r
+ AF_INET=2;\r
AF_INET6=23;\r
{$else}\r
- AF_INET6=10;\r
+ //redeclare these constants so units that use us can use them\r
+ //without using sockets directly\r
+ AF_INET=AF_INET;\r
+ AF_INET6=AF_INET6;\r
+ //AF_INET6=10;\r
{$endif}\r
\r
type\r
\r
function needconverttov4(const ip:tbinip):boolean;\r
procedure converttov4(var ip:tbinip);\r
+procedure converttov6(var ip:tbinip);\r
\r
function inaddrvtobinip(inaddrv:tinetsockaddrv):tbinip;\r
function makeinaddrv(addr:tbinip;port:string;var inaddr:tinetsockaddrv):integer;\r
{$endif}\r
end;\r
\r
+\r
+{converts a binary IP to v6 if it is a v4 IP}\r
+procedure converttov6(var ip:tbinip);\r
+begin\r
+ {$ifdef ipv6}\r
+ if ip.family = AF_INET then begin\r
+ ip.family := AF_INET6;\r
+ ip.ip6.s6_addr32[3] := ip.ip; \r
+ ip.ip6.u6_addr32[0] := 0; \r
+ ip.ip6.u6_addr32[1] := 0;\r
+ ip.ip6.u6_addr16[4] := 0;\r
+ ip.ip6.u6_addr16[5] := $ffff;\r
+ end;\r
+ {$endif}\r
+end;\r
+\r
+\r
{-----------biniplist stuff--------------------------------------------------}\r
\r
const\r