1 /* 2 * PROJECT: ReactOS WLAN Service 3 * LICENSE: GPL - See COPYING in the top level directory 4 * FILE: base/services/wlansvc/rpcserver.c 5 * PURPOSE: RPC server interface 6 * COPYRIGHT: Copyright 2009 Christoph von Wittich 7 */ 8 9 #include "precomp.h" 10 11 #define NDEBUG 12 #include <debug.h> 13 //#define GET_IF_ENTRY2_IMPLEMENTED 1 14 15 LIST_ENTRY WlanSvcHandleListHead; 16 17 DWORD WINAPI RpcThreadRoutine(LPVOID lpParameter) 18 { 19 RPC_STATUS Status; 20 21 InitializeListHead(&WlanSvcHandleListHead); 22 23 Status = RpcServerUseProtseqEpW(L"ncalrpc", 20, L"wlansvc", NULL); 24 if (Status != RPC_S_OK) 25 { 26 DPRINT("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status); 27 return 0; 28 } 29 30 Status = RpcServerRegisterIf(wlansvc_interface_v1_0_s_ifspec, NULL, NULL); 31 if (Status != RPC_S_OK) 32 { 33 DPRINT("RpcServerRegisterIf() failed (Status %lx)\n", Status); 34 return 0; 35 } 36 37 Status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, 0); 38 if (Status != RPC_S_OK) 39 { 40 DPRINT("RpcServerListen() failed (Status %lx)\n", Status); 41 } 42 43 DPRINT("RpcServerListen finished\n"); 44 return 0; 45 } 46 47 PWLANSVCHANDLE WlanSvcGetHandleEntry(LPWLANSVC_RPC_HANDLE ClientHandle) 48 { 49 PLIST_ENTRY CurrentEntry; 50 PWLANSVCHANDLE lpWlanSvcHandle; 51 52 CurrentEntry = WlanSvcHandleListHead.Flink; 53 while (CurrentEntry != &WlanSvcHandleListHead) 54 { 55 lpWlanSvcHandle = CONTAINING_RECORD(CurrentEntry, 56 WLANSVCHANDLE, 57 WlanSvcHandleListEntry); 58 CurrentEntry = CurrentEntry->Flink; 59 60 if (lpWlanSvcHandle == (PWLANSVCHANDLE) ClientHandle) 61 return lpWlanSvcHandle; 62 } 63 64 return NULL; 65 } 66 67 DWORD _RpcOpenHandle( 68 wchar_t *arg_1, 69 DWORD dwClientVersion, 70 DWORD *pdwNegotiatedVersion, 71 LPWLANSVC_RPC_HANDLE phClientHandle) 72 { 73 PWLANSVCHANDLE lpWlanSvcHandle; 74 75 lpWlanSvcHandle = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WLANSVCHANDLE)); 76 if (lpWlanSvcHandle == NULL) 77 { 78 DPRINT1("Failed to allocate Heap!\n"); 79 return ERROR_NOT_ENOUGH_MEMORY; 80 } 81 82 if (dwClientVersion > 2) 83 dwClientVersion = 2; 84 85 if (dwClientVersion < 1) 86 dwClientVersion = 1; 87 88 lpWlanSvcHandle->dwClientVersion = dwClientVersion; 89 *pdwNegotiatedVersion = dwClientVersion; 90 91 InsertTailList(&WlanSvcHandleListHead, &lpWlanSvcHandle->WlanSvcHandleListEntry); 92 *phClientHandle = lpWlanSvcHandle; 93 94 return ERROR_SUCCESS; 95 } 96 97 DWORD _RpcCloseHandle( 98 LPWLANSVC_RPC_HANDLE phClientHandle) 99 { 100 PWLANSVCHANDLE lpWlanSvcHandle; 101 102 lpWlanSvcHandle = WlanSvcGetHandleEntry(*phClientHandle); 103 if (!lpWlanSvcHandle) 104 { 105 return ERROR_INVALID_HANDLE; 106 } 107 108 RemoveEntryList(&lpWlanSvcHandle->WlanSvcHandleListEntry); 109 HeapFree(GetProcessHeap(), 0, lpWlanSvcHandle); 110 111 return ERROR_SUCCESS; 112 } 113 114 DWORD _RpcEnumInterfaces( 115 WLANSVC_RPC_HANDLE hClientHandle, 116 PWLAN_INTERFACE_INFO_LIST *ppInterfaceList) 117 { 118 #if GET_IF_ENTRY2_IMPLEMENTED 119 DWORD dwNumInterfaces; 120 DWORD dwResult, dwSize; 121 DWORD dwIndex; 122 MIB_IF_ROW2 IfRow; 123 PWLAN_INTERFACE_INFO_LIST InterfaceList; 124 125 dwResult = GetNumberOfInterfaces(&dwNumInterfaces); 126 dwSize = sizeof(WLAN_INTERFACE_INFO_LIST); 127 if (dwResult != NO_ERROR) 128 { 129 /* set num interfaces to zero when an error occurs */ 130 dwNumInterfaces = 0; 131 } 132 else 133 { 134 if (dwNumInterfaces > 1) 135 { 136 /* add extra size for interface */ 137 dwSize += (dwNumInterfaces-1) * sizeof(WLAN_INTERFACE_INFO); 138 } 139 } 140 141 /* allocate interface list */ 142 InterfaceList = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSize); 143 if (!InterfaceList) 144 { 145 return ERROR_NOT_ENOUGH_MEMORY; 146 } 147 148 *ppInterfaceList = InterfaceList; 149 if (!dwNumInterfaces) 150 { 151 return ERROR_SUCCESS; 152 } 153 154 for(dwIndex = 0; dwIndex < dwNumInterfaces; dwIndex++) 155 { 156 ZeroMemory(&IfRow, sizeof(MIB_IF_ROW2)); 157 IfRow.InterfaceIndex = dwIndex; 158 159 dwResult = GetIfEntry2(&IfRow); 160 if (dwResult == NO_ERROR) 161 { 162 if (IfRow.Type == IF_TYPE_IEEE80211 && IfRow.InterfaceAndOperStatusFlags.HardwareInterface) 163 { 164 RtlMoveMemory(&InterfaceList->InterfaceInfo[InterfaceList->dwNumberOfItems].InterfaceGuid, &IfRow.InterfaceGuid, sizeof(GUID)); 165 wcscpy(InterfaceList->InterfaceInfo[InterfaceList->dwNumberOfItems].strInterfaceDescription, IfRow.Description); 166 //FIXME set state 167 InterfaceList->dwNumberOfItems++; 168 } 169 } 170 } 171 172 return ERROR_SUCCESS; 173 #else 174 UNIMPLEMENTED; 175 return ERROR_CALL_NOT_IMPLEMENTED; 176 #endif 177 } 178 179 DWORD _RpcSetAutoConfigParameter( 180 WLANSVC_RPC_HANDLE hClientHandle, 181 long OpCode, 182 DWORD dwDataSize, 183 LPBYTE pData) 184 { 185 UNIMPLEMENTED; 186 return ERROR_CALL_NOT_IMPLEMENTED; 187 } 188 189 DWORD _RpcQueryAutoConfigParameter( 190 WLANSVC_RPC_HANDLE hClientHandle, 191 DWORD OpCode, 192 LPDWORD pdwDataSize, 193 char **ppData, 194 DWORD *pWlanOpcodeValueType) 195 { 196 UNIMPLEMENTED; 197 return ERROR_CALL_NOT_IMPLEMENTED; 198 } 199 200 DWORD _RpcGetInterfaceCapability( 201 WLANSVC_RPC_HANDLE hClientHandle, 202 const GUID *pInterfaceGuid, 203 PWLAN_INTERFACE_CAPABILITY *ppCapability) 204 { 205 PWLANSVCHANDLE lpWlanSvcHandle; 206 207 lpWlanSvcHandle = WlanSvcGetHandleEntry(hClientHandle); 208 if (!lpWlanSvcHandle) 209 { 210 return ERROR_INVALID_HANDLE; 211 } 212 213 UNIMPLEMENTED; 214 return ERROR_CALL_NOT_IMPLEMENTED; 215 } 216 217 DWORD _RpcSetInterface( 218 WLANSVC_RPC_HANDLE hClientHandle, 219 const GUID *pInterfaceGuid, 220 DWORD OpCode, 221 DWORD dwDataSize, 222 LPBYTE pData) 223 { 224 UNIMPLEMENTED; 225 return ERROR_CALL_NOT_IMPLEMENTED; 226 } 227 228 DWORD _RpcQueryInterface( 229 WLANSVC_RPC_HANDLE hClientHandle, 230 const GUID *pInterfaceGuid, 231 long OpCode, 232 LPDWORD pdwDataSize, 233 LPBYTE *ppData, 234 LPDWORD pWlanOpcodeValueType) 235 { 236 UNIMPLEMENTED; 237 return ERROR_CALL_NOT_IMPLEMENTED; 238 } 239 240 DWORD _RpcIhvControl( 241 WLANSVC_RPC_HANDLE hClientHandle, 242 const GUID *pInterfaceGuid, 243 DWORD Type, 244 DWORD dwInBufferSize, 245 LPBYTE pInBuffer, 246 DWORD dwOutBufferSize, 247 LPBYTE pOutBuffer, 248 LPDWORD pdwBytesReturned) 249 { 250 UNIMPLEMENTED; 251 return ERROR_CALL_NOT_IMPLEMENTED; 252 } 253 254 DWORD _RpcScan( 255 WLANSVC_RPC_HANDLE hClientHandle, 256 const GUID *pInterfaceGuid, 257 PDOT11_SSID pDot11Ssid, 258 PWLAN_RAW_DATA pIeData) 259 { 260 PWLANSVCHANDLE lpWlanSvcHandle; 261 262 lpWlanSvcHandle = WlanSvcGetHandleEntry(hClientHandle); 263 if (!lpWlanSvcHandle) 264 { 265 return ERROR_INVALID_HANDLE; 266 } 267 268 /* 269 DWORD dwBytesReturned; 270 HANDLE hDevice; 271 ULONG OidCode = OID_802_11_BSSID_LIST_SCAN; 272 PNDIS_802_11_BSSID_LIST pBssIDList; 273 274 DeviceIoControl(hDevice, 275 IOCTL_NDIS_QUERY_GLOBAL_STATS, 276 &OidCode, 277 sizeof(ULONG), 278 NULL, 279 0, 280 &dwBytesReturned, 281 NULL); 282 */ 283 UNIMPLEMENTED; 284 return ERROR_CALL_NOT_IMPLEMENTED; 285 } 286 287 DWORD _RpcGetAvailableNetworkList( 288 WLANSVC_RPC_HANDLE hClientHandle, 289 const GUID *pInterfaceGuid, 290 DWORD dwFlags, 291 WLAN_AVAILABLE_NETWORK_LIST **ppAvailableNetworkList) 292 { 293 UNIMPLEMENTED; 294 return ERROR_CALL_NOT_IMPLEMENTED; 295 } 296 297 DWORD _RpcGetNetworkBssList( 298 WLANSVC_RPC_HANDLE hClientHandle, 299 const GUID *pInterfaceGuid, 300 PDOT11_SSID pDot11Ssid, 301 short dot11BssType, 302 DWORD bSecurityEnabled, 303 LPDWORD dwBssListSize, 304 LPBYTE *ppWlanBssList) 305 { 306 UNIMPLEMENTED; 307 return ERROR_CALL_NOT_IMPLEMENTED; 308 } 309 310 DWORD _RpcConnect( 311 WLANSVC_RPC_HANDLE hClientHandle, 312 const GUID *pInterfaceGuid, 313 const PWLAN_CONNECTION_PARAMETERS *pConnectionParameters) 314 { 315 UNIMPLEMENTED; 316 return ERROR_CALL_NOT_IMPLEMENTED; 317 } 318 319 DWORD _RpcDisconnect( 320 WLANSVC_RPC_HANDLE hClientHandle, 321 const GUID *pInterfaceGUID) 322 { 323 UNIMPLEMENTED; 324 return ERROR_CALL_NOT_IMPLEMENTED; 325 } 326 327 DWORD _RpcRegisterNotification( 328 WLANSVC_RPC_HANDLE hClientHandle, 329 DWORD arg_2, 330 LPDWORD pdwPrevNotifSource) 331 { 332 UNIMPLEMENTED; 333 return ERROR_CALL_NOT_IMPLEMENTED; 334 } 335 336 DWORD _RpcAsyncGetNotification( 337 WLANSVC_RPC_HANDLE hClientHandle, 338 PWLAN_NOTIFICATION_DATA *NotificationData) 339 { 340 UNIMPLEMENTED; 341 return ERROR_CALL_NOT_IMPLEMENTED; 342 } 343 344 DWORD _RpcSetProfileEapUserData( 345 WLANSVC_RPC_HANDLE hClientHandle, 346 const GUID *pInterfaceGuid, 347 wchar_t *strProfileName, 348 EAP_METHOD_TYPE MethodType, 349 DWORD dwFlags, 350 DWORD dwEapUserDataSize, 351 LPBYTE pbEapUserData) 352 { 353 UNIMPLEMENTED; 354 return ERROR_CALL_NOT_IMPLEMENTED; 355 } 356 357 DWORD _RpcSetProfile( 358 WLANSVC_RPC_HANDLE hClientHandle, 359 const GUID *pInterfaceGuid, 360 DWORD dwFlags, 361 wchar_t *strProfileXml, 362 wchar_t *strAllUserProfileSecurity, 363 BOOL bOverwrite, 364 LPDWORD pdwReasonCode) 365 { 366 UNIMPLEMENTED; 367 return ERROR_CALL_NOT_IMPLEMENTED; 368 } 369 370 DWORD _RpcGetProfile( 371 WLANSVC_RPC_HANDLE hClientHandle, 372 const GUID *pInterfaceGuid, 373 wchar_t *strProfileName, 374 wchar_t **pstrProfileXml, 375 LPDWORD pdwFlags, 376 LPDWORD pdwGrantedAccess) 377 { 378 UNIMPLEMENTED; 379 return ERROR_CALL_NOT_IMPLEMENTED; 380 } 381 382 DWORD _RpcDeleteProfile( 383 WLANSVC_RPC_HANDLE hClientHandle, 384 const GUID *pInterfaceGuid, 385 const wchar_t *strProfileName) 386 { 387 UNIMPLEMENTED; 388 return ERROR_CALL_NOT_IMPLEMENTED; 389 } 390 391 DWORD _RpcRenameProfile( 392 WLANSVC_RPC_HANDLE hClientHandle, 393 const GUID *pInterfaceGuid, 394 const wchar_t *strOldProfileName, 395 const wchar_t *strNewProfileName) 396 { 397 UNIMPLEMENTED; 398 return ERROR_CALL_NOT_IMPLEMENTED; 399 } 400 401 DWORD _RpcSetProfileList( 402 WLANSVC_RPC_HANDLE hClientHandle, 403 const GUID *pInterfaceGuid, 404 DWORD dwItems, 405 BYTE **strProfileNames) 406 { 407 UNIMPLEMENTED; 408 return ERROR_CALL_NOT_IMPLEMENTED; 409 } 410 411 DWORD _RpcGetProfileList( 412 WLANSVC_RPC_HANDLE hClientHandle, 413 const GUID *pInterfaceGuid, 414 PWLAN_PROFILE_INFO_LIST *ppProfileList) 415 { 416 UNIMPLEMENTED; 417 return ERROR_CALL_NOT_IMPLEMENTED; 418 } 419 420 DWORD _RpcSetProfilePosition( 421 WLANSVC_RPC_HANDLE hClientHandle, 422 const GUID *pInterfaceGuid, 423 wchar_t *strProfileName, 424 DWORD dwPosition) 425 { 426 UNIMPLEMENTED; 427 return ERROR_CALL_NOT_IMPLEMENTED; 428 } 429 430 DWORD _RpcSetProfileCustomUserData( 431 WLANSVC_RPC_HANDLE hClientHandle, 432 const GUID *pInterfaceGuid, 433 wchar_t *strProfileName, 434 DWORD dwDataSize, 435 LPBYTE pData) 436 { 437 UNIMPLEMENTED; 438 return ERROR_CALL_NOT_IMPLEMENTED; 439 } 440 441 DWORD _RpcGetProfileCustomUserData( 442 WLANSVC_RPC_HANDLE hClientHandle, 443 const GUID *pInterfaceGuid, 444 wchar_t *strProfileName, 445 LPDWORD dwDataSize, 446 LPBYTE *pData) 447 { 448 UNIMPLEMENTED; 449 return ERROR_CALL_NOT_IMPLEMENTED; 450 } 451 452 DWORD _RpcSetFilterList( 453 WLANSVC_RPC_HANDLE hClientHandle, 454 short wlanFilterListType, 455 PDOT11_NETWORK_LIST pNetworkList) 456 { 457 UNIMPLEMENTED; 458 return ERROR_CALL_NOT_IMPLEMENTED; 459 } 460 461 DWORD _RpcGetFilterList( 462 WLANSVC_RPC_HANDLE hClientHandle, 463 short wlanFilterListType, 464 PDOT11_NETWORK_LIST *pNetworkList) 465 { 466 UNIMPLEMENTED; 467 return ERROR_CALL_NOT_IMPLEMENTED; 468 } 469 470 DWORD _RpcSetPsdIEDataList( 471 WLANSVC_RPC_HANDLE hClientHandle, 472 wchar_t *strFormat, 473 DWORD dwDataListSize, 474 LPBYTE pPsdIEDataList) 475 { 476 UNIMPLEMENTED; 477 return ERROR_CALL_NOT_IMPLEMENTED; 478 } 479 480 DWORD _RpcSaveTemporaryProfile( 481 WLANSVC_RPC_HANDLE hClientHandle, 482 const GUID *pInterfaceGuid, 483 wchar_t *strProfileName, 484 wchar_t *strAllUserProfileSecurity, 485 DWORD dwFlags, 486 BOOL bOverWrite) 487 { 488 UNIMPLEMENTED; 489 return ERROR_CALL_NOT_IMPLEMENTED; 490 } 491 492 DWORD _RpcIsUIRequestPending( 493 wchar_t *arg_1, 494 const GUID *pInterfaceGuid, 495 struct_C *arg_3, 496 LPDWORD arg_4) 497 { 498 UNIMPLEMENTED; 499 return ERROR_CALL_NOT_IMPLEMENTED; 500 } 501 502 DWORD _RpcSetUIForwardingNetworkList( 503 wchar_t *arg_1, 504 GUID *arg_2, 505 DWORD dwSize, 506 GUID *arg_4) 507 { 508 UNIMPLEMENTED; 509 return ERROR_CALL_NOT_IMPLEMENTED; 510 } 511 512 DWORD _RpcIsNetworkSuppressed( 513 wchar_t *arg_1, 514 DWORD arg_2, 515 const GUID *pInterfaceGuid, 516 LPDWORD arg_4) 517 { 518 UNIMPLEMENTED; 519 return ERROR_CALL_NOT_IMPLEMENTED; 520 } 521 522 DWORD _RpcRemoveUIForwardingNetworkList( 523 wchar_t *arg_1, 524 const GUID *pInterfaceGuid) 525 { 526 UNIMPLEMENTED; 527 return ERROR_CALL_NOT_IMPLEMENTED; 528 } 529 530 DWORD _RpcQueryExtUIRequest( 531 wchar_t *arg_1, 532 GUID *arg_2, 533 GUID *arg_3, 534 short arg_4, 535 GUID *pInterfaceGuid, 536 struct_C **arg_6) 537 { 538 UNIMPLEMENTED; 539 return ERROR_CALL_NOT_IMPLEMENTED; 540 } 541 542 DWORD _RpcUIResponse( 543 wchar_t *arg_1, 544 struct_C *arg_2, 545 struct_D *arg_3) 546 { 547 UNIMPLEMENTED; 548 return ERROR_CALL_NOT_IMPLEMENTED; 549 } 550 551 DWORD _RpcGetProfileKeyInfo( 552 wchar_t *arg_1, 553 DWORD arg_2, 554 const GUID *pInterfaceGuid, 555 wchar_t *arg_4, 556 DWORD arg_5, 557 LPDWORD arg_6, 558 char *arg_7, 559 LPDWORD arg_8) 560 { 561 UNIMPLEMENTED; 562 return ERROR_CALL_NOT_IMPLEMENTED; 563 } 564 565 DWORD _RpcAsyncDoPlap( 566 wchar_t *arg_1, 567 const GUID *pInterfaceGuid, 568 wchar_t *arg_3, 569 DWORD dwSize, 570 struct_E arg_5[]) 571 { 572 UNIMPLEMENTED; 573 return ERROR_CALL_NOT_IMPLEMENTED; 574 } 575 576 DWORD _RpcQueryPlapCredentials( 577 wchar_t *arg_1, 578 LPDWORD dwSize, 579 struct_E **arg_3, 580 wchar_t **arg_4, 581 GUID *pInterfaceGuid, 582 LPDWORD arg_6, 583 LPDWORD arg_7, 584 LPDWORD arg_8, 585 LPDWORD arg_9) 586 { 587 UNIMPLEMENTED; 588 return ERROR_CALL_NOT_IMPLEMENTED; 589 } 590 591 DWORD _RpcCancelPlap( 592 wchar_t *arg_1, 593 const GUID *pInterfaceGuid) 594 { 595 UNIMPLEMENTED; 596 return ERROR_CALL_NOT_IMPLEMENTED; 597 } 598 599 DWORD _RpcSetSecuritySettings( 600 WLANSVC_RPC_HANDLE hClientHandle, 601 WLAN_SECURABLE_OBJECT SecurableObject, 602 const wchar_t *strModifiedSDDL) 603 { 604 UNIMPLEMENTED; 605 return ERROR_CALL_NOT_IMPLEMENTED; 606 } 607 608 DWORD _RpcGetSecuritySettings( 609 WLANSVC_RPC_HANDLE hClientHandle, 610 WLAN_SECURABLE_OBJECT SecurableObject, 611 WLAN_OPCODE_VALUE_TYPE *pValueType, 612 wchar_t **pstrCurrentSDDL, 613 LPDWORD pdwGrantedAccess) 614 { 615 UNIMPLEMENTED; 616 return ERROR_CALL_NOT_IMPLEMENTED; 617 } 618 619 void __RPC_FAR * __RPC_USER midl_user_allocate(SIZE_T len) 620 { 621 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len); 622 } 623 624 625 void __RPC_USER midl_user_free(void __RPC_FAR * ptr) 626 { 627 HeapFree(GetProcessHeap(), 0, ptr); 628 } 629 630 631 void __RPC_USER WLANSVC_RPC_HANDLE_rundown(WLANSVC_RPC_HANDLE hClientHandle) 632 { 633 } 634 635