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.

1130 lines
25 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. rasflag.c
  5. Abstract:
  6. Handlers for ras commands
  7. Revision History:
  8. pmay
  9. --*/
  10. #include "precomp.h"
  11. #pragma hdrstop
  12. static const WCHAR g_pszRegValServerFlags[] = L"ServerFlags";
  13. static const WCHAR g_pszRegKeyServerFlags[] =
  14. L"SYSTEM\\CurrentControlSet\\Services\\RemoteAccess\\Parameters";
  15. //
  16. // Defines data that all server flag commands deal with
  17. //
  18. typedef struct _RASFLAG_DATA
  19. {
  20. HKEY hkFlags;
  21. DWORD dwServerFlags;
  22. } RASFLAG_DATA;
  23. DWORD
  24. RasflagOpen(
  25. OUT PHANDLE phRasFlag);
  26. DWORD
  27. RasflagClose(
  28. IN HANDLE hRasFlag);
  29. DWORD
  30. RasflagRead(
  31. IN HANDLE hRasFlag,
  32. OUT LPDWORD lpdwFlags);
  33. DWORD
  34. RasflagWrite(
  35. IN HANDLE hRasFlag,
  36. IN DWORD dwFlags);
  37. DWORD
  38. RasflagAuthtypeDump(
  39. IN LPCWSTR pszToken,
  40. IN BOOL bAdd);
  41. DWORD
  42. RasflagLinkDump(
  43. IN LPCWSTR pszToken,
  44. IN BOOL bAdd);
  45. DWORD
  46. RasflagMlinkDump(
  47. IN LPCWSTR pszToken,
  48. IN BOOL bAdd);
  49. DWORD
  50. RasflagOpen(
  51. OUT PHANDLE phRasFlag)
  52. {
  53. RASFLAG_DATA* pData = NULL;
  54. DWORD dwErr = NO_ERROR, dwType, dwSize;
  55. do
  56. {
  57. // Alloc the return value
  58. //
  59. pData = (RASFLAG_DATA*) RutlAlloc(sizeof(RASFLAG_DATA), TRUE);
  60. if (pData == NULL)
  61. {
  62. dwErr = ERROR_NOT_ENOUGH_MEMORY;
  63. break;
  64. }
  65. dwErr = RegOpenKeyExW(
  66. g_pServerInfo->hkMachine,
  67. (PWCHAR) g_pszRegKeyServerFlags,
  68. 0,
  69. KEY_READ | KEY_SET_VALUE,
  70. &(pData->hkFlags));
  71. BREAK_ON_DWERR(dwErr);
  72. dwType = REG_DWORD;
  73. dwSize = sizeof(DWORD);
  74. dwErr = RegQueryValueExW(
  75. pData->hkFlags,
  76. (PWCHAR) g_pszRegValServerFlags,
  77. NULL,
  78. &dwType,
  79. (LPBYTE)&(pData->dwServerFlags),
  80. &dwSize);
  81. BREAK_ON_DWERR(dwErr);
  82. // Assign the return value
  83. //
  84. *phRasFlag = (HANDLE)pData;
  85. } while (FALSE);
  86. // Cleanup
  87. {
  88. if (dwErr != NO_ERROR)
  89. {
  90. RasflagClose(pData);
  91. }
  92. }
  93. return dwErr;
  94. }
  95. DWORD
  96. RasflagClose(
  97. IN HANDLE hRasFlag)
  98. {
  99. RASFLAG_DATA* pData = (RASFLAG_DATA*)hRasFlag;
  100. if (pData)
  101. {
  102. if (pData->hkFlags)
  103. {
  104. RegCloseKey(pData->hkFlags);
  105. }
  106. RutlFree(pData);
  107. }
  108. return NO_ERROR;
  109. }
  110. DWORD
  111. RasflagRead(
  112. IN HANDLE hRasFlag,
  113. OUT LPDWORD lpdwFlags)
  114. {
  115. RASFLAG_DATA* pData = (RASFLAG_DATA*)hRasFlag;
  116. *lpdwFlags = pData->dwServerFlags;
  117. return NO_ERROR;
  118. }
  119. DWORD
  120. RasflagWrite(
  121. IN HANDLE hRasFlag,
  122. IN DWORD dwFlags)
  123. {
  124. RASFLAG_DATA* pData = (RASFLAG_DATA*)hRasFlag;
  125. DWORD dwErr;
  126. dwErr = RegSetValueEx(
  127. pData->hkFlags,
  128. (PWCHAR) g_pszRegValServerFlags,
  129. 0,
  130. REG_DWORD,
  131. (CONST BYTE*)&dwFlags,
  132. sizeof(DWORD));
  133. if (dwErr != NO_ERROR)
  134. {
  135. return dwErr;
  136. }
  137. pData->dwServerFlags = dwFlags;
  138. return NO_ERROR;
  139. }
  140. //
  141. // Dumps domain related configuration
  142. //
  143. DWORD
  144. RasflagDumpConfig(
  145. IN HANDLE hFile
  146. )
  147. {
  148. DWORD dwErr = NO_ERROR, dwServerFlags = 0, i;
  149. HANDLE hRasflag = NULL;
  150. PWCHAR pszFlag = NULL, pszEnable = NULL, pszCmd = NULL;
  151. BOOL bEnabled;
  152. do
  153. {
  154. // Get the server flags info
  155. //
  156. dwErr = RasflagOpen( &hRasflag);
  157. BREAK_ON_DWERR(dwErr);
  158. // Read in the current flags
  159. //
  160. dwErr = RasflagRead(hRasflag, &dwServerFlags);
  161. BREAK_ON_DWERR(dwErr);
  162. // Dump the command to set the authentication mode
  163. //
  164. {
  165. PWCHAR pszToken;
  166. if (dwServerFlags & PPPCFG_AllowNoAuthentication)
  167. {
  168. pszToken = TOKEN_BYPASS;
  169. }
  170. else if (dwServerFlags & PPPCFG_AllowNoAuthOnDCPorts)
  171. {
  172. pszToken = TOKEN_NODCC;
  173. }
  174. else
  175. {
  176. pszToken = TOKEN_STANDARD;
  177. }
  178. pszCmd = RutlAssignmentFromTokens(
  179. g_hModule,
  180. TOKEN_MODE,
  181. pszToken);
  182. if (pszCmd == NULL)
  183. {
  184. dwErr = ERROR_NOT_ENOUGH_MEMORY;
  185. break;
  186. }
  187. DisplayMessage(
  188. g_hModule,
  189. MSG_RASFLAG_DUMP2,
  190. DMP_RASFLAG_AUTHMODE_SET,
  191. pszCmd);
  192. RutlFree(pszCmd);
  193. }
  194. // Dump the commands to set the authentication type
  195. //
  196. {
  197. RasflagAuthtypeDump(TOKEN_PAP, FALSE);
  198. RasflagAuthtypeDump(TOKEN_SPAP, FALSE);
  199. RasflagAuthtypeDump(TOKEN_MD5CHAP, FALSE);
  200. RasflagAuthtypeDump(TOKEN_MSCHAP, FALSE);
  201. RasflagAuthtypeDump(TOKEN_MSCHAP2, FALSE);
  202. RasflagAuthtypeDump(TOKEN_EAP, FALSE);
  203. if (dwServerFlags & PPPCFG_NegotiatePAP)
  204. {
  205. RasflagAuthtypeDump(TOKEN_PAP, TRUE);
  206. }
  207. if (dwServerFlags & PPPCFG_NegotiateSPAP)
  208. {
  209. RasflagAuthtypeDump(TOKEN_SPAP, TRUE);
  210. }
  211. if (dwServerFlags & PPPCFG_NegotiateMD5CHAP)
  212. {
  213. RasflagAuthtypeDump(TOKEN_MD5CHAP, TRUE);
  214. }
  215. if (dwServerFlags & PPPCFG_NegotiateMSCHAP)
  216. {
  217. RasflagAuthtypeDump(TOKEN_MSCHAP, TRUE);
  218. }
  219. if (dwServerFlags & PPPCFG_NegotiateStrongMSCHAP)
  220. {
  221. RasflagAuthtypeDump(TOKEN_MSCHAP2, TRUE);
  222. }
  223. if (dwServerFlags & PPPCFG_NegotiateEAP)
  224. {
  225. RasflagAuthtypeDump(TOKEN_EAP, TRUE);
  226. }
  227. }
  228. // Dump the commands to set the link options
  229. //
  230. {
  231. RasflagLinkDump(TOKEN_SWC, FALSE);
  232. RasflagLinkDump(TOKEN_LCP, FALSE);
  233. if (dwServerFlags & PPPCFG_UseSwCompression)
  234. {
  235. RasflagLinkDump(TOKEN_SWC, TRUE);
  236. }
  237. if (dwServerFlags & PPPCFG_UseLcpExtensions)
  238. {
  239. RasflagLinkDump(TOKEN_LCP, TRUE);
  240. }
  241. }
  242. // Dump the commands to set the multilink options
  243. //
  244. {
  245. RasflagMlinkDump(TOKEN_MULTI, FALSE);
  246. RasflagMlinkDump(TOKEN_BACP, FALSE);
  247. if (dwServerFlags & PPPCFG_NegotiateMultilink)
  248. {
  249. RasflagMlinkDump(TOKEN_MULTI, TRUE);
  250. }
  251. if (dwServerFlags & PPPCFG_NegotiateBacp)
  252. {
  253. RasflagMlinkDump(TOKEN_BACP, TRUE);
  254. }
  255. }
  256. } while (FALSE);
  257. // Cleanup
  258. {
  259. if (hRasflag)
  260. {
  261. RasflagClose(hRasflag);
  262. }
  263. }
  264. return dwErr;
  265. }
  266. DWORD
  267. HandleRasflagAuthmodeSet(
  268. IN LPCWSTR pwszMachine,
  269. IN OUT LPWSTR *ppwcArguments,
  270. IN DWORD dwCurrentIndex,
  271. IN DWORD dwArgCount,
  272. IN DWORD dwFlags,
  273. IN LPCVOID pvData,
  274. OUT BOOL *pbDone
  275. )
  276. {
  277. DWORD dwErr = NO_ERROR, dwFlag, dwServerFlags;
  278. HANDLE hRasflag = NULL;
  279. TOKEN_VALUE rgEnum[] =
  280. {
  281. {TOKEN_STANDARD, 0},
  282. {TOKEN_NODCC, PPPCFG_AllowNoAuthOnDCPorts},
  283. {TOKEN_BYPASS, PPPCFG_AllowNoAuthentication}
  284. };
  285. RASMON_CMD_ARG pArgs[] =
  286. {
  287. {
  288. RASMONTR_CMD_TYPE_ENUM,
  289. {TOKEN_MODE, TRUE, FALSE},
  290. rgEnum,
  291. sizeof(rgEnum)/sizeof(*rgEnum),
  292. NULL
  293. }
  294. };
  295. do
  296. {
  297. // Parse
  298. //
  299. dwErr = RutlParse(
  300. ppwcArguments,
  301. dwCurrentIndex,
  302. dwArgCount,
  303. NULL,
  304. pArgs,
  305. sizeof(pArgs)/sizeof(*pArgs));
  306. BREAK_ON_DWERR(dwErr);
  307. // Get arguments
  308. //
  309. dwFlag = RASMON_CMD_ARG_GetDword(&pArgs[0]);
  310. // Read in the ras flags
  311. //
  312. dwErr = RasflagOpen(&hRasflag);
  313. BREAK_ON_DWERR(dwErr);
  314. dwErr = RasflagRead(
  315. hRasflag,
  316. &dwServerFlags);
  317. BREAK_ON_DWERR(dwErr);
  318. // Modify the server flags accordingly
  319. //
  320. switch (dwFlag)
  321. {
  322. case 0:
  323. dwServerFlags &= ~PPPCFG_AllowNoAuthOnDCPorts;
  324. dwServerFlags &= ~PPPCFG_AllowNoAuthentication;
  325. break;
  326. case PPPCFG_AllowNoAuthOnDCPorts:
  327. dwServerFlags |= PPPCFG_AllowNoAuthOnDCPorts;
  328. dwServerFlags &= ~PPPCFG_AllowNoAuthentication;
  329. break;
  330. case PPPCFG_AllowNoAuthentication:
  331. dwServerFlags &= ~PPPCFG_AllowNoAuthOnDCPorts;
  332. dwServerFlags |= PPPCFG_AllowNoAuthentication;
  333. break;
  334. }
  335. dwErr = RasflagWrite(hRasflag, dwServerFlags);
  336. BREAK_ON_DWERR(dwErr);
  337. } while (FALSE);
  338. // Cleanup
  339. //
  340. {
  341. if (hRasflag)
  342. {
  343. RasflagClose(hRasflag);
  344. }
  345. }
  346. return dwErr;
  347. }
  348. DWORD
  349. HandleRasflagAuthmodeShow(
  350. IN LPCWSTR pwszMachine,
  351. IN OUT LPWSTR *ppwcArguments,
  352. IN DWORD dwCurrentIndex,
  353. IN DWORD dwArgCount,
  354. IN DWORD dwFlags,
  355. IN LPCVOID pvData,
  356. OUT BOOL *pbDone
  357. )
  358. {
  359. DWORD dwErr = NO_ERROR, dwRasFlags, dwMessage;
  360. HANDLE hRasflag = NULL;
  361. do
  362. {
  363. // Make sure no arguments were passed in
  364. //
  365. if (dwArgCount - dwCurrentIndex != 0)
  366. {
  367. dwErr = ERROR_INVALID_SYNTAX;
  368. break;
  369. }
  370. // Read in the ras flags
  371. //
  372. dwErr = RasflagOpen(&hRasflag);
  373. BREAK_ON_DWERR(dwErr);
  374. dwErr = RasflagRead(
  375. hRasflag,
  376. &dwRasFlags);
  377. BREAK_ON_DWERR(dwErr);
  378. // Determine the message to print
  379. //
  380. if (dwRasFlags & PPPCFG_AllowNoAuthentication)
  381. {
  382. dwMessage = MSG_RASFLAG_AUTHMODE_BYPASS;
  383. }
  384. else if (dwRasFlags & PPPCFG_AllowNoAuthOnDCPorts)
  385. {
  386. dwMessage = MSG_RASFLAG_AUTHMODE_NODCC;
  387. }
  388. else
  389. {
  390. dwMessage = MSG_RASFLAG_AUTHMODE_STANDARD;
  391. }
  392. DisplayMessage(g_hModule, dwMessage);
  393. } while (FALSE);
  394. // Cleanup
  395. {
  396. if (hRasflag)
  397. {
  398. RasflagClose(hRasflag);
  399. }
  400. }
  401. return dwErr;
  402. }
  403. DWORD
  404. HandleRasflagAuthtypeAddDel(
  405. IN OUT LPWSTR *ppwcArguments,
  406. IN DWORD dwCurrentIndex,
  407. IN DWORD dwArgCount,
  408. IN BOOL *pbDone,
  409. IN BOOL bAdd
  410. )
  411. {
  412. DWORD dwErr = NO_ERROR, dwFlag, dwServerFlags;
  413. HANDLE hRasflag = NULL;
  414. TOKEN_VALUE rgEnum[] =
  415. {
  416. {TOKEN_PAP, PPPCFG_NegotiatePAP},
  417. {TOKEN_SPAP, PPPCFG_NegotiateSPAP},
  418. {TOKEN_MD5CHAP, PPPCFG_NegotiateMD5CHAP},
  419. {TOKEN_MSCHAP, PPPCFG_NegotiateMSCHAP},
  420. {TOKEN_MSCHAP2, PPPCFG_NegotiateStrongMSCHAP},
  421. {TOKEN_EAP, PPPCFG_NegotiateEAP},
  422. };
  423. RASMON_CMD_ARG pArgs[] =
  424. {
  425. {
  426. RASMONTR_CMD_TYPE_ENUM,
  427. {TOKEN_TYPE, TRUE, FALSE},
  428. rgEnum,
  429. sizeof(rgEnum)/sizeof(*rgEnum),
  430. NULL
  431. }
  432. };
  433. do
  434. {
  435. // Parse
  436. //
  437. dwErr = RutlParse(
  438. ppwcArguments,
  439. dwCurrentIndex,
  440. dwArgCount,
  441. NULL,
  442. pArgs,
  443. sizeof(pArgs)/sizeof(*pArgs));
  444. BREAK_ON_DWERR(dwErr);
  445. // Get arguments
  446. //
  447. dwFlag = RASMON_CMD_ARG_GetDword(&pArgs[0]);
  448. // Read in the ras flags
  449. //
  450. dwErr = RasflagOpen(&hRasflag);
  451. BREAK_ON_DWERR(dwErr);
  452. dwErr = RasflagRead(
  453. hRasflag,
  454. &dwServerFlags);
  455. BREAK_ON_DWERR(dwErr);
  456. // Modify the server flags accordingly
  457. //
  458. if (bAdd)
  459. {
  460. dwServerFlags |= dwFlag;
  461. }
  462. else
  463. {
  464. dwServerFlags &= ~dwFlag;
  465. }
  466. dwErr = RasflagWrite(hRasflag, dwServerFlags);
  467. BREAK_ON_DWERR(dwErr);
  468. } while (FALSE);
  469. // Cleanup
  470. //
  471. {
  472. if (hRasflag)
  473. {
  474. RasflagClose(hRasflag);
  475. }
  476. }
  477. return dwErr;
  478. }
  479. DWORD
  480. HandleRasflagAuthtypeAdd(
  481. IN LPCWSTR pwszMachine,
  482. IN OUT LPWSTR *ppwcArguments,
  483. IN DWORD dwCurrentIndex,
  484. IN DWORD dwArgCount,
  485. IN DWORD dwFlags,
  486. IN LPCVOID pvData,
  487. OUT BOOL *pbDone
  488. )
  489. {
  490. return HandleRasflagAuthtypeAddDel(
  491. ppwcArguments,
  492. dwCurrentIndex,
  493. dwArgCount,
  494. pbDone,
  495. TRUE);
  496. }
  497. DWORD
  498. HandleRasflagAuthtypeDel(
  499. IN LPCWSTR pwszMachine,
  500. IN OUT LPWSTR *ppwcArguments,
  501. IN DWORD dwCurrentIndex,
  502. IN DWORD dwArgCount,
  503. IN DWORD dwFlags,
  504. IN LPCVOID pvData,
  505. OUT BOOL *pbDone
  506. )
  507. {
  508. return HandleRasflagAuthtypeAddDel(
  509. ppwcArguments,
  510. dwCurrentIndex,
  511. dwArgCount,
  512. pbDone,
  513. FALSE);
  514. }
  515. DWORD
  516. HandleRasflagAuthtypeShow(
  517. IN LPCWSTR pwszMachine,
  518. IN OUT LPWSTR *ppwcArguments,
  519. IN DWORD dwCurrentIndex,
  520. IN DWORD dwArgCount,
  521. IN DWORD dwFlags,
  522. IN LPCVOID pvData,
  523. OUT BOOL *pbDone
  524. )
  525. {
  526. DWORD dwErr = NO_ERROR, dwRasFlags, dwMessage;
  527. HANDLE hRasflag = NULL;
  528. do
  529. {
  530. // Make sure no arguments were passed in
  531. //
  532. if (dwArgCount - dwCurrentIndex != 0)
  533. {
  534. dwErr = ERROR_INVALID_SYNTAX;
  535. break;
  536. }
  537. // Read in the ras flags
  538. //
  539. dwErr = RasflagOpen(&hRasflag);
  540. BREAK_ON_DWERR(dwErr);
  541. dwErr = RasflagRead(
  542. hRasflag,
  543. &dwRasFlags);
  544. BREAK_ON_DWERR(dwErr);
  545. // Display the header
  546. //
  547. DisplayMessage(g_hModule, MSG_RASFLAG_AUTHTYPE_HEADER);
  548. // Determine the types to print out
  549. //
  550. if (dwRasFlags & PPPCFG_NegotiatePAP)
  551. {
  552. DisplayMessage(g_hModule, MSG_RASFLAG_AUTHTYPE_PAP);
  553. }
  554. if (dwRasFlags & PPPCFG_NegotiateSPAP)
  555. {
  556. DisplayMessage(g_hModule, MSG_RASFLAG_AUTHTYPE_SPAP);
  557. }
  558. if (dwRasFlags & PPPCFG_NegotiateMD5CHAP)
  559. {
  560. DisplayMessage(g_hModule, MSG_RASFLAG_AUTHTYPE_MD5CHAP);
  561. }
  562. if (dwRasFlags & PPPCFG_NegotiateMSCHAP)
  563. {
  564. DisplayMessage(g_hModule, MSG_RASFLAG_AUTHTYPE_MSCHAP);
  565. }
  566. if (dwRasFlags & PPPCFG_NegotiateStrongMSCHAP)
  567. {
  568. DisplayMessage(g_hModule, MSG_RASFLAG_AUTHTYPE_MSCHAP2);
  569. }
  570. if (dwRasFlags & PPPCFG_NegotiateEAP)
  571. {
  572. DisplayMessage(g_hModule, MSG_RASFLAG_AUTHTYPE_EAP);
  573. }
  574. } while (FALSE);
  575. // Cleanup
  576. {
  577. if (hRasflag)
  578. {
  579. RasflagClose(hRasflag);
  580. }
  581. }
  582. return dwErr;
  583. }
  584. DWORD
  585. HandleRasflagLinkAddDel(
  586. IN OUT LPWSTR *ppwcArguments,
  587. IN DWORD dwCurrentIndex,
  588. IN DWORD dwArgCount,
  589. IN BOOL *pbDone,
  590. IN BOOL bAdd
  591. )
  592. {
  593. DWORD dwErr = NO_ERROR, dwFlag, dwServerFlags;
  594. HANDLE hRasflag = NULL;
  595. TOKEN_VALUE rgEnum[] =
  596. {
  597. {TOKEN_SWC, PPPCFG_UseSwCompression},
  598. {TOKEN_LCP, PPPCFG_UseLcpExtensions},
  599. };
  600. RASMON_CMD_ARG pArgs[] =
  601. {
  602. {
  603. RASMONTR_CMD_TYPE_ENUM,
  604. {TOKEN_TYPE, TRUE, FALSE},
  605. rgEnum,
  606. sizeof(rgEnum)/sizeof(*rgEnum),
  607. NULL
  608. }
  609. };
  610. do
  611. {
  612. // Parse
  613. //
  614. dwErr = RutlParse(
  615. ppwcArguments,
  616. dwCurrentIndex,
  617. dwArgCount,
  618. NULL,
  619. pArgs,
  620. sizeof(pArgs)/sizeof(*pArgs));
  621. BREAK_ON_DWERR(dwErr);
  622. // Get arguments
  623. //
  624. dwFlag = RASMON_CMD_ARG_GetDword(&pArgs[0]);
  625. // Read in the ras flags
  626. //
  627. dwErr = RasflagOpen(&hRasflag);
  628. BREAK_ON_DWERR(dwErr);
  629. dwErr = RasflagRead(
  630. hRasflag,
  631. &dwServerFlags);
  632. BREAK_ON_DWERR(dwErr);
  633. // Modify the server flags accordingly
  634. //
  635. if (bAdd)
  636. {
  637. dwServerFlags |= dwFlag;
  638. }
  639. else
  640. {
  641. dwServerFlags &= ~dwFlag;
  642. }
  643. dwErr = RasflagWrite(hRasflag, dwServerFlags);
  644. BREAK_ON_DWERR(dwErr);
  645. } while (FALSE);
  646. // Cleanup
  647. //
  648. {
  649. if (hRasflag)
  650. {
  651. RasflagClose(hRasflag);
  652. }
  653. }
  654. return dwErr;
  655. }
  656. DWORD
  657. HandleRasflagLinkAdd(
  658. IN LPCWSTR pwszMachine,
  659. IN OUT LPWSTR *ppwcArguments,
  660. IN DWORD dwCurrentIndex,
  661. IN DWORD dwArgCount,
  662. IN DWORD dwFlags,
  663. IN LPCVOID pvData,
  664. OUT BOOL *pbDone
  665. )
  666. {
  667. return HandleRasflagLinkAddDel(
  668. ppwcArguments,
  669. dwCurrentIndex,
  670. dwArgCount,
  671. pbDone,
  672. TRUE);
  673. }
  674. DWORD
  675. HandleRasflagLinkDel(
  676. IN LPCWSTR pwszMachine,
  677. IN OUT LPWSTR *ppwcArguments,
  678. IN DWORD dwCurrentIndex,
  679. IN DWORD dwArgCount,
  680. IN DWORD dwFlags,
  681. IN LPCVOID pvData,
  682. OUT BOOL *pbDone
  683. )
  684. {
  685. return HandleRasflagLinkAddDel(
  686. ppwcArguments,
  687. dwCurrentIndex,
  688. dwArgCount,
  689. pbDone,
  690. FALSE);
  691. }
  692. DWORD
  693. HandleRasflagLinkShow(
  694. IN LPCWSTR pwszMachine,
  695. IN OUT LPWSTR *ppwcArguments,
  696. IN DWORD dwCurrentIndex,
  697. IN DWORD dwArgCount,
  698. IN DWORD dwFlags,
  699. IN LPCVOID pvData,
  700. OUT BOOL *pbDone
  701. )
  702. {
  703. DWORD dwErr = NO_ERROR, dwRasFlags, dwMessage;
  704. HANDLE hRasflag = NULL;
  705. do
  706. {
  707. // Make sure no arguments were passed in
  708. //
  709. if (dwArgCount - dwCurrentIndex != 0)
  710. {
  711. dwErr = ERROR_INVALID_SYNTAX;
  712. break;
  713. }
  714. // Read in the ras flags
  715. //
  716. dwErr = RasflagOpen(&hRasflag);
  717. BREAK_ON_DWERR(dwErr);
  718. dwErr = RasflagRead(
  719. hRasflag,
  720. &dwRasFlags);
  721. BREAK_ON_DWERR(dwErr);
  722. // Display the header
  723. //
  724. DisplayMessage(g_hModule, MSG_RASFLAG_LINK_HEADER);
  725. // Determine the types to print out
  726. //
  727. if (dwRasFlags & PPPCFG_UseSwCompression)
  728. {
  729. DisplayMessage(g_hModule, MSG_RASFLAG_LINK_SWC);
  730. }
  731. if (dwRasFlags & PPPCFG_UseLcpExtensions)
  732. {
  733. DisplayMessage(g_hModule, MSG_RASFLAG_LINK_LCP);
  734. }
  735. } while (FALSE);
  736. // Cleanup
  737. {
  738. if (hRasflag)
  739. {
  740. RasflagClose(hRasflag);
  741. }
  742. }
  743. return dwErr;
  744. }
  745. DWORD
  746. HandleRasflagMlinkAddDel(
  747. IN OUT LPWSTR *ppwcArguments,
  748. IN DWORD dwCurrentIndex,
  749. IN DWORD dwArgCount,
  750. IN BOOL *pbDone,
  751. IN BOOL bAdd
  752. )
  753. {
  754. DWORD dwErr = NO_ERROR, dwFlag, dwServerFlags;
  755. HANDLE hRasflag = NULL;
  756. TOKEN_VALUE rgEnum[] =
  757. {
  758. {TOKEN_MULTI, PPPCFG_NegotiateMultilink},
  759. {TOKEN_BACP, PPPCFG_NegotiateBacp},
  760. };
  761. RASMON_CMD_ARG pArgs[] =
  762. {
  763. {
  764. RASMONTR_CMD_TYPE_ENUM,
  765. {TOKEN_TYPE, TRUE, FALSE},
  766. rgEnum,
  767. sizeof(rgEnum)/sizeof(*rgEnum),
  768. NULL
  769. }
  770. };
  771. do
  772. {
  773. // Parse
  774. //
  775. dwErr = RutlParse(
  776. ppwcArguments,
  777. dwCurrentIndex,
  778. dwArgCount,
  779. NULL,
  780. pArgs,
  781. sizeof(pArgs)/sizeof(*pArgs));
  782. BREAK_ON_DWERR(dwErr);
  783. // Get arguments
  784. //
  785. dwFlag = RASMON_CMD_ARG_GetDword(&pArgs[0]);
  786. // Read in the ras flags
  787. //
  788. dwErr = RasflagOpen(&hRasflag);
  789. BREAK_ON_DWERR(dwErr);
  790. dwErr = RasflagRead(
  791. hRasflag,
  792. &dwServerFlags);
  793. BREAK_ON_DWERR(dwErr);
  794. // Modify the server flags accordingly
  795. //
  796. if (bAdd)
  797. {
  798. dwServerFlags |= dwFlag;
  799. }
  800. else
  801. {
  802. dwServerFlags &= ~dwFlag;
  803. }
  804. dwErr = RasflagWrite(hRasflag, dwServerFlags);
  805. BREAK_ON_DWERR(dwErr);
  806. } while (FALSE);
  807. // Cleanup
  808. //
  809. {
  810. if (hRasflag)
  811. {
  812. RasflagClose(hRasflag);
  813. }
  814. }
  815. return dwErr;
  816. }
  817. DWORD
  818. HandleRasflagMlinkAdd(
  819. IN LPCWSTR pwszMachine,
  820. IN OUT LPWSTR *ppwcArguments,
  821. IN DWORD dwCurrentIndex,
  822. IN DWORD dwArgCount,
  823. IN DWORD dwFlags,
  824. IN LPCVOID pvData,
  825. OUT BOOL *pbDone
  826. )
  827. {
  828. return HandleRasflagMlinkAddDel(
  829. ppwcArguments,
  830. dwCurrentIndex,
  831. dwArgCount,
  832. pbDone,
  833. TRUE);
  834. }
  835. DWORD
  836. HandleRasflagMlinkDel(
  837. IN LPCWSTR pwszMachine,
  838. IN OUT LPWSTR *ppwcArguments,
  839. IN DWORD dwCurrentIndex,
  840. IN DWORD dwArgCount,
  841. IN DWORD dwFlags,
  842. IN LPCVOID pvData,
  843. OUT BOOL *pbDone
  844. )
  845. {
  846. return HandleRasflagMlinkAddDel(
  847. ppwcArguments,
  848. dwCurrentIndex,
  849. dwArgCount,
  850. pbDone,
  851. FALSE);
  852. }
  853. DWORD
  854. HandleRasflagMlinkShow(
  855. IN LPCWSTR pwszMachine,
  856. IN OUT LPWSTR *ppwcArguments,
  857. IN DWORD dwCurrentIndex,
  858. IN DWORD dwArgCount,
  859. IN DWORD dwFlags,
  860. IN LPCVOID pvData,
  861. OUT BOOL *pbDone
  862. )
  863. {
  864. DWORD dwErr = NO_ERROR, dwRasFlags, dwMessage;
  865. HANDLE hRasflag = NULL;
  866. do
  867. {
  868. // Make sure no arguments were passed in
  869. //
  870. if (dwArgCount - dwCurrentIndex != 0)
  871. {
  872. dwErr = ERROR_INVALID_SYNTAX;
  873. break;
  874. }
  875. // Read in the ras flags
  876. //
  877. dwErr = RasflagOpen(&hRasflag);
  878. BREAK_ON_DWERR(dwErr);
  879. dwErr = RasflagRead(
  880. hRasflag,
  881. &dwRasFlags);
  882. BREAK_ON_DWERR(dwErr);
  883. // Display the header
  884. //
  885. DisplayMessage(g_hModule, MSG_RASFLAG_MLINK_HEADER);
  886. // Determine the types to print out
  887. //
  888. if (dwRasFlags & PPPCFG_NegotiateMultilink)
  889. {
  890. DisplayMessage(g_hModule, MSG_RASFLAG_MLINK_MULTI);
  891. }
  892. if (dwRasFlags & PPPCFG_NegotiateBacp)
  893. {
  894. DisplayMessage(g_hModule, MSG_RASFLAG_MLINK_BACP);
  895. }
  896. } while (FALSE);
  897. // Cleanup
  898. {
  899. if (hRasflag)
  900. {
  901. RasflagClose(hRasflag);
  902. }
  903. }
  904. return dwErr;
  905. }
  906. DWORD
  907. RasflagAuthtypeDump(
  908. IN LPCWSTR pszToken,
  909. IN BOOL bAdd)
  910. {
  911. PWCHAR pszCmd = NULL;
  912. pszCmd = RutlAssignmentFromTokens(
  913. g_hModule,
  914. TOKEN_TYPE,
  915. pszToken);
  916. if (pszCmd == NULL)
  917. {
  918. return ERROR_NOT_ENOUGH_MEMORY;
  919. }
  920. DisplayMessage(
  921. g_hModule,
  922. MSG_RASFLAG_DUMP2,
  923. (bAdd) ? DMP_RASFLAG_AUTHTYPE_ADD : DMP_RASFLAG_AUTHTYPE_DEL,
  924. pszCmd);
  925. RutlFree(pszCmd);
  926. return NO_ERROR;
  927. }
  928. DWORD
  929. RasflagLinkDump(
  930. IN LPCWSTR pszToken,
  931. IN BOOL bAdd)
  932. {
  933. PWCHAR pszCmd = NULL;
  934. pszCmd = RutlAssignmentFromTokens(
  935. g_hModule,
  936. TOKEN_TYPE,
  937. pszToken);
  938. if (pszCmd == NULL)
  939. {
  940. return ERROR_NOT_ENOUGH_MEMORY;
  941. }
  942. DisplayMessage(
  943. g_hModule,
  944. MSG_RASFLAG_DUMP2,
  945. (bAdd) ? DMP_RASFLAG_LINK_ADD : DMP_RASFLAG_LINK_DEL,
  946. pszCmd);
  947. RutlFree(pszCmd);
  948. return NO_ERROR;
  949. }
  950. DWORD
  951. RasflagMlinkDump(
  952. IN LPCWSTR pszToken,
  953. IN BOOL bAdd)
  954. {
  955. PWCHAR pszCmd = NULL;
  956. pszCmd = RutlAssignmentFromTokens(
  957. g_hModule,
  958. TOKEN_TYPE,
  959. pszToken);
  960. if (pszCmd == NULL)
  961. {
  962. return ERROR_NOT_ENOUGH_MEMORY;
  963. }
  964. DisplayMessage(
  965. g_hModule,
  966. MSG_RASFLAG_DUMP2,
  967. (bAdd) ? DMP_RASFLAG_MLINK_ADD : DMP_RASFLAG_MLINK_DEL,
  968. pszCmd);
  969. RutlFree(pszCmd);
  970. return NO_ERROR;
  971. }