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.

713 lines
18 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Abstract:
  4. Port Proxy Helper.
  5. --*/
  6. #include "precomp.h"
  7. GUID g_PpGuid = PORTPROXY_GUID;
  8. #define KEY_PORTS L"System\\CurrentControlSet\\Services\\PortProxy"
  9. typedef enum {
  10. V4TOV4,
  11. V4TOV6,
  12. V6TOV4,
  13. V6TOV6
  14. } PPTYPE, *PPPTYPE;
  15. typedef struct {
  16. PWCHAR Token;
  17. PWCHAR ListenFamily;
  18. PWCHAR ConnectFamily;
  19. PWCHAR KeyString;
  20. } PPTYPEINFO, *PPPTYPEINFO;
  21. #define IPV4_STR L"IPv4"
  22. #define IPV6_STR L"IPv6"
  23. PPTYPEINFO PpTypeInfo[] = {
  24. { CMD_V4TOV4, IPV4_STR, IPV4_STR, KEY_PORTS L"\\" CMD_V4TOV4 },
  25. { CMD_V4TOV6, IPV4_STR, IPV6_STR, KEY_PORTS L"\\" CMD_V4TOV6 },
  26. { CMD_V6TOV4, IPV6_STR, IPV4_STR, KEY_PORTS L"\\" CMD_V6TOV4 },
  27. { CMD_V6TOV6, IPV6_STR, IPV6_STR, KEY_PORTS L"\\" CMD_V6TOV6 },
  28. };
  29. //
  30. // Port Proxy commands.
  31. //
  32. FN_HANDLE_CMD PpHandleReset;
  33. FN_HANDLE_CMD PpHandleDelV4ToV4;
  34. FN_HANDLE_CMD PpHandleDelV4ToV6;
  35. FN_HANDLE_CMD PpHandleDelV6ToV4;
  36. FN_HANDLE_CMD PpHandleDelV6ToV6;
  37. FN_HANDLE_CMD PpHandleAddSetV4ToV4;
  38. FN_HANDLE_CMD PpHandleAddSetV4ToV6;
  39. FN_HANDLE_CMD PpHandleAddSetV6ToV4;
  40. FN_HANDLE_CMD PpHandleAddSetV6ToV6;
  41. FN_HANDLE_CMD PpHandleShowAll;
  42. FN_HANDLE_CMD PpHandleShowV4ToV4;
  43. FN_HANDLE_CMD PpHandleShowV4ToV6;
  44. FN_HANDLE_CMD PpHandleShowV6ToV4;
  45. FN_HANDLE_CMD PpHandleShowV6ToV6;
  46. CMD_ENTRY g_PpAddCmdTable[] =
  47. {
  48. CREATE_UNDOCUMENTED_CMD_ENTRY(PP_ADD_V4TOV4, PpHandleAddSetV4ToV4),
  49. CREATE_UNDOCUMENTED_CMD_ENTRY(PP_ADD_V4TOV6, PpHandleAddSetV4ToV6),
  50. CREATE_UNDOCUMENTED_CMD_ENTRY(PP_ADD_V6TOV4, PpHandleAddSetV6ToV4),
  51. CREATE_UNDOCUMENTED_CMD_ENTRY(PP_ADD_V6TOV6, PpHandleAddSetV6ToV6),
  52. };
  53. CMD_ENTRY g_PpDelCmdTable[] =
  54. {
  55. CREATE_UNDOCUMENTED_CMD_ENTRY(PP_DEL_V4TOV4, PpHandleDelV4ToV4),
  56. CREATE_UNDOCUMENTED_CMD_ENTRY(PP_DEL_V4TOV6, PpHandleDelV4ToV6),
  57. CREATE_UNDOCUMENTED_CMD_ENTRY(PP_DEL_V6TOV4, PpHandleDelV6ToV4),
  58. CREATE_UNDOCUMENTED_CMD_ENTRY(PP_DEL_V6TOV6, PpHandleDelV6ToV6),
  59. };
  60. CMD_ENTRY g_PpSetCmdTable[] =
  61. {
  62. CREATE_UNDOCUMENTED_CMD_ENTRY(PP_SET_V4TOV4, PpHandleAddSetV4ToV4),
  63. CREATE_UNDOCUMENTED_CMD_ENTRY(PP_SET_V4TOV6, PpHandleAddSetV4ToV6),
  64. CREATE_UNDOCUMENTED_CMD_ENTRY(PP_SET_V6TOV4, PpHandleAddSetV6ToV4),
  65. CREATE_UNDOCUMENTED_CMD_ENTRY(PP_SET_V6TOV6, PpHandleAddSetV6ToV6),
  66. };
  67. CMD_ENTRY g_PpShowCmdTable[] =
  68. {
  69. CREATE_UNDOCUMENTED_CMD_ENTRY(PP_SHOW_ALL, PpHandleShowAll),
  70. CREATE_UNDOCUMENTED_CMD_ENTRY(PP_SHOW_V4TOV4, PpHandleShowV4ToV4),
  71. CREATE_UNDOCUMENTED_CMD_ENTRY(PP_SHOW_V4TOV6, PpHandleShowV4ToV6),
  72. CREATE_UNDOCUMENTED_CMD_ENTRY(PP_SHOW_V6TOV4, PpHandleShowV6ToV4),
  73. CREATE_UNDOCUMENTED_CMD_ENTRY(PP_SHOW_V6TOV6, PpHandleShowV6ToV6),
  74. };
  75. CMD_GROUP_ENTRY g_PpCmdGroups[] =
  76. {
  77. CREATE_CMD_GROUP_ENTRY(GROUP_ADD, g_PpAddCmdTable),
  78. CREATE_CMD_GROUP_ENTRY(GROUP_DELETE, g_PpDelCmdTable),
  79. CREATE_CMD_GROUP_ENTRY(GROUP_SHOW, g_PpShowCmdTable),
  80. CREATE_CMD_GROUP_ENTRY(GROUP_SET, g_PpSetCmdTable),
  81. };
  82. ULONG g_ulNumPpCmdGroups = sizeof(g_PpCmdGroups)/sizeof(CMD_GROUP_ENTRY);
  83. CMD_ENTRY g_PpTopCmds[] =
  84. {
  85. CREATE_CMD_ENTRY(IPV6_RESET, PpHandleReset),
  86. };
  87. ULONG g_ulNumPpTopCmds = sizeof(g_PpTopCmds)/sizeof(CMD_ENTRY);
  88. DWORD
  89. WINAPI
  90. PpStartHelper(
  91. IN CONST GUID *pguidParent,
  92. IN DWORD dwParentVersion
  93. )
  94. {
  95. DWORD dwErr;
  96. NS_CONTEXT_ATTRIBUTES attMyAttributes;
  97. ZeroMemory(&attMyAttributes, sizeof(attMyAttributes));
  98. attMyAttributes.pwszContext = L"portproxy";
  99. attMyAttributes.guidHelper = g_PpGuid;
  100. attMyAttributes.dwVersion = PORTPROXY_HELPER_VERSION;
  101. attMyAttributes.dwFlags = CMD_FLAG_LOCAL | CMD_FLAG_ONLINE;
  102. attMyAttributes.pfnDumpFn = PpDump;
  103. attMyAttributes.ulNumTopCmds= g_ulNumPpTopCmds;
  104. attMyAttributes.pTopCmds = (CMD_ENTRY (*)[])&g_PpTopCmds;
  105. attMyAttributes.ulNumGroups = g_ulNumPpCmdGroups;
  106. attMyAttributes.pCmdGroups = (CMD_GROUP_ENTRY (*)[])&g_PpCmdGroups;
  107. dwErr = RegisterContext( &attMyAttributes );
  108. return dwErr;
  109. }
  110. VOID
  111. ShowPorts(
  112. IN PPTYPE Type,
  113. IN FORMAT Format
  114. )
  115. {
  116. ULONG Status, i, ListenChars, ConnectBytes, dwType;
  117. HKEY hType, hProto;
  118. WCHAR ListenBuffer[256], *ListenAddress, *ListenPort;
  119. WCHAR ConnectAddress[256], *ConnectPort;
  120. Status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, PpTypeInfo[Type].KeyString, 0,
  121. KEY_QUERY_VALUE, &hType);
  122. if (Status != NO_ERROR) {
  123. return;
  124. }
  125. Status = RegOpenKeyEx(hType, TOKEN_VALUE_TCP, 0,
  126. KEY_QUERY_VALUE, &hProto);
  127. if (Status == NO_ERROR) {
  128. for (i=0; ; i++) {
  129. ListenChars = sizeof(ListenBuffer)/sizeof(WCHAR);
  130. ConnectBytes = sizeof(ConnectAddress);
  131. Status = RegEnumValueW(hProto, i, ListenBuffer, &ListenChars,
  132. NULL, &dwType, (PVOID)ConnectAddress,
  133. &ConnectBytes);
  134. if (Status != NO_ERROR) {
  135. break;
  136. }
  137. if (dwType != REG_SZ) {
  138. continue;
  139. }
  140. ListenPort = wcschr(ListenBuffer, L'/');
  141. if (ListenPort) {
  142. //
  143. // Replace slash with NULL, so we have 2 strings to pass
  144. // to getaddrinfo.
  145. //
  146. ListenAddress = ListenBuffer;
  147. *ListenPort++ = L'\0';
  148. } else {
  149. //
  150. // If the address data didn't include a connect address
  151. // use "*".
  152. //
  153. ListenAddress = L"*";
  154. ListenPort = ListenBuffer;
  155. }
  156. ConnectPort = wcschr(ConnectAddress, L'/');
  157. if (ConnectPort) {
  158. //
  159. // Replace slash with NULL, so we have 2 strings to pass
  160. // to getaddrinfo.
  161. //
  162. *ConnectPort++ = L'\0';
  163. } else {
  164. //
  165. // If the address data didn't include a connect port
  166. // number, use the same port as the listen port number.
  167. //
  168. ConnectPort = ListenPort;
  169. }
  170. if (Format == FORMAT_NORMAL) {
  171. if (i==0) {
  172. // DisplayMessage(g_hModule, MSG_PORT_PROXY_HEADER,
  173. // PpTypeInfo[Type].ListenFamily,
  174. // PpTypeInfo[Type].ConnectFamily);
  175. }
  176. // DisplayMessage(g_hModule, MSG_PORT_PROXY, ListenAddress,
  177. // ListenPort, ConnectAddress, ConnectPort);
  178. } else {
  179. DisplayMessageT(DMP_ADD_PORT_PROXY, PpTypeInfo[Type].Token);
  180. DisplayMessageT(DMP_STRING_ARG, TOKEN_LISTENPORT, ListenPort);
  181. DisplayMessageT(DMP_STRING_ARG, TOKEN_CONNECTADDRESS, ConnectAddress);
  182. DisplayMessageT(DMP_STRING_ARG, TOKEN_CONNECTPORT, ConnectPort);
  183. DisplayMessageT(DMP_NEWLINE);
  184. }
  185. }
  186. RegCloseKey(hProto);
  187. }
  188. RegCloseKey(hType);
  189. }
  190. ULONG
  191. PpHandleShowV4ToV4(
  192. IN LPCWSTR MachineName,
  193. IN LPWSTR *Argv,
  194. IN ULONG CurrentIndex,
  195. IN ULONG Argc,
  196. IN ULONG Flags,
  197. IN LPCVOID Data,
  198. OUT BOOL *Done
  199. )
  200. {
  201. ShowPorts(V4TOV4, FORMAT_NORMAL);
  202. return STATUS_SUCCESS;
  203. }
  204. ULONG
  205. PpHandleShowV6ToV4(
  206. IN LPCWSTR MachineName,
  207. IN LPWSTR *Argv,
  208. IN ULONG CurrentIndex,
  209. IN ULONG Argc,
  210. IN ULONG Flags,
  211. IN LPCVOID Data,
  212. OUT BOOL *Done
  213. )
  214. {
  215. ShowPorts(V6TOV4, FORMAT_NORMAL);
  216. return STATUS_SUCCESS;
  217. }
  218. ULONG
  219. PpHandleShowV4ToV6(
  220. IN LPCWSTR MachineName,
  221. IN LPWSTR *Argv,
  222. IN ULONG CurrentIndex,
  223. IN ULONG Argc,
  224. IN ULONG Flags,
  225. IN LPCVOID Data,
  226. OUT BOOL *Done
  227. )
  228. {
  229. ShowPorts(V4TOV6, FORMAT_NORMAL);
  230. return STATUS_SUCCESS;
  231. }
  232. ULONG
  233. PpHandleShowV6ToV6(
  234. IN LPCWSTR MachineName,
  235. IN LPWSTR *Argv,
  236. IN ULONG CurrentIndex,
  237. IN ULONG Argc,
  238. IN ULONG Flags,
  239. IN LPCVOID Data,
  240. OUT BOOL *Done
  241. )
  242. {
  243. ShowPorts(V6TOV6, FORMAT_NORMAL);
  244. return STATUS_SUCCESS;
  245. }
  246. ULONG
  247. PpHandleShowAll(
  248. IN LPCWSTR MachineName,
  249. IN LPWSTR *Argv,
  250. IN ULONG CurrentIndex,
  251. IN ULONG Argc,
  252. IN ULONG Flags,
  253. IN LPCVOID Data,
  254. OUT BOOL *Done
  255. )
  256. {
  257. ShowPorts(V4TOV4, FORMAT_NORMAL);
  258. ShowPorts(V4TOV6, FORMAT_NORMAL);
  259. ShowPorts(V6TOV4, FORMAT_NORMAL);
  260. ShowPorts(V6TOV6, FORMAT_NORMAL);
  261. return STATUS_SUCCESS;
  262. }
  263. PWCHAR
  264. PpFormValue(
  265. IN PWCHAR Address,
  266. IN PWCHAR Port
  267. )
  268. {
  269. ULONG Length;
  270. PWCHAR Value;
  271. Length = wcslen(Address) + wcslen(Port) + 2;
  272. Value = MALLOC(Length * sizeof(WCHAR));
  273. swprintf(Value, L"%s/%s", Address, Port);
  274. return Value;
  275. }
  276. TOKEN_VALUE g_ProtocolEnum[] = {{ TOKEN_VALUE_TCP, IPPROTO_TCP }};
  277. ULONG
  278. PpHandleAddSetPort(
  279. IN PPTYPE Type,
  280. IN LPWSTR *Argv,
  281. IN ULONG CurrentIndex,
  282. IN ULONG Argc
  283. )
  284. {
  285. ULONG Status, i;
  286. TAG_TYPE Tags[] = {{TOKEN_LISTENPORT, NS_REQ_PRESENT, FALSE},
  287. {TOKEN_CONNECTADDRESS, NS_REQ_ZERO, FALSE},
  288. {TOKEN_CONNECTPORT, NS_REQ_ZERO, FALSE},
  289. {TOKEN_LISTENADDRESS, NS_REQ_ZERO, FALSE},
  290. {TOKEN_PROTOCOL, NS_REQ_ZERO, FALSE}};
  291. ULONG TagType[sizeof(Tags)/sizeof(TAG_TYPE)];
  292. PWCHAR ListenAddress = NULL, ListenPort = NULL;
  293. PWCHAR ConnectAddress = NULL, ConnectPort = NULL;
  294. PWCHAR ProtocolString = NULL;
  295. ULONG Protocol = IPPROTO_TCP;
  296. PWCHAR KeyValue, KeyData;
  297. HKEY hType, hProto;
  298. if ((Type == V4TOV4) || (Type == V6TOV6)) {
  299. Tags[1].dwRequired = NS_REQ_PRESENT;
  300. }
  301. Status = PreprocessCommand(g_hModule,
  302. Argv,
  303. CurrentIndex,
  304. Argc,
  305. Tags,
  306. sizeof(Tags)/sizeof(TAG_TYPE),
  307. 0,
  308. sizeof(Tags)/sizeof(TAG_TYPE),
  309. TagType);
  310. for (i=0; (Status == NO_ERROR) && (i < Argc-CurrentIndex); i++) {
  311. switch (TagType[i]) {
  312. case 0: // LISTENPORT
  313. ListenPort = Argv[CurrentIndex + i];
  314. break;
  315. case 1: // CONNECTADDRESS
  316. ConnectAddress = Argv[CurrentIndex + i];
  317. break;
  318. case 2: // CONNECTPORT
  319. ConnectPort = Argv[CurrentIndex + i];
  320. break;
  321. case 3: // LISTENADDRESS
  322. ListenAddress = Argv[CurrentIndex + i];
  323. break;
  324. case 4: // PROTOCOL
  325. Status = MatchEnumTag(NULL,
  326. Argv[CurrentIndex + i],
  327. NUM_TOKENS_IN_TABLE(g_ProtocolEnum),
  328. g_ProtocolEnum,
  329. (PULONG)&Protocol);
  330. if (Status != NO_ERROR) {
  331. Status = ERROR_INVALID_PARAMETER;
  332. }
  333. ProtocolString = Argv[CurrentIndex + i];
  334. break;
  335. default:
  336. Status = ERROR_INVALID_SYNTAX;
  337. break;
  338. }
  339. }
  340. if (Status != NO_ERROR) {
  341. return Status;
  342. }
  343. if (ConnectAddress == NULL) {
  344. ConnectAddress = L"localhost";
  345. }
  346. if (ListenAddress == NULL) {
  347. ListenAddress = L"*";
  348. }
  349. if (ProtocolString == NULL) {
  350. ProtocolString = TOKEN_VALUE_TCP;
  351. }
  352. if (ConnectPort == NULL) {
  353. ConnectPort = ListenPort;
  354. }
  355. Status = RegCreateKeyEx(HKEY_LOCAL_MACHINE, PpTypeInfo[Type].KeyString, 0,
  356. NULL, 0, KEY_ALL_ACCESS, NULL, &hType, NULL);
  357. if (Status != NO_ERROR) {
  358. return Status;
  359. }
  360. Status = RegCreateKeyEx(hType, ProtocolString, 0,
  361. NULL, 0, KEY_ALL_ACCESS, NULL, &hProto, NULL);
  362. if (Status != NO_ERROR) {
  363. RegCloseKey(hType);
  364. return Status;
  365. }
  366. KeyValue = PpFormValue(ListenAddress, ListenPort);
  367. KeyData = PpFormValue(ConnectAddress, ConnectPort);
  368. if (KeyValue && KeyData) {
  369. Status = RegSetValueEx(hProto, KeyValue, 0, REG_SZ, (PVOID)KeyData,
  370. wcslen(KeyData) * sizeof(WCHAR));
  371. FREE(KeyValue);
  372. }
  373. RegCloseKey(hProto);
  374. RegCloseKey(hType);
  375. Ip6to4PokeService();
  376. return Status;
  377. }
  378. ULONG
  379. PpHandleDeletePort(
  380. IN PPTYPE Type,
  381. IN LPWSTR *Argv,
  382. IN ULONG CurrentIndex,
  383. IN ULONG Argc
  384. )
  385. {
  386. ULONG Status, i;
  387. TAG_TYPE Tags[] = {{TOKEN_LISTENPORT, NS_REQ_PRESENT, FALSE},
  388. {TOKEN_LISTENADDRESS, NS_REQ_ZERO, FALSE},
  389. {TOKEN_PROTOCOL, NS_REQ_ZERO, FALSE}};
  390. ULONG TagType[sizeof(Tags)/sizeof(TAG_TYPE)];
  391. PWCHAR ListenAddress = NULL, ListenPort = NULL;
  392. PWCHAR ConnectAddress = NULL, ConnectPort = NULL;
  393. ULONG Protocol;
  394. PWCHAR ProtocolString = NULL;
  395. HKEY hType, hProto;
  396. PWCHAR Value;
  397. Status = PreprocessCommand(g_hModule,
  398. Argv,
  399. CurrentIndex,
  400. Argc,
  401. Tags,
  402. sizeof(Tags)/sizeof(TAG_TYPE),
  403. 0,
  404. sizeof(Tags)/sizeof(TAG_TYPE),
  405. TagType);
  406. for (i=0; (Status == NO_ERROR) && (i < Argc-CurrentIndex); i++) {
  407. switch (TagType[i]) {
  408. case 0: // LISTENPORT
  409. ListenPort = Argv[CurrentIndex + i];
  410. break;
  411. case 1: // LISTENADDRESS
  412. ListenAddress = Argv[CurrentIndex + i];
  413. break;
  414. case 2: // PROTOCOL
  415. Status = MatchEnumTag(NULL,
  416. Argv[CurrentIndex + i],
  417. NUM_TOKENS_IN_TABLE(g_ProtocolEnum),
  418. g_ProtocolEnum,
  419. (PULONG)&Protocol);
  420. if (Status != NO_ERROR) {
  421. Status = ERROR_INVALID_PARAMETER;
  422. }
  423. ProtocolString = Argv[CurrentIndex + i];
  424. break;
  425. default:
  426. Status = ERROR_INVALID_SYNTAX;
  427. break;
  428. }
  429. }
  430. if (Status != NO_ERROR) {
  431. return Status;
  432. }
  433. if (ListenAddress == NULL) {
  434. ListenAddress = L"*";
  435. }
  436. if (ProtocolString == NULL) {
  437. ProtocolString = TOKEN_VALUE_TCP;
  438. }
  439. Status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, PpTypeInfo[Type].KeyString, 0,
  440. KEY_ALL_ACCESS, &hType);
  441. if (Status != NO_ERROR) {
  442. return Status;
  443. }
  444. Status = RegOpenKeyEx(hType, ProtocolString, 0, KEY_ALL_ACCESS, &hProto);
  445. if (Status != NO_ERROR) {
  446. RegCloseKey(hType);
  447. return Status;
  448. }
  449. Value = PpFormValue(ListenAddress, ListenPort);
  450. if (Value) {
  451. Status = RegDeleteValue(hProto, Value);
  452. FREE(Value);
  453. }
  454. RegCloseKey(hProto);
  455. RegCloseKey(hType);
  456. Ip6to4PokeService();
  457. return Status;
  458. }
  459. ULONG
  460. PpHandleDelV4ToV4(
  461. IN LPCWSTR MachineName,
  462. IN LPWSTR *Argv,
  463. IN ULONG CurrentIndex,
  464. IN ULONG Argc,
  465. IN ULONG Flags,
  466. IN LPCVOID Data,
  467. OUT BOOL *Done
  468. )
  469. {
  470. return PpHandleDeletePort(V4TOV4, Argv, CurrentIndex, Argc);
  471. }
  472. ULONG
  473. PpHandleDelV4ToV6(
  474. IN LPCWSTR MachineName,
  475. IN LPWSTR *Argv,
  476. IN ULONG CurrentIndex,
  477. IN ULONG Argc,
  478. IN ULONG Flags,
  479. IN LPCVOID Data,
  480. OUT BOOL *Done
  481. )
  482. {
  483. return PpHandleDeletePort(V4TOV6, Argv, CurrentIndex, Argc);
  484. }
  485. ULONG
  486. PpHandleDelV6ToV4(
  487. IN LPCWSTR MachineName,
  488. IN LPWSTR *Argv,
  489. IN ULONG CurrentIndex,
  490. IN ULONG Argc,
  491. IN ULONG Flags,
  492. IN LPCVOID Data,
  493. OUT BOOL *Done
  494. )
  495. {
  496. return PpHandleDeletePort(V6TOV4, Argv, CurrentIndex, Argc);
  497. }
  498. ULONG
  499. PpHandleDelV6ToV6(
  500. IN LPCWSTR MachineName,
  501. IN LPWSTR *Argv,
  502. IN ULONG CurrentIndex,
  503. IN ULONG Argc,
  504. IN ULONG Flags,
  505. IN LPCVOID Data,
  506. OUT BOOL *Done
  507. )
  508. {
  509. return PpHandleDeletePort(V6TOV6, Argv, CurrentIndex, Argc);
  510. }
  511. ULONG
  512. PpHandleAddSetV4ToV4(
  513. IN LPCWSTR MachineName,
  514. IN LPWSTR *Argv,
  515. IN ULONG CurrentIndex,
  516. IN ULONG Argc,
  517. IN ULONG Flags,
  518. IN LPCVOID Data,
  519. OUT BOOL *Done
  520. )
  521. {
  522. return PpHandleAddSetPort(V4TOV4, Argv, CurrentIndex, Argc);
  523. }
  524. ULONG
  525. PpHandleAddSetV4ToV6(
  526. IN LPCWSTR MachineName,
  527. IN LPWSTR *Argv,
  528. IN ULONG CurrentIndex,
  529. IN ULONG Argc,
  530. IN ULONG Flags,
  531. IN LPCVOID Data,
  532. OUT BOOL *Done
  533. )
  534. {
  535. return PpHandleAddSetPort(V4TOV6, Argv, CurrentIndex, Argc);
  536. }
  537. ULONG
  538. PpHandleAddSetV6ToV4(
  539. IN LPCWSTR MachineName,
  540. IN LPWSTR *Argv,
  541. IN ULONG CurrentIndex,
  542. IN ULONG Argc,
  543. IN ULONG Flags,
  544. IN LPCVOID Data,
  545. OUT BOOL *Done
  546. )
  547. {
  548. return PpHandleAddSetPort(V6TOV4, Argv, CurrentIndex, Argc);
  549. }
  550. ULONG
  551. PpHandleAddSetV6ToV6(
  552. IN LPCWSTR MachineName,
  553. IN LPWSTR *Argv,
  554. IN ULONG CurrentIndex,
  555. IN ULONG Argc,
  556. IN ULONG Flags,
  557. IN LPCVOID Data,
  558. OUT BOOL *Done
  559. )
  560. {
  561. return PpHandleAddSetPort(V6TOV6, Argv, CurrentIndex, Argc);
  562. }
  563. VOID
  564. PpReset(
  565. IN PPTYPE Type
  566. )
  567. {
  568. HKEY hType;
  569. ULONG Status;
  570. Status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, PpTypeInfo[Type].KeyString, 0,
  571. KEY_ALL_ACCESS, &hType);
  572. if (Status != NO_ERROR) {
  573. return;
  574. }
  575. SHDeleteKey(hType, TOKEN_VALUE_TCP);
  576. RegCloseKey(hType);
  577. Ip6to4PokeService();
  578. }
  579. ULONG
  580. PpHandleReset(
  581. IN LPCWSTR MachineName,
  582. IN LPWSTR *Argv,
  583. IN ULONG CurrentIndex,
  584. IN ULONG Argc,
  585. IN ULONG Flags,
  586. IN LPCVOID Data,
  587. OUT BOOL *Done
  588. )
  589. {
  590. PpReset(V4TOV4);
  591. PpReset(V4TOV6);
  592. PpReset(V6TOV4);
  593. PpReset(V6TOV6);
  594. return STATUS_SUCCESS;
  595. }
  596. DWORD
  597. WINAPI
  598. PpDump(
  599. IN LPCWSTR pwszRouter,
  600. IN OUT LPWSTR *ppwcArguments,
  601. IN DWORD dwArgCount,
  602. IN LPCVOID pvData
  603. )
  604. {
  605. // DisplayMessage(g_hModule, DMP_PP_HEADER_COMMENTS);
  606. DisplayMessageT(DMP_PP_PUSHD);
  607. ShowPorts(V4TOV4, FORMAT_DUMP);
  608. ShowPorts(V4TOV6, FORMAT_DUMP);
  609. ShowPorts(V6TOV4, FORMAT_DUMP);
  610. ShowPorts(V6TOV6, FORMAT_DUMP);
  611. DisplayMessageT(DMP_PP_POPD);
  612. // DisplayMessage(g_hModule, DMP_PP_FOOTER_COMMENTS);
  613. return NO_ERROR;
  614. }