test_irda_sendZeroByte
Wolfgang Schwotzer
wolfgang.schwotzer at gmx.net
Sun Sep 5 14:24:21 CDT 2010
---
dlls/ws2_32/tests/sock.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 133 insertions(+), 0 deletions(-)
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index e61d550..17dc65e 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -25,6 +25,7 @@
#include <windows.h>
#include <ws2tcpip.h>
#include <mswsock.h>
+#include <af_irda.h>
#include <stdio.h>
#include "wine/test.h"
@@ -44,6 +45,8 @@
#define SERVERIP "127.0.0.1" /* IP to bind to */
#define SERVERPORT 9374 /* Port number to bind to */
+#define IRDADEVICE_LIST_LEN 10 /* Max. number of detected IrDA devices */
+
#define wsa_ok(op, cond, msg) \
do { \
int tmp, err = 0; \
@@ -52,6 +55,27 @@
ok ( cond tmp, msg, GetCurrentThreadId(), err); \
} while (0);
+/* Common IrDA service names */
+const char *irdaServiceNames[] = {
+ "IrDA:IrCOMM",
+ "OBEX",
+ "IrLPT",
+ "OBEX:IrXfer",
+ "IrNetv1",
+ "IrModem",
+ "IrLMP",
+ "IrDA:TELECOM",
+ "IrLAN",
+ "IrTranPv1",
+ "IrCOMM:HotSync",
+ "JetSend",
+ "HRM",
+ "Nokia:PhoNet",
+ "Nokia:PhoNet_Games",
+ "Nokia:NBSrouter",
+ NULL
+};
+
/* Function pointers */
static void (WINAPI *pFreeAddrInfoW)(PADDRINFOW) = 0;
static int (WINAPI *pGetAddrInfoW)(LPCWSTR,LPCWSTR,const ADDRINFOW *,PADDRINFOW *) = 0;
@@ -4246,6 +4270,113 @@ static void test_getpeername(void)
closesocket(sock);
}
+void test_irda_sendZeroByte(void)
+{
+ SOCKET sock = INVALID_SOCKET;
+ int i, result;
+ DWORD err;
+ char name[32];
+ unsigned char deviceListBuff[
+ sizeof (DEVICELIST) -
+ sizeof (IRDA_DEVICE_INFO) +
+ (sizeof (IRDA_DEVICE_INFO) * IRDADEVICE_LIST_LEN)];
+ int deviceListLen;
+ PDEVICELIST pDeviceList;
+ SOCKADDR_IRDA destSockAddr = { AF_IRDA, { 0,0,0,0 }, "SampleIrDAService" };
+
+ pDeviceList = (PDEVICELIST) &deviceListBuff;
+
+ sock = socket ( AF_IRDA, SOCK_STREAM, 0 );
+ if (sock == INVALID_SOCKET)
+ {
+ err = WSAGetLastError();
+ skip ( "Error creating IrDA socket. Error: %d. Test aborted.\n", err );
+ goto abort;
+ }
+
+ deviceListLen = sizeof (deviceListBuff);
+ pDeviceList->numDevice = 0;
+
+ result = getsockopt( sock, SOL_IRLMP, IRLMP_ENUMDEVICES,
+ (char *)pDeviceList, &deviceListLen );
+
+ if (result == SOCKET_ERROR || ( pDeviceList->numDevice == 0 ))
+ {
+ err = WSAGetLastError();
+ skip ( "getsockopt, no IrDA device detected. Error: %d. Test aborted\n",
+ err );
+ goto abort;
+ }
+ closesocket( sock );
+ sock = INVALID_SOCKET;
+
+ for (i = 0; i < pDeviceList->numDevice; i++)
+ {
+ memset(name, 0, sizeof(name));
+ memcpy(name, &pDeviceList->Device[i].irdaDeviceName[0],
+ sizeof(pDeviceList->Device[i].irdaDeviceName));
+
+ trace( "Detected IrDA device id: 0x%02x%02x%02x%02x name: '%s'\n",
+ pDeviceList->Device[i].irdaDeviceID[0],
+ pDeviceList->Device[i].irdaDeviceID[1],
+ pDeviceList->Device[i].irdaDeviceID[2],
+ pDeviceList->Device[i].irdaDeviceID[3],
+ name );
+ memcpy(&destSockAddr.irdaDeviceID[0],
+ &pDeviceList->Device[i].irdaDeviceID[0],
+ sizeof(destSockAddr.irdaDeviceID));
+
+ /* We want to test any connected IrDA device and do not
+ know supported service names. So we iterate over a
+ list of common service names.
+ */
+ for (i = 1; irdaServiceNames[i] != NULL; i++)
+ {
+ strcpy(destSockAddr.irdaServiceName, irdaServiceNames[i]);
+
+ sock = socket ( AF_IRDA, SOCK_STREAM, 0 );
+ if (sock == INVALID_SOCKET)
+ {
+ err = WSAGetLastError();
+ skip ( "Error creating IrDA socket. Service %s. Error: %d.\n",
+ destSockAddr.irdaServiceName, err );
+ } else {
+ result = connect(sock, (const struct sockaddr *)&destSockAddr,
+ sizeof(SOCKADDR_IRDA));
+ if (result == SOCKET_ERROR)
+ {
+ /*err = WSAGetLastError();
+ skip ( "Service %s not available. Error: %d\n",
+ destSockAddr.irdaServiceName, err );*/
+ } else {
+
+ todo_wine
+ {
+ char buffer[1] = { 0x00 };
+ int size = 0;
+
+ /* Now try to send a zero byte buffer over the
+ IrDA stack */
+ result = send(sock, &buffer[0], size, 0);
+ err = WSAGetLastError();
+ ok (result == size && (err == 0),
+ "Sending %d bytes on IrDA device. Service %s. "
+ "Expected: %d, got: %d\n",
+ size, destSockAddr.irdaServiceName, 0, err );
+ }
+ }
+ closesocket( sock );
+ sock = INVALID_SOCKET;
+ }
+ }
+ }
+ return;
+
+abort:
+ if ( sock != INVALID_SOCKET )
+ closesocket( sock );
+}
+
/**************** Main program ***************/
START_TEST( sock )
@@ -4303,6 +4434,8 @@ START_TEST( sock )
test_AcceptEx();
test_ConnectEx();
+ test_irda_sendZeroByte();
+
/* this is a io heavy test, do it at the end so the kernel doesn't start dropping packets */
test_send();
--
1.7.0.4
--------------020409090906000906020209--
More information about the wine-patches
mailing list