wsdapi/tests: Add initial test for receiving probe messages.
[wine.git] / dlls / dpwsockx / dpwsockx_main.c
blob9606d73df76aee94d092df6f25d8fe1aa3c49871
1 /* Internet TCP/IP and IPX Connection For DirectPlay
3 * Copyright 2008 Ismael Barros Barros
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "config.h"
22 #include <stdarg.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winsock2.h"
27 #include "dpwsockx_dll.h"
28 #include "wine/debug.h"
29 #include "dplay.h"
30 #include "wine/dplaysp.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(dplay);
35 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
37 TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
39 switch (fdwReason)
41 case DLL_WINE_PREATTACH:
42 return FALSE; /* prefer native version */
43 case DLL_PROCESS_ATTACH:
44 /* TODO: Initialization */
45 DisableThreadLibraryCalls(hinstDLL);
46 break;
49 return TRUE;
53 static HRESULT WINAPI DPWSCB_EnumSessions( LPDPSP_ENUMSESSIONSDATA data )
55 FIXME( "(%p,%d,%p,%u) stub\n",
56 data->lpMessage, data->dwMessageSize,
57 data->lpISP, data->bReturnStatus );
58 return DPERR_UNSUPPORTED;
61 static HRESULT WINAPI DPWSCB_Reply( LPDPSP_REPLYDATA data )
63 FIXME( "(%p,%p,%d,%d,%p) stub\n",
64 data->lpSPMessageHeader, data->lpMessage, data->dwMessageSize,
65 data->idNameServer, data->lpISP );
66 return DPERR_UNSUPPORTED;
69 static HRESULT WINAPI DPWSCB_Send( LPDPSP_SENDDATA data )
71 FIXME( "(0x%08x,%d,%d,%p,%d,%u,%p) stub\n",
72 data->dwFlags, data->idPlayerTo, data->idPlayerFrom,
73 data->lpMessage, data->dwMessageSize,
74 data->bSystemMessage, data->lpISP );
75 return DPERR_UNSUPPORTED;
78 static HRESULT WINAPI DPWSCB_CreatePlayer( LPDPSP_CREATEPLAYERDATA data )
80 FIXME( "(%d,0x%08x,%p,%p) stub\n",
81 data->idPlayer, data->dwFlags,
82 data->lpSPMessageHeader, data->lpISP );
83 return DPERR_UNSUPPORTED;
86 static HRESULT WINAPI DPWSCB_DeletePlayer( LPDPSP_DELETEPLAYERDATA data )
88 FIXME( "(%d,0x%08x,%p) stub\n",
89 data->idPlayer, data->dwFlags, data->lpISP );
90 return DPERR_UNSUPPORTED;
93 static HRESULT WINAPI DPWSCB_GetAddress( LPDPSP_GETADDRESSDATA data )
95 FIXME( "(%d,0x%08x,%p,%p,%p) stub\n",
96 data->idPlayer, data->dwFlags, data->lpAddress,
97 data->lpdwAddressSize, data->lpISP );
98 return DPERR_UNSUPPORTED;
101 static HRESULT WINAPI DPWSCB_GetCaps( LPDPSP_GETCAPSDATA data )
103 TRACE( "(%d,%p,0x%08x,%p)\n",
104 data->idPlayer, data->lpCaps, data->dwFlags, data->lpISP );
106 data->lpCaps->dwFlags = ( DPCAPS_ASYNCSUPPORTED |
107 DPCAPS_GUARANTEEDOPTIMIZED |
108 DPCAPS_GUARANTEEDSUPPORTED );
110 data->lpCaps->dwMaxQueueSize = DPWS_MAXQUEUESIZE;
111 data->lpCaps->dwHundredBaud = DPWS_HUNDREDBAUD;
112 data->lpCaps->dwLatency = DPWS_LATENCY;
113 data->lpCaps->dwMaxLocalPlayers = DPWS_MAXLOCALPLAYERS;
114 data->lpCaps->dwHeaderLength = sizeof(DPSP_MSG_HEADER);
115 data->lpCaps->dwTimeout = DPWS_TIMEOUT;
117 if ( data->dwFlags & DPGETCAPS_GUARANTEED )
119 data->lpCaps->dwMaxBufferSize = DPWS_GUARANTEED_MAXBUFFERSIZE;
120 data->lpCaps->dwMaxPlayers = DPWS_GUARANTEED_MAXPLAYERS;
122 else
124 data->lpCaps->dwMaxBufferSize = DPWS_MAXBUFFERSIZE;
125 data->lpCaps->dwMaxPlayers = DPWS_MAXPLAYERS;
128 return DP_OK;
131 static HRESULT WINAPI DPWSCB_Open( LPDPSP_OPENDATA data )
133 FIXME( "(%u,%p,%p,%u,0x%08x,0x%08x) stub\n",
134 data->bCreate, data->lpSPMessageHeader, data->lpISP,
135 data->bReturnStatus, data->dwOpenFlags, data->dwSessionFlags );
136 return DPERR_UNSUPPORTED;
139 static HRESULT WINAPI DPWSCB_CloseEx( LPDPSP_CLOSEDATA data )
141 FIXME( "(%p) stub\n", data->lpISP );
142 return DPERR_UNSUPPORTED;
145 static HRESULT WINAPI DPWSCB_ShutdownEx( LPDPSP_SHUTDOWNDATA data )
147 FIXME( "(%p) stub\n", data->lpISP );
148 return DPERR_UNSUPPORTED;
151 static HRESULT WINAPI DPWSCB_GetAddressChoices( LPDPSP_GETADDRESSCHOICESDATA data )
153 FIXME( "(%p,%p,%p) stub\n",
154 data->lpAddress, data->lpdwAddressSize, data->lpISP );
155 return DPERR_UNSUPPORTED;
158 static HRESULT WINAPI DPWSCB_SendEx( LPDPSP_SENDEXDATA data )
160 FIXME( "(%p,0x%08x,%d,%d,%p,%d,%d,%d,%d,%p,%p,%u) stub\n",
161 data->lpISP, data->dwFlags, data->idPlayerTo, data->idPlayerFrom,
162 data->lpSendBuffers, data->cBuffers, data->dwMessageSize,
163 data->dwPriority, data->dwTimeout, data->lpDPContext,
164 data->lpdwSPMsgID, data->bSystemMessage );
165 return DPERR_UNSUPPORTED;
168 static HRESULT WINAPI DPWSCB_SendToGroupEx( LPDPSP_SENDTOGROUPEXDATA data )
170 FIXME( "(%p,0x%08x,%d,%d,%p,%d,%d,%d,%d,%p,%p) stub\n",
171 data->lpISP, data->dwFlags, data->idGroupTo, data->idPlayerFrom,
172 data->lpSendBuffers, data->cBuffers, data->dwMessageSize,
173 data->dwPriority, data->dwTimeout, data->lpDPContext,
174 data->lpdwSPMsgID );
175 return DPERR_UNSUPPORTED;
178 static HRESULT WINAPI DPWSCB_Cancel( LPDPSP_CANCELDATA data )
180 FIXME( "(%p,0x%08x,%p,%d,0x%08x,0x%08x) stub\n",
181 data->lpISP, data->dwFlags, data->lprglpvSPMsgID, data->cSPMsgID,
182 data->dwMinPriority, data->dwMaxPriority );
183 return DPERR_UNSUPPORTED;
186 static HRESULT WINAPI DPWSCB_GetMessageQueue( LPDPSP_GETMESSAGEQUEUEDATA data )
188 FIXME( "(%p,0x%08x,%d,%d,%p,%p) stub\n",
189 data->lpISP, data->dwFlags, data->idFrom, data->idTo,
190 data->lpdwNumMsgs, data->lpdwNumBytes );
191 return DPERR_UNSUPPORTED;
194 static void setup_callbacks( LPDPSP_SPCALLBACKS lpCB )
196 lpCB->EnumSessions = DPWSCB_EnumSessions;
197 lpCB->Reply = DPWSCB_Reply;
198 lpCB->Send = DPWSCB_Send;
199 lpCB->CreatePlayer = DPWSCB_CreatePlayer;
200 lpCB->DeletePlayer = DPWSCB_DeletePlayer;
201 lpCB->GetAddress = DPWSCB_GetAddress;
202 lpCB->GetCaps = DPWSCB_GetCaps;
203 lpCB->Open = DPWSCB_Open;
204 lpCB->CloseEx = DPWSCB_CloseEx;
205 lpCB->ShutdownEx = DPWSCB_ShutdownEx;
206 lpCB->GetAddressChoices = DPWSCB_GetAddressChoices;
207 lpCB->SendEx = DPWSCB_SendEx;
208 lpCB->SendToGroupEx = DPWSCB_SendToGroupEx;
209 lpCB->Cancel = DPWSCB_Cancel;
210 lpCB->GetMessageQueue = DPWSCB_GetMessageQueue;
212 lpCB->AddPlayerToGroup = NULL;
213 lpCB->Close = NULL;
214 lpCB->CreateGroup = NULL;
215 lpCB->DeleteGroup = NULL;
216 lpCB->RemovePlayerFromGroup = NULL;
217 lpCB->SendToGroup = NULL;
218 lpCB->Shutdown = NULL;
223 /******************************************************************
224 * SPInit (DPWSOCKX.1)
226 HRESULT WINAPI SPInit( LPSPINITDATA lpspData )
228 WSADATA wsaData;
229 DPWS_DATA dpwsData;
231 TRACE( "Initializing library for %s (%s)\n",
232 wine_dbgstr_guid(lpspData->lpGuid), debugstr_w(lpspData->lpszName) );
234 /* We only support TCP/IP service */
235 if ( !IsEqualGUID(lpspData->lpGuid, &DPSPGUID_TCPIP) )
237 return DPERR_UNAVAILABLE;
240 /* Assign callback functions */
241 setup_callbacks( lpspData->lpCB );
243 /* Load Winsock 2.0 DLL */
244 if ( WSAStartup( MAKEWORD(2, 0), &wsaData ) != 0 )
246 ERR( "WSAStartup() failed\n" );
247 return DPERR_UNAVAILABLE;
250 /* Initialize internal data */
251 memset( &dpwsData, 0, sizeof(DPWS_DATA) );
252 dpwsData.lpISP = lpspData->lpISP;
253 IDirectPlaySP_SetSPData( lpspData->lpISP, &dpwsData, sizeof(DPWS_DATA),
254 DPSET_LOCAL );
256 /* dplay needs to know the size of the header */
257 lpspData->dwSPHeaderSize = sizeof(DPSP_MSG_HEADER);
259 return DP_OK;