CVS: winex/dlls/winsock socket.c,1.45,1.46

[email protected]
Newsgroups gmane.comp.emulators.winex.cvs
Message-ID <[email protected]>
Subject: winex/dlls/winsock socket.c,1.45,1.46Update of /var/lib/cvsd/cvsroot/winex/dlls/winsock
In directory agravaine:/tmp/cvs-serv13739/dlls/winsock

Modified Files:
	socket.c 
Log Message:

- refresh our iphlpapi from WineHQ's, updating the license accordingly
- implement SIO_ROUTING_INTERFACE_QUERY



Index: socket.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/winsock/socket.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- socket.c	28 Mar 2007 18:43:01 -0000	1.45
+++ socket.c	30 Mar 2007 20:11:23 -0000	1.46
@@ -2102,6 +2102,91 @@
             break;
          }
 
+         case SIO_ROUTING_INTERFACE_QUERY: {
+            SOCKADDR_IN *saddr,*daddr;
+            DWORD DestIF, Count;
+            PMIB_IPADDRTABLE pTable;
+            ULONG TableSize = 0;
+            BOOL Found = FALSE;
+
+            /* Check buffers are correct size; if not, return required size */
+            if ((cbInBuffer < sizeof (SOCKADDR_IN)) ||
+                !lpvInBuffer || ! lpbOutBuffer)
+            {
+               WSASetLastError (WSAEINVAL);
+               close (fd);
+               return SOCKET_ERROR;
+            }
+
+            if (cbOutBuffer < sizeof (SOCKADDR_IN))
+            {
+               WSASetLastError (WSAEFAULT);
+               if (lpcbBytesReturned)
+                  *lpcbBytesReturned = sizeof (SOCKADDR_IN);
+               close (fd);
+               return SOCKET_ERROR;
+            }
+
+            saddr = (SOCKADDR_IN *)lpvInBuffer;
+            daddr = (SOCKADDR_IN *)lpbOutBuffer;
+
+            if (GetBestInterface (saddr->sin_addr.S_un.S_addr,
+                                  &DestIF) != NO_ERROR)
+            {
+               WSASetLastError (WSAENETUNREACH);
+               close (fd);
+               return SOCKET_ERROR;
+            }
+
+            if (GetIpAddrTable (NULL, &TableSize, FALSE) !=
+		ERROR_INSUFFICIENT_BUFFER)
+            {
+               WSASetLastError (WSAENETUNREACH);
+               close (fd);
+               return SOCKET_ERROR;
+            }
+
+            pTable = (PMIB_IPADDRTABLE)HeapAlloc (GetProcessHeap (),
+                                                  HEAP_ZERO_MEMORY, TableSize);
+            if (!pTable)
+            {
+               WSASetLastError (WSAEFAULT);
+               close (fd);
+               return SOCKET_ERROR;
+            }
+
+            if (GetIpAddrTable (pTable, &TableSize, FALSE) != NO_ERROR)
+            {
+               WSASetLastError (WSAENETUNREACH);
+               close (fd);
+               HeapFree (GetProcessHeap (), 0, pTable);
+               return SOCKET_ERROR;
+            }
+
+            for (Count = 0; Count < pTable->dwNumEntries; Count++)
+            {
+               if (pTable->table[Count].dwIndex == DestIF)
+               {
+                  daddr->sin_family = AF_INET;
+                  daddr->sin_port = 0;
+                  daddr->sin_addr.S_un.S_addr = pTable->table[Count].dwAddr;
+                  Found = TRUE;
+                  break;
+               }
+            }
+
+            HeapFree (GetProcessHeap (), 0, pTable);
+
+            if (!Found)
+            {
+               WSASetLastError (WSAENETUNREACH);
+               close (fd);
+               return SOCKET_ERROR;
+            }
+
+            break;
+         }
+
          default:
          {
             WARN("\tunsupported WS_IOCTL cmd (%08lx)\n", dwIoControlCode);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.