3740f916af17836386daf400554446b7ad72defb
[reactos.git] / dll / win32 / wlanapi / main.c
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 #include <windows.h>
25 #include "wlansvc_c.h"
26
27 #include "wine/debug.h"
28
29 WINE_DEFAULT_DEBUG_CHANNEL(wlanapi);
30
31 handle_t __RPC_USER
32 WLANSVC_HANDLE_bind(WLANSVC_HANDLE szMachineName)
33 {
34 handle_t hBinding = NULL;
35 LPWSTR pszStringBinding;
36 RPC_STATUS Status;
37
38 TRACE("RPC_SERVICE_STATUS_HANDLE_bind() called\n");
39
40 Status = RpcStringBindingComposeW(NULL,
41 L"ncalrpc",
42 szMachineName,
43 L"wlansvc",
44 NULL,
45 &pszStringBinding);
46 if (Status != RPC_S_OK)
47 {
48 ERR("RpcStringBindingCompose returned 0x%x\n", Status);
49 return NULL;
50 }
51
52 /* Set the binding handle that will be used to bind to the server. */
53 Status = RpcBindingFromStringBindingW(pszStringBinding,
54 &hBinding);
55 if (Status != RPC_S_OK)
56 {
57 ERR("RpcBindingFromStringBinding returned 0x%x\n", Status);
58 }
59
60 Status = RpcStringFreeW(&pszStringBinding);
61 if (Status != RPC_S_OK)
62 {
63 ERR("RpcStringFree returned 0x%x\n", Status);
64 }
65
66 return hBinding;
67 }
68
69 void __RPC_USER
70 WLANSVC_HANDLE_unbind(WLANSVC_HANDLE szMachineName,
71 handle_t hBinding)
72 {
73 RPC_STATUS Status;
74
75 TRACE("WLANSVC_HANDLE_unbind() called\n");
76
77 Status = RpcBindingFree(&hBinding);
78 if (Status != RPC_S_OK)
79 {
80 ERR("RpcBindingFree returned 0x%x\n", Status);
81 }
82 }
83
84 PVOID
85 WINAPI
86 WlanAllocateMemory(IN DWORD dwSize)
87 {
88 return HeapAlloc(GetProcessHeap(), 0, dwSize);
89 }
90
91 VOID
92 WINAPI
93 WlanFreeMemory(IN PVOID pMem)
94 {
95 HeapFree(GetProcessHeap(), 0, pMem);
96 }
97
98 DWORD
99 WINAPI
100 WlanOpenHandle(IN DWORD dwClientVersion,
101 PVOID pReserved,
102 OUT DWORD *pdwNegotiatedVersion,
103 OUT HANDLE *phClientHandle)
104 {
105 DWORD dwError = ERROR_SUCCESS;
106 WCHAR szDummy[] = L"localhost";
107
108 if ((pReserved != NULL) || (pdwNegotiatedVersion == NULL) || (phClientHandle == NULL))
109 return ERROR_INVALID_PARAMETER;
110
111 RpcTryExcept
112 {
113 dwError = _RpcOpenHandle(szDummy,
114 dwClientVersion,
115 pdwNegotiatedVersion,
116 (WLANSVC_RPC_HANDLE) phClientHandle);
117 }
118 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
119 {
120 dwError = RpcExceptionCode();
121 }
122 RpcEndExcept;
123
124 return dwError;
125 }
126
127 DWORD
128 WINAPI
129 WlanCloseHandle(IN HANDLE hClientHandle,
130 PVOID pReserved)
131 {
132 DWORD dwError = ERROR_SUCCESS;
133
134 if ((pReserved != NULL) || (hClientHandle == NULL))
135 return ERROR_INVALID_PARAMETER;
136
137 RpcTryExcept
138 {
139 _RpcCloseHandle(hClientHandle);
140 }
141 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
142 {
143 dwError = RpcExceptionCode();
144 }
145 RpcEndExcept;
146
147 return dwError;
148 }
149
150 DWORD
151 WINAPI
152 WlanEnumInterfaces(IN HANDLE hClientHandle,
153 PVOID pReserved,
154 OUT PWLAN_INTERFACE_INFO_LIST *ppInterfaceList)
155 {
156 DWORD dwError = ERROR_SUCCESS;
157
158 if ((pReserved != NULL) || (ppInterfaceList == NULL) || (hClientHandle == NULL))
159 return ERROR_INVALID_PARAMETER;
160
161 RpcTryExcept
162 {
163 _RpcEnumInterfaces(hClientHandle, ppInterfaceList);
164 }
165 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
166 {
167 dwError = RpcExceptionCode();
168 }
169 RpcEndExcept;
170
171 return dwError;
172 }
173
174 DWORD
175 WINAPI
176 WlanScan(IN HANDLE hClientHandle,
177 IN GUID *pInterfaceGuid,
178 IN PDOT11_SSID pDot11Ssid,
179 IN PWLAN_RAW_DATA pIeData,
180 PVOID pReserved)
181 {
182 DWORD dwError = ERROR_SUCCESS;
183
184 if ((pReserved != NULL) || (pInterfaceGuid == NULL) || (hClientHandle == NULL))
185 return ERROR_INVALID_PARAMETER;
186
187 RpcTryExcept
188 {
189 _RpcScan(hClientHandle, pInterfaceGuid, pDot11Ssid, pIeData);
190 }
191 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
192 {
193 dwError = RpcExceptionCode();
194 }
195 RpcEndExcept;
196
197 return dwError;
198 }
199
200 void __RPC_FAR * __RPC_USER
201 midl_user_allocate(SIZE_T len)
202 {
203 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
204 }
205
206 void __RPC_USER
207 midl_user_free(void __RPC_FAR * ptr)
208 {
209 HeapFree(GetProcessHeap(), 0, ptr);
210 }
211