wlanapi: Implement WlanOpenHandle.

Signed-off-by: Bruno Jesus <00cpxxx@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Bruno Jesus 2017-01-30 04:59:43 -02:00 committed by Alexandre Julliard
parent 382755af1f
commit 8b3c6943e3
2 changed files with 58 additions and 10 deletions

View File

@ -28,6 +28,29 @@
WINE_DEFAULT_DEBUG_CHANNEL(wlanapi);
#define WLAN_MAGIC 0x574c414e /* WLAN */
static struct wine_wlan
{
DWORD magic, cli_version;
} handle_table[16];
static HANDLE handle_new(struct wine_wlan **entry)
{
ULONG_PTR i;
for (i = 0; i < sizeof(handle_table) / sizeof(handle_table[0]); i++)
{
if (handle_table[i].magic == 0)
{
*entry = &handle_table[i];
return (HANDLE)(i + 1);
}
}
return NULL;
}
DWORD WINAPI WlanEnumInterfaces(HANDLE handle, void *reserved, WLAN_INTERFACE_INFO_LIST **interface_list)
{
FIXME("(%p, %p, %p) stub\n", handle, reserved, interface_list);
@ -42,8 +65,26 @@ DWORD WINAPI WlanCloseHandle(HANDLE handle, void *reserved)
DWORD WINAPI WlanOpenHandle(DWORD client_version, void *reserved, DWORD *negotiated_version, HANDLE *handle)
{
FIXME("(%u, %p, %p, %p) stub\n", client_version, reserved, negotiated_version, handle);
return ERROR_CALL_NOT_IMPLEMENTED;
struct wine_wlan *wlan;
HANDLE ret_handle;
TRACE("(%u, %p, %p, %p)\n", client_version, reserved, negotiated_version, handle);
if (reserved || !negotiated_version || !handle)
return ERROR_INVALID_PARAMETER;
if (client_version != 1 && client_version != 2)
return ERROR_NOT_SUPPORTED;
ret_handle = handle_new(&wlan);
if (!ret_handle)
return ERROR_REMOTE_SESSION_LIMIT_EXCEEDED;
wlan->magic = WLAN_MAGIC;
wlan->cli_version = *negotiated_version = client_version;
*handle = ret_handle;
return ERROR_SUCCESS;
}
void WINAPI WlanFreeMemory(void *ptr)

View File

@ -26,7 +26,7 @@
static void test_WlanOpenHandle(void)
{
HANDLE bad_handle = (HANDLE) 0xdeadcafe, handle = bad_handle;
HANDLE bad_handle = (HANDLE) 0xdeadcafe, handle = bad_handle, handle2;
DWORD ret, neg_version = 0xdeadbeef, reserved = 0xdead;
BOOL is_xp;
@ -35,30 +35,25 @@ static void test_WlanOpenHandle(void)
is_xp = ret == ERROR_SUCCESS;
if (!is_xp) /* the results in XP differ completely from all other versions */
{
todo_wine
ok(ret == ERROR_NOT_SUPPORTED, "Expected 50, got %d\n", ret);
ok(neg_version == 0xdeadbeef, "neg_vesion changed\n");
ok(handle == bad_handle, "handle changed\n");
ret = WlanOpenHandle(10, NULL, &neg_version, &handle);
todo_wine
ok(ret == ERROR_NOT_SUPPORTED, "Expected 50, got %d\n", ret);
ok(neg_version == 0xdeadbeef, "neg_vesion changed\n");
ok(handle == bad_handle, "handle changed\n");
/* reserved parameter must not be used */
ret = WlanOpenHandle(1, &reserved, &neg_version, &handle);
todo_wine
ok(ret == ERROR_INVALID_PARAMETER, "Expected 87, got %d\n", ret);
ok(neg_version == 0xdeadbeef, "neg_vesion changed\n");
ok(handle == bad_handle, "handle changed\n");
/* invalid parameters */
ret = WlanOpenHandle(1, NULL, NULL, &handle);
todo_wine
ok(ret == ERROR_INVALID_PARAMETER, "Expected 87, got %d\n", ret);
ok(handle == bad_handle, "bad handle\n");
ret = WlanOpenHandle(1, NULL, &neg_version, NULL);
todo_wine
ok(ret == ERROR_INVALID_PARAMETER, "Expected 87, got %d\n", ret);
ok(neg_version == 0xdeadbeef, "neg_vesion changed\n");
}
@ -71,12 +66,12 @@ todo_wine
}
/* good tests */
todo_wine {
ret = WlanOpenHandle(1, NULL, &neg_version, &handle);
ok(ret == ERROR_SUCCESS, "Expected 0, got %d\n", ret);
ok(neg_version == 1, "Expected 1, got %d\n", neg_version);
ok(handle != bad_handle && handle, "handle changed\n");
ret = WlanCloseHandle(handle, NULL);
todo_wine
ok(ret == 0, "Expected 0, got %d\n", ret);
ret = WlanOpenHandle(2, NULL, &neg_version, &handle);
@ -87,8 +82,21 @@ todo_wine {
ok(neg_version == 1, "Expected 1, got %d\n", neg_version);
ok(handle != bad_handle && handle, "bad handle\n");
ret = WlanCloseHandle(handle, NULL);
todo_wine
ok(ret == 0, "Expected 0, got %d\n", ret);
/* open twice */
ret = WlanOpenHandle(1, NULL, &neg_version, &handle);
ok(ret == ERROR_SUCCESS, "Expected 0, got %d\n", ret);
ret = WlanOpenHandle(1, NULL, &neg_version, &handle2);
ok(ret == ERROR_SUCCESS, "Expected 0, got %d\n", ret);
todo_wine {
ret = WlanCloseHandle(handle, NULL);
ok(ret == ERROR_SUCCESS, "Expected 0, got %d\n", ret);
ret = WlanCloseHandle(handle2, NULL);
ok(ret == ERROR_SUCCESS, "Expected 0, got %d\n", ret);
ret = WlanCloseHandle(NULL, NULL);
ok(ret == ERROR_INVALID_PARAMETER, "Expected 0, got %d\n", ret);
}
@ -120,7 +128,6 @@ static void test_WlanEnumInterfaces(void)
WLAN_INTERFACE_INFO *info;
ret = WlanOpenHandle(1, NULL, &neg_version, &handle);
todo_wine
ok(ret == 0, "Expected 0, got %d\n", ret);
/* invalid parameters */