widl: Always check the runtimeclass interfaces presence.
[wine/zf.git] / dlls / wlanapi / main.c
blobd54cc1463baa2890e12f23cfd92fa0108642ec8f
1 /*
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.
29 #include <stdarg.h>
31 #include "windef.h"
32 #include "winbase.h"
33 #include "wine/debug.h"
35 #include "wlanapi.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(wlanapi);
39 #define WLAN_MAGIC 0x574c414e /* WLAN */
41 static struct wine_wlan
43 DWORD magic, cli_version;
44 } handle_table[16];
46 static struct wine_wlan* handle_index(HANDLE handle)
48 ULONG_PTR i = (ULONG_PTR)handle - 1;
50 if (i < ARRAY_SIZE(handle_table) && handle_table[i].magic == WLAN_MAGIC)
51 return &handle_table[i];
53 return NULL;
56 static HANDLE handle_new(struct wine_wlan **entry)
58 ULONG_PTR i;
60 for (i = 0; i < ARRAY_SIZE(handle_table); i++)
62 if (handle_table[i].magic == 0)
64 *entry = &handle_table[i];
65 return (HANDLE)(i + 1);
69 return NULL;
72 DWORD WINAPI WlanEnumInterfaces(HANDLE handle, void *reserved, WLAN_INTERFACE_INFO_LIST **interface_list)
74 struct wine_wlan *wlan;
75 WLAN_INTERFACE_INFO_LIST *ret_list;
77 FIXME("(%p, %p, %p) semi-stub\n", handle, reserved, interface_list);
79 if (!handle || reserved || !interface_list)
80 return ERROR_INVALID_PARAMETER;
82 wlan = handle_index(handle);
83 if (!wlan)
84 return ERROR_INVALID_HANDLE;
86 ret_list = WlanAllocateMemory(sizeof(WLAN_INTERFACE_INFO_LIST));
87 if (!ret_list)
88 return ERROR_NOT_ENOUGH_MEMORY;
90 memset(&ret_list->InterfaceInfo[0], 0, sizeof(WLAN_INTERFACE_INFO));
91 ret_list->dwNumberOfItems = 0;
92 ret_list->dwIndex = 0; /* unused in this function */
93 *interface_list = ret_list;
95 return ERROR_SUCCESS;
98 DWORD WINAPI WlanCloseHandle(HANDLE handle, void *reserved)
100 struct wine_wlan *wlan;
102 TRACE("(%p, %p)\n", handle, reserved);
104 if (!handle || reserved)
105 return ERROR_INVALID_PARAMETER;
107 wlan = handle_index(handle);
108 if (!wlan)
109 return ERROR_INVALID_HANDLE;
111 wlan->magic = 0;
112 return ERROR_SUCCESS;
115 DWORD WINAPI WlanOpenHandle(DWORD client_version, void *reserved, DWORD *negotiated_version, HANDLE *handle)
117 struct wine_wlan *wlan;
118 HANDLE ret_handle;
120 TRACE("(%u, %p, %p, %p)\n", client_version, reserved, negotiated_version, handle);
122 if (reserved || !negotiated_version || !handle)
123 return ERROR_INVALID_PARAMETER;
125 if (client_version != 1 && client_version != 2)
126 return ERROR_NOT_SUPPORTED;
128 ret_handle = handle_new(&wlan);
129 if (!ret_handle)
130 return ERROR_REMOTE_SESSION_LIMIT_EXCEEDED;
132 wlan->magic = WLAN_MAGIC;
133 wlan->cli_version = *negotiated_version = client_version;
134 *handle = ret_handle;
136 return ERROR_SUCCESS;
139 DWORD WINAPI WlanScan(HANDLE handle, const GUID *guid, const DOT11_SSID *ssid,
140 const WLAN_RAW_DATA *raw, void *reserved)
142 FIXME("(%p, %s, %p, %p, %p) stub\n",
143 handle, wine_dbgstr_guid(guid), ssid, raw, reserved);
145 return ERROR_CALL_NOT_IMPLEMENTED;
148 DWORD WINAPI WlanRegisterNotification(HANDLE handle, DWORD notify_source, BOOL ignore_dup,
149 WLAN_NOTIFICATION_CALLBACK callback, void *context,
150 void *reserved, DWORD *notify_prev)
152 FIXME("(%p, %d, %d, %p, %p, %p, %p) stub\n",
153 handle, notify_source, ignore_dup, callback, context, reserved, notify_prev);
155 return ERROR_CALL_NOT_IMPLEMENTED;
158 DWORD WINAPI WlanGetAvailableNetworkList(HANDLE handle, const GUID *guid, DWORD flags,
159 void *reserved, WLAN_AVAILABLE_NETWORK_LIST **network_list)
161 FIXME("(%p, %s, 0x%x, %p, %p) stub\n",
162 handle, wine_dbgstr_guid(guid), flags, reserved, network_list);
164 return ERROR_CALL_NOT_IMPLEMENTED;
167 DWORD WINAPI WlanQueryInterface(HANDLE handle, const GUID *guid, WLAN_INTF_OPCODE opcode,
168 void *reserved, DWORD *data_size, void **data, WLAN_OPCODE_VALUE_TYPE *opcode_type)
170 FIXME("(%p, %s, 0x%x, %p, %p, %p, %p) stub\n",
171 handle, wine_dbgstr_guid(guid), opcode, reserved, data_size, data, opcode_type);
173 return ERROR_CALL_NOT_IMPLEMENTED;
175 void WINAPI WlanFreeMemory(void *ptr)
177 TRACE("(%p)\n", ptr);
179 HeapFree(GetProcessHeap(), 0, ptr);
182 void *WINAPI WlanAllocateMemory(DWORD size)
184 void *ret;
186 TRACE("(%d)\n", size);
188 if (!size)
190 SetLastError(ERROR_INVALID_PARAMETER);
191 return NULL;
194 ret = HeapAlloc(GetProcessHeap(), 0, size);
195 if (!ret)
196 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
198 return ret;