Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4744 lines
123 KiB

  1. /*++
  2. Copyright (C) 1992-98 Microsft Corporation. All rights reserved.
  3. Module Name:
  4. dlparams.c
  5. Abstract:
  6. Contains the code for submitting rpc request to the
  7. rasman service
  8. Author:
  9. Gurdeep Singh Pall (gurdeep) 06-Jun-1997
  10. Revision History:
  11. Miscellaneous Modifications - raos 31-Dec-1997
  12. --*/
  13. #include <nt.h>
  14. #include <ntrtl.h>
  15. #include <nturtl.h>
  16. #include <rasman.h>
  17. #include <wanpub.h>
  18. #include <ntlsa.h>
  19. #include <ntmsv1_0.h>
  20. #include <raserror.h>
  21. #include <rasppp.h>
  22. #include <media.h>
  23. #include <devioctl.h>
  24. #include <stdio.h>
  25. #include <stdarg.h>
  26. #include <stdlib.h>
  27. #include <string.h>
  28. #include "defs.h"
  29. #include "structs.h"
  30. #include "protos.h"
  31. #include "globals.h"
  32. #include "ras.h" // for RAS_STATS structure
  33. #include "rasapip.h"
  34. DWORD
  35. AllocateBuffer(DWORD dwSize,
  36. PBYTE *ppbuf,
  37. PDWORD pdwSizeofBuffer)
  38. {
  39. DWORD retcode = SUCCESS;
  40. DWORD dwSizeRequired;
  41. *ppbuf = NULL;
  42. dwSizeRequired = dwSize +
  43. sizeof( RequestBuffer ) +
  44. sizeof (REQTYPECAST);
  45. if ( dwSizeRequired <= *pdwSizeofBuffer )
  46. {
  47. goto done;
  48. }
  49. *ppbuf = LocalAlloc(LPTR, dwSizeRequired);
  50. if ( NULL == *ppbuf )
  51. {
  52. retcode = GetLastError();
  53. goto done;
  54. }
  55. ((RequestBuffer *) *ppbuf)->RB_Dummy = sizeof(ULONG_PTR);
  56. *pdwSizeofBuffer = dwSizeRequired;
  57. done:
  58. return retcode;
  59. }
  60. /* SubmitRequest ()
  61. Function: This function submits the different types
  62. of requests and waits for their completion.
  63. Since the different requests require different
  64. number of arguments and require different
  65. information to be passed to and from the
  66. Requestor thread - case statements are
  67. used to send and retrieve information in
  68. the request buffer.
  69. Returns: Error codes returned by the request.
  70. */
  71. DWORD _cdecl
  72. SubmitRequest (HANDLE hConnection, WORD reqtype, ...)
  73. {
  74. RequestBuffer *preqbuf ;
  75. DWORD retcode ;
  76. DWORD i ;
  77. va_list ap ;
  78. RequestBuffer *pBuffer = NULL;
  79. DWORD *pdwSize;
  80. DWORD *pdwEntries;
  81. DWORD dwSizeofBuffer = sizeof ( RequestBuffer )
  82. + REQUEST_BUFFER_SIZE;
  83. RequestBuffer *pbTemp;
  84. PBYTE pUserBuffer;
  85. PDWORD pdwVersion;
  86. PDWORD pdwMaskDialParams;
  87. PDWORD pdwFlags = 0;
  88. preqbuf = GetRequestBuffer();
  89. if (NULL == preqbuf)
  90. {
  91. //
  92. // couldn't get a req. buffer. can't do
  93. // much in this case. this can happen
  94. // if we are not able to initialize the
  95. // shared memory.
  96. //
  97. return GetLastError();
  98. }
  99. va_start (ap, reqtype) ;
  100. preqbuf->RB_Reqtype = reqtype;
  101. preqbuf->RB_Dummy = sizeof(ULONG_PTR);
  102. pbTemp = preqbuf;
  103. switch (reqtype)
  104. {
  105. case REQTYPE_DEVICEENUM:
  106. {
  107. PCHAR devicetype = va_arg( ap, PCHAR ) ;
  108. pdwSize = va_arg(ap, PDWORD );
  109. pUserBuffer = va_arg( ap, PBYTE );
  110. if ( NULL == pUserBuffer )
  111. {
  112. *pdwSize = 0;
  113. }
  114. if ( *pdwSize )
  115. {
  116. retcode = AllocateBuffer(*pdwSize,
  117. (PBYTE *) &pBuffer,
  118. &dwSizeofBuffer);
  119. if(retcode)
  120. { //
  121. // failed to allocate
  122. //
  123. goto done;
  124. }
  125. if (pBuffer)
  126. {
  127. pBuffer->RB_Reqtype = reqtype;
  128. pbTemp = pBuffer;
  129. }
  130. }
  131. else
  132. {
  133. pbTemp = preqbuf;
  134. }
  135. ((REQTYPECAST *) pbTemp->RB_Buffer )->DeviceEnum.dwsize
  136. = *pdwSize;
  137. memcpy (((REQTYPECAST *)
  138. pbTemp->RB_Buffer)->DeviceEnum.devicetype,
  139. devicetype,
  140. MAX_DEVICETYPE_NAME) ;
  141. }
  142. break ;
  143. case REQTYPE_DEVICECONNECT:
  144. {
  145. HPORT porthandle = va_arg(ap, HPORT);
  146. PCHAR devicetype = va_arg(ap, PCHAR);
  147. PCHAR devicename = va_arg(ap, PCHAR);
  148. DWORD timeout = va_arg(ap, DWORD);
  149. HANDLE handle = va_arg(ap, HANDLE);
  150. DWORD pid = va_arg(ap, DWORD);
  151. preqbuf->RB_PCBIndex = PtrToUlong( porthandle) ;
  152. strcpy(((REQTYPECAST *)
  153. preqbuf->RB_Buffer)->DeviceConnect.devicetype,
  154. devicetype) ;
  155. strcpy(((REQTYPECAST *)
  156. preqbuf->RB_Buffer)->DeviceConnect.devicename,
  157. devicename) ;
  158. ((REQTYPECAST *)
  159. preqbuf->RB_Buffer)->DeviceConnect.timeout = timeout;
  160. ((REQTYPECAST *)
  161. preqbuf->RB_Buffer)->DeviceConnect.handle = handle;
  162. ((REQTYPECAST *)
  163. preqbuf->RB_Buffer)->DeviceConnect.pid = pid;
  164. }
  165. break ;
  166. case REQTYPE_DEVICEGETINFO:
  167. {
  168. HPORT porthandle = va_arg(ap, HPORT) ;
  169. PCHAR devicetype = va_arg(ap, PCHAR) ;
  170. PCHAR devicename = va_arg(ap, PCHAR) ;
  171. pUserBuffer = va_arg( ap, PBYTE );
  172. pdwSize = va_arg( ap, PDWORD );
  173. if ( NULL == pUserBuffer )
  174. {
  175. *pdwSize = 0;
  176. }
  177. if ( *pdwSize )
  178. {
  179. retcode = AllocateBuffer(*pdwSize,
  180. (PBYTE *) &pBuffer,
  181. &dwSizeofBuffer);
  182. if(retcode)
  183. {
  184. goto done;
  185. }
  186. if(pBuffer)
  187. {
  188. pBuffer->RB_Reqtype = reqtype;
  189. pbTemp = pBuffer;
  190. }
  191. }
  192. else
  193. {
  194. pbTemp = preqbuf;
  195. }
  196. pbTemp->RB_PCBIndex = PtrToUlong( porthandle) ;
  197. ((REQTYPECAST *)
  198. pbTemp->RB_Buffer)->DeviceGetInfo.dwSize = (DWORD) *pdwSize;
  199. strcpy(((REQTYPECAST *)
  200. pbTemp->RB_Buffer)->DeviceGetInfo.devicetype,
  201. devicetype) ;
  202. strcpy(((REQTYPECAST *)
  203. pbTemp->RB_Buffer)->DeviceGetInfo.devicename,
  204. devicename) ;
  205. }
  206. break ;
  207. case REQTYPE_GETINFOEX:
  208. {
  209. ((REQTYPECAST *)
  210. preqbuf->RB_Buffer)->InfoEx.pid = GetCurrentProcessId();
  211. }
  212. break;
  213. case REQTYPE_PORTENUM:
  214. {
  215. pdwSize = va_arg ( ap, DWORD * );
  216. pUserBuffer = (PBYTE ) va_arg ( ap, PBYTE ) ;
  217. if ( NULL == pUserBuffer )
  218. {
  219. *pdwSize = 0;
  220. }
  221. if ( *pdwSize )
  222. {
  223. retcode = AllocateBuffer(*pdwSize,
  224. (PBYTE *) &pBuffer,
  225. &dwSizeofBuffer);
  226. if ( retcode )
  227. {
  228. goto done;
  229. }
  230. if ( pBuffer )
  231. {
  232. pBuffer->RB_Reqtype = reqtype;
  233. pbTemp = pBuffer;
  234. }
  235. }
  236. else
  237. {
  238. //
  239. // Use default buffer
  240. //
  241. pbTemp = preqbuf;
  242. }
  243. ((REQTYPECAST *)
  244. pbTemp->RB_Buffer)->Enum.size = *pdwSize;
  245. }
  246. break;
  247. case REQTYPE_ENUMCONNECTION:
  248. {
  249. pdwSize = va_arg ( ap, DWORD * );
  250. pUserBuffer = (PBYTE ) va_arg ( ap, HCONN * ) ;
  251. if ( NULL == pUserBuffer )
  252. {
  253. *pdwSize = 0;
  254. }
  255. if ( *pdwSize )
  256. {
  257. retcode = AllocateBuffer(*pdwSize,
  258. (PBYTE *) &pBuffer,
  259. &dwSizeofBuffer);
  260. if (retcode)
  261. {
  262. goto done;
  263. }
  264. if(pBuffer)
  265. {
  266. pBuffer->RB_Reqtype = reqtype;
  267. pbTemp = pBuffer;
  268. }
  269. }
  270. else
  271. {
  272. //
  273. // Use default buffer
  274. //
  275. pbTemp = preqbuf;
  276. }
  277. ((REQTYPECAST *)
  278. pbTemp->RB_Buffer)->Enum.size = *pdwSize;
  279. }
  280. break;
  281. case REQTYPE_PROTOCOLENUM:
  282. {
  283. pdwSize = va_arg ( ap, DWORD * );
  284. pUserBuffer = (PBYTE ) va_arg ( ap, PBYTE ) ;
  285. if ( NULL == pUserBuffer )
  286. {
  287. *pdwSize = 0;
  288. }
  289. if ( *pdwSize )
  290. {
  291. retcode = AllocateBuffer(*pdwSize,
  292. (PBYTE *) &pBuffer,
  293. &dwSizeofBuffer);
  294. if(retcode)
  295. {
  296. goto done;
  297. }
  298. if(pBuffer)
  299. {
  300. pBuffer->RB_Reqtype = reqtype;
  301. pbTemp = pBuffer;
  302. }
  303. }
  304. else
  305. {
  306. //
  307. // Use default buffer
  308. //
  309. pbTemp = preqbuf;
  310. }
  311. ((REQTYPECAST *)
  312. pbTemp->RB_Buffer)->Enum.size = *pdwSize;
  313. }
  314. break;
  315. case REQTYPE_ENUMLANNETS:
  316. case REQTYPE_GETATTACHEDCOUNT:
  317. break ;
  318. case REQTYPE_RETRIEVEUSERDATA:
  319. {
  320. HPORT porthandle = va_arg ( ap, HPORT );
  321. pUserBuffer = va_arg ( ap, PBYTE );
  322. pdwSize = va_arg ( ap, DWORD * );
  323. if ( NULL == pUserBuffer )
  324. {
  325. *pdwSize = 0;
  326. }
  327. if ( *pdwSize )
  328. {
  329. retcode = AllocateBuffer(*pdwSize,
  330. (PBYTE *) &pBuffer,
  331. &dwSizeofBuffer);
  332. if(retcode)
  333. {
  334. goto done;
  335. }
  336. if(pBuffer)
  337. {
  338. pBuffer->RB_Reqtype = reqtype;
  339. pbTemp = pBuffer;
  340. }
  341. }
  342. else
  343. {
  344. pbTemp = preqbuf;
  345. }
  346. ((REQTYPECAST *)
  347. pbTemp->RB_Buffer)->OldUserData.size = *pdwSize;
  348. pbTemp->RB_PCBIndex = PtrToUlong( porthandle);
  349. }
  350. break;
  351. case REQTYPE_PORTGETINFO:
  352. {
  353. HPORT porthandle = va_arg ( ap, HPORT );
  354. pUserBuffer = va_arg ( ap, PBYTE );
  355. pdwSize = va_arg( ap, PDWORD );
  356. if ( NULL == pUserBuffer )
  357. {
  358. *pdwSize = 0;
  359. }
  360. if ( *pdwSize )
  361. {
  362. retcode = AllocateBuffer(*pdwSize,
  363. (PBYTE *) &pBuffer,
  364. &dwSizeofBuffer);
  365. if(retcode)
  366. {
  367. goto done;
  368. }
  369. if(pBuffer)
  370. {
  371. pBuffer->RB_Reqtype = reqtype;
  372. pbTemp = pBuffer;
  373. }
  374. }
  375. else
  376. {
  377. pbTemp = preqbuf;
  378. }
  379. pbTemp->RB_PCBIndex = PtrToUlong( porthandle );
  380. ((REQTYPECAST *)
  381. pbTemp->RB_Buffer)->GetInfo.size = *pdwSize;
  382. }
  383. break;
  384. case REQTYPE_GETINFO:
  385. case REQTYPE_CANCELRECEIVE:
  386. case REQTYPE_PORTCLEARSTATISTICS:
  387. case REQTYPE_PORTGETSTATISTICS:
  388. case REQTYPE_BUNDLECLEARSTATISTICS:
  389. case REQTYPE_BUNDLEGETSTATISTICS:
  390. case REQTYPE_PORTGETSTATISTICSEX:
  391. case REQTYPE_BUNDLEGETSTATISTICSEX:
  392. case REQTYPE_COMPRESSIONGETINFO:
  393. case REQTYPE_PORTCONNECTCOMPLETE:
  394. case REQTYPE_PORTENUMPROTOCOLS:
  395. case REQTYPE_GETFRAMINGCAPABILITIES:
  396. case REQTYPE_GETFRAMINGEX:
  397. case REQTYPE_GETBUNDLEDPORT:
  398. case REQTYPE_PORTGETBUNDLE:
  399. case REQTYPE_PORTRECEIVEEX:
  400. case REQTYPE_PPPSTARTED:
  401. {
  402. HPORT porthandle = va_arg(ap, HPORT) ;
  403. preqbuf->RB_PCBIndex = PtrToUlong( porthandle );
  404. }
  405. break ;
  406. case REQTYPE_BUNDLEGETPORT:
  407. {
  408. HBUNDLE bundlehandle = va_arg(ap, HBUNDLE) ;
  409. ((REQTYPECAST *)
  410. preqbuf->RB_Buffer)->BundleGetPort.bundle = bundlehandle;
  411. }
  412. break ;
  413. case REQTYPE_PORTCLOSE:
  414. case REQTYPE_SERVERPORTCLOSE:
  415. {
  416. HPORT porthandle = va_arg(ap, HPORT) ;
  417. DWORD pid = va_arg(ap, DWORD) ;
  418. DWORD close = va_arg(ap, DWORD) ;
  419. preqbuf->RB_PCBIndex = PtrToUlong( porthandle );
  420. ((REQTYPECAST *)
  421. preqbuf->RB_Buffer)->PortClose.pid = pid;
  422. ((REQTYPECAST *)
  423. preqbuf->RB_Buffer)->PortClose.close = close ;
  424. }
  425. break ;
  426. case REQTYPE_REQUESTNOTIFICATION:
  427. {
  428. HPORT porthandle = va_arg(ap, HPORT) ;
  429. HANDLE handle = va_arg(ap, HANDLE) ;
  430. DWORD pid = va_arg(ap, DWORD) ;
  431. preqbuf->RB_PCBIndex = PtrToUlong( porthandle );
  432. ((REQTYPECAST *)
  433. preqbuf->RB_Buffer)->ReqNotification.handle = handle;
  434. ((REQTYPECAST *)
  435. preqbuf->RB_Buffer)->ReqNotification.pid = pid;
  436. }
  437. break ;
  438. case REQTYPE_PORTLISTEN:
  439. {
  440. HPORT porthandle = va_arg(ap, HPORT) ;
  441. DWORD timeout = va_arg(ap, DWORD) ;
  442. HANDLE handle = va_arg(ap, HANDLE) ;
  443. DWORD pid = va_arg(ap, DWORD) ;
  444. preqbuf->RB_PCBIndex = PtrToUlong( porthandle );
  445. ((REQTYPECAST *)
  446. preqbuf->RB_Buffer)->PortListen.timeout = timeout;
  447. ((REQTYPECAST *)
  448. preqbuf->RB_Buffer)->PortListen.handle = handle;
  449. ((REQTYPECAST *)
  450. preqbuf->RB_Buffer)->PortListen.pid = pid ;
  451. }
  452. break ;
  453. case REQTYPE_PORTSETINFO:
  454. {
  455. HPORT porthandle = va_arg(ap, HPORT) ;
  456. RASMAN_PORTINFO *info = va_arg(ap, RASMAN_PORTINFO *) ;
  457. preqbuf->RB_PCBIndex = PtrToUlong( porthandle );
  458. ((REQTYPECAST*)
  459. preqbuf->RB_Buffer)->PortSetInfo.info.PI_NumOfParams =
  460. info->PI_NumOfParams ;
  461. CopyParams (
  462. info->PI_Params,
  463. ((REQTYPECAST*)
  464. preqbuf->RB_Buffer)->PortSetInfo.info.PI_Params,
  465. info->PI_NumOfParams) ;
  466. }
  467. //
  468. // So that we don't get hit by the shared memory being mapped to
  469. // different addresses we convert pointers to offsets:
  470. //
  471. ConvParamPointerToOffset(
  472. ((REQTYPECAST*)
  473. preqbuf->RB_Buffer)->PortSetInfo.info.PI_Params,
  474. ((REQTYPECAST*)
  475. preqbuf->RB_Buffer)->PortSetInfo.info.PI_NumOfParams);
  476. break ;
  477. case REQTYPE_DEVICESETINFO:
  478. {
  479. HPORT porthandle = va_arg(ap, HPORT) ;
  480. PCHAR devicetype = va_arg(ap, PCHAR) ;
  481. PCHAR devicename = va_arg(ap, PCHAR) ;
  482. RASMAN_DEVICEINFO* info = va_arg(ap, RASMAN_DEVICEINFO*) ;
  483. preqbuf->RB_PCBIndex = PtrToUlong( porthandle );
  484. strcpy(((REQTYPECAST *)
  485. preqbuf->RB_Buffer)->DeviceSetInfo.devicetype,
  486. devicetype) ;
  487. strcpy(((REQTYPECAST *)
  488. preqbuf->RB_Buffer)->DeviceSetInfo.devicename,
  489. devicename) ;
  490. ((REQTYPECAST*)
  491. preqbuf->RB_Buffer)->DeviceSetInfo.info.DI_NumOfParams =
  492. info->DI_NumOfParams ;
  493. CopyParams (
  494. info->DI_Params,
  495. ((REQTYPECAST*)
  496. preqbuf->RB_Buffer)->DeviceSetInfo.info.DI_Params,
  497. info->DI_NumOfParams) ;
  498. }
  499. //
  500. // So that we don't get hit by the shared memory being mapped to
  501. // different addresses we convert pointers to offsets:
  502. //
  503. ConvParamPointerToOffset(
  504. ((REQTYPECAST*)
  505. preqbuf->RB_Buffer)->DeviceSetInfo.info.DI_Params,
  506. ((REQTYPECAST*)
  507. preqbuf->RB_Buffer)->DeviceSetInfo.info.DI_NumOfParams) ;
  508. break ;
  509. case REQTYPE_PORTOPEN:
  510. {
  511. PCHAR portname = va_arg(ap, PCHAR) ;
  512. HANDLE notifier= va_arg(ap, HANDLE) ;
  513. DWORD pid = va_arg(ap, DWORD) ;
  514. DWORD open = va_arg(ap, DWORD) ;
  515. strcpy(
  516. ((REQTYPECAST *)
  517. preqbuf->RB_Buffer)->PortOpen.portname,
  518. portname);
  519. ((REQTYPECAST *)
  520. preqbuf->RB_Buffer)->PortOpen.notifier = notifier ;
  521. ((REQTYPECAST *)
  522. preqbuf->RB_Buffer)->PortOpen.PID = pid ;
  523. ((REQTYPECAST *)
  524. preqbuf->RB_Buffer)->PortOpen.open = open ;
  525. }
  526. break ;
  527. case REQTYPE_PORTOPENEX:
  528. {
  529. PCHAR pszDeviceName = va_arg(ap, PCHAR);
  530. DWORD dwCounter = va_arg(ap, DWORD);
  531. HANDLE hnotifier = va_arg(ap, HANDLE);
  532. DWORD pid = GetCurrentProcessId();
  533. DWORD dwOpen = va_arg(ap, DWORD);
  534. pdwFlags = va_arg(ap, DWORD *);
  535. strcpy(
  536. ((REQTYPECAST *)
  537. preqbuf->RB_Buffer)->PortOpenEx.szDeviceName,
  538. pszDeviceName);
  539. ((REQTYPECAST *)
  540. preqbuf->RB_Buffer)->PortOpenEx.dwDeviceLineCounter
  541. = dwCounter;
  542. ((REQTYPECAST *)
  543. preqbuf->RB_Buffer)->PortOpenEx.hnotifier = hnotifier;
  544. ((REQTYPECAST *)
  545. preqbuf->RB_Buffer)->PortOpenEx.pid = pid;
  546. ((REQTYPECAST *)
  547. preqbuf->RB_Buffer)->PortOpenEx.dwFlags = *pdwFlags;
  548. ((REQTYPECAST *)
  549. preqbuf->RB_Buffer)->PortOpenEx.dwOpen = dwOpen;
  550. ((REQTYPECAST *)
  551. preqbuf->RB_Buffer)->PortOpenEx.hnotifier = hnotifier;
  552. }
  553. break;
  554. case REQTYPE_PORTDISCONNECT:
  555. {
  556. HPORT porthandle = va_arg(ap, HPORT) ;
  557. HANDLE handle = va_arg(ap, HANDLE) ;
  558. DWORD pid = va_arg(ap, DWORD) ;
  559. preqbuf->RB_PCBIndex = PtrToUlong( porthandle );
  560. ((REQTYPECAST *)
  561. preqbuf->RB_Buffer)->PortDisconnect.handle = handle;
  562. ((REQTYPECAST *)
  563. preqbuf->RB_Buffer)->PortDisconnect.pid = pid;
  564. }
  565. break ;
  566. case REQTYPE_PORTSEND:
  567. {
  568. HPORT porthandle = va_arg(ap, HPORT) ;
  569. SendRcvBuffer *pbuffer = va_arg(ap, SendRcvBuffer *) ;
  570. DWORD size = va_arg(ap, DWORD) ;
  571. preqbuf->RB_PCBIndex = PtrToUlong( porthandle );
  572. ((REQTYPECAST *)
  573. preqbuf->RB_Buffer)->PortSend.size = size;
  574. memcpy (&(( (REQTYPECAST *)
  575. preqbuf->RB_Buffer)->PortSend.buffer),
  576. pbuffer,
  577. sizeof ( SendRcvBuffer ) );
  578. }
  579. break ;
  580. case REQTYPE_PORTRECEIVE:
  581. {
  582. HPORT porthandle = va_arg(ap, HPORT) ;
  583. SendRcvBuffer *pSendRcvBuffer = va_arg(ap, SendRcvBuffer *) ;
  584. PDWORD size = va_arg(ap, PDWORD) ;
  585. DWORD timeout = va_arg(ap, DWORD) ;
  586. HANDLE handle = va_arg(ap, HANDLE) ;
  587. DWORD pid = va_arg(ap, DWORD) ;
  588. preqbuf->RB_PCBIndex = PtrToUlong( porthandle );
  589. ((REQTYPECAST *)
  590. preqbuf->RB_Buffer)->PortReceive.size = *size;
  591. ((REQTYPECAST *)
  592. preqbuf->RB_Buffer)->PortReceive.handle = handle;
  593. ((REQTYPECAST *)
  594. preqbuf->RB_Buffer)->PortReceive.pid = pid;
  595. ((REQTYPECAST *)
  596. preqbuf->RB_Buffer)->PortReceive.timeout = timeout;
  597. ((REQTYPECAST *)
  598. preqbuf->RB_Buffer)->PortReceive.buffer = pSendRcvBuffer;
  599. }
  600. break ;
  601. case REQTYPE_ALLOCATEROUTE:
  602. {
  603. HPORT porthandle = va_arg(ap, HPORT) ;
  604. RAS_PROTOCOLTYPE type = va_arg(ap, RAS_PROTOCOLTYPE) ;
  605. BOOL wrknet = va_arg(ap, BOOL) ;
  606. preqbuf->RB_PCBIndex = PtrToUlong( porthandle );
  607. ((REQTYPECAST *)
  608. preqbuf->RB_Buffer)->AllocateRoute.type = type ;
  609. ((REQTYPECAST *)
  610. preqbuf->RB_Buffer)->AllocateRoute.wrknet = wrknet ;
  611. }
  612. break ;
  613. case REQTYPE_DEALLOCATEROUTE:
  614. {
  615. HBUNDLE hbundle = va_arg(ap, HBUNDLE) ;
  616. RAS_PROTOCOLTYPE type = va_arg(ap, RAS_PROTOCOLTYPE) ;
  617. ((REQTYPECAST *)
  618. preqbuf->RB_Buffer)->DeAllocateRoute.hbundle =
  619. hbundle;
  620. ((REQTYPECAST *)
  621. preqbuf->RB_Buffer)->DeAllocateRoute.type = type ;
  622. }
  623. break ;
  624. case REQTYPE_ACTIVATEROUTE:
  625. {
  626. HPORT porthandle = va_arg(ap, HPORT) ;
  627. RAS_PROTOCOLTYPE type = va_arg(ap, RAS_PROTOCOLTYPE) ;
  628. PROTOCOL_CONFIG_INFO *config = va_arg(ap,
  629. PROTOCOL_CONFIG_INFO*) ;
  630. preqbuf->RB_PCBIndex = PtrToUlong( porthandle );
  631. ((REQTYPECAST *)
  632. preqbuf->RB_Buffer)->ActivateRoute.type = type ;
  633. memcpy (
  634. &((REQTYPECAST *)
  635. preqbuf->RB_Buffer)->ActivateRoute.config.P_Info,
  636. config->P_Info,
  637. config->P_Length) ;
  638. ((REQTYPECAST *)
  639. preqbuf->RB_Buffer)->ActivateRoute.config.P_Length =
  640. config->P_Length ;
  641. }
  642. break ;
  643. case REQTYPE_ACTIVATEROUTEEX:
  644. {
  645. HPORT porthandle = va_arg(ap, HPORT) ;
  646. RAS_PROTOCOLTYPE type = va_arg(ap, RAS_PROTOCOLTYPE) ;
  647. DWORD framesize = va_arg(ap, DWORD) ;
  648. PROTOCOL_CONFIG_INFO *config = va_arg(ap,
  649. PROTOCOL_CONFIG_INFO*) ;
  650. preqbuf->RB_PCBIndex = PtrToUlong( porthandle );
  651. ((REQTYPECAST *)
  652. preqbuf->RB_Buffer)->ActivateRouteEx.type = type ;
  653. ((REQTYPECAST *)
  654. preqbuf->RB_Buffer)->ActivateRouteEx.framesize = framesize ;
  655. memcpy (
  656. &((REQTYPECAST *)
  657. preqbuf->RB_Buffer)->ActivateRouteEx.config.P_Info,
  658. config->P_Info,
  659. config->P_Length) ;
  660. ((REQTYPECAST *)
  661. preqbuf->RB_Buffer)->ActivateRouteEx.config.P_Length =
  662. config->P_Length ;
  663. }
  664. break ;
  665. case REQTYPE_COMPRESSIONSETINFO:
  666. {
  667. HPORT porthandle = va_arg(ap, HPORT) ;
  668. RAS_COMPRESSION_INFO *send = va_arg(ap, RAS_COMPRESSION_INFO *) ;
  669. RAS_COMPRESSION_INFO *recv = va_arg(ap, RAS_COMPRESSION_INFO *) ;
  670. preqbuf->RB_PCBIndex = PtrToUlong( porthandle );
  671. memcpy (&((REQTYPECAST *)
  672. preqbuf->RB_Buffer)->CompressionSetInfo.send,
  673. send,
  674. sizeof (RAS_COMPRESSION_INFO)) ;
  675. memcpy (&((REQTYPECAST *)
  676. preqbuf->RB_Buffer)->CompressionSetInfo.recv,
  677. recv,
  678. sizeof (RAS_COMPRESSION_INFO)) ;
  679. }
  680. break ;
  681. case REQTYPE_GETUSERCREDENTIALS:
  682. {
  683. PBYTE pChallenge = va_arg(ap, PBYTE) ;
  684. PLUID LogonId = va_arg(ap, PLUID) ;
  685. memcpy (((REQTYPECAST*)
  686. preqbuf->RB_Buffer)->GetCredentials.Challenge,
  687. pChallenge,
  688. MAX_CHALLENGE_SIZE) ;
  689. ((REQTYPECAST *)
  690. preqbuf->RB_Buffer)->GetCredentials.LogonId = *LogonId;
  691. }
  692. break ;
  693. case REQTYPE_SETCACHEDCREDENTIALS:
  694. {
  695. PCHAR Account = va_arg( ap, PCHAR );
  696. PCHAR Domain = va_arg( ap, PCHAR );
  697. PCHAR NewPassword = va_arg( ap, PCHAR );
  698. strcpy(
  699. ((REQTYPECAST* )
  700. preqbuf->RB_Buffer)->SetCachedCredentials.Account,
  701. Account );
  702. strcpy(
  703. ((REQTYPECAST* )
  704. preqbuf->RB_Buffer)->SetCachedCredentials.Domain,
  705. Domain );
  706. strcpy(
  707. ((REQTYPECAST* )
  708. preqbuf->RB_Buffer)->SetCachedCredentials.NewPassword,
  709. NewPassword );
  710. }
  711. break;
  712. case REQTYPE_SETFRAMING:
  713. {
  714. HPORT porthandle = va_arg(ap, HPORT) ;
  715. DWORD SendFeatureBits = va_arg(ap, DWORD) ;
  716. DWORD RecvFeatureBits = va_arg(ap, DWORD) ;
  717. DWORD SendBitMask = va_arg(ap, DWORD) ;
  718. DWORD RecvBitMask = va_arg(ap, DWORD) ;
  719. preqbuf->RB_PCBIndex = PtrToUlong( porthandle );
  720. ((REQTYPECAST *)
  721. preqbuf->RB_Buffer)->SetFraming.Sendbits = SendFeatureBits ;
  722. ((REQTYPECAST *)
  723. preqbuf->RB_Buffer)->SetFraming.Recvbits = RecvFeatureBits ;
  724. ((REQTYPECAST *)
  725. preqbuf->RB_Buffer)->SetFraming.SendbitMask = SendBitMask ;
  726. ((REQTYPECAST *)
  727. preqbuf->RB_Buffer)->SetFraming.RecvbitMask = RecvBitMask ;
  728. }
  729. break ;
  730. case REQTYPE_SETFRAMINGEX:
  731. {
  732. HPORT porthandle = va_arg(ap, HPORT) ;
  733. RAS_FRAMING_INFO *info = va_arg(ap, RAS_FRAMING_INFO *) ;
  734. preqbuf->RB_PCBIndex = PtrToUlong( porthandle );
  735. memcpy (&((REQTYPECAST *)
  736. preqbuf->RB_Buffer)->FramingInfo.info,
  737. info,
  738. sizeof (RAS_FRAMING_INFO)) ;
  739. }
  740. break ;
  741. case REQTYPE_REGISTERSLIP:
  742. {
  743. HPORT porthandle = va_arg(ap, HPORT) ;
  744. DWORD ipaddr = va_arg(ap, DWORD) ;
  745. DWORD dwFrameSize = va_arg ( ap, DWORD ) ;
  746. BOOL priority = va_arg(ap, BOOL) ;
  747. WCHAR *pszDNSAddress = va_arg(ap, WCHAR*);
  748. WCHAR *pszDNS2Address = va_arg(ap, WCHAR*);
  749. WCHAR *pszWINSAddress = va_arg(ap, WCHAR*);
  750. WCHAR *pszWINS2Address = va_arg(ap, WCHAR*);
  751. preqbuf->RB_PCBIndex = PtrToUlong( porthandle );
  752. ((REQTYPECAST*)
  753. preqbuf->RB_Buffer)->RegisterSlip.dwFrameSize = dwFrameSize;
  754. ((REQTYPECAST *)
  755. preqbuf->RB_Buffer)->RegisterSlip.ipaddr = ipaddr ;
  756. ((REQTYPECAST *)
  757. preqbuf->RB_Buffer)->RegisterSlip.priority = priority ;
  758. if (pszDNSAddress != NULL)
  759. {
  760. memcpy (
  761. ((REQTYPECAST *)
  762. preqbuf->RB_Buffer)->RegisterSlip.szDNSAddress,
  763. pszDNSAddress,
  764. ( wcslen(pszDNSAddress) + 1 ) * sizeof (WCHAR)) ;
  765. }
  766. else
  767. {
  768. memset(
  769. ((REQTYPECAST *)
  770. preqbuf->RB_Buffer)->RegisterSlip.szDNSAddress,
  771. 0,
  772. 17 * sizeof (WCHAR));
  773. }
  774. if (pszDNS2Address != NULL)
  775. {
  776. memcpy (
  777. ((REQTYPECAST *)
  778. preqbuf->RB_Buffer)->RegisterSlip.szDNS2Address,
  779. pszDNS2Address,
  780. ( wcslen(pszDNS2Address) + 1 ) * sizeof (WCHAR)) ;
  781. }
  782. else
  783. {
  784. memset(
  785. ((REQTYPECAST *)
  786. preqbuf->RB_Buffer)->RegisterSlip.szDNS2Address,
  787. 0,
  788. 17 * sizeof (WCHAR));
  789. }
  790. if (pszWINSAddress != NULL)
  791. {
  792. memcpy (
  793. ((REQTYPECAST *)
  794. preqbuf->RB_Buffer)->RegisterSlip.szWINSAddress,
  795. pszWINSAddress,
  796. ( wcslen(pszWINSAddress) + 1 ) * sizeof (WCHAR)) ;
  797. }
  798. else
  799. {
  800. memset(
  801. ((REQTYPECAST *)
  802. preqbuf->RB_Buffer)->RegisterSlip.szWINSAddress,
  803. 0,
  804. 17 * sizeof (WCHAR));
  805. }
  806. if (pszWINS2Address != NULL)
  807. {
  808. memcpy (
  809. ((REQTYPECAST *)
  810. preqbuf->RB_Buffer)->RegisterSlip.szWINS2Address,
  811. pszWINS2Address,
  812. ( wcslen(pszWINS2Address) + 1 ) * sizeof (WCHAR)) ;
  813. }
  814. else
  815. {
  816. memset(
  817. ((REQTYPECAST *)
  818. preqbuf->RB_Buffer)->RegisterSlip.szWINS2Address,
  819. 0,
  820. 17 * sizeof (WCHAR));
  821. }
  822. }
  823. break ;
  824. case REQTYPE_GETPROTOCOLCOMPRESSION:
  825. {
  826. HPORT porthandle = va_arg(ap, HPORT) ;
  827. RAS_PROTOCOLTYPE type = va_arg(ap, RAS_PROTOCOLTYPE) ;
  828. preqbuf->RB_PCBIndex = PtrToUlong( porthandle );
  829. ((REQTYPECAST *)
  830. preqbuf->RB_Buffer)->ProtocolComp.type = type ;
  831. }
  832. break ;
  833. case REQTYPE_PORTBUNDLE:
  834. {
  835. HPORT porthandle = va_arg(ap, HPORT) ;
  836. HPORT porttobundle = va_arg(ap, HPORT) ;
  837. preqbuf->RB_PCBIndex = PtrToUlong( porthandle );
  838. ((REQTYPECAST *)
  839. preqbuf->RB_Buffer)->PortBundle.porttobundle = porttobundle ;
  840. }
  841. break ;
  842. case REQTYPE_SETPROTOCOLCOMPRESSION:
  843. {
  844. HPORT porthandle = va_arg(ap, HPORT) ;
  845. RAS_PROTOCOLTYPE type = va_arg(ap, RAS_PROTOCOLTYPE) ;
  846. RAS_PROTOCOLCOMPRESSION *send = va_arg(ap, RAS_PROTOCOLCOMPRESSION *) ;
  847. RAS_PROTOCOLCOMPRESSION *recv = va_arg(ap, RAS_PROTOCOLCOMPRESSION *) ;
  848. preqbuf->RB_PCBIndex = PtrToUlong( porthandle );
  849. ((REQTYPECAST *)
  850. preqbuf->RB_Buffer)->ProtocolComp.type = type ;
  851. memcpy (&((REQTYPECAST *)
  852. preqbuf->RB_Buffer)->ProtocolComp.send,
  853. send,
  854. sizeof (RAS_PROTOCOLCOMPRESSION)) ;
  855. memcpy (&((REQTYPECAST *)
  856. preqbuf->RB_Buffer)->ProtocolComp.recv,
  857. recv,
  858. sizeof (RAS_PROTOCOLCOMPRESSION)) ;
  859. }
  860. break ;
  861. case REQTYPE_STOREUSERDATA:
  862. {
  863. HPORT porthandle = va_arg(ap, HPORT) ;
  864. PBYTE data = va_arg(ap, PBYTE) ;
  865. DWORD size = va_arg(ap, DWORD) ;
  866. retcode = AllocateBuffer(size,
  867. (PBYTE *) &pBuffer,
  868. &dwSizeofBuffer);
  869. if (retcode)
  870. {
  871. goto done;
  872. }
  873. if(pBuffer)
  874. {
  875. pBuffer->RB_Reqtype = reqtype;
  876. pBuffer->RB_PCBIndex = PtrToUlong( porthandle );
  877. pbTemp = pBuffer;
  878. }
  879. ((REQTYPECAST *)
  880. pbTemp->RB_Buffer)->OldUserData.size = (size < 5000 ?
  881. size : 5000) ;
  882. memcpy (((REQTYPECAST *)
  883. pbTemp->RB_Buffer)->OldUserData.data,
  884. data,
  885. (size < 5000 ? size : 5000)) ; // max 5000 bytes copied
  886. }
  887. break ;
  888. case REQTYPE_SETATTACHCOUNT:
  889. {
  890. BOOL fAttach = va_arg(ap, BOOL);
  891. ((REQTYPECAST *)
  892. preqbuf->RB_Buffer)->AttachInfo.dwPid = GetCurrentProcessId();
  893. ((REQTYPECAST *)
  894. preqbuf->RB_Buffer)->AttachInfo.fAttach = fAttach;
  895. }
  896. break;
  897. case REQTYPE_GETDIALPARAMS:
  898. {
  899. DWORD dwUID = va_arg(ap, DWORD);
  900. pdwMaskDialParams = va_arg(ap, LPDWORD);
  901. dwSizeofBuffer = sizeof ( RequestBuffer )
  902. + sizeof( REQTYPECAST )
  903. + 5000 * sizeof( WCHAR );
  904. pBuffer = LocalAlloc( LPTR, dwSizeofBuffer );
  905. if ( NULL == pBuffer )
  906. {
  907. retcode = GetLastError();
  908. goto done;
  909. }
  910. pBuffer->RB_Reqtype = reqtype;
  911. pBuffer->RB_PCBIndex = 0;
  912. ((REQTYPECAST *)
  913. pBuffer->RB_Buffer)->DialParams.dwUID = dwUID;
  914. ((REQTYPECAST *)
  915. pBuffer->RB_Buffer)->DialParams.dwMask = *pdwMaskDialParams;
  916. ((REQTYPECAST *)
  917. pBuffer->RB_Buffer)->DialParams.dwPid = GetCurrentProcessId();
  918. GetUserSid(((REQTYPECAST *)
  919. pBuffer->RB_Buffer)->DialParams.sid,
  920. 5000);
  921. pbTemp = pBuffer;
  922. }
  923. break;
  924. case REQTYPE_SETDIALPARAMS:
  925. {
  926. DWORD dwUID = va_arg(ap, DWORD);
  927. DWORD dwMask = va_arg(ap, DWORD);
  928. PRAS_DIALPARAMS pDialParams = va_arg(ap, PRAS_DIALPARAMS);
  929. BOOL fDelete = va_arg(ap, BOOL);
  930. dwSizeofBuffer = sizeof ( RequestBuffer )
  931. + sizeof ( REQTYPECAST )
  932. + 5000 * sizeof ( WCHAR );
  933. pBuffer = LocalAlloc( LPTR, dwSizeofBuffer );
  934. if ( NULL == pBuffer )
  935. {
  936. retcode = GetLastError();
  937. goto done;
  938. }
  939. pBuffer->RB_PCBIndex = 0;
  940. pBuffer->RB_Reqtype = reqtype;
  941. ((REQTYPECAST *)
  942. pBuffer->RB_Buffer)->DialParams.dwUID = dwUID;
  943. ((REQTYPECAST *)
  944. pBuffer->RB_Buffer)->DialParams.dwMask = dwMask;
  945. ((REQTYPECAST *)
  946. pBuffer->RB_Buffer)->DialParams.dwPid = GetCurrentProcessId();
  947. if(NULL != pDialParams)
  948. {
  949. RtlCopyMemory(
  950. &(((REQTYPECAST *)
  951. pBuffer->RB_Buffer)->DialParams.params),
  952. pDialParams,
  953. sizeof (RAS_DIALPARAMS));
  954. }
  955. ((REQTYPECAST *)
  956. pBuffer->RB_Buffer)->DialParams.fDelete = fDelete;
  957. GetUserSid(((REQTYPECAST *)
  958. pBuffer->RB_Buffer)->DialParams.sid,
  959. 5000);
  960. pbTemp = pBuffer;
  961. }
  962. break;
  963. case REQTYPE_CREATECONNECTION:
  964. {
  965. DWORD pid = va_arg (ap, DWORD);
  966. DWORD dwSubEntries = va_arg (ap, DWORD );
  967. DWORD dwDialMode = va_arg (ap, DWORD );
  968. GUID *pGuidEntry = va_arg (ap, GUID *);
  969. CHAR *pszPhonebookPath = va_arg (ap, CHAR *);
  970. CHAR *pszEntryName = va_arg (ap, CHAR *);
  971. CHAR *pszRefPbkPath = va_arg (ap, CHAR *);
  972. CHAR *pszRefEntryName = va_arg (ap, CHAR *);
  973. retcode = AllocateBuffer(dwSubEntries * sizeof(DWORD),
  974. (PBYTE *) &pBuffer,
  975. &dwSizeofBuffer);
  976. if(retcode)
  977. {
  978. goto done;
  979. }
  980. if(pBuffer)
  981. {
  982. pBuffer->RB_Reqtype = reqtype;
  983. pBuffer->RB_PCBIndex = 0;
  984. pbTemp = pBuffer;
  985. }
  986. strcpy (((REQTYPECAST *)
  987. pbTemp->RB_Buffer)->Connection.szPhonebookPath,
  988. pszPhonebookPath);
  989. strcpy (((REQTYPECAST *)
  990. pbTemp->RB_Buffer)->Connection.szEntryName,
  991. pszEntryName);
  992. strcpy (((REQTYPECAST *)
  993. pbTemp->RB_Buffer)->Connection.szRefPbkPath,
  994. pszRefPbkPath);
  995. strcpy (((REQTYPECAST *)
  996. pbTemp->RB_Buffer)->Connection.szRefEntryName,
  997. pszRefEntryName);
  998. if(NULL != pGuidEntry)
  999. {
  1000. memcpy(&((REQTYPECAST *)
  1001. pbTemp->RB_Buffer)->Connection.guidEntry,
  1002. pGuidEntry,
  1003. sizeof(GUID));
  1004. }
  1005. ((REQTYPECAST *)
  1006. pbTemp->RB_Buffer)->Connection.dwSubEntries = dwSubEntries;
  1007. ((REQTYPECAST *)
  1008. pbTemp->RB_Buffer)->Connection.dwDialMode = dwDialMode;
  1009. ((REQTYPECAST *)pbTemp->RB_Buffer)->Connection.pid = pid;
  1010. }
  1011. break;
  1012. case REQTYPE_DESTROYCONNECTION:
  1013. {
  1014. HCONN conn = va_arg(ap, HCONN);
  1015. DWORD pid = va_arg(ap, DWORD);
  1016. ((REQTYPECAST *)preqbuf->RB_Buffer)->Connection.conn = conn;
  1017. ((REQTYPECAST *)preqbuf->RB_Buffer)->Connection.pid = pid;
  1018. }
  1019. break;
  1020. case REQTYPE_ENUMCONNECTIONPORTS:
  1021. {
  1022. HCONN conn = va_arg ( ap, HCONN );
  1023. pdwSize = va_arg ( ap, DWORD *);
  1024. pUserBuffer = (PBYTE ) va_arg ( ap, RASMAN_PORT *);
  1025. if ( NULL == pUserBuffer )
  1026. {
  1027. *pdwSize = 0;
  1028. }
  1029. if ( *pdwSize )
  1030. {
  1031. retcode = AllocateBuffer(*pdwSize,
  1032. (PBYTE *) &pBuffer,
  1033. &dwSizeofBuffer);
  1034. if(retcode)
  1035. {
  1036. goto done;
  1037. }
  1038. if(pBuffer)
  1039. {
  1040. pBuffer->RB_Reqtype = reqtype;
  1041. pbTemp = pBuffer;
  1042. }
  1043. }
  1044. else
  1045. {
  1046. pbTemp = preqbuf;
  1047. }
  1048. ((REQTYPECAST *)
  1049. pbTemp->RB_Buffer)->EnumConnectionPorts.conn = conn;
  1050. ((REQTYPECAST *)
  1051. pbTemp->RB_Buffer)->EnumConnectionPorts.size = *pdwSize;
  1052. }
  1053. break;
  1054. case REQTYPE_GETCONNECTIONPARAMS:
  1055. {
  1056. HCONN conn = va_arg(ap, HCONN);
  1057. ((REQTYPECAST *)preqbuf->RB_Buffer)->Connection.conn = conn;
  1058. }
  1059. break;
  1060. case REQTYPE_ADDCONNECTIONPORT:
  1061. {
  1062. HCONN conn = va_arg(ap, HCONN);
  1063. HPORT porthandle = va_arg(ap, HPORT);
  1064. DWORD dwSubEntry = va_arg(ap, DWORD);
  1065. preqbuf->RB_PCBIndex = PtrToUlong( porthandle );
  1066. ((REQTYPECAST *)
  1067. preqbuf->RB_Buffer)->AddConnectionPort.conn = conn;
  1068. ((REQTYPECAST *)
  1069. preqbuf->RB_Buffer)->AddConnectionPort.dwSubEntry = dwSubEntry;
  1070. }
  1071. break;
  1072. case REQTYPE_SETCONNECTIONPARAMS:
  1073. {
  1074. HCONN conn = va_arg(ap, HCONN) ;
  1075. PRAS_CONNECTIONPARAMS pParams = va_arg(ap, PRAS_CONNECTIONPARAMS);
  1076. ((REQTYPECAST *)
  1077. preqbuf->RB_Buffer)->ConnectionParams.conn = conn;
  1078. RtlCopyMemory(
  1079. &(((REQTYPECAST *)
  1080. preqbuf->RB_Buffer)->ConnectionParams.params),
  1081. pParams,
  1082. sizeof (RAS_CONNECTIONPARAMS));
  1083. }
  1084. break;
  1085. case REQTYPE_GETCONNECTIONUSERDATA:
  1086. {
  1087. HCONN conn = va_arg(ap, HCONN);
  1088. DWORD dwTag = va_arg(ap, DWORD);
  1089. pUserBuffer = va_arg ( ap, PBYTE );
  1090. pdwSize = va_arg ( ap, DWORD *);
  1091. if ( NULL == pUserBuffer )
  1092. {
  1093. *pdwSize = 0;
  1094. }
  1095. if ( *pdwSize )
  1096. {
  1097. retcode = AllocateBuffer(*pdwSize,
  1098. (PBYTE *) &pBuffer,
  1099. &dwSizeofBuffer);
  1100. if(retcode)
  1101. {
  1102. goto done;
  1103. }
  1104. if(pBuffer)
  1105. {
  1106. pBuffer->RB_Reqtype = reqtype;
  1107. pbTemp = pBuffer;
  1108. }
  1109. }
  1110. else
  1111. {
  1112. pbTemp = preqbuf;
  1113. }
  1114. ((REQTYPECAST *)
  1115. pbTemp->RB_Buffer)->ConnectionUserData.dwcb = *pdwSize;
  1116. ((REQTYPECAST *)
  1117. pbTemp->RB_Buffer)->ConnectionUserData.conn = conn;
  1118. ((REQTYPECAST *)
  1119. pbTemp->RB_Buffer)->ConnectionUserData.dwTag = dwTag;
  1120. }
  1121. break;
  1122. case REQTYPE_SETCONNECTIONUSERDATA:
  1123. {
  1124. HCONN conn = va_arg(ap, HCONN) ;
  1125. DWORD dwTag = va_arg(ap, DWORD);
  1126. PBYTE pBuf = va_arg(ap, PBYTE);
  1127. DWORD dwcb = va_arg(ap, DWORD);
  1128. ((REQTYPECAST *)
  1129. preqbuf->RB_Buffer)->ConnectionUserData.conn = conn;
  1130. ((REQTYPECAST *)
  1131. preqbuf->RB_Buffer)->ConnectionUserData.dwTag = dwTag;
  1132. dwcb = (dwcb < 5000 ? dwcb : 5000);
  1133. ((REQTYPECAST *)
  1134. preqbuf->RB_Buffer)->ConnectionUserData.dwcb = dwcb;
  1135. memcpy (
  1136. ((REQTYPECAST *)
  1137. preqbuf->RB_Buffer)->ConnectionUserData.data,
  1138. pBuf,
  1139. dwcb);
  1140. }
  1141. break;
  1142. case REQTYPE_GETPORTUSERDATA:
  1143. {
  1144. HPORT port = va_arg(ap, HPORT);
  1145. DWORD dwTag = va_arg(ap, DWORD);
  1146. pUserBuffer = va_arg ( ap, PBYTE );
  1147. pdwSize = va_arg ( ap, DWORD *);
  1148. if ( NULL == pUserBuffer )
  1149. {
  1150. *pdwSize = 0;
  1151. }
  1152. if ( *pdwSize )
  1153. {
  1154. retcode = AllocateBuffer(*pdwSize,
  1155. (PBYTE *) &pBuffer,
  1156. &dwSizeofBuffer);
  1157. if(retcode)
  1158. {
  1159. goto done;
  1160. }
  1161. if(pBuffer)
  1162. {
  1163. pBuffer->RB_Reqtype = reqtype;
  1164. pbTemp = pBuffer;
  1165. }
  1166. }
  1167. else
  1168. {
  1169. pbTemp = preqbuf;
  1170. }
  1171. pbTemp->RB_PCBIndex = PtrToUlong( port);
  1172. ((REQTYPECAST *)
  1173. pbTemp->RB_Buffer)->PortUserData.dwTag = dwTag;
  1174. ((REQTYPECAST *)
  1175. pbTemp->RB_Buffer)->PortUserData.dwcb = *pdwSize;
  1176. }
  1177. break;
  1178. case REQTYPE_SETPORTUSERDATA:
  1179. {
  1180. HPORT port = va_arg(ap, HPORT);
  1181. DWORD dwTag = va_arg(ap, DWORD);
  1182. PBYTE pBuf = va_arg(ap, PBYTE);
  1183. DWORD dwcb = va_arg(ap, DWORD);
  1184. if ( dwcb )
  1185. {
  1186. retcode = AllocateBuffer(dwcb,
  1187. (PBYTE *) &pBuffer,
  1188. &dwSizeofBuffer);
  1189. if(retcode)
  1190. {
  1191. goto done;
  1192. }
  1193. if(pBuffer)
  1194. {
  1195. pBuffer->RB_Reqtype = reqtype;
  1196. pbTemp = pBuffer;
  1197. }
  1198. }
  1199. else
  1200. {
  1201. pbTemp = preqbuf;
  1202. }
  1203. pbTemp->RB_PCBIndex = PtrToUlong( port);
  1204. ((REQTYPECAST *)
  1205. pbTemp->RB_Buffer)->PortUserData.dwTag = dwTag;
  1206. dwcb = (dwcb < 5000 ? dwcb : 5000);
  1207. ((REQTYPECAST *)
  1208. pbTemp->RB_Buffer)->PortUserData.dwcb = dwcb;
  1209. memcpy (
  1210. ((REQTYPECAST *)pbTemp->RB_Buffer)->PortUserData.data,
  1211. pBuf,
  1212. dwcb);
  1213. }
  1214. break;
  1215. case REQTYPE_PPPCALLBACK:
  1216. {
  1217. HPORT porthandle = va_arg(ap, HPORT) ;
  1218. CHAR * pszCallbackNumber = va_arg(ap, CHAR *) ;
  1219. preqbuf->RB_PCBIndex = PtrToUlong( porthandle );
  1220. ((REQTYPECAST *)preqbuf->RB_Buffer)->PppEMsg.dwMsgId =
  1221. PPPEMSG_Callback;
  1222. ((REQTYPECAST *)preqbuf->RB_Buffer)->PppEMsg.hPort =
  1223. porthandle;
  1224. strcpy(((REQTYPECAST *)
  1225. preqbuf->RB_Buffer)->PppEMsg.ExtraInfo.Callback.
  1226. szCallbackNumber,
  1227. pszCallbackNumber );
  1228. }
  1229. break;
  1230. case REQTYPE_PPPSTOP:
  1231. {
  1232. HPORT porthandle = va_arg(ap, HPORT) ;
  1233. preqbuf->RB_PCBIndex = PtrToUlong( porthandle );
  1234. ((REQTYPECAST *)
  1235. preqbuf->RB_Buffer)->PppEMsg.dwMsgId = PPPEMSG_Stop;
  1236. ((REQTYPECAST *)
  1237. preqbuf->RB_Buffer)->PppEMsg.hPort = porthandle;
  1238. }
  1239. break;
  1240. case REQTYPE_PPPSTART:
  1241. {
  1242. HPORT porthandle = va_arg(ap, HPORT) ;
  1243. CHAR * pszPortName = va_arg(ap, CHAR *) ;
  1244. CHAR * pszUserName = va_arg(ap, CHAR *) ;
  1245. CHAR * pszPassword = va_arg(ap, CHAR *) ;
  1246. CHAR * pszDomain = va_arg(ap, CHAR *) ;
  1247. LUID * pLuid = va_arg(ap, LUID *) ;
  1248. PPP_CONFIG_INFO* pConfigInfo = va_arg(ap, PPP_CONFIG_INFO *) ;
  1249. PPP_INTERFACE_INFO* pPppInterfaceInfo = va_arg(ap,
  1250. PPP_INTERFACE_INFO*);
  1251. CHAR * pszzParameters = va_arg(ap, CHAR *) ;
  1252. BOOL fThisIsACallback = va_arg(ap, BOOL) ;
  1253. HANDLE hEvent = va_arg(ap, HANDLE) ;
  1254. DWORD dwPid = va_arg(ap, DWORD) ;
  1255. DWORD dwAutoDisconnectTime = va_arg(ap, DWORD) ;
  1256. BOOL fRedialOnLinkFailure = va_arg(ap, BOOL);
  1257. PPP_BAPPARAMS *pBapParams = va_arg(ap, PPP_BAPPARAMS *);
  1258. BOOL fNonInteractive = va_arg(ap, BOOL);
  1259. DWORD dwEapTypeId = va_arg(ap, DWORD);
  1260. DWORD dwFlags = va_arg(ap, DWORD);
  1261. preqbuf->RB_PCBIndex = PtrToUlong( porthandle );
  1262. ((REQTYPECAST *)preqbuf->RB_Buffer)->PppEMsg.dwMsgId =
  1263. PPPEMSG_Start;
  1264. ((REQTYPECAST *)preqbuf->RB_Buffer)->PppEMsg.hPort = porthandle;
  1265. strcpy( ((REQTYPECAST *)
  1266. preqbuf->RB_Buffer)->PppEMsg.ExtraInfo.Start.szPortName,
  1267. pszPortName );
  1268. strcpy( ((REQTYPECAST *)
  1269. preqbuf->RB_Buffer)->PppEMsg.ExtraInfo.Start.szUserName,
  1270. pszUserName );
  1271. strcpy( ((REQTYPECAST *)
  1272. preqbuf->RB_Buffer)->PppEMsg.ExtraInfo.Start.szPassword,
  1273. pszPassword );
  1274. strcpy( ((REQTYPECAST *)
  1275. preqbuf->RB_Buffer)->PppEMsg.ExtraInfo.Start.szDomain,
  1276. pszDomain );
  1277. ((REQTYPECAST *)
  1278. preqbuf->RB_Buffer)->PppEMsg.ExtraInfo.Start.Luid = *pLuid;
  1279. ((REQTYPECAST *)
  1280. preqbuf->RB_Buffer)->PppEMsg.ExtraInfo.Start.ConfigInfo =
  1281. *pConfigInfo;
  1282. if ( pPppInterfaceInfo != NULL )
  1283. {
  1284. ((REQTYPECAST *)
  1285. preqbuf->RB_Buffer)->PppEMsg.ExtraInfo.Start.PppInterfaceInfo
  1286. = *pPppInterfaceInfo;
  1287. }
  1288. else
  1289. {
  1290. ((REQTYPECAST *)
  1291. preqbuf->RB_Buffer)->PppEMsg.ExtraInfo.Start.
  1292. PppInterfaceInfo.IfType = (DWORD)-1;
  1293. }
  1294. memcpy( ((REQTYPECAST *)
  1295. preqbuf->RB_Buffer)->PppEMsg.ExtraInfo.Start.szzParameters,
  1296. pszzParameters, PARAMETERBUFLEN );
  1297. ((REQTYPECAST *)
  1298. preqbuf->RB_Buffer)->PppEMsg.ExtraInfo.Start.fThisIsACallback =
  1299. fThisIsACallback;
  1300. ((REQTYPECAST *)
  1301. preqbuf->RB_Buffer)->PppEMsg.ExtraInfo.Start.hEvent = hEvent;
  1302. ((REQTYPECAST *)
  1303. preqbuf->RB_Buffer)->PppEMsg.ExtraInfo.Start.dwPid = dwPid;
  1304. ((REQTYPECAST *)
  1305. preqbuf->RB_Buffer)->PppEMsg.ExtraInfo.Start.dwAutoDisconnectTime
  1306. = dwAutoDisconnectTime;
  1307. ((REQTYPECAST *)
  1308. preqbuf->RB_Buffer)->PppEMsg.ExtraInfo.Start.fRedialOnLinkFailure
  1309. = fRedialOnLinkFailure;
  1310. memcpy( &(((REQTYPECAST *)
  1311. preqbuf->RB_Buffer)->PppEMsg.ExtraInfo.Start.BapParams),
  1312. pBapParams, sizeof (PPP_BAPPARAMS));
  1313. ((REQTYPECAST *)
  1314. preqbuf->RB_Buffer)->PppEMsg.ExtraInfo.Start.fNonInteractive
  1315. = fNonInteractive;
  1316. ((REQTYPECAST *)
  1317. preqbuf->RB_Buffer)->PppEMsg.ExtraInfo.Start.dwEapTypeId =
  1318. dwEapTypeId;
  1319. ((REQTYPECAST *)
  1320. preqbuf->RB_Buffer)->PppEMsg.ExtraInfo.Start.dwFlags =
  1321. dwFlags;
  1322. }
  1323. break;
  1324. case REQTYPE_PPPRETRY:
  1325. {
  1326. HPORT porthandle = va_arg(ap, HPORT) ;
  1327. CHAR * pszUserName = va_arg(ap, CHAR *) ;
  1328. CHAR * pszPassword = va_arg(ap, CHAR *) ;
  1329. CHAR * pszDomain = va_arg(ap, CHAR *) ;
  1330. preqbuf->RB_PCBIndex = PtrToUlong( porthandle);
  1331. ((REQTYPECAST *)preqbuf->RB_Buffer)->PppEMsg.dwMsgId =
  1332. PPPEMSG_Retry;
  1333. ((REQTYPECAST *)preqbuf->RB_Buffer)->PppEMsg.hPort = porthandle;
  1334. strcpy( ((REQTYPECAST *)
  1335. preqbuf->RB_Buffer)->PppEMsg.ExtraInfo.Retry.szUserName,
  1336. pszUserName );
  1337. strcpy( ((REQTYPECAST *)
  1338. preqbuf->RB_Buffer)->PppEMsg.ExtraInfo.Retry.szPassword,
  1339. pszPassword );
  1340. strcpy( ((REQTYPECAST *)
  1341. preqbuf->RB_Buffer)->PppEMsg.ExtraInfo.Retry.szDomain,
  1342. pszDomain );
  1343. }
  1344. break;
  1345. case REQTYPE_PPPGETINFO:
  1346. {
  1347. HPORT porthandle = va_arg(ap, HPORT) ;
  1348. preqbuf->RB_PCBIndex = PtrToUlong( porthandle );
  1349. }
  1350. break;
  1351. case REQTYPE_GETTIMESINCELASTACTIVITY:
  1352. {
  1353. HPORT porthandle = va_arg(ap, HPORT) ;
  1354. preqbuf->RB_PCBIndex = PtrToUlong( porthandle );
  1355. }
  1356. break;
  1357. case REQTYPE_PPPCHANGEPWD:
  1358. {
  1359. HPORT porthandle = va_arg(ap, HPORT) ;
  1360. CHAR * pszUserName = va_arg(ap, CHAR *) ;
  1361. CHAR * pszOldPassword = va_arg(ap, CHAR *) ;
  1362. CHAR * pszNewPassword = va_arg(ap, CHAR *) ;
  1363. preqbuf->RB_PCBIndex = PtrToUlong( porthandle );
  1364. ((REQTYPECAST *)
  1365. preqbuf->RB_Buffer)->PppEMsg.dwMsgId = PPPEMSG_ChangePw;
  1366. ((REQTYPECAST *)
  1367. preqbuf->RB_Buffer)->PppEMsg.hPort = porthandle;
  1368. strcpy( ((REQTYPECAST *)
  1369. preqbuf->RB_Buffer)->PppEMsg.ExtraInfo.ChangePw.szUserName,
  1370. pszUserName );
  1371. strcpy( ((REQTYPECAST *)
  1372. preqbuf->RB_Buffer)->PppEMsg.ExtraInfo.ChangePw.szOldPassword,
  1373. pszOldPassword );
  1374. strcpy( ((REQTYPECAST *)
  1375. preqbuf->RB_Buffer)->PppEMsg.ExtraInfo.ChangePw.szNewPassword,
  1376. pszNewPassword );
  1377. }
  1378. break;
  1379. case REQTYPE_ADDNOTIFICATION:
  1380. {
  1381. DWORD pid = va_arg(ap, DWORD);
  1382. HCONN hconn = va_arg(ap, HCONN);
  1383. HANDLE hevent = va_arg(ap, HANDLE);
  1384. DWORD dwfFlags = va_arg(ap, DWORD);
  1385. //
  1386. // Either a HPORT or a HCONN can be passed
  1387. // in as the HCONN argument.
  1388. //
  1389. ((REQTYPECAST *)
  1390. preqbuf->RB_Buffer)->AddNotification.pid = pid;
  1391. ((REQTYPECAST *)
  1392. preqbuf->RB_Buffer)->AddNotification.fAny =
  1393. (hconn == INVALID_HPORT);
  1394. if ( hconn == INVALID_HPORT
  1395. || (HandleToUlong(hconn) & 0xffff0000))
  1396. {
  1397. ((REQTYPECAST *)
  1398. preqbuf->RB_Buffer)->AddNotification.hconn = hconn;
  1399. }
  1400. else
  1401. {
  1402. preqbuf->RB_PCBIndex = PtrToUlong( hconn );
  1403. ((REQTYPECAST *)
  1404. preqbuf->RB_Buffer)->AddNotification.hconn = 0;//(HCONN)NULL;
  1405. }
  1406. ((REQTYPECAST *)
  1407. preqbuf->RB_Buffer)->AddNotification.hevent = hevent;
  1408. ((REQTYPECAST *)
  1409. preqbuf->RB_Buffer)->AddNotification.dwfFlags = dwfFlags;
  1410. }
  1411. break;
  1412. case REQTYPE_SIGNALCONNECTION:
  1413. {
  1414. HCONN hconn = va_arg(ap, HCONN);
  1415. ((REQTYPECAST *)
  1416. preqbuf->RB_Buffer)->SignalConnection.hconn = hconn;
  1417. }
  1418. break;
  1419. case REQTYPE_SETDEVCONFIG:
  1420. {
  1421. HPORT porthandle = va_arg(ap, HPORT) ;
  1422. PCHAR devicetype = va_arg(ap, PCHAR) ;
  1423. PBYTE config = va_arg(ap, PBYTE) ;
  1424. DWORD size = va_arg(ap, DWORD) ;
  1425. preqbuf->RB_PCBIndex = PtrToUlong( porthandle );
  1426. ((REQTYPECAST *)
  1427. preqbuf->RB_Buffer)->SetDevConfig.size = size ;
  1428. strcpy(((REQTYPECAST *)
  1429. preqbuf->RB_Buffer)->SetDevConfig.devicetype,
  1430. devicetype) ;
  1431. memcpy (((REQTYPECAST *)
  1432. preqbuf->RB_Buffer)->SetDevConfig.config,
  1433. config,
  1434. size) ;
  1435. }
  1436. break;
  1437. case REQTYPE_GETDEVCONFIG:
  1438. {
  1439. HPORT porthandle = va_arg(ap, HPORT) ;
  1440. PCHAR devicetype = va_arg(ap, PCHAR) ;
  1441. pUserBuffer = va_arg ( ap, PBYTE );
  1442. pdwSize = va_arg ( ap, DWORD *);
  1443. if (NULL == pUserBuffer)
  1444. {
  1445. *pdwSize = 0;
  1446. }
  1447. if (*pdwSize)
  1448. {
  1449. retcode = AllocateBuffer(*pdwSize,
  1450. (PBYTE *) &pBuffer,
  1451. &dwSizeofBuffer);
  1452. if(retcode)
  1453. {
  1454. goto done;
  1455. }
  1456. if(pBuffer)
  1457. {
  1458. pBuffer->RB_Reqtype = reqtype;
  1459. pbTemp = pBuffer;
  1460. }
  1461. }
  1462. else
  1463. {
  1464. pbTemp = preqbuf;
  1465. }
  1466. pbTemp->RB_PCBIndex = PtrToUlong( porthandle );
  1467. strcpy(((REQTYPECAST *)
  1468. pbTemp->RB_Buffer)->GetDevConfig.devicetype,
  1469. devicetype) ;
  1470. ((REQTYPECAST *)
  1471. pbTemp->RB_Buffer)->GetDevConfig.size = *pdwSize;
  1472. }
  1473. break;
  1474. case REQTYPE_GETDEVCONFIGEX:
  1475. {
  1476. HPORT porthandle = va_arg(ap, HPORT) ;
  1477. PCHAR devicetype = va_arg(ap, PCHAR) ;
  1478. pUserBuffer = va_arg ( ap, PBYTE );
  1479. pdwSize = va_arg ( ap, DWORD *);
  1480. if (NULL == pUserBuffer)
  1481. {
  1482. *pdwSize = 0;
  1483. }
  1484. if (*pdwSize)
  1485. {
  1486. retcode = AllocateBuffer(*pdwSize,
  1487. (PBYTE *) &pBuffer,
  1488. &dwSizeofBuffer);
  1489. if(retcode)
  1490. {
  1491. goto done;
  1492. }
  1493. if(pBuffer)
  1494. {
  1495. pBuffer->RB_Reqtype = reqtype;
  1496. pbTemp = pBuffer;
  1497. }
  1498. }
  1499. else
  1500. {
  1501. pbTemp = preqbuf;
  1502. }
  1503. pbTemp->RB_PCBIndex = PtrToUlong( porthandle );
  1504. strcpy(((REQTYPECAST *)
  1505. pbTemp->RB_Buffer)->GetDevConfigEx.devicetype,
  1506. devicetype) ;
  1507. ((REQTYPECAST *)
  1508. pbTemp->RB_Buffer)->GetDevConfigEx.size = *pdwSize;
  1509. break;
  1510. }
  1511. case REQTYPE_CLOSEPROCESSPORTS:
  1512. {
  1513. ((REQTYPECAST *)
  1514. preqbuf->RB_Buffer)->CloseProcessPortsInfo.pid =
  1515. GetCurrentProcessId();
  1516. }
  1517. break;
  1518. case REQTYPE_PNPCONTROL:
  1519. {
  1520. DWORD dwOp = va_arg(ap, DWORD);
  1521. HPORT porthandle = va_arg(ap, HPORT);
  1522. preqbuf->RB_PCBIndex = PtrToUlong( porthandle);
  1523. ((REQTYPECAST *)preqbuf->RB_Buffer)->PnPControlInfo.dwOp = dwOp;
  1524. }
  1525. break;
  1526. case REQTYPE_SETIOCOMPLETIONPORT:
  1527. {
  1528. HPORT porthandle = va_arg(ap, HPORT);
  1529. HANDLE hIoCompletionPort = va_arg(ap, HANDLE);
  1530. LPOVERLAPPED lpOvDrop = va_arg(ap, LPOVERLAPPED);
  1531. LPOVERLAPPED lpOvStateChange = va_arg(ap, LPOVERLAPPED);
  1532. LPOVERLAPPED lpOvPpp = va_arg(ap, LPOVERLAPPED);
  1533. LPOVERLAPPED lpOvLast = va_arg(ap, LPOVERLAPPED);
  1534. preqbuf->RB_PCBIndex = PtrToUlong( porthandle);
  1535. ((REQTYPECAST *)
  1536. preqbuf->RB_Buffer)->SetIoCompletionPortInfo.hIoCompletionPort =
  1537. hIoCompletionPort;
  1538. ((REQTYPECAST *)
  1539. preqbuf->RB_Buffer)->SetIoCompletionPortInfo.pid =
  1540. GetCurrentProcessId();
  1541. ((REQTYPECAST *)
  1542. preqbuf->RB_Buffer)->SetIoCompletionPortInfo.lpOvDrop =
  1543. lpOvDrop;
  1544. ((REQTYPECAST *)
  1545. preqbuf->RB_Buffer)->SetIoCompletionPortInfo.lpOvStateChange =
  1546. lpOvStateChange;
  1547. ((REQTYPECAST *)
  1548. preqbuf->RB_Buffer)->SetIoCompletionPortInfo.lpOvPpp = lpOvPpp;
  1549. ((REQTYPECAST *)
  1550. preqbuf->RB_Buffer)->SetIoCompletionPortInfo.lpOvLast = lpOvLast;
  1551. }
  1552. break;
  1553. case REQTYPE_SETROUTERUSAGE:
  1554. {
  1555. HPORT porthandle = va_arg(ap, HPORT);
  1556. BOOL fRouter = va_arg(ap, BOOL);
  1557. preqbuf->RB_PCBIndex = PtrToUlong( porthandle);
  1558. ((REQTYPECAST *)
  1559. preqbuf->RB_Buffer)->SetRouterUsageInfo.fRouter = fRouter;
  1560. }
  1561. break;
  1562. case REQTYPE_SENDPPPMESSAGETORASMAN:
  1563. {
  1564. HPORT hPort = va_arg(ap, HPORT);
  1565. PPP_MESSAGE *pppMsg = (PPP_MESSAGE *) va_arg(ap, PPP_MESSAGE *);
  1566. memcpy( &(((REQTYPECAST *)preqbuf->RB_Buffer)->PppMsg),
  1567. pppMsg,
  1568. sizeof( PPP_MESSAGE ) );
  1569. }
  1570. break;
  1571. case REQTYPE_SETRASDIALINFO:
  1572. {
  1573. HPORT hPort = va_arg (ap, HPORT);
  1574. CHAR *pszPhonebookPath = va_arg (ap, CHAR *);
  1575. CHAR *pszEntryName = va_arg (ap, CHAR *);
  1576. CHAR *pszPhoneNumber = va_arg(ap, CHAR *);
  1577. DWORD cbCustomAuthData = va_arg(ap, DWORD);
  1578. PBYTE pbCustomAuthData = va_arg(ap, PBYTE);
  1579. DWORD dwRequiredSize;
  1580. dwRequiredSize = strlen(pszPhonebookPath) + 1
  1581. + strlen(pszEntryName) + 1
  1582. + strlen(pszPhoneNumber)
  1583. + sizeof(RAS_CUSTOM_AUTH_DATA)
  1584. + cbCustomAuthData;
  1585. retcode = AllocateBuffer(dwRequiredSize,
  1586. (PBYTE *) &pBuffer,
  1587. &dwSizeofBuffer);
  1588. if(retcode)
  1589. {
  1590. goto done;
  1591. }
  1592. if(pBuffer)
  1593. {
  1594. pBuffer->RB_Reqtype = reqtype;
  1595. pbTemp = pBuffer;
  1596. }
  1597. pbTemp->RB_PCBIndex = PtrToUlong( hPort);
  1598. strcpy (((REQTYPECAST *)
  1599. pbTemp->RB_Buffer)->SetRasdialInfo.szPhonebookPath,
  1600. pszPhonebookPath);
  1601. strcpy (((REQTYPECAST *)
  1602. pbTemp->RB_Buffer)->SetRasdialInfo.szEntryName,
  1603. pszEntryName);
  1604. strcpy (((REQTYPECAST *)
  1605. pbTemp->RB_Buffer)->SetRasdialInfo.szPhoneNumber,
  1606. pszPhoneNumber);
  1607. ((REQTYPECAST *)
  1608. pbTemp->RB_Buffer)->SetRasdialInfo.rcad.cbCustomAuthData
  1609. = cbCustomAuthData;
  1610. if(cbCustomAuthData > 0)
  1611. {
  1612. memcpy(
  1613. ((REQTYPECAST *)
  1614. pbTemp->RB_Buffer)->SetRasdialInfo.rcad.abCustomAuthData,
  1615. pbCustomAuthData,
  1616. cbCustomAuthData);
  1617. }
  1618. break;
  1619. }
  1620. case REQTYPE_REGISTERPNPNOTIF:
  1621. {
  1622. PVOID pvNotifier = va_arg ( ap, PVOID );
  1623. DWORD dwFlags = va_arg ( ap, DWORD );
  1624. DWORD pid = va_arg ( ap, DWORD );
  1625. HANDLE hThreadHandle = va_arg ( ap, HANDLE );
  1626. BOOL fRegister = va_arg( ap, BOOL );
  1627. (( REQTYPECAST *)
  1628. preqbuf->RB_Buffer )->PnPNotif.pvNotifier = pvNotifier;
  1629. (( REQTYPECAST *)
  1630. preqbuf->RB_Buffer )->PnPNotif.dwFlags = dwFlags;
  1631. (( REQTYPECAST *)
  1632. preqbuf->RB_Buffer )->PnPNotif.pid = pid;
  1633. (( REQTYPECAST *)
  1634. preqbuf->RB_Buffer )->PnPNotif.hThreadHandle = hThreadHandle;
  1635. ((REQTYPECAST *)
  1636. preqbuf->RB_Buffer)->PnPNotif.fRegister = fRegister;
  1637. preqbuf->RB_PCBIndex = 0;
  1638. }
  1639. break;
  1640. /*
  1641. case REQTYPE_NOTIFYCONFIGCHANGE:
  1642. {
  1643. GUID *pGuid = va_arg( ap, GUID * );
  1644. memcpy (&((REQTYPECAST *)
  1645. preqbuf->RB_Buffer)->NotifyConfigChanged.
  1646. Info.guidDevice ,
  1647. pGuid,
  1648. sizeof(GUID));
  1649. }
  1650. break;
  1651. */
  1652. case REQTYPE_SETBAPPOLICY:
  1653. {
  1654. HCONN hConn = va_arg ( ap, HCONN );
  1655. DWORD dwLowThreshold = va_arg ( ap, DWORD );
  1656. DWORD dwLowSamplePeriod = va_arg ( ap, DWORD );
  1657. DWORD dwHighThreshold = va_arg ( ap, DWORD );
  1658. DWORD dwHighSamplePeriod = va_arg ( ap, DWORD );
  1659. ((REQTYPECAST *)
  1660. preqbuf->RB_Buffer)->SetBapPolicy.hConn = hConn;
  1661. ((REQTYPECAST *)
  1662. preqbuf->RB_Buffer)->SetBapPolicy.dwLowThreshold =
  1663. dwLowThreshold;
  1664. ((REQTYPECAST *)
  1665. preqbuf->RB_Buffer)->SetBapPolicy.dwLowSamplePeriod =
  1666. dwLowSamplePeriod;
  1667. ((REQTYPECAST *)
  1668. preqbuf->RB_Buffer)->SetBapPolicy.dwHighThreshold =
  1669. dwHighThreshold;
  1670. ((REQTYPECAST *)
  1671. preqbuf->RB_Buffer)->SetBapPolicy.dwHighSamplePeriod =
  1672. dwHighSamplePeriod;
  1673. }
  1674. break;
  1675. case REQTYPE_REFCONNECTION:
  1676. {
  1677. HCONN hConn = va_arg ( ap, HCONN );
  1678. BOOL fAddref = va_arg ( ap, BOOL );
  1679. preqbuf->RB_PCBIndex = 0;
  1680. ((REQTYPECAST * )
  1681. preqbuf->RB_Buffer)->RefConnection.hConn = hConn;
  1682. ((REQTYPECAST * )
  1683. preqbuf->RB_Buffer)->RefConnection.fAddref = fAddref;
  1684. }
  1685. break;
  1686. case REQTYPE_GETEAPINFO:
  1687. {
  1688. HCONN hConn = va_arg( ap, HCONN);
  1689. DWORD dwSubEntry = va_arg( ap, DWORD);
  1690. pdwSize = va_arg(ap, DWORD *);
  1691. pUserBuffer = va_arg(ap, PBYTE);
  1692. if ( NULL == pUserBuffer )
  1693. {
  1694. *pdwSize = 0;
  1695. }
  1696. if ( *pdwSize )
  1697. {
  1698. retcode = AllocateBuffer(*pdwSize,
  1699. (PBYTE *) &pBuffer,
  1700. &dwSizeofBuffer);
  1701. if(retcode)
  1702. {
  1703. goto done;
  1704. }
  1705. if(pBuffer)
  1706. {
  1707. pBuffer->RB_Reqtype = reqtype;
  1708. pbTemp = pBuffer;
  1709. }
  1710. }
  1711. else
  1712. {
  1713. pbTemp = preqbuf;
  1714. }
  1715. pbTemp->RB_PCBIndex = 0;
  1716. ((REQTYPECAST *)
  1717. pbTemp->RB_Buffer)->GetEapInfo.hConn = hConn;
  1718. ((REQTYPECAST *)
  1719. pbTemp->RB_Buffer)->GetEapInfo.dwSubEntry = dwSubEntry;
  1720. ((REQTYPECAST *)
  1721. pbTemp->RB_Buffer)->GetEapInfo.dwSizeofEapUIData = *pdwSize;
  1722. }
  1723. break;
  1724. case REQTYPE_SETEAPINFO:
  1725. {
  1726. HPORT port = va_arg(ap, HPORT);
  1727. DWORD dwContextId = va_arg(ap, DWORD);
  1728. DWORD dwcb = va_arg(ap, DWORD);
  1729. PBYTE pbdata = va_arg(ap, PBYTE);
  1730. if ( dwcb )
  1731. {
  1732. retcode = AllocateBuffer(dwcb,
  1733. (PBYTE *) &pBuffer,
  1734. &dwSizeofBuffer);
  1735. if(retcode)
  1736. {
  1737. goto done;
  1738. }
  1739. if (pBuffer)
  1740. {
  1741. pBuffer->RB_Reqtype = reqtype;
  1742. pbTemp = pBuffer;
  1743. }
  1744. }
  1745. else
  1746. {
  1747. pbTemp = preqbuf;
  1748. }
  1749. pbTemp->RB_PCBIndex = PtrToUlong( port);
  1750. ((REQTYPECAST *)
  1751. pbTemp->RB_Buffer)->SetEapInfo.dwContextId = dwContextId;
  1752. ((REQTYPECAST *)
  1753. pbTemp->RB_Buffer)->SetEapInfo.dwSizeofEapUIData = dwcb;
  1754. memcpy (
  1755. ((REQTYPECAST *)pbTemp->RB_Buffer)->SetEapInfo.data,
  1756. pbdata,
  1757. dwcb);
  1758. }
  1759. break;
  1760. case REQTYPE_SETDEVICECONFIGINFO:
  1761. {
  1762. DWORD cEntries = va_arg(ap, DWORD);
  1763. DWORD cbData = va_arg(ap, DWORD);
  1764. pUserBuffer = va_arg(ap, BYTE *);
  1765. retcode = AllocateBuffer(cbData,
  1766. (PBYTE *) &pBuffer,
  1767. &dwSizeofBuffer);
  1768. if(retcode)
  1769. {
  1770. goto done;
  1771. }
  1772. if(pBuffer)
  1773. {
  1774. pBuffer->RB_Reqtype = reqtype;
  1775. pbTemp = pBuffer;
  1776. }
  1777. ((REQTYPECAST *)
  1778. pbTemp->RB_Buffer)->DeviceConfigInfo.cEntries = cEntries;
  1779. ((REQTYPECAST *)
  1780. pbTemp->RB_Buffer)->DeviceConfigInfo.cbBuffer = cbData;
  1781. memcpy(
  1782. ((REQTYPECAST *)
  1783. pbTemp->RB_Buffer)->DeviceConfigInfo.abdata,
  1784. pUserBuffer,
  1785. cbData);
  1786. }
  1787. break;
  1788. case REQTYPE_GETDEVICECONFIGINFO:
  1789. {
  1790. pdwVersion = va_arg(ap, DWORD *);
  1791. pdwSize = va_arg(ap, DWORD *);
  1792. pUserBuffer = (PBYTE) va_arg(ap, PBYTE);
  1793. if(NULL == pUserBuffer)
  1794. {
  1795. *pdwSize = 0;
  1796. }
  1797. if(*pdwSize)
  1798. {
  1799. retcode = AllocateBuffer(*pdwSize,
  1800. (PBYTE *) &pBuffer,
  1801. &dwSizeofBuffer);
  1802. if(retcode)
  1803. {
  1804. goto done;
  1805. }
  1806. if(pBuffer)
  1807. {
  1808. pBuffer->RB_Reqtype = reqtype;
  1809. pbTemp = pBuffer;
  1810. }
  1811. }
  1812. else
  1813. {
  1814. pbTemp = preqbuf;
  1815. }
  1816. ((REQTYPECAST *)
  1817. pbTemp->RB_Buffer)->DeviceConfigInfo.dwVersion = *pdwVersion;
  1818. ((REQTYPECAST *)
  1819. pbTemp->RB_Buffer)->DeviceConfigInfo.cbBuffer = *pdwSize;
  1820. }
  1821. break;
  1822. case REQTYPE_FINDPREREQUISITEENTRY:
  1823. {
  1824. HCONN hConn = va_arg(ap, HCONN);
  1825. ((REQTYPECAST *)
  1826. preqbuf->RB_Buffer)->FindRefConnection.hConn = hConn;
  1827. break;
  1828. }
  1829. case REQTYPE_GETLINKSTATS:
  1830. {
  1831. HCONN hConn = va_arg(ap, HCONN);
  1832. DWORD dwSubEntry = va_arg(ap, DWORD);
  1833. ((REQTYPECAST *)
  1834. preqbuf->RB_Buffer)->GetStats.hConn = hConn;
  1835. ((REQTYPECAST *)
  1836. preqbuf->RB_Buffer)->GetStats.dwSubEntry = dwSubEntry;
  1837. break;
  1838. }
  1839. case REQTYPE_GETCONNECTIONSTATS:
  1840. {
  1841. HCONN hConn = va_arg(ap, HCONN);
  1842. ((REQTYPECAST *)
  1843. preqbuf->RB_Buffer)->GetStats.hConn = hConn;
  1844. break;
  1845. }
  1846. case REQTYPE_GETHPORTFROMCONNECTION:
  1847. {
  1848. HCONN hConn = va_arg(ap, HCONN);
  1849. ((REQTYPECAST *)
  1850. preqbuf->RB_Buffer)->GetHportFromConnection.hConn = hConn;
  1851. break;
  1852. }
  1853. case REQTYPE_REFERENCECUSTOMCOUNT:
  1854. {
  1855. HCONN hConn = va_arg(ap, HCONN);
  1856. BOOL fAddref = va_arg(ap, BOOL);
  1857. CHAR *pszPhonebook = NULL;
  1858. CHAR *pszEntry = NULL;
  1859. if(fAddref)
  1860. {
  1861. pszPhonebook = va_arg(ap, CHAR *);
  1862. pszEntry = va_arg(ap, CHAR *);
  1863. }
  1864. if( pszPhonebook
  1865. && pszEntry)
  1866. {
  1867. strcpy(
  1868. ((REQTYPECAST *)
  1869. preqbuf->RB_Buffer)->ReferenceCustomCount.szPhonebookPath,
  1870. pszPhonebook);
  1871. strcpy(
  1872. ((REQTYPECAST *)
  1873. preqbuf->RB_Buffer)->ReferenceCustomCount.szEntryName,
  1874. pszEntry);
  1875. }
  1876. ((REQTYPECAST *)
  1877. preqbuf->RB_Buffer)->ReferenceCustomCount.fAddRef = fAddref;
  1878. ((REQTYPECAST *)
  1879. preqbuf->RB_Buffer)->ReferenceCustomCount.hConn = hConn;
  1880. break;
  1881. }
  1882. case REQTYPE_GETHCONNFROMENTRY:
  1883. {
  1884. CHAR *pszPhonebookPath = va_arg(ap, CHAR *);
  1885. CHAR *pszEntryName = va_arg(ap, CHAR *);
  1886. strcpy(
  1887. ((REQTYPECAST *)
  1888. preqbuf->RB_Buffer)->HconnFromEntry.szPhonebookPath,
  1889. pszPhonebookPath);
  1890. strcpy(
  1891. ((REQTYPECAST *)
  1892. preqbuf->RB_Buffer)->HconnFromEntry.szEntryName,
  1893. pszEntryName);
  1894. break;
  1895. }
  1896. case REQTYPE_GETCONNECTINFO:
  1897. {
  1898. HPORT hPort = va_arg(ap, HPORT);
  1899. pdwSize = va_arg(ap, DWORD *);
  1900. pUserBuffer = (PBYTE) va_arg(ap, RAS_CONNECT_INFO *);
  1901. if(NULL == pUserBuffer)
  1902. {
  1903. *pdwSize = 0;
  1904. }
  1905. if(*pdwSize)
  1906. {
  1907. retcode = AllocateBuffer(*pdwSize,
  1908. (PBYTE *) &pBuffer,
  1909. &dwSizeofBuffer);
  1910. if(retcode)
  1911. {
  1912. goto done;
  1913. }
  1914. if(pBuffer)
  1915. {
  1916. pBuffer->RB_Reqtype = reqtype;
  1917. pbTemp = pBuffer;
  1918. }
  1919. }
  1920. else
  1921. {
  1922. pbTemp = preqbuf;
  1923. }
  1924. pbTemp->RB_PCBIndex = PtrToUlong( hPort);
  1925. ((REQTYPECAST *)
  1926. pbTemp->RB_Buffer)->GetConnectInfo.dwSize = *pdwSize;
  1927. break;
  1928. }
  1929. case REQTYPE_GETDEVICENAME:
  1930. {
  1931. RASDEVICETYPE eDeviceType = va_arg(ap, RASDEVICETYPE);
  1932. //
  1933. // dummy - this won't be looked at
  1934. //
  1935. pbTemp->RB_PCBIndex = 0;
  1936. ((REQTYPECAST *)
  1937. pbTemp->RB_Buffer)->GetDeviceName.eDeviceType = eDeviceType;
  1938. break;
  1939. }
  1940. case REQTYPE_GETDEVICENAMEW:
  1941. {
  1942. RASDEVICETYPE eDeviceType = va_arg(ap, RASDEVICETYPE);
  1943. //
  1944. // dummy - this won't be looked at
  1945. //
  1946. pbTemp->RB_PCBIndex = 0;
  1947. ((REQTYPECAST *)
  1948. pbTemp->RB_Buffer)->GetDeviceNameW.eDeviceType = eDeviceType;
  1949. break;
  1950. }
  1951. case REQTYPE_GETCALLEDID:
  1952. {
  1953. RAS_DEVICE_INFO *pDeviceInfo = va_arg(ap, RAS_DEVICE_INFO *);
  1954. pdwSize = va_arg(ap, DWORD *);
  1955. pUserBuffer = (PBYTE) va_arg(ap, RAS_CALLEDID_INFO *);
  1956. if(NULL == pUserBuffer)
  1957. {
  1958. *pdwSize = 0;
  1959. }
  1960. if(*pdwSize)
  1961. {
  1962. retcode = AllocateBuffer(*pdwSize,
  1963. (PBYTE *) &pBuffer,
  1964. &dwSizeofBuffer);
  1965. if(retcode)
  1966. {
  1967. goto done;
  1968. }
  1969. if(pBuffer)
  1970. {
  1971. pBuffer->RB_Reqtype = reqtype;
  1972. pbTemp = pBuffer;
  1973. }
  1974. }
  1975. else
  1976. {
  1977. pbTemp = preqbuf;
  1978. }
  1979. pbTemp->RB_PCBIndex = 0;
  1980. ((REQTYPECAST *)
  1981. pbTemp->RB_Buffer)->GetSetCalledId.dwSize = *pdwSize;
  1982. memcpy(
  1983. (PBYTE) &((REQTYPECAST *)
  1984. pbTemp->RB_Buffer)->GetSetCalledId.rdi,
  1985. pDeviceInfo,
  1986. sizeof(RAS_DEVICE_INFO));
  1987. break;
  1988. }
  1989. case REQTYPE_SETCALLEDID:
  1990. {
  1991. RAS_DEVICE_INFO *pDeviceInfo = va_arg(ap, RAS_DEVICE_INFO *);
  1992. RAS_CALLEDID_INFO *pCalledId = va_arg(ap, RAS_CALLEDID_INFO *);
  1993. BOOL fWrite = va_arg(ap, BOOL);
  1994. retcode = AllocateBuffer(pCalledId->dwSize,
  1995. (PBYTE *) &pBuffer,
  1996. &dwSizeofBuffer);
  1997. if(retcode)
  1998. {
  1999. goto done;
  2000. }
  2001. if(pBuffer)
  2002. {
  2003. pBuffer->RB_Reqtype = reqtype;
  2004. pbTemp = pBuffer;
  2005. }
  2006. pbTemp->RB_PCBIndex = 0;
  2007. ((REQTYPECAST *)
  2008. pbTemp->RB_Buffer)->GetSetCalledId.fWrite = fWrite;
  2009. memcpy(
  2010. (LPBYTE) &((REQTYPECAST *)
  2011. pbTemp->RB_Buffer)->GetSetCalledId.rdi,
  2012. (LPBYTE) pDeviceInfo,
  2013. sizeof(RAS_DEVICE_INFO));
  2014. memcpy(
  2015. (LPBYTE) ((REQTYPECAST *)
  2016. pbTemp->RB_Buffer)->GetSetCalledId.rciInfo.bCalledId,
  2017. pCalledId->bCalledId,
  2018. pCalledId->dwSize);
  2019. ((REQTYPECAST *)
  2020. pbTemp->RB_Buffer)->GetSetCalledId.rciInfo.dwSize =
  2021. pCalledId->dwSize;
  2022. break;
  2023. }
  2024. case REQTYPE_ENABLEIPSEC:
  2025. {
  2026. HPORT hPort = va_arg(ap, HPORT);
  2027. BOOL fEnable = va_arg(ap, BOOL);
  2028. BOOL fServer = va_arg(ap, BOOL);
  2029. RAS_L2TP_ENCRYPTION eEncryption =
  2030. va_arg(ap, RAS_L2TP_ENCRYPTION);
  2031. preqbuf->RB_PCBIndex = PtrToUlong( hPort);
  2032. ((REQTYPECAST *)
  2033. preqbuf->RB_Buffer)->EnableIpSec.fEnable = fEnable;
  2034. ((REQTYPECAST *)
  2035. preqbuf->RB_Buffer)->EnableIpSec.fServer = fServer;
  2036. ((REQTYPECAST *)
  2037. preqbuf->RB_Buffer)->EnableIpSec.eEncryption = eEncryption;
  2038. break;
  2039. }
  2040. case REQTYPE_ISIPSECENABLED:
  2041. {
  2042. HPORT hPort = va_arg(ap, HPORT);
  2043. preqbuf->RB_PCBIndex = PtrToUlong( hPort);
  2044. break;
  2045. }
  2046. case REQTYPE_SETEAPLOGONINFO:
  2047. {
  2048. HPORT hPort = va_arg(ap, HPORT);
  2049. BOOL fLogon = va_arg(ap, BOOL);
  2050. RASEAPINFO * pEapInfo = va_arg(ap, RASEAPINFO *);
  2051. retcode = AllocateBuffer(pEapInfo->dwSizeofEapInfo,
  2052. (PBYTE *) &pBuffer,
  2053. &dwSizeofBuffer);
  2054. if(retcode)
  2055. {
  2056. goto done;
  2057. }
  2058. if(pBuffer)
  2059. {
  2060. pBuffer->RB_Reqtype = reqtype;
  2061. pbTemp = pBuffer;
  2062. }
  2063. pbTemp->RB_PCBIndex = PtrToUlong( hPort);
  2064. ((REQTYPECAST *)
  2065. pbTemp->RB_Buffer)->SetEapLogonInfo.dwSizeofEapData =
  2066. pEapInfo->dwSizeofEapInfo;
  2067. ((REQTYPECAST *)
  2068. pbTemp->RB_Buffer)->SetEapLogonInfo.fLogon = fLogon;
  2069. memcpy(((REQTYPECAST *)
  2070. pbTemp->RB_Buffer)->SetEapLogonInfo.abEapData,
  2071. pEapInfo->pbEapInfo,
  2072. pEapInfo->dwSizeofEapInfo);
  2073. break;
  2074. }
  2075. case REQTYPE_SENDNOTIFICATION:
  2076. {
  2077. RASEVENT *pRasEvent = va_arg(ap, RASEVENT *);
  2078. //
  2079. // dummy - this won't be looked at
  2080. //
  2081. pbTemp->RB_PCBIndex = 0;
  2082. memcpy(
  2083. (PBYTE) &((REQTYPECAST *)
  2084. pbTemp->RB_Buffer)->SendNotification.RasEvent,
  2085. (PBYTE) pRasEvent,
  2086. sizeof(RASEVENT));
  2087. break;
  2088. }
  2089. case REQTYPE_GETNDISWANDRIVERCAPS:
  2090. {
  2091. pbTemp->RB_PCBIndex = 0;
  2092. break;
  2093. }
  2094. case REQTYPE_GETBANDWIDTHUTILIZATION:
  2095. {
  2096. HPORT hPort = va_arg(ap, HPORT);
  2097. pbTemp->RB_PCBIndex = PtrToUlong( hPort);
  2098. break;
  2099. }
  2100. case REQTYPE_REGISTERREDIALCALLBACK:
  2101. {
  2102. PVOID pvfn = va_arg(ap, PVOID);
  2103. pbTemp->RB_PCBIndex = 0;
  2104. ((REQTYPECAST *)
  2105. pbTemp->RB_Buffer)->RegisterRedialCallback.pvCallback
  2106. = pvfn;
  2107. break;
  2108. }
  2109. case REQTYPE_GETPROTOCOLINFO:
  2110. {
  2111. pbTemp->RB_PCBIndex = 0;
  2112. break;
  2113. }
  2114. case REQTYPE_GETCUSTOMSCRIPTDLL:
  2115. {
  2116. pbTemp->RB_PCBIndex = 0;
  2117. break;
  2118. }
  2119. case REQTYPE_ISTRUSTEDCUSTOMDLL:
  2120. {
  2121. WCHAR *pwszCustomDll = va_arg( ap, WCHAR * );
  2122. pbTemp->RB_PCBIndex = 0;
  2123. wcscpy(
  2124. ((REQTYPECAST *)
  2125. pbTemp->RB_Buffer)->IsTrusted.wszCustomDll,
  2126. pwszCustomDll);
  2127. break;
  2128. }
  2129. case REQTYPE_DOIKE:
  2130. {
  2131. HPORT hPort = va_arg(ap, HPORT);
  2132. HANDLE hEvent = va_arg(ap, HANDLE);
  2133. pbTemp->RB_PCBIndex = PtrToUlong( hPort);
  2134. ((REQTYPECAST *) pbTemp->RB_Buffer)->DoIke.hEvent = hEvent;
  2135. ((REQTYPECAST *) pbTemp->RB_Buffer)->DoIke.pid =
  2136. GetCurrentProcessId();
  2137. break;
  2138. }
  2139. case REQTYPE_QUERYIKESTATUS:
  2140. {
  2141. HPORT hPort = va_arg(ap, HPORT);
  2142. pbTemp->RB_PCBIndex = PtrToUlong(hPort);
  2143. break;
  2144. }
  2145. case REQTYPE_SETRASCOMMSETTINGS:
  2146. {
  2147. HPORT hPort = va_arg(ap, HPORT);
  2148. RASCOMMSETTINGS *rs = va_arg(ap, RASCOMMSETTINGS *);
  2149. pbTemp->RB_PCBIndex = PtrToUlong(hPort);
  2150. ((REQTYPECAST *)
  2151. pbTemp->RB_Buffer)->SetRasCommSettings.Settings.bParity
  2152. = rs->bParity;
  2153. ((REQTYPECAST *)
  2154. pbTemp->RB_Buffer)->SetRasCommSettings.Settings.bStop
  2155. = rs->bStop;
  2156. ((REQTYPECAST *)
  2157. pbTemp->RB_Buffer)->SetRasCommSettings.Settings.bByteSize
  2158. = rs->bByteSize;
  2159. break;
  2160. }
  2161. case REQTYPE_ENABLERASAUDIO:
  2162. {
  2163. //
  2164. // This is ignored
  2165. //
  2166. pbTemp->RB_PCBIndex = 0;
  2167. ((REQTYPECAST *)
  2168. pbTemp->RB_Buffer)->EnableRasAudio.fEnable =
  2169. va_arg(ap, BOOL);
  2170. break;
  2171. }
  2172. case REQTYPE_SETKEY:
  2173. {
  2174. GUID *pGuid = va_arg(ap, GUID *);
  2175. DWORD dwMask = va_arg(ap, DWORD);
  2176. DWORD cbkey = va_arg(ap, DWORD);
  2177. PBYTE pbkey = va_arg(ap, PBYTE);
  2178. retcode = AllocateBuffer(cbkey,
  2179. (PBYTE *) &pBuffer,
  2180. &dwSizeofBuffer);
  2181. if(retcode)
  2182. {
  2183. goto done;
  2184. }
  2185. pbTemp->RB_PCBIndex = 0;
  2186. if(pBuffer)
  2187. {
  2188. pBuffer->RB_Reqtype = reqtype;
  2189. pbTemp = pBuffer;
  2190. }
  2191. if(NULL != pGuid)
  2192. {
  2193. memcpy(
  2194. &((REQTYPECAST *)
  2195. pbTemp->RB_Buffer)->GetSetKey.guid,
  2196. pGuid,
  2197. sizeof(GUID));
  2198. }
  2199. else
  2200. {
  2201. memset(
  2202. &((REQTYPECAST *)
  2203. pbTemp->RB_Buffer)->GetSetKey.guid,
  2204. 0, sizeof(GUID));
  2205. }
  2206. ((REQTYPECAST *)
  2207. pbTemp->RB_Buffer)->GetSetKey.dwMask = dwMask;
  2208. ((REQTYPECAST *)
  2209. pbTemp->RB_Buffer)->GetSetKey.cbkey = cbkey;
  2210. if(cbkey > 0)
  2211. {
  2212. memcpy(
  2213. ((REQTYPECAST *)
  2214. pbTemp->RB_Buffer)->GetSetKey.data,
  2215. pbkey,
  2216. cbkey);
  2217. }
  2218. break;
  2219. }
  2220. case REQTYPE_GETKEY:
  2221. {
  2222. GUID *pGuid = va_arg(ap, GUID *);
  2223. DWORD dwMask = va_arg(ap, DWORD);
  2224. pdwSize = va_arg(ap, DWORD *);
  2225. retcode = AllocateBuffer(*pdwSize,
  2226. (PBYTE *) &pBuffer,
  2227. &dwSizeofBuffer);
  2228. if(retcode)
  2229. {
  2230. goto done;
  2231. }
  2232. pbTemp->RB_PCBIndex = 0;
  2233. if(pBuffer)
  2234. {
  2235. pBuffer->RB_Reqtype = reqtype;
  2236. pbTemp = pBuffer;
  2237. }
  2238. if(NULL != pGuid)
  2239. {
  2240. memcpy(
  2241. &((REQTYPECAST *)
  2242. pbTemp->RB_Buffer)->GetSetKey.guid,
  2243. pGuid,
  2244. sizeof(GUID));
  2245. }
  2246. ((REQTYPECAST *)
  2247. pbTemp->RB_Buffer)->GetSetKey.dwMask = dwMask;
  2248. ((REQTYPECAST *)
  2249. pbTemp->RB_Buffer)->GetSetKey.cbkey = *pdwSize;
  2250. break;
  2251. }
  2252. case REQTYPE_ADDRESSDISABLE:
  2253. {
  2254. WCHAR *pszAddress = va_arg( ap, WCHAR * );
  2255. BOOL fDisable = va_arg(ap, BOOL);
  2256. pbTemp->RB_PCBIndex = 0;
  2257. wcscpy(((REQTYPECAST *)
  2258. pbTemp->RB_Buffer)->AddressDisable.szAddress,
  2259. pszAddress);
  2260. ((REQTYPECAST *)
  2261. pbTemp->RB_Buffer)->AddressDisable.fDisable = fDisable;
  2262. break;
  2263. }
  2264. case REQTYPE_SENDCREDS:
  2265. {
  2266. HPORT hport = va_arg(ap, HPORT);
  2267. CHAR controlchar = va_arg(ap, CHAR);
  2268. pbTemp->RB_PCBIndex = PtrToUlong(hport);
  2269. ((REQTYPECAST *)
  2270. pbTemp->RB_Buffer)->SendCreds.pid =
  2271. GetCurrentProcessId();
  2272. ((REQTYPECAST *)
  2273. pbTemp->RB_Buffer)->SendCreds.controlchar =
  2274. controlchar;
  2275. break;
  2276. }
  2277. case REQTYPE_GETUNICODEDEVICENAME:
  2278. {
  2279. HPORT hport = va_arg(ap, HPORT);
  2280. //
  2281. // dummy - this won't be looked at
  2282. //
  2283. pbTemp->RB_PCBIndex = HandleToUlong(hport);
  2284. break;
  2285. }
  2286. } // switch(reqtype)
  2287. //
  2288. // The request packet is now ready. Pass it on to
  2289. // the request thread:
  2290. //
  2291. retcode = PutRequestInQueue (hConnection, pbTemp, dwSizeofBuffer) ;
  2292. if(ERROR_SUCCESS != retcode)
  2293. {
  2294. goto done;
  2295. }
  2296. #if DBG
  2297. ASSERT(reqtype == pbTemp->RB_Reqtype);
  2298. #endif
  2299. //
  2300. // The request has been completed by the requestor thread:
  2301. // copy the results into the user supplied arguments:
  2302. //
  2303. switch (reqtype) {
  2304. case REQTYPE_PORTENUM:
  2305. case REQTYPE_DEVICEENUM:
  2306. {
  2307. PDWORD entries = va_arg(ap, PDWORD) ;
  2308. if (*pdwSize >= ((REQTYPECAST *)pbTemp->RB_Buffer)->Enum.size)
  2309. {
  2310. retcode = ((REQTYPECAST *)pbTemp->RB_Buffer)->Enum.retcode ;
  2311. }
  2312. else
  2313. {
  2314. retcode = ERROR_BUFFER_TOO_SMALL ;
  2315. }
  2316. *pdwSize = ((REQTYPECAST *)pbTemp->RB_Buffer)->Enum.size ;
  2317. *entries = ((REQTYPECAST *)pbTemp->RB_Buffer)->Enum.entries ;
  2318. if (retcode == SUCCESS)
  2319. {
  2320. memcpy (pUserBuffer,
  2321. ((REQTYPECAST *)pbTemp->RB_Buffer)->Enum.buffer,
  2322. *pdwSize);
  2323. }
  2324. }
  2325. break ;
  2326. case REQTYPE_PROTOCOLENUM:
  2327. {
  2328. PBYTE buffer = pUserBuffer ;
  2329. PDWORD size = pdwSize ;
  2330. PDWORD entries = va_arg(ap, PDWORD) ;
  2331. if (*size >= ((REQTYPECAST *)pbTemp->RB_Buffer)->Enum.size)
  2332. {
  2333. retcode = ((REQTYPECAST *)pbTemp->RB_Buffer)->Enum.retcode ;
  2334. }
  2335. else
  2336. {
  2337. retcode = ERROR_BUFFER_TOO_SMALL ;
  2338. }
  2339. *size = ((REQTYPECAST *)pbTemp->RB_Buffer)->Enum.size ;
  2340. *entries = ((REQTYPECAST *)pbTemp->RB_Buffer)->Enum.entries ;
  2341. if (retcode == SUCCESS)
  2342. {
  2343. memcpy (buffer,
  2344. ((REQTYPECAST *)pbTemp->RB_Buffer)->Enum.buffer,
  2345. *size);
  2346. }
  2347. }
  2348. break;
  2349. case REQTYPE_PORTGETINFO:
  2350. case REQTYPE_DEVICEGETINFO:
  2351. {
  2352. PBYTE buffer = pUserBuffer ;
  2353. PDWORD size = pdwSize ;
  2354. if (*size >= ((REQTYPECAST *)
  2355. pbTemp->RB_Buffer)->GetInfo.size)
  2356. {
  2357. retcode = ((REQTYPECAST *)
  2358. pbTemp->RB_Buffer)->GetInfo.retcode ;
  2359. }
  2360. else
  2361. {
  2362. retcode = ERROR_BUFFER_TOO_SMALL ;
  2363. }
  2364. *size = ((REQTYPECAST *)pbTemp->RB_Buffer)->GetInfo.size ;
  2365. if (retcode == SUCCESS)
  2366. {
  2367. RASMAN_DEVICEINFO *devinfo =
  2368. (RASMAN_DEVICEINFO *)
  2369. ((REQTYPECAST*)pbTemp->RB_Buffer)->GetInfo.buffer ;
  2370. //
  2371. // Convert the offset based param structure into
  2372. // pointer based.
  2373. //
  2374. ConvParamOffsetToPointer (devinfo->DI_Params,
  2375. devinfo->DI_NumOfParams);
  2376. CopyParams (
  2377. devinfo->DI_Params,
  2378. ((RASMAN_DEVICEINFO *) buffer)->DI_Params,
  2379. devinfo->DI_NumOfParams);
  2380. ((RASMAN_DEVICEINFO*)buffer)->DI_NumOfParams =
  2381. devinfo->DI_NumOfParams;
  2382. }
  2383. }
  2384. break ;
  2385. case REQTYPE_PORTOPEN:
  2386. {
  2387. HPORT *handle = va_arg(ap, HPORT*) ;
  2388. if ((retcode = ((REQTYPECAST *)
  2389. preqbuf->RB_Buffer)->PortOpen.retcode)
  2390. == SUCCESS)
  2391. {
  2392. *handle = ((REQTYPECAST*)
  2393. preqbuf->RB_Buffer)->PortOpen.porthandle;
  2394. }
  2395. }
  2396. break ;
  2397. case REQTYPE_PORTOPENEX:
  2398. {
  2399. HPORT *phport = va_arg(ap, HPORT *);
  2400. if(SUCCESS == (retcode = ((REQTYPECAST *)
  2401. preqbuf->RB_Buffer)->PortOpenEx.retcode))
  2402. {
  2403. *phport = ((REQTYPECAST *)
  2404. preqbuf->RB_Buffer)->PortOpenEx.hport;
  2405. }
  2406. *pdwFlags = ((REQTYPECAST *)
  2407. preqbuf->RB_Buffer)->PortOpenEx.dwFlags;
  2408. }
  2409. break;
  2410. case REQTYPE_PORTGETSTATISTICS:
  2411. case REQTYPE_BUNDLEGETSTATISTICS:
  2412. case REQTYPE_PORTGETSTATISTICSEX:
  2413. case REQTYPE_BUNDLEGETSTATISTICSEX:
  2414. {
  2415. RAS_STATISTICS *statbuffer = va_arg(ap, RAS_STATISTICS*) ;
  2416. PDWORD size = va_arg(ap, PDWORD) ;
  2417. //
  2418. // some local variables...
  2419. //
  2420. DWORD returnedsize ;
  2421. RAS_STATISTICS *temp = &((REQTYPECAST*)
  2422. preqbuf->RB_Buffer)->PortGetStatistics.statbuffer;
  2423. retcode = ((REQTYPECAST *)
  2424. preqbuf->RB_Buffer)->PortGetStatistics.retcode;
  2425. returnedsize = ((temp->S_NumOfStatistics - 1) * sizeof(ULONG))
  2426. + sizeof(RAS_STATISTICS);
  2427. if ( (SUCCESS == retcode)
  2428. && (*size < returnedsize))
  2429. {
  2430. retcode = ERROR_BUFFER_TOO_SMALL ;
  2431. }
  2432. /*
  2433. else
  2434. {
  2435. retcode = ((REQTYPECAST*)
  2436. preqbuf->RB_Buffer)->PortGetStatistics.retcode;
  2437. } */
  2438. if ( (retcode == SUCCESS)
  2439. || (retcode == ERROR_BUFFER_TOO_SMALL))
  2440. {
  2441. memcpy (statbuffer, temp, *size) ;
  2442. }
  2443. *size = returnedsize ;
  2444. }
  2445. break ;
  2446. case REQTYPE_GETINFO:
  2447. {
  2448. RASMAN_INFO *info = va_arg(ap, RASMAN_INFO*) ;
  2449. retcode = ((REQTYPECAST*)preqbuf->RB_Buffer)->Info.retcode ;
  2450. memcpy (info,
  2451. &((REQTYPECAST *)preqbuf->RB_Buffer)->Info.info,
  2452. sizeof (RASMAN_INFO));
  2453. //
  2454. // Now we set the OwnershipFlag in the GetInfo
  2455. // structure to tell us whether the caller owns
  2456. // the port or not.
  2457. //
  2458. if (info->RI_OwnershipFlag == GetCurrentProcessId())
  2459. {
  2460. info->RI_OwnershipFlag = TRUE ;
  2461. }
  2462. else
  2463. {
  2464. info->RI_OwnershipFlag = FALSE ;
  2465. }
  2466. }
  2467. break ;
  2468. case REQTYPE_GETINFOEX:
  2469. {
  2470. RASMAN_INFO *info = va_arg(ap, RASMAN_INFO*) ;
  2471. retcode = ((REQTYPECAST*)preqbuf->RB_Buffer)->InfoEx.retcode;
  2472. memcpy (info,
  2473. &((REQTYPECAST *)preqbuf->RB_Buffer)->InfoEx.info,
  2474. sizeof (RASMAN_INFO)
  2475. * ((REQTYPECAST *)preqbuf->RB_Buffer)->InfoEx.count);
  2476. }
  2477. break ;
  2478. case REQTYPE_ACTIVATEROUTEEX:
  2479. case REQTYPE_ACTIVATEROUTE:
  2480. case REQTYPE_ALLOCATEROUTE:
  2481. {
  2482. RASMAN_ROUTEINFO *info = va_arg(ap,RASMAN_ROUTEINFO*) ;
  2483. retcode= ((REQTYPECAST*)preqbuf->RB_Buffer)->Route.retcode ;
  2484. if ((retcode == SUCCESS) && info)
  2485. {
  2486. memcpy(info,
  2487. &((REQTYPECAST*)preqbuf->RB_Buffer)->Route.info,
  2488. sizeof(RASMAN_ROUTEINFO));
  2489. }
  2490. }
  2491. break ;
  2492. case REQTYPE_GETUSERCREDENTIALS:
  2493. {
  2494. PWCHAR UserName = va_arg(ap, PWCHAR);
  2495. PBYTE CSCResponse = va_arg(ap, PBYTE);
  2496. PBYTE CICResponse = va_arg(ap, PBYTE);
  2497. PBYTE LMSessionKey= va_arg(ap, PBYTE);
  2498. PBYTE UserSessionKey = va_arg(ap, PBYTE);
  2499. memcpy (UserName,
  2500. ((REQTYPECAST*)
  2501. preqbuf->RB_Buffer)->GetCredentials.UserName,
  2502. sizeof(WCHAR) * MAX_USERNAME_SIZE) ;
  2503. memcpy(CSCResponse,
  2504. ((REQTYPECAST*)
  2505. preqbuf->RB_Buffer)->GetCredentials.CSCResponse,
  2506. MAX_RESPONSE_SIZE);
  2507. memcpy(CICResponse,
  2508. ((REQTYPECAST*)
  2509. preqbuf->RB_Buffer)->GetCredentials.CICResponse,
  2510. MAX_RESPONSE_SIZE);
  2511. memcpy(LMSessionKey,
  2512. ((REQTYPECAST*)
  2513. preqbuf->RB_Buffer)->GetCredentials.LMSessionKey,
  2514. MAX_SESSIONKEY_SIZE);
  2515. memcpy(UserSessionKey,
  2516. ((REQTYPECAST*)
  2517. preqbuf->RB_Buffer)->GetCredentials.UserSessionKey,
  2518. MAX_USERSESSIONKEY_SIZE);
  2519. retcode = ((REQTYPECAST *)
  2520. preqbuf->RB_Buffer)->GetCredentials.retcode ;
  2521. }
  2522. break ;
  2523. case REQTYPE_SETCACHEDCREDENTIALS:
  2524. {
  2525. retcode = ((REQTYPECAST *)
  2526. preqbuf->RB_Buffer)->SetCachedCredentials.retcode;
  2527. }
  2528. break;
  2529. case REQTYPE_COMPRESSIONGETINFO:
  2530. {
  2531. RAS_COMPRESSION_INFO *send = va_arg(ap, RAS_COMPRESSION_INFO *) ;
  2532. RAS_COMPRESSION_INFO *recv = va_arg(ap, RAS_COMPRESSION_INFO *) ;
  2533. memcpy (send,
  2534. &((REQTYPECAST *)preqbuf->RB_Buffer)->CompressionGetInfo.
  2535. send,
  2536. sizeof (RAS_COMPRESSION_INFO)) ;
  2537. memcpy (recv,
  2538. &((REQTYPECAST *)preqbuf->RB_Buffer)->CompressionGetInfo.
  2539. recv,
  2540. sizeof (RAS_COMPRESSION_INFO)) ;
  2541. retcode = ((REQTYPECAST*)
  2542. preqbuf->RB_Buffer)->CompressionGetInfo.retcode;
  2543. }
  2544. break ;
  2545. case REQTYPE_ENUMLANNETS:
  2546. {
  2547. DWORD *count = va_arg (ap, DWORD*) ;
  2548. UCHAR *lanas = va_arg (ap, UCHAR*) ;
  2549. *count =
  2550. (((REQTYPECAST*)preqbuf->RB_Buffer)->EnumLanNets.count <
  2551. MAX_LAN_NETS) ?
  2552. ((REQTYPECAST*)preqbuf->RB_Buffer)->EnumLanNets.count :
  2553. MAX_LAN_NETS ;
  2554. memcpy (lanas,
  2555. ((REQTYPECAST *)preqbuf->RB_Buffer)->EnumLanNets.lanas,
  2556. (*count) * sizeof (UCHAR)) ;
  2557. retcode = SUCCESS ;
  2558. }
  2559. break ;
  2560. case REQTYPE_RETRIEVEUSERDATA:
  2561. {
  2562. if ((retcode =
  2563. ((REQTYPECAST *)pbTemp->RB_Buffer)->OldUserData.retcode)
  2564. != SUCCESS)
  2565. {
  2566. break ;
  2567. }
  2568. if (*pdwSize < ((REQTYPECAST *)pbTemp->RB_Buffer)->OldUserData.size)
  2569. {
  2570. *pdwSize = ((REQTYPECAST *)pbTemp->RB_Buffer)->OldUserData.
  2571. size ;
  2572. retcode = ERROR_BUFFER_TOO_SMALL ;
  2573. break ;
  2574. }
  2575. *pdwSize = ((REQTYPECAST *)pbTemp->RB_Buffer)->OldUserData.size ;
  2576. memcpy (pUserBuffer,
  2577. ((REQTYPECAST *)pbTemp->RB_Buffer)->OldUserData.data,
  2578. *pdwSize) ;
  2579. retcode = SUCCESS ;
  2580. }
  2581. break ;
  2582. case REQTYPE_GETFRAMINGEX:
  2583. {
  2584. RAS_FRAMING_INFO *info = va_arg(ap, RAS_FRAMING_INFO *) ;
  2585. if ((retcode =
  2586. ((REQTYPECAST *)preqbuf->RB_Buffer)->FramingInfo.retcode)
  2587. != SUCCESS)
  2588. {
  2589. break ;
  2590. }
  2591. memcpy (info,
  2592. &((REQTYPECAST *)preqbuf->RB_Buffer)->FramingInfo.info,
  2593. sizeof (RAS_FRAMING_INFO)) ;
  2594. retcode = SUCCESS ;
  2595. }
  2596. break ;
  2597. case REQTYPE_GETPROTOCOLCOMPRESSION:
  2598. {
  2599. RAS_PROTOCOLCOMPRESSION *send = va_arg(ap,
  2600. RAS_PROTOCOLCOMPRESSION *) ;
  2601. RAS_PROTOCOLCOMPRESSION *recv = va_arg(ap,
  2602. RAS_PROTOCOLCOMPRESSION *) ;
  2603. if ((retcode =
  2604. ((REQTYPECAST *)preqbuf->RB_Buffer)->ProtocolComp.retcode)
  2605. != SUCCESS)
  2606. {
  2607. break ;
  2608. }
  2609. memcpy (send,
  2610. &((REQTYPECAST *)
  2611. preqbuf->RB_Buffer)->ProtocolComp.send,
  2612. sizeof (RAS_PROTOCOLCOMPRESSION)) ;
  2613. memcpy (recv,
  2614. &((REQTYPECAST *)preqbuf->RB_Buffer)->ProtocolComp.recv,
  2615. sizeof (RAS_PROTOCOLCOMPRESSION)) ;
  2616. }
  2617. break ;
  2618. case REQTYPE_PORTENUMPROTOCOLS:
  2619. {
  2620. RAS_PROTOCOLS *protocols = va_arg (ap, RAS_PROTOCOLS*) ;
  2621. PDWORD count = va_arg (ap, PDWORD) ;
  2622. memcpy (protocols,
  2623. &((REQTYPECAST *)
  2624. preqbuf->RB_Buffer)->EnumProtocols.protocols,
  2625. sizeof (RAS_PROTOCOLS)) ;
  2626. *count = ((REQTYPECAST *)
  2627. preqbuf->RB_Buffer)->EnumProtocols.count ;
  2628. retcode = ((REQTYPECAST *)
  2629. preqbuf->RB_Buffer)->EnumProtocols.retcode ;
  2630. }
  2631. break ;
  2632. case REQTYPE_GETFRAMINGCAPABILITIES:
  2633. {
  2634. RAS_FRAMING_CAPABILITIES* caps = va_arg (ap,
  2635. RAS_FRAMING_CAPABILITIES*) ;
  2636. memcpy (caps,
  2637. &((REQTYPECAST *)
  2638. preqbuf->RB_Buffer)->FramingCapabilities.caps,
  2639. sizeof (RAS_FRAMING_CAPABILITIES)) ;
  2640. retcode = ((REQTYPECAST *)
  2641. preqbuf->RB_Buffer)->FramingCapabilities.retcode ;
  2642. }
  2643. break ;
  2644. case REQTYPE_GETBUNDLEDPORT:
  2645. {
  2646. HPORT *phport = va_arg (ap, HPORT*) ;
  2647. *phport = ((REQTYPECAST *)
  2648. preqbuf->RB_Buffer)->GetBundledPort.port ;
  2649. retcode = ((REQTYPECAST *)
  2650. preqbuf->RB_Buffer)->GetBundledPort.retcode ;
  2651. }
  2652. break ;
  2653. case REQTYPE_PORTGETBUNDLE:
  2654. {
  2655. HBUNDLE *phbundle = va_arg(ap, HBUNDLE *) ;
  2656. *phbundle = ((REQTYPECAST *)
  2657. preqbuf->RB_Buffer)->PortGetBundle.bundle;
  2658. retcode = ((REQTYPECAST *)
  2659. preqbuf->RB_Buffer)->PortGetBundle.retcode ;
  2660. }
  2661. break ;
  2662. case REQTYPE_BUNDLEGETPORT:
  2663. {
  2664. HPORT *phport = va_arg (ap, HPORT*) ;
  2665. *phport = ((REQTYPECAST *)
  2666. preqbuf->RB_Buffer)->BundleGetPort.port ;
  2667. retcode = ((REQTYPECAST *)
  2668. preqbuf->RB_Buffer)->BundleGetPort.retcode ;
  2669. }
  2670. break ;
  2671. case REQTYPE_GETDIALPARAMS:
  2672. {
  2673. PRAS_DIALPARAMS pDialParams = va_arg(ap, PRAS_DIALPARAMS);
  2674. retcode = ((REQTYPECAST *)
  2675. pbTemp->RB_Buffer)->DialParams.retcode;
  2676. if(retcode == SUCCESS)
  2677. {
  2678. *pdwMaskDialParams = ((REQTYPECAST *)
  2679. pbTemp->RB_Buffer)->DialParams.dwMask;
  2680. RtlCopyMemory(
  2681. pDialParams,
  2682. &(((REQTYPECAST *)
  2683. pbTemp->RB_Buffer)->DialParams.params),
  2684. sizeof (RAS_DIALPARAMS));
  2685. }
  2686. }
  2687. break;
  2688. case REQTYPE_SETDIALPARAMS:
  2689. {
  2690. retcode = ((REQTYPECAST *)
  2691. pbTemp->RB_Buffer)->DialParams.retcode;
  2692. }
  2693. break;
  2694. case REQTYPE_CREATECONNECTION:
  2695. {
  2696. HCONN *lphconn = va_arg(ap, HCONN *);
  2697. DWORD *pdwAlreadyConnected = va_arg(ap, DWORD *);
  2698. DWORD *pdwSubEntryInfo = va_arg(ap, DWORD * );
  2699. retcode = ((REQTYPECAST *)
  2700. pbTemp->RB_Buffer)->Connection.retcode;
  2701. if (retcode == SUCCESS)
  2702. {
  2703. DWORD dwSubEntries = ((REQTYPECAST *)
  2704. pbTemp->RB_Buffer)->Connection.dwSubEntries;
  2705. *lphconn = ((REQTYPECAST *)
  2706. pbTemp->RB_Buffer)->Connection.conn;
  2707. *pdwAlreadyConnected = ((REQTYPECAST *)
  2708. pbTemp->RB_Buffer)->Connection.
  2709. dwEntryAlreadyConnected;
  2710. if ( *pdwAlreadyConnected )
  2711. {
  2712. memcpy ( pdwSubEntryInfo,
  2713. ((REQTYPECAST *)
  2714. pbTemp->RB_Buffer)->Connection.data,
  2715. dwSubEntries * sizeof ( DWORD ) );
  2716. }
  2717. }
  2718. }
  2719. break;
  2720. case REQTYPE_DESTROYCONNECTION:
  2721. {
  2722. retcode = ((REQTYPECAST *)
  2723. preqbuf->RB_Buffer)->Connection.retcode;
  2724. }
  2725. break;
  2726. case REQTYPE_ENUMCONNECTION:
  2727. {
  2728. HCONN *lphconn = (HCONN *) pUserBuffer;
  2729. LPDWORD lpdwcbConnections = pdwSize;
  2730. LPDWORD lpdwcConnections = va_arg(ap, LPDWORD);
  2731. retcode = ((REQTYPECAST *)
  2732. pbTemp->RB_Buffer)->Enum.retcode;
  2733. if (lphconn != NULL)
  2734. {
  2735. if (*lpdwcbConnections >=
  2736. ((REQTYPECAST *)pbTemp->RB_Buffer)->Enum.size)
  2737. {
  2738. memcpy(
  2739. lphconn,
  2740. &((REQTYPECAST *)pbTemp->RB_Buffer)->Enum.buffer,
  2741. ((REQTYPECAST *)pbTemp->RB_Buffer)->Enum.size);
  2742. }
  2743. else
  2744. retcode = ERROR_BUFFER_TOO_SMALL;
  2745. }
  2746. *lpdwcbConnections =
  2747. ((REQTYPECAST *)pbTemp->RB_Buffer)->Enum.size;
  2748. *lpdwcConnections =
  2749. ((REQTYPECAST *)pbTemp->RB_Buffer)->Enum.entries;
  2750. }
  2751. break;
  2752. case REQTYPE_ADDCONNECTIONPORT:
  2753. {
  2754. retcode = ((REQTYPECAST *)
  2755. preqbuf->RB_Buffer)->AddConnectionPort.retcode;
  2756. }
  2757. break;
  2758. case REQTYPE_ENUMCONNECTIONPORTS:
  2759. {
  2760. RASMAN_PORT *lpPorts = ( RASMAN_PORT *) pUserBuffer;
  2761. LPDWORD lpdwcbPorts = pdwSize;
  2762. LPDWORD lpdwcPorts = va_arg(ap, LPDWORD);
  2763. if (*lpdwcbPorts >= ((REQTYPECAST *)
  2764. pbTemp->RB_Buffer)->EnumConnectionPorts.size)
  2765. {
  2766. retcode = ((REQTYPECAST *)
  2767. pbTemp->RB_Buffer)->EnumConnectionPorts.retcode;
  2768. }
  2769. else
  2770. {
  2771. retcode = ERROR_BUFFER_TOO_SMALL;
  2772. }
  2773. *lpdwcbPorts = ((REQTYPECAST *)
  2774. pbTemp->RB_Buffer)->EnumConnectionPorts.size;
  2775. *lpdwcPorts = ((REQTYPECAST *)
  2776. pbTemp->RB_Buffer)->EnumConnectionPorts.entries;
  2777. if ( retcode == SUCCESS
  2778. && lpPorts != NULL)
  2779. {
  2780. memcpy(
  2781. lpPorts,
  2782. ((REQTYPECAST *)
  2783. pbTemp->RB_Buffer)->EnumConnectionPorts.buffer,
  2784. ((REQTYPECAST *)
  2785. pbTemp->RB_Buffer)->EnumConnectionPorts.size);
  2786. }
  2787. }
  2788. break;
  2789. case REQTYPE_GETCONNECTIONPARAMS:
  2790. {
  2791. PRAS_CONNECTIONPARAMS pParams = va_arg(ap, PRAS_CONNECTIONPARAMS);
  2792. memcpy(
  2793. pParams,
  2794. &(((REQTYPECAST *)
  2795. preqbuf->RB_Buffer)->ConnectionParams.params),
  2796. sizeof (RAS_CONNECTIONPARAMS));
  2797. retcode = ((REQTYPECAST *)
  2798. preqbuf->RB_Buffer)->ConnectionParams.retcode;
  2799. }
  2800. break;
  2801. case REQTYPE_SETCONNECTIONPARAMS:
  2802. {
  2803. retcode = ((REQTYPECAST *)
  2804. preqbuf->RB_Buffer)->ConnectionParams.retcode;
  2805. }
  2806. break;
  2807. case REQTYPE_GETCONNECTIONUSERDATA:
  2808. {
  2809. PBYTE pBuf = pUserBuffer ;
  2810. LPDWORD lpdwcb = pdwSize;
  2811. if ((retcode =
  2812. ((REQTYPECAST *)
  2813. pbTemp->RB_Buffer)->ConnectionUserData.retcode)
  2814. != SUCCESS)
  2815. {
  2816. break ;
  2817. }
  2818. if (lpdwcb != NULL)
  2819. {
  2820. if (*lpdwcb <
  2821. ((REQTYPECAST *)
  2822. pbTemp->RB_Buffer)->ConnectionUserData.dwcb)
  2823. {
  2824. *lpdwcb = ((REQTYPECAST *)
  2825. pbTemp->RB_Buffer)->ConnectionUserData.dwcb;
  2826. retcode = ERROR_BUFFER_TOO_SMALL ;
  2827. break ;
  2828. }
  2829. *lpdwcb = ((REQTYPECAST *)
  2830. pbTemp->RB_Buffer)->ConnectionUserData.dwcb;
  2831. }
  2832. if (pBuf != NULL)
  2833. {
  2834. memcpy(
  2835. pBuf,
  2836. ((REQTYPECAST *)
  2837. pbTemp->RB_Buffer)->ConnectionUserData.data,
  2838. ((REQTYPECAST *)
  2839. pbTemp->RB_Buffer)->ConnectionUserData.dwcb);
  2840. }
  2841. retcode = SUCCESS ;
  2842. }
  2843. break;
  2844. case REQTYPE_SETCONNECTIONUSERDATA:
  2845. {
  2846. retcode = ((REQTYPECAST *)
  2847. preqbuf->RB_Buffer)->ConnectionUserData.retcode;
  2848. }
  2849. break;
  2850. case REQTYPE_GETPORTUSERDATA:
  2851. {
  2852. PBYTE pBuf = pUserBuffer;
  2853. LPDWORD lpdwcb = pdwSize;
  2854. if ((retcode =
  2855. ((REQTYPECAST *)
  2856. pbTemp->RB_Buffer)->PortUserData.retcode)
  2857. != SUCCESS)
  2858. {
  2859. break ;
  2860. }
  2861. if (lpdwcb != NULL)
  2862. {
  2863. if (*lpdwcb < ((REQTYPECAST *)
  2864. pbTemp->RB_Buffer)->PortUserData.dwcb)
  2865. {
  2866. *lpdwcb = ((REQTYPECAST *)
  2867. pbTemp->RB_Buffer)->PortUserData.dwcb;
  2868. retcode = ERROR_BUFFER_TOO_SMALL ;
  2869. break ;
  2870. }
  2871. *lpdwcb = ((REQTYPECAST *)
  2872. pbTemp->RB_Buffer)->PortUserData.dwcb;
  2873. }
  2874. if (pBuf != NULL)
  2875. {
  2876. memcpy(
  2877. pBuf,
  2878. ((REQTYPECAST *)
  2879. pbTemp->RB_Buffer)->PortUserData.data,
  2880. ((REQTYPECAST *)
  2881. pbTemp->RB_Buffer)->PortUserData.dwcb);
  2882. }
  2883. retcode = SUCCESS ;
  2884. }
  2885. break;
  2886. case REQTYPE_SETPORTUSERDATA:
  2887. {
  2888. retcode = ((REQTYPECAST *)
  2889. pbTemp->RB_Buffer)->PortUserData.retcode;
  2890. }
  2891. break;
  2892. case REQTYPE_PPPGETINFO:
  2893. {
  2894. PPP_MESSAGE * pPppMsg = va_arg(ap, PPP_MESSAGE*);
  2895. memcpy( pPppMsg,
  2896. &(((REQTYPECAST *)
  2897. preqbuf->RB_Buffer)->PppMsg),
  2898. sizeof( PPP_MESSAGE ) );
  2899. retcode = pPppMsg->dwError;
  2900. }
  2901. break;
  2902. case REQTYPE_GETTIMESINCELASTACTIVITY:
  2903. {
  2904. LPDWORD lpdwTimeSinceLastActivity = va_arg(ap, LPDWORD);
  2905. *lpdwTimeSinceLastActivity =
  2906. ((REQTYPECAST *)
  2907. preqbuf->RB_Buffer)->GetTimeSinceLastActivity.dwTimeSinceLastActivity;
  2908. retcode =
  2909. ((REQTYPECAST *)
  2910. preqbuf->RB_Buffer)->GetTimeSinceLastActivity.dwRetCode;
  2911. }
  2912. break;
  2913. case REQTYPE_ADDNOTIFICATION:
  2914. {
  2915. retcode = ((REQTYPECAST *)
  2916. preqbuf->RB_Buffer)->AddNotification.retcode;
  2917. }
  2918. break;
  2919. case REQTYPE_SIGNALCONNECTION:
  2920. {
  2921. retcode = ((REQTYPECAST *)
  2922. preqbuf->RB_Buffer)->SignalConnection.retcode;
  2923. }
  2924. break;
  2925. case REQTYPE_GETDEVCONFIG:
  2926. {
  2927. if ((retcode =
  2928. ((REQTYPECAST *)
  2929. pbTemp->RB_Buffer)->GetDevConfig.retcode)
  2930. != SUCCESS)
  2931. {
  2932. ;
  2933. }
  2934. else if (((REQTYPECAST *)
  2935. pbTemp->RB_Buffer)->GetDevConfig.size > *pdwSize)
  2936. {
  2937. retcode = ERROR_BUFFER_TOO_SMALL ;
  2938. }
  2939. else
  2940. {
  2941. memcpy (pUserBuffer,
  2942. ((REQTYPECAST *)
  2943. pbTemp->RB_Buffer)->GetDevConfig.config,
  2944. ((REQTYPECAST *)
  2945. pbTemp->RB_Buffer)->GetDevConfig.size) ;
  2946. }
  2947. *pdwSize = ((REQTYPECAST *)
  2948. pbTemp->RB_Buffer)->GetDevConfig.size ;
  2949. }
  2950. break ;
  2951. case REQTYPE_GETDEVCONFIGEX:
  2952. {
  2953. if ((retcode =
  2954. ((REQTYPECAST *)
  2955. pbTemp->RB_Buffer)->GetDevConfigEx.retcode)
  2956. != SUCCESS)
  2957. {
  2958. ;
  2959. }
  2960. else if (((REQTYPECAST *)
  2961. pbTemp->RB_Buffer)->GetDevConfigEx.size > *pdwSize)
  2962. {
  2963. retcode = ERROR_BUFFER_TOO_SMALL ;
  2964. }
  2965. else
  2966. {
  2967. memcpy (pUserBuffer,
  2968. ((REQTYPECAST *)
  2969. pbTemp->RB_Buffer)->GetDevConfigEx.config,
  2970. ((REQTYPECAST *)
  2971. pbTemp->RB_Buffer)->GetDevConfigEx.size) ;
  2972. }
  2973. *pdwSize = ((REQTYPECAST *)
  2974. pbTemp->RB_Buffer)->GetDevConfigEx.size ;
  2975. break;
  2976. }
  2977. case REQTYPE_PORTRECEIVEEX:
  2978. {
  2979. PBYTE pBuffer = va_arg ( ap, PBYTE );
  2980. PDWORD size = va_arg (ap, DWORD * );
  2981. DWORD dwSize;
  2982. if ((retcode =
  2983. ((REQTYPECAST *)
  2984. preqbuf->RB_Buffer)->PortReceiveEx.retcode )
  2985. == SUCCESS )
  2986. {
  2987. memcpy (pBuffer,
  2988. &((REQTYPECAST *)
  2989. preqbuf->RB_Buffer)->PortReceiveEx.
  2990. buffer.SRB_Packet.PacketData,
  2991. MAX_SENDRCVBUFFER_SIZE);
  2992. dwSize = ((REQTYPECAST *)
  2993. preqbuf->RB_Buffer)->PortReceiveEx.size;
  2994. *size = ((dwSize > MAX_SENDRCVBUFFER_SIZE)
  2995. ? MAX_SENDRCVBUFFER_SIZE : dwSize );
  2996. }
  2997. break;
  2998. }
  2999. case REQTYPE_GETATTACHEDCOUNT:
  3000. {
  3001. DWORD *pdwAttachedCount = va_arg ( ap, DWORD * );
  3002. if ((retcode =
  3003. ((REQTYPECAST *)
  3004. preqbuf->RB_Buffer)->GetAttachedCount.retcode )
  3005. == SUCCESS )
  3006. {
  3007. *pdwAttachedCount = ((REQTYPECAST *)
  3008. preqbuf->RB_Buffer)->GetAttachedCount.
  3009. dwAttachedCount;
  3010. }
  3011. break;
  3012. }
  3013. case REQTYPE_REFCONNECTION:
  3014. {
  3015. PDWORD pdwRefCount = va_arg ( ap, DWORD * );
  3016. retcode = ((REQTYPECAST*)
  3017. preqbuf->RB_Buffer)->RefConnection.retcode;
  3018. if ( SUCCESS == retcode
  3019. && pdwRefCount )
  3020. {
  3021. *pdwRefCount = ((REQTYPECAST *)
  3022. preqbuf->RB_Buffer )->RefConnection.dwRef;
  3023. }
  3024. }
  3025. break;
  3026. case REQTYPE_GETEAPINFO:
  3027. {
  3028. PBYTE pBuf = pUserBuffer;
  3029. LPDWORD lpdwcb = pdwSize;
  3030. DWORD *pdwContextId = va_arg(ap, DWORD *);
  3031. DWORD *pdwEapTypeId = va_arg(ap, DWORD *);
  3032. if ((retcode =
  3033. ((REQTYPECAST *)pbTemp->RB_Buffer)->GetEapInfo.retcode)
  3034. != SUCCESS)
  3035. {
  3036. break ;
  3037. }
  3038. if ( pdwContextId )
  3039. {
  3040. *pdwContextId = ((REQTYPECAST *)
  3041. pbTemp->RB_Buffer)->GetEapInfo.dwContextId;
  3042. }
  3043. if ( pdwEapTypeId )
  3044. {
  3045. *pdwEapTypeId = ((REQTYPECAST *)
  3046. pbTemp->RB_Buffer)->GetEapInfo.dwEapTypeId;
  3047. }
  3048. if (lpdwcb != NULL)
  3049. {
  3050. if (*lpdwcb <
  3051. ((REQTYPECAST *)
  3052. pbTemp->RB_Buffer)->GetEapInfo.dwSizeofEapUIData)
  3053. {
  3054. *lpdwcb = ((REQTYPECAST *)
  3055. pbTemp->RB_Buffer)->GetEapInfo.dwSizeofEapUIData;
  3056. retcode = ERROR_BUFFER_TOO_SMALL ;
  3057. break ;
  3058. }
  3059. *lpdwcb = ((REQTYPECAST *)
  3060. pbTemp->RB_Buffer)->GetEapInfo.dwSizeofEapUIData;
  3061. }
  3062. if (pBuf != NULL)
  3063. {
  3064. memcpy(
  3065. pBuf,
  3066. ((REQTYPECAST *)pbTemp->RB_Buffer)->GetEapInfo.data,
  3067. ((REQTYPECAST *)
  3068. pbTemp->RB_Buffer)->GetEapInfo.dwSizeofEapUIData);
  3069. }
  3070. retcode = SUCCESS ;
  3071. }
  3072. break;
  3073. case REQTYPE_SETEAPINFO:
  3074. {
  3075. retcode = ((REQTYPECAST *)
  3076. pbTemp->RB_Buffer)->SetEapInfo.retcode;
  3077. }
  3078. break;
  3079. case REQTYPE_GETDEVICECONFIGINFO:
  3080. {
  3081. DWORD *pcEntries = va_arg(ap, DWORD *);
  3082. if(*pdwSize >= ((REQTYPECAST *)
  3083. pbTemp->RB_Buffer)->DeviceConfigInfo.cbBuffer)
  3084. {
  3085. retcode = ((REQTYPECAST *)
  3086. pbTemp->RB_Buffer)->DeviceConfigInfo.retcode;
  3087. }
  3088. else
  3089. {
  3090. retcode = ERROR_BUFFER_TOO_SMALL;
  3091. }
  3092. *pcEntries = ((REQTYPECAST *)
  3093. pbTemp->RB_Buffer)->DeviceConfigInfo.cEntries;
  3094. *pdwSize = ((REQTYPECAST *)
  3095. pbTemp->RB_Buffer)->DeviceConfigInfo.cbBuffer;
  3096. *pdwVersion = ((REQTYPECAST *)
  3097. pbTemp->RB_Buffer)->DeviceConfigInfo.dwVersion;
  3098. if(SUCCESS == retcode)
  3099. {
  3100. memcpy(pUserBuffer,
  3101. ((REQTYPECAST *)
  3102. pbTemp->RB_Buffer)->DeviceConfigInfo.abdata,
  3103. *pdwSize);
  3104. }
  3105. break;
  3106. }
  3107. case REQTYPE_SETDEVICECONFIGINFO:
  3108. {
  3109. retcode = ((REQTYPECAST *)
  3110. pbTemp->RB_Buffer)->DeviceConfigInfo.retcode;
  3111. if(retcode)
  3112. {
  3113. //
  3114. // Copy the buffer to users buffer.
  3115. // the Buffer may have error information
  3116. //
  3117. memcpy(pUserBuffer,
  3118. ((REQTYPECAST *)
  3119. pbTemp->RB_Buffer)->DeviceConfigInfo.abdata,
  3120. ((REQTYPECAST *)
  3121. pbTemp->RB_Buffer)->DeviceConfigInfo.cbBuffer);
  3122. }
  3123. break;
  3124. }
  3125. case REQTYPE_FINDPREREQUISITEENTRY:
  3126. {
  3127. HCONN *phRefConn = va_arg(ap, HCONN *);
  3128. retcode = ((REQTYPECAST *)
  3129. pbTemp->RB_Buffer)->FindRefConnection.retcode;
  3130. if(SUCCESS == retcode)
  3131. {
  3132. *phRefConn =
  3133. ((REQTYPECAST *)
  3134. pbTemp->RB_Buffer)->FindRefConnection.hRefConn;
  3135. }
  3136. break;
  3137. }
  3138. case REQTYPE_GETLINKSTATS:
  3139. case REQTYPE_GETCONNECTIONSTATS:
  3140. {
  3141. PBYTE pStats = va_arg(ap, PBYTE);
  3142. retcode = ((REQTYPECAST *)
  3143. pbTemp->RB_Buffer)->GetStats.retcode;
  3144. if(SUCCESS == retcode)
  3145. {
  3146. //
  3147. // Copy everything except the dwVersion parameter
  3148. // of the RAS_STATS structure. This is what is
  3149. // returned by the rasman server
  3150. //
  3151. memcpy(pStats,
  3152. ((REQTYPECAST *)
  3153. pbTemp->RB_Buffer)->GetStats.abStats,
  3154. (sizeof(RAS_STATS) - sizeof(DWORD)));
  3155. }
  3156. break;
  3157. }
  3158. case REQTYPE_GETHPORTFROMCONNECTION:
  3159. {
  3160. HPORT *phport = va_arg(ap, HPORT *);
  3161. retcode = ((REQTYPECAST *)
  3162. pbTemp->RB_Buffer)->GetHportFromConnection.retcode;
  3163. if(SUCCESS == retcode)
  3164. {
  3165. *phport = ((REQTYPECAST *)
  3166. pbTemp->RB_Buffer)->GetHportFromConnection.hPort;
  3167. }
  3168. break;
  3169. }
  3170. case REQTYPE_REFERENCECUSTOMCOUNT:
  3171. {
  3172. retcode = ((REQTYPECAST *)
  3173. pbTemp->RB_Buffer)->ReferenceCustomCount.retcode;
  3174. if(SUCCESS == retcode)
  3175. {
  3176. BOOL fAddref;
  3177. DWORD *pdwCount;
  3178. fAddref = ((REQTYPECAST *)
  3179. pbTemp->RB_Buffer)->ReferenceCustomCount.fAddRef;
  3180. if(!fAddref)
  3181. {
  3182. CHAR *pszPhonebook = va_arg(ap, CHAR *);
  3183. CHAR *pszEntry = va_arg(ap, CHAR *);
  3184. DWORD *pdwCount = va_arg(ap, DWORD *);
  3185. *pdwCount =
  3186. ((REQTYPECAST *)
  3187. pbTemp->RB_Buffer)->ReferenceCustomCount.dwCount;
  3188. if( NULL == pszPhonebook
  3189. || NULL == pszEntry)
  3190. {
  3191. break;
  3192. }
  3193. strcpy(
  3194. pszPhonebook,
  3195. ((REQTYPECAST *)
  3196. pbTemp->RB_Buffer)->ReferenceCustomCount.szPhonebookPath);
  3197. strcpy(
  3198. pszEntry,
  3199. ((REQTYPECAST *)
  3200. pbTemp->RB_Buffer)->ReferenceCustomCount.szEntryName);
  3201. }
  3202. else
  3203. {
  3204. DWORD *pdwCount = va_arg(ap, DWORD *);
  3205. if(NULL != pdwCount)
  3206. {
  3207. *pdwCount =
  3208. ((REQTYPECAST *)
  3209. pbTemp->RB_Buffer)->ReferenceCustomCount.dwCount;
  3210. }
  3211. }
  3212. }
  3213. break;
  3214. }
  3215. case REQTYPE_GETHCONNFROMENTRY:
  3216. {
  3217. HCONN *phConn = va_arg(ap, HCONN *);
  3218. retcode = ((REQTYPECAST *)
  3219. preqbuf->RB_Buffer)->HconnFromEntry.retcode;
  3220. if(ERROR_SUCCESS == retcode)
  3221. {
  3222. *phConn = ((REQTYPECAST *)
  3223. preqbuf->RB_Buffer)->HconnFromEntry.hConn;
  3224. }
  3225. break;
  3226. }
  3227. case REQTYPE_GETCONNECTINFO:
  3228. {
  3229. DWORD dwRequiredSize;
  3230. dwRequiredSize = ((REQTYPECAST *)
  3231. pbTemp->RB_Buffer)->GetConnectInfo.dwSize
  3232. + sizeof(RAS_CONNECT_INFO)
  3233. - sizeof(RASTAPI_CONNECT_INFO);
  3234. if(*pdwSize < dwRequiredSize)
  3235. {
  3236. retcode = ERROR_BUFFER_TOO_SMALL;
  3237. }
  3238. else
  3239. {
  3240. retcode = ((REQTYPECAST *)
  3241. pbTemp->RB_Buffer)->GetConnectInfo.retcode;
  3242. }
  3243. *pdwSize = dwRequiredSize;
  3244. if(ERROR_SUCCESS == retcode)
  3245. {
  3246. RAS_CONNECT_INFO *pConnectInfo;
  3247. RASTAPI_CONNECT_INFO *pRasTapiConnectInfo;
  3248. //
  3249. // Fixup users buffer to change
  3250. // offsets to pointers.
  3251. //
  3252. pConnectInfo = (RAS_CONNECT_INFO *) pUserBuffer;
  3253. pRasTapiConnectInfo = (RASTAPI_CONNECT_INFO *)
  3254. &((REQTYPECAST *)
  3255. pbTemp->RB_Buffer)->GetConnectInfo.rci;
  3256. // DebugBreak();
  3257. pConnectInfo->dwCallerIdSize =
  3258. pRasTapiConnectInfo->dwCallerIdSize;
  3259. pConnectInfo->dwCalledIdSize =
  3260. pRasTapiConnectInfo->dwCalledIdSize;
  3261. pConnectInfo->dwConnectResponseSize =
  3262. pRasTapiConnectInfo->dwConnectResponseSize;
  3263. pConnectInfo->dwAltCalledIdSize =
  3264. pRasTapiConnectInfo->dwAltCalledIdSize;
  3265. if(pConnectInfo->dwCallerIdSize > 0)
  3266. {
  3267. //
  3268. // Note abdata is already aligned at 8-byte boundary
  3269. //
  3270. pConnectInfo->pszCallerId =
  3271. (CHAR *) pConnectInfo->abdata;
  3272. memcpy(
  3273. pConnectInfo->pszCallerId,
  3274. ((PBYTE) pRasTapiConnectInfo)
  3275. + pRasTapiConnectInfo->dwCallerIdOffset,
  3276. pRasTapiConnectInfo->dwCallerIdSize);
  3277. }
  3278. else
  3279. {
  3280. pConnectInfo->pszCallerId = NULL;
  3281. }
  3282. if(pConnectInfo->dwCalledIdSize > 0)
  3283. {
  3284. pConnectInfo->pszCalledId =
  3285. (CHAR *) pConnectInfo->abdata
  3286. + RASMAN_ALIGN8(pConnectInfo->dwCallerIdSize);
  3287. memcpy(pConnectInfo->pszCalledId,
  3288. ((PBYTE) pRasTapiConnectInfo)
  3289. + pRasTapiConnectInfo->dwCalledIdOffset,
  3290. pRasTapiConnectInfo->dwCalledIdSize);
  3291. }
  3292. else
  3293. {
  3294. pConnectInfo->pszCalledId = NULL;
  3295. }
  3296. if(pConnectInfo->dwConnectResponseSize > 0)
  3297. {
  3298. pConnectInfo->pszConnectResponse =
  3299. (CHAR *) pConnectInfo->abdata
  3300. + RASMAN_ALIGN8(pConnectInfo->dwCallerIdSize)
  3301. + RASMAN_ALIGN8(pConnectInfo->dwCalledIdSize);
  3302. memcpy(pConnectInfo->pszConnectResponse,
  3303. ((PBYTE) pRasTapiConnectInfo)
  3304. + pRasTapiConnectInfo->dwConnectResponseOffset,
  3305. pRasTapiConnectInfo->dwConnectResponseSize);
  3306. }
  3307. else
  3308. {
  3309. pConnectInfo->pszConnectResponse = NULL;
  3310. }
  3311. if(pConnectInfo->dwAltCalledIdSize > 0)
  3312. {
  3313. pConnectInfo->pszAltCalledId =
  3314. (CHAR *) pConnectInfo->abdata
  3315. + RASMAN_ALIGN8(pConnectInfo->dwCallerIdSize)
  3316. + RASMAN_ALIGN8(pConnectInfo->dwCalledIdSize)
  3317. + RASMAN_ALIGN8(pConnectInfo->dwConnectResponseSize);
  3318. memcpy(pConnectInfo->pszAltCalledId,
  3319. ((PBYTE) pRasTapiConnectInfo)
  3320. + pRasTapiConnectInfo->dwAltCalledIdOffset,
  3321. pRasTapiConnectInfo->dwAltCalledIdSize);
  3322. }
  3323. else
  3324. {
  3325. pConnectInfo->pszAltCalledId = NULL;
  3326. }
  3327. // DebugBreak();
  3328. }
  3329. break;
  3330. }
  3331. case REQTYPE_GETDEVICENAME:
  3332. {
  3333. CHAR *pszDeviceName = va_arg(ap, CHAR *);
  3334. retcode = ((REQTYPECAST *)
  3335. pbTemp->RB_Buffer)->GetDeviceName.retcode;
  3336. if(ERROR_SUCCESS == retcode)
  3337. {
  3338. strcpy(pszDeviceName,
  3339. ((REQTYPECAST *)
  3340. pbTemp->RB_Buffer)->GetDeviceName.szDeviceName);
  3341. }
  3342. break;
  3343. }
  3344. case REQTYPE_GETDEVICENAMEW:
  3345. {
  3346. WCHAR *pszDeviceName = va_arg(ap, WCHAR *);
  3347. retcode = ((REQTYPECAST *)
  3348. pbTemp->RB_Buffer)->GetDeviceNameW.retcode;
  3349. if(ERROR_SUCCESS == retcode)
  3350. {
  3351. wcscpy(pszDeviceName,
  3352. //MAX_DEVICE_NAME + 1,
  3353. ((REQTYPECAST *)
  3354. pbTemp->RB_Buffer)->GetDeviceNameW.szDeviceName);
  3355. }
  3356. break;
  3357. }
  3358. case REQTYPE_GETCALLEDID:
  3359. {
  3360. RAS_CALLEDID_INFO *pCalledId =
  3361. &((REQTYPECAST *)
  3362. pbTemp->RB_Buffer)->GetSetCalledId.rciInfo;
  3363. retcode = ((REQTYPECAST *)
  3364. pbTemp->RB_Buffer)->GetSetCalledId.retcode;
  3365. if( (ERROR_SUCCESS == retcode)
  3366. && (*pdwSize < ((REQTYPECAST *)
  3367. pbTemp->RB_Buffer)->GetSetCalledId.dwSize))
  3368. {
  3369. retcode = ERROR_BUFFER_TOO_SMALL;
  3370. }
  3371. *pdwSize = ((REQTYPECAST *)
  3372. pbTemp->RB_Buffer)->GetSetCalledId.dwSize;
  3373. if(ERROR_SUCCESS == retcode)
  3374. {
  3375. memcpy(((RAS_CALLEDID_INFO *)pUserBuffer)->bCalledId,
  3376. pCalledId->bCalledId,
  3377. pCalledId->dwSize);
  3378. ((RAS_CALLEDID_INFO *)pUserBuffer)->dwSize =
  3379. pCalledId->dwSize;
  3380. }
  3381. break;
  3382. }
  3383. case REQTYPE_SETCALLEDID:
  3384. {
  3385. retcode = ((REQTYPECAST *)
  3386. pbTemp->RB_Buffer)->GetSetCalledId.retcode;
  3387. break;
  3388. }
  3389. case REQTYPE_ENABLEIPSEC:
  3390. {
  3391. retcode = ((REQTYPECAST *)
  3392. pbTemp->RB_Buffer)->EnableIpSec.retcode;
  3393. break;
  3394. }
  3395. case REQTYPE_ISIPSECENABLED:
  3396. {
  3397. BOOL *pfIsIpSecEnabled = va_arg(ap, BOOL *);
  3398. retcode = ((REQTYPECAST *)
  3399. pbTemp->RB_Buffer)->IsIpSecEnabled.retcode;
  3400. if(ERROR_SUCCESS == retcode)
  3401. {
  3402. *pfIsIpSecEnabled =
  3403. ((REQTYPECAST *)
  3404. pbTemp->RB_Buffer)->IsIpSecEnabled.fIsIpSecEnabled;
  3405. }
  3406. break;
  3407. }
  3408. case REQTYPE_SETEAPLOGONINFO:
  3409. {
  3410. retcode = ((REQTYPECAST *)
  3411. pbTemp->RB_Buffer)->SetEapLogonInfo.retcode;
  3412. break;
  3413. }
  3414. case REQTYPE_SENDNOTIFICATION:
  3415. {
  3416. retcode = ((REQTYPECAST *)
  3417. pbTemp->RB_Buffer)->SendNotification.retcode;
  3418. break;
  3419. }
  3420. case REQTYPE_GETNDISWANDRIVERCAPS:
  3421. {
  3422. RAS_NDISWAN_DRIVER_INFO *pInfo =
  3423. va_arg(ap, RAS_NDISWAN_DRIVER_INFO *);
  3424. retcode = ((REQTYPECAST *)
  3425. pbTemp->RB_Buffer)->GetNdiswanDriverCaps.retcode;
  3426. if(SUCCESS == retcode)
  3427. {
  3428. memcpy(
  3429. (PBYTE) pInfo,
  3430. (PBYTE) &((REQTYPECAST *)
  3431. pbTemp->RB_Buffer)->GetNdiswanDriverCaps.NdiswanDriverInfo,
  3432. sizeof(RAS_NDISWAN_DRIVER_INFO));
  3433. }
  3434. break;
  3435. }
  3436. case REQTYPE_GETBANDWIDTHUTILIZATION:
  3437. {
  3438. RAS_GET_BANDWIDTH_UTILIZATION *pUtilization =
  3439. va_arg(ap, RAS_GET_BANDWIDTH_UTILIZATION *);
  3440. retcode = ((REQTYPECAST *)
  3441. pbTemp->RB_Buffer)->GetBandwidthUtilization.retcode;
  3442. if(SUCCESS == retcode)
  3443. {
  3444. memcpy(
  3445. (PBYTE) pUtilization,
  3446. (PBYTE) &((REQTYPECAST *)
  3447. pbTemp->RB_Buffer)->GetBandwidthUtilization.BandwidthUtilization,
  3448. sizeof(RAS_GET_BANDWIDTH_UTILIZATION));
  3449. }
  3450. break;
  3451. }
  3452. case REQTYPE_REGISTERREDIALCALLBACK:
  3453. {
  3454. retcode = ((REQTYPECAST *)
  3455. pbTemp->RB_Buffer)->RegisterRedialCallback.retcode;
  3456. break;
  3457. }
  3458. case REQTYPE_GETPROTOCOLINFO:
  3459. {
  3460. RASMAN_GET_PROTOCOL_INFO *pInfo =
  3461. va_arg(ap, RASMAN_GET_PROTOCOL_INFO *);
  3462. retcode = ((REQTYPECAST *)
  3463. pbTemp->RB_Buffer)->GetProtocolInfo.retcode;
  3464. if(SUCCESS != retcode)
  3465. {
  3466. break;
  3467. }
  3468. memcpy(pInfo,
  3469. (PBYTE) &((REQTYPECAST *)
  3470. pbTemp->RB_Buffer)->GetProtocolInfo.Info,
  3471. sizeof(RASMAN_GET_PROTOCOL_INFO));
  3472. break;
  3473. }
  3474. case REQTYPE_GETCUSTOMSCRIPTDLL:
  3475. {
  3476. CHAR *pszCustomScriptDll =
  3477. va_arg(ap, CHAR *);
  3478. retcode = ((REQTYPECAST *)
  3479. pbTemp->RB_Buffer)->GetCustomScriptDll.retcode;
  3480. if(ERROR_SUCCESS == retcode)
  3481. {
  3482. strcpy(pszCustomScriptDll,
  3483. ((REQTYPECAST *)
  3484. pbTemp->RB_Buffer)->GetCustomScriptDll.szCustomScript);
  3485. }
  3486. break;
  3487. }
  3488. case REQTYPE_ISTRUSTEDCUSTOMDLL:
  3489. {
  3490. BOOL *pfTrusted = va_arg( ap, BOOL * );
  3491. retcode = ((REQTYPECAST *)
  3492. pbTemp->RB_Buffer)->IsTrusted.retcode;
  3493. if(SUCCESS == retcode)
  3494. {
  3495. *pfTrusted = ((REQTYPECAST *)
  3496. pbTemp->RB_Buffer)->IsTrusted.fTrusted;
  3497. }
  3498. break;
  3499. }
  3500. case REQTYPE_DOIKE:
  3501. {
  3502. retcode = ((REQTYPECAST *)
  3503. pbTemp->RB_Buffer)->DoIke.retcode;
  3504. break;
  3505. }
  3506. case REQTYPE_QUERYIKESTATUS:
  3507. {
  3508. DWORD * pdwStatus = va_arg(ap, DWORD *);
  3509. retcode = ((REQTYPECAST *)
  3510. pbTemp->RB_Buffer)->QueryIkeStatus.retcode;
  3511. if(SUCCESS == retcode)
  3512. {
  3513. *pdwStatus = ((REQTYPECAST *)
  3514. pbTemp->RB_Buffer)->QueryIkeStatus.dwStatus;
  3515. }
  3516. break;
  3517. }
  3518. case REQTYPE_SETRASCOMMSETTINGS:
  3519. {
  3520. retcode = ((REQTYPECAST *)
  3521. pbTemp->RB_Buffer)->SetRasCommSettings.retcode;
  3522. break;
  3523. }
  3524. case REQTYPE_ENABLERASAUDIO:
  3525. {
  3526. retcode = ((REQTYPECAST *)
  3527. pbTemp->RB_Buffer)->EnableRasAudio.retcode;
  3528. break;
  3529. }
  3530. case REQTYPE_SETKEY:
  3531. {
  3532. retcode = ((REQTYPECAST *)
  3533. pbTemp->RB_Buffer)->GetSetKey.retcode;
  3534. break;
  3535. }
  3536. case REQTYPE_GETKEY:
  3537. {
  3538. PBYTE pbkey = va_arg(ap, PBYTE);
  3539. retcode = ((REQTYPECAST *)
  3540. pbTemp->RB_Buffer)->GetSetKey.retcode;
  3541. *pdwSize = ((REQTYPECAST *)
  3542. pbTemp->RB_Buffer)->GetSetKey.cbkey;
  3543. if(ERROR_SUCCESS == retcode)
  3544. {
  3545. memcpy(pbkey,
  3546. ((REQTYPECAST *)
  3547. pbTemp->RB_Buffer)->GetSetKey.data,
  3548. ((REQTYPECAST *)
  3549. pbTemp->RB_Buffer)->GetSetKey.cbkey);
  3550. }
  3551. break;
  3552. }
  3553. case REQTYPE_ADDRESSDISABLE:
  3554. {
  3555. retcode = ((REQTYPECAST *)
  3556. pbTemp->RB_Buffer)->AddressDisable.retcode;
  3557. break;
  3558. }
  3559. case REQTYPE_SENDCREDS:
  3560. {
  3561. retcode = ((REQTYPECAST *)
  3562. pbTemp->RB_Buffer)->SendCreds.retcode;
  3563. break;
  3564. }
  3565. case REQTYPE_GETUNICODEDEVICENAME:
  3566. {
  3567. WCHAR *pwszDeviceName = va_arg(ap, WCHAR *);
  3568. retcode = ((REQTYPECAST *)
  3569. pbTemp->RB_Buffer)->GetUDeviceName.retcode;
  3570. if(ERROR_SUCCESS == retcode)
  3571. {
  3572. wcscpy(pwszDeviceName,
  3573. ((REQTYPECAST *)
  3574. pbTemp->RB_Buffer)->GetUDeviceName.wszDeviceName);
  3575. }
  3576. break;
  3577. }
  3578. case REQTYPE_REQUESTNOTIFICATION:
  3579. case REQTYPE_COMPRESSIONSETINFO:
  3580. case REQTYPE_DEALLOCATEROUTE:
  3581. case REQTYPE_PORTCLEARSTATISTICS:
  3582. case REQTYPE_BUNDLECLEARSTATISTICS:
  3583. case REQTYPE_PORTDISCONNECT:
  3584. case REQTYPE_PORTCLOSE:
  3585. case REQTYPE_SERVERPORTCLOSE:
  3586. case REQTYPE_PORTSETINFO:
  3587. case REQTYPE_PORTSEND:
  3588. case REQTYPE_PORTRECEIVE:
  3589. case REQTYPE_PORTCONNECTCOMPLETE:
  3590. case REQTYPE_DEVICESETINFO:
  3591. case REQTYPE_DEVICECONNECT:
  3592. case REQTYPE_PORTLISTEN:
  3593. case REQTYPE_CANCELRECEIVE:
  3594. case REQTYPE_STOREUSERDATA:
  3595. case REQTYPE_REGISTERSLIP:
  3596. case REQTYPE_SETFRAMING:
  3597. case REQTYPE_SETFRAMINGEX:
  3598. case REQTYPE_SETPROTOCOLCOMPRESSION:
  3599. case REQTYPE_PORTBUNDLE:
  3600. case REQTYPE_SETATTACHCOUNT:
  3601. case REQTYPE_PPPCHANGEPWD:
  3602. case REQTYPE_PPPSTOP:
  3603. case REQTYPE_PPPSTART:
  3604. case REQTYPE_PPPRETRY:
  3605. case REQTYPE_PPPCALLBACK:
  3606. case REQTYPE_SETDEVCONFIG:
  3607. case REQTYPE_CLOSEPROCESSPORTS:
  3608. case REQTYPE_PNPCONTROL:
  3609. case REQTYPE_SETIOCOMPLETIONPORT:
  3610. case REQTYPE_SETROUTERUSAGE:
  3611. case REQTYPE_SENDPPPMESSAGETORASMAN:
  3612. case REQTYPE_SETRASDIALINFO:
  3613. case REQTYPE_REGISTERPNPNOTIF:
  3614. case REQTYPE_SETBAPPOLICY:
  3615. case REQTYPE_PPPSTARTED:
  3616. default:
  3617. {
  3618. retcode = ((REQTYPECAST *)
  3619. pbTemp->RB_Buffer)->Generic.retcode ;
  3620. }
  3621. break ;
  3622. }
  3623. done:
  3624. if ( pBuffer )
  3625. {
  3626. LocalFree ( pBuffer );
  3627. }
  3628. va_end (ap) ;
  3629. FreeRequestBuffer(preqbuf) ;
  3630. return retcode ;
  3631. }