1 /*
2 * Wireless LAN API (wlanapi.dll)
3 *
4 * Copyright 2009 Christoph von Wittich (Christoph@ApiViewer.de)
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21
22 /* INCLUDES ****************************************************************/
23 #define WIN32_NO_STATUS
24 #define _INC_WINDOWS
25 #define COM_NO_WINDOWS_H
26 #include <stdarg.h>
27 #include <windef.h>
28 #include <winbase.h>
29 #include <wlansvc_c.h>
30
31 #include <wine/debug.h>
32
33 WINE_DEFAULT_DEBUG_CHANNEL(wlanapi);
34
35 DWORD
WlanRpcStatusToWinError(RPC_STATUS Status)36 WlanRpcStatusToWinError(RPC_STATUS Status)
37 {
38 switch (Status)
39 {
40 case RPC_S_INVALID_BINDING:
41 case RPC_X_SS_IN_NULL_CONTEXT:
42 return ERROR_INVALID_HANDLE;
43
44 case RPC_X_ENUM_VALUE_OUT_OF_RANGE:
45 case RPC_X_BYTE_COUNT_TOO_SMALL:
46 return ERROR_INVALID_PARAMETER;
47
48 case RPC_X_NULL_REF_POINTER:
49 return ERROR_INVALID_ADDRESS;
50
51 default:
52 return (DWORD)Status;
53 }
54 }
55
56 handle_t __RPC_USER
WLANSVC_HANDLE_bind(WLANSVC_HANDLE szMachineName)57 WLANSVC_HANDLE_bind(WLANSVC_HANDLE szMachineName)
58 {
59 handle_t hBinding = NULL;
60 LPWSTR pszStringBinding;
61 RPC_STATUS Status;
62
63 TRACE("RPC_SERVICE_STATUS_HANDLE_bind() called\n");
64
65 Status = RpcStringBindingComposeW(NULL,
66 L"ncalrpc",
67 szMachineName,
68 L"wlansvc",
69 NULL,
70 &pszStringBinding);
71 if (Status != RPC_S_OK)
72 {
73 ERR("RpcStringBindingCompose returned 0x%x\n", Status);
74 return NULL;
75 }
76
77 /* Set the binding handle that will be used to bind to the server. */
78 Status = RpcBindingFromStringBindingW(pszStringBinding,
79 &hBinding);
80 if (Status != RPC_S_OK)
81 {
82 ERR("RpcBindingFromStringBinding returned 0x%x\n", Status);
83 }
84
85 Status = RpcStringFreeW(&pszStringBinding);
86 if (Status != RPC_S_OK)
87 {
88 ERR("RpcStringFree returned 0x%x\n", Status);
89 }
90
91 return hBinding;
92 }
93
94 void __RPC_USER
WLANSVC_HANDLE_unbind(WLANSVC_HANDLE szMachineName,handle_t hBinding)95 WLANSVC_HANDLE_unbind(WLANSVC_HANDLE szMachineName,
96 handle_t hBinding)
97 {
98 RPC_STATUS Status;
99
100 TRACE("WLANSVC_HANDLE_unbind() called\n");
101
102 Status = RpcBindingFree(&hBinding);
103 if (Status != RPC_S_OK)
104 {
105 ERR("RpcBindingFree returned 0x%x\n", Status);
106 }
107 }
108
109 PVOID
110 WINAPI
WlanAllocateMemory(IN DWORD dwSize)111 WlanAllocateMemory(IN DWORD dwSize)
112 {
113 return HeapAlloc(GetProcessHeap(), 0, dwSize);
114 }
115
116 VOID
117 WINAPI
WlanFreeMemory(IN PVOID pMem)118 WlanFreeMemory(IN PVOID pMem)
119 {
120 HeapFree(GetProcessHeap(), 0, pMem);
121 }
122
123 DWORD
124 WINAPI
WlanConnect(IN HANDLE hClientHandle,IN const GUID * pInterfaceGuid,IN const PWLAN_CONNECTION_PARAMETERS pConnectionParameters,PVOID pReserved)125 WlanConnect(IN HANDLE hClientHandle,
126 IN const GUID *pInterfaceGuid,
127 IN const PWLAN_CONNECTION_PARAMETERS pConnectionParameters,
128 PVOID pReserved)
129 {
130 DWORD dwResult = ERROR_SUCCESS;
131
132 if ((pReserved != NULL) || (hClientHandle == NULL) || (pInterfaceGuid == NULL) || (pConnectionParameters == NULL))
133 return ERROR_INVALID_PARAMETER;
134
135 RpcTryExcept
136 {
137 dwResult = _RpcConnect(hClientHandle, pInterfaceGuid, &pConnectionParameters);
138 }
139 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
140 {
141 dwResult = WlanRpcStatusToWinError(RpcExceptionCode());
142 }
143 RpcEndExcept;
144
145 return dwResult;
146 }
147
148 DWORD
149 WINAPI
WlanDisconnect(IN HANDLE hClientHandle,IN const GUID * pInterfaceGuid,PVOID pReserved)150 WlanDisconnect(IN HANDLE hClientHandle,
151 IN const GUID *pInterfaceGuid,
152 PVOID pReserved)
153 {
154 DWORD dwResult = ERROR_SUCCESS;
155
156 if ((pReserved != NULL) || (hClientHandle == NULL) || (pInterfaceGuid == NULL))
157 return ERROR_INVALID_PARAMETER;
158
159 RpcTryExcept
160 {
161 dwResult = _RpcDisconnect(hClientHandle, pInterfaceGuid);
162 }
163 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
164 {
165 dwResult = WlanRpcStatusToWinError(RpcExceptionCode());
166 }
167 RpcEndExcept;
168
169 return dwResult;
170 }
171
172 DWORD
173 WINAPI
WlanOpenHandle(IN DWORD dwClientVersion,PVOID pReserved,OUT DWORD * pdwNegotiatedVersion,OUT HANDLE * phClientHandle)174 WlanOpenHandle(IN DWORD dwClientVersion,
175 PVOID pReserved,
176 OUT DWORD *pdwNegotiatedVersion,
177 OUT HANDLE *phClientHandle)
178 {
179 DWORD dwResult = ERROR_SUCCESS;
180 WCHAR szDummy[] = L"localhost";
181
182 if ((pReserved != NULL) || (pdwNegotiatedVersion == NULL) || (phClientHandle == NULL))
183 return ERROR_INVALID_PARAMETER;
184
185 RpcTryExcept
186 {
187 dwResult = _RpcOpenHandle(szDummy,
188 dwClientVersion,
189 pdwNegotiatedVersion,
190 (WLANSVC_RPC_HANDLE) phClientHandle);
191 }
192 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
193 {
194 dwResult = WlanRpcStatusToWinError(RpcExceptionCode());
195 }
196 RpcEndExcept;
197
198 return dwResult;
199 }
200
201 DWORD
202 WINAPI
WlanCloseHandle(IN HANDLE hClientHandle,PVOID pReserved)203 WlanCloseHandle(IN HANDLE hClientHandle,
204 PVOID pReserved)
205 {
206 DWORD dwResult = ERROR_SUCCESS;
207
208 if ((pReserved != NULL) || (hClientHandle == NULL))
209 return ERROR_INVALID_PARAMETER;
210
211 RpcTryExcept
212 {
213 dwResult = _RpcCloseHandle(&hClientHandle);
214 }
215 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
216 {
217 dwResult = WlanRpcStatusToWinError(RpcExceptionCode());
218 }
219 RpcEndExcept;
220
221 return dwResult;
222 }
223
224 DWORD
225 WINAPI
WlanEnumInterfaces(IN HANDLE hClientHandle,PVOID pReserved,OUT PWLAN_INTERFACE_INFO_LIST * ppInterfaceList)226 WlanEnumInterfaces(IN HANDLE hClientHandle,
227 PVOID pReserved,
228 OUT PWLAN_INTERFACE_INFO_LIST *ppInterfaceList)
229 {
230 DWORD dwResult = ERROR_SUCCESS;
231
232 if ((pReserved != NULL) || (ppInterfaceList == NULL) || (hClientHandle == NULL))
233 return ERROR_INVALID_PARAMETER;
234
235 RpcTryExcept
236 {
237 dwResult = _RpcEnumInterfaces(hClientHandle, ppInterfaceList);
238 }
239 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
240 {
241 dwResult = WlanRpcStatusToWinError(RpcExceptionCode());
242 }
243 RpcEndExcept;
244
245 return dwResult;
246 }
247
248 DWORD
249 WINAPI
WlanScan(IN HANDLE hClientHandle,IN const GUID * pInterfaceGuid,IN PDOT11_SSID pDot11Ssid,IN PWLAN_RAW_DATA pIeData,PVOID pReserved)250 WlanScan(IN HANDLE hClientHandle,
251 IN const GUID *pInterfaceGuid,
252 IN PDOT11_SSID pDot11Ssid,
253 IN PWLAN_RAW_DATA pIeData,
254 PVOID pReserved)
255 {
256 DWORD dwResult = ERROR_SUCCESS;
257
258 if ((pReserved != NULL) || (pInterfaceGuid == NULL) || (hClientHandle == NULL))
259 return ERROR_INVALID_PARAMETER;
260
261 RpcTryExcept
262 {
263 dwResult = _RpcScan(hClientHandle, pInterfaceGuid, pDot11Ssid, pIeData);
264 }
265 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
266 {
267 dwResult = WlanRpcStatusToWinError(RpcExceptionCode());
268 }
269 RpcEndExcept;
270
271 return dwResult;
272 }
273
274 DWORD
275 WINAPI
WlanQueryInterface(IN HANDLE hClientHandle,IN const GUID * pInterfaceGuid,IN WLAN_INTF_OPCODE OpCode,PVOID pReserved,OUT PDWORD pdwDataSize,OUT PVOID * ppData,WLAN_OPCODE_VALUE_TYPE * pWlanOpcodeValueType)276 WlanQueryInterface(IN HANDLE hClientHandle,
277 IN const GUID *pInterfaceGuid,
278 IN WLAN_INTF_OPCODE OpCode,
279 PVOID pReserved,
280 OUT PDWORD pdwDataSize,
281 OUT PVOID *ppData,
282 WLAN_OPCODE_VALUE_TYPE *pWlanOpcodeValueType)
283 {
284 if ((pReserved != NULL) || (pInterfaceGuid == NULL) || (hClientHandle == NULL) || (pdwDataSize == NULL) || (ppData == NULL))
285 return ERROR_INVALID_PARAMETER;
286
287 UNIMPLEMENTED;
288 return ERROR_SUCCESS;
289 }
290
291 DWORD
292 WINAPI
WlanGetInterfaceCapability(IN HANDLE hClientHandle,IN const GUID * pInterfaceGuid,PVOID pReserved,OUT PWLAN_INTERFACE_CAPABILITY * ppCapability)293 WlanGetInterfaceCapability(IN HANDLE hClientHandle,
294 IN const GUID *pInterfaceGuid,
295 PVOID pReserved,
296 OUT PWLAN_INTERFACE_CAPABILITY *ppCapability)
297 {
298 if ((pReserved != NULL) || (pInterfaceGuid == NULL) || (hClientHandle == NULL) || (ppCapability == NULL))
299 return ERROR_INVALID_PARAMETER;
300
301 UNIMPLEMENTED;
302 return ERROR_SUCCESS;
303 }
304
WlanRegisterNotification(IN HANDLE hClientHandle,IN DWORD dwNotifSource,IN BOOL bIgnoreDuplicate,WLAN_NOTIFICATION_CALLBACK funcCallback,PVOID pCallbackContext,PVOID pReserved,PDWORD pdwPrevNotifSource)305 DWORD WINAPI WlanRegisterNotification(IN HANDLE hClientHandle,
306 IN DWORD dwNotifSource,
307 IN BOOL bIgnoreDuplicate,
308 WLAN_NOTIFICATION_CALLBACK funcCallback,
309 PVOID pCallbackContext,
310 PVOID pReserved,
311 PDWORD pdwPrevNotifSource)
312 {
313 UNIMPLEMENTED;
314 return ERROR_SUCCESS;
315 }
316
317 DWORD
318 WINAPI
WlanReasonCodeToString(IN DWORD dwReasonCode,IN DWORD dwBufferSize,IN PWCHAR pStringBuffer,PVOID pReserved)319 WlanReasonCodeToString(IN DWORD dwReasonCode,
320 IN DWORD dwBufferSize,
321 IN PWCHAR pStringBuffer,
322 PVOID pReserved)
323 {
324 if ((pReserved != NULL) || (pStringBuffer == NULL) || (dwBufferSize == 0))
325 return ERROR_INVALID_PARAMETER;
326
327 UNIMPLEMENTED;
328 return ERROR_SUCCESS;
329 }
330
331 DWORD
332 WINAPI
WlanIhvControl(IN HANDLE hClientHandle,IN const GUID * pInterfaceGuid,IN WLAN_IHV_CONTROL_TYPE Type,IN DWORD dwInBufferSize,IN PVOID pInBuffer,IN DWORD dwOutBufferSize,PVOID pOutBuffer,OUT PDWORD pdwBytesReturned)333 WlanIhvControl(IN HANDLE hClientHandle,
334 IN const GUID *pInterfaceGuid,
335 IN WLAN_IHV_CONTROL_TYPE Type,
336 IN DWORD dwInBufferSize,
337 IN PVOID pInBuffer,
338 IN DWORD dwOutBufferSize,
339 PVOID pOutBuffer,
340 OUT PDWORD pdwBytesReturned)
341 {
342 if ((hClientHandle == NULL) || (pInterfaceGuid == NULL) || (pdwBytesReturned == NULL))
343 return ERROR_INVALID_PARAMETER;
344
345 UNIMPLEMENTED;
346 return ERROR_SUCCESS;
347 }
348
349 DWORD
350 WINAPI
WlanSetSecuritySettings(IN HANDLE hClientHandle,IN WLAN_SECURABLE_OBJECT SecurableObject,IN LPCWSTR strModifiedSDDL)351 WlanSetSecuritySettings(IN HANDLE hClientHandle,
352 IN WLAN_SECURABLE_OBJECT SecurableObject,
353 IN LPCWSTR strModifiedSDDL)
354 {
355 DWORD dwResult = ERROR_SUCCESS;
356
357 if ((hClientHandle == NULL) || (strModifiedSDDL == NULL) || (SecurableObject >= WLAN_SECURABLE_OBJECT_COUNT))
358 return ERROR_INVALID_PARAMETER;
359
360 RpcTryExcept
361 {
362 dwResult = _RpcSetSecuritySettings(hClientHandle, SecurableObject, strModifiedSDDL);
363 }
364 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
365 {
366 dwResult = WlanRpcStatusToWinError(RpcExceptionCode());
367 }
368 RpcEndExcept;
369
370 return dwResult;
371 }
372
373 DWORD
374 WINAPI
WlanGetAvailableNetworkList(IN HANDLE hClientHandle,IN const GUID * pInterfaceGuid,IN DWORD dwFlags,PVOID pReserved,OUT PWLAN_AVAILABLE_NETWORK_LIST * ppAvailableNetworkList)375 WlanGetAvailableNetworkList(IN HANDLE hClientHandle,
376 IN const GUID *pInterfaceGuid,
377 IN DWORD dwFlags,
378 PVOID pReserved,
379 OUT PWLAN_AVAILABLE_NETWORK_LIST *ppAvailableNetworkList)
380 {
381 if ((pReserved != NULL) || (pInterfaceGuid == NULL) || (hClientHandle == NULL) || (ppAvailableNetworkList == NULL))
382 return ERROR_INVALID_PARAMETER;
383
384 UNIMPLEMENTED;
385 return ERROR_SUCCESS;
386 }
387
388 void __RPC_FAR * __RPC_USER
midl_user_allocate(SIZE_T len)389 midl_user_allocate(SIZE_T len)
390 {
391 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
392 }
393
394 void __RPC_USER
midl_user_free(void __RPC_FAR * ptr)395 midl_user_free(void __RPC_FAR * ptr)
396 {
397 HeapFree(GetProcessHeap(), 0, ptr);
398 }
399
400