2 * Copyright 2010 Ričardas Barkauskas
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 /* How does this DLL work?
20 * This DLL is used to probe and configure wireless access points using the
21 * available wireless interfaces. Most functions are tied to a handle that is
22 * first obtained by calling WlanOpenHandle. Usually it is followed by a call
23 * to WlanEnumInterfaces and then for each interface a WlanScan call is made.
24 * WlanScan starts a parallel access point discovery that delivers the ready
25 * response through the callback registered by WlanRegisterNotification. After
26 * that the program calls WlanGetAvailableNetworkList or WlanGetNetworkBssList.
35 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(wlanapi
);
41 #define WLAN_MAGIC 0x574c414e /* WLAN */
43 static struct wine_wlan
45 DWORD magic
, cli_version
;
48 static struct wine_wlan
* handle_index(HANDLE handle
)
50 ULONG_PTR i
= (ULONG_PTR
)handle
- 1;
52 if (i
< ARRAY_SIZE(handle_table
) && handle_table
[i
].magic
== WLAN_MAGIC
)
53 return &handle_table
[i
];
58 static HANDLE
handle_new(struct wine_wlan
**entry
)
62 for (i
= 0; i
< ARRAY_SIZE(handle_table
); i
++)
64 if (handle_table
[i
].magic
== 0)
66 *entry
= &handle_table
[i
];
67 return (HANDLE
)(i
+ 1);
74 DWORD WINAPI
WlanEnumInterfaces(HANDLE handle
, void *reserved
, WLAN_INTERFACE_INFO_LIST
**interface_list
)
76 struct wine_wlan
*wlan
;
77 WLAN_INTERFACE_INFO_LIST
*ret_list
;
79 FIXME("(%p, %p, %p) semi-stub\n", handle
, reserved
, interface_list
);
81 if (!handle
|| reserved
|| !interface_list
)
82 return ERROR_INVALID_PARAMETER
;
84 wlan
= handle_index(handle
);
86 return ERROR_INVALID_HANDLE
;
88 ret_list
= WlanAllocateMemory(sizeof(WLAN_INTERFACE_INFO_LIST
));
90 return ERROR_NOT_ENOUGH_MEMORY
;
92 memset(&ret_list
->InterfaceInfo
[0], 0, sizeof(WLAN_INTERFACE_INFO
));
93 ret_list
->dwNumberOfItems
= 0;
94 ret_list
->dwIndex
= 0; /* unused in this function */
95 *interface_list
= ret_list
;
100 DWORD WINAPI
WlanCloseHandle(HANDLE handle
, void *reserved
)
102 struct wine_wlan
*wlan
;
104 TRACE("(%p, %p)\n", handle
, reserved
);
106 if (!handle
|| reserved
)
107 return ERROR_INVALID_PARAMETER
;
109 wlan
= handle_index(handle
);
111 return ERROR_INVALID_HANDLE
;
114 return ERROR_SUCCESS
;
117 DWORD WINAPI
WlanOpenHandle(DWORD client_version
, void *reserved
, DWORD
*negotiated_version
, HANDLE
*handle
)
119 struct wine_wlan
*wlan
;
122 TRACE("(%u, %p, %p, %p)\n", client_version
, reserved
, negotiated_version
, handle
);
124 if (reserved
|| !negotiated_version
|| !handle
)
125 return ERROR_INVALID_PARAMETER
;
127 if (client_version
!= 1 && client_version
!= 2)
128 return ERROR_NOT_SUPPORTED
;
130 ret_handle
= handle_new(&wlan
);
132 return ERROR_REMOTE_SESSION_LIMIT_EXCEEDED
;
134 wlan
->magic
= WLAN_MAGIC
;
135 wlan
->cli_version
= *negotiated_version
= client_version
;
136 *handle
= ret_handle
;
138 return ERROR_SUCCESS
;
141 DWORD WINAPI
WlanScan(HANDLE handle
, const GUID
*guid
, const DOT11_SSID
*ssid
,
142 const WLAN_RAW_DATA
*raw
, void *reserved
)
144 FIXME("(%p, %s, %p, %p, %p) stub\n",
145 handle
, wine_dbgstr_guid(guid
), ssid
, raw
, reserved
);
147 return ERROR_CALL_NOT_IMPLEMENTED
;
150 DWORD WINAPI
WlanRegisterNotification(HANDLE handle
, DWORD notify_source
, BOOL ignore_dup
,
151 WLAN_NOTIFICATION_CALLBACK callback
, void *context
,
152 void *reserved
, DWORD
*notify_prev
)
154 FIXME("(%p, %d, %d, %p, %p, %p, %p) stub\n",
155 handle
, notify_source
, ignore_dup
, callback
, context
, reserved
, notify_prev
);
157 return ERROR_CALL_NOT_IMPLEMENTED
;
160 DWORD WINAPI
WlanGetAvailableNetworkList(HANDLE handle
, const GUID
*guid
, DWORD flags
,
161 void *reserved
, WLAN_AVAILABLE_NETWORK_LIST
**network_list
)
163 FIXME("(%p, %s, 0x%x, %p, %p) stub\n",
164 handle
, wine_dbgstr_guid(guid
), flags
, reserved
, network_list
);
166 return ERROR_CALL_NOT_IMPLEMENTED
;
169 void WINAPI
WlanFreeMemory(void *ptr
)
171 TRACE("(%p)\n", ptr
);
173 HeapFree(GetProcessHeap(), 0, ptr
);
176 void *WINAPI
WlanAllocateMemory(DWORD size
)
180 TRACE("(%d)\n", size
);
184 SetLastError(ERROR_INVALID_PARAMETER
);
188 ret
= HeapAlloc(GetProcessHeap(), 0, size
);
190 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
195 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD reason
, void *reserved
)
197 TRACE("(0x%p, %u, %p)\n", hinstDLL
, reason
, reserved
);
201 case DLL_WINE_PREATTACH
:
202 return FALSE
; /* prefer native version */
203 case DLL_PROCESS_ATTACH
:
204 DisableThreadLibraryCalls(hinstDLL
);