server: Use a shared_object_t for the dummy object.
[wine.git] / dlls / wlanapi / main.c
blobc371266223236868b3a5ee1fd8539556d3a553c1
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("(%lu, %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, %ld, %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%lx, %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;
176 DWORD WINAPI WlanHostedNetworkQueryProperty(HANDLE handle, WLAN_HOSTED_NETWORK_OPCODE opcode,
177 DWORD *data_size, void **data,
178 WLAN_OPCODE_VALUE_TYPE *opcode_type, void *reserved)
180 FIXME("(%p, 0x%x, %p, %p, %p, %p) stub\n",
181 handle, opcode, data_size, data, opcode_type, reserved);
183 return ERROR_CALL_NOT_IMPLEMENTED;
186 DWORD WINAPI WlanHostedNetworkQuerySecondaryKey(HANDLE handle, DWORD *key_size, unsigned char *key,
187 BOOL *passphrase, BOOL *persistent,
188 WLAN_HOSTED_NETWORK_REASON *error, void *reserved)
190 FIXME("(%p, %p, %p, %p, %p, %p, %p) stub\n",
191 handle, key_size, key, passphrase, persistent, error, reserved);
193 return ERROR_CALL_NOT_IMPLEMENTED;
196 DWORD WINAPI WlanHostedNetworkQueryStatus(HANDLE handle, WLAN_HOSTED_NETWORK_STATUS *status, void *reserved)
198 FIXME("(%p, %p, %p) stub\n", handle, status, reserved);
200 return ERROR_CALL_NOT_IMPLEMENTED;
203 void WINAPI WlanFreeMemory(void *ptr)
205 TRACE("(%p)\n", ptr);
207 HeapFree(GetProcessHeap(), 0, ptr);
210 void *WINAPI WlanAllocateMemory(DWORD size)
212 void *ret;
214 TRACE("(%ld)\n", size);
216 if (!size)
218 SetLastError(ERROR_INVALID_PARAMETER);
219 return NULL;
222 ret = HeapAlloc(GetProcessHeap(), 0, size);
223 if (!ret)
224 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
226 return ret;