 
 TYPEDEF: FIXED_INFO* PFIXED_INFO
 
+STRUCT: S_un_b
+    { s_b1 uchar }
+    { s_b2 uchar }
+    { s_b3 uchar }
+    { s_b4 uchar } ;
+    
+STRUCT: S_un_w
+    { s_w1 ushort }
+    { s_w2 ushort } ;
+
+UNION-STRUCT: IPAddr
+    { S_un_b S_un_b }
+    { S_un_w S_un_w }
+    { S_addr ulong } ;
+    
+UNION-STRUCT: S_un
+    { S_un_b S_un_b }
+    { S_un_w S_un_w }
+    { S_addr ulong } ;
+    
+STRUCT: IP_ADAPTER_INDEX_MAP
+    { Index ULONG }
+    { Name WCHAR[MAX_ADAPTER_NAME] } ;
+TYPEDEF: IP_ADAPTER_INDEX_MAP* PIP_ADAPTER_INDEX_MAP
+
+FUNCTION: DWORD IpReleaseAddress ( PIP_ADAPTER_INDEX_MAP AdapterInfo ) ;
+FUNCTION: DWORD IpRenewAddress ( PIP_ADAPTER_INDEX_MAP AdapterInfo ) ;
+
+
+FUNCTION: DWORD GetBestInterface (
+   IPAddr dwDestAddr,
+   PDWORD pdwBestIfIndex
+) ;
+
+FUNCTION: DWORD GetBestInterfaceEx (
+    sockaddr* pDestAddr,
+    PDWORD pdwBestIfIndex
+) ;
+
 FUNCTION: ULONG GetAdaptersAddresses (
     ULONG Family,
     ULONG Flags,

CONSTANT: MIB_IF_TYPE_SLIP 28
CONSTANT: MAX_DNS_SUFFIX_STRING_LENGTH 256 ! 246?
CONSTANT: MAX_DHCPV6_DUID_LENGTH 130


STRUCT: IP_ADDRESS_STRING
    { String char[16] } ;

            [ FirstUnicastAddress>> loop-list [ Address>> SOCKET_ADDRESS>sockaddr sockaddr>ip ] map ]
        } cleave>array
    ] interfaces-map ;

: get-best-interface ( inet -- interface )
    make-sockaddr 0 DWORD <ref>
    [ GetBestInterfaceEx win32-error=0/f ] keep DWORD deref ;
