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.

2307 lines
42 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation. All Rights Reserved.
  3. Module Name:
  4. cntest.c
  5. Abstract:
  6. Test program for managing the cluster transport.
  7. --*/
  8. #include <nt.h>
  9. #include <ntrtl.h>
  10. #include <nturtl.h>
  11. #include <windows.h>
  12. #include <stdlib.h>
  13. #include <stdio.h>
  14. #include <winsock2.h>
  15. #include <tdi.h>
  16. #include <clusapi.h>
  17. #include <clusdef.h>
  18. #include <ntddcnet.h>
  19. #include <cnetapi.h>
  20. //
  21. // Local prototypes
  22. //
  23. PWCHAR
  24. ConvertStringToUnicode(
  25. PUCHAR String
  26. );
  27. PTRANSPORT_ADDRESS
  28. BuildTdiAddressForIp(
  29. IN ULONG Address,
  30. IN USHORT Port,
  31. OUT PULONG TdiAddressLength
  32. );
  33. DWORD
  34. Initialize(
  35. IN char ** argv,
  36. IN int argc
  37. );
  38. DWORD
  39. RegisterNode(
  40. IN char ** argv,
  41. IN int argc
  42. );
  43. DWORD
  44. DeregisterNode(
  45. IN char ** argv,
  46. IN int argc
  47. );
  48. DWORD
  49. RegisterNetwork(
  50. IN char ** argv,
  51. IN int argc
  52. );
  53. DWORD
  54. DeregisterNetwork(
  55. IN char ** argv,
  56. IN int argc
  57. );
  58. DWORD
  59. RegisterInterface(
  60. IN char ** argv,
  61. IN int argc
  62. );
  63. DWORD
  64. DeregisterInterface(
  65. IN char ** argv,
  66. IN int argc
  67. );
  68. DWORD
  69. GetNetworkPriority(
  70. IN char ** argv,
  71. IN int argc
  72. );
  73. DWORD
  74. OnlineNodeComm(
  75. IN char ** argv,
  76. IN int argc
  77. );
  78. DWORD
  79. OfflineNodeComm(
  80. IN char ** argv,
  81. IN int argc
  82. );
  83. DWORD
  84. OnlineNetwork(
  85. IN char ** argv,
  86. IN int argc
  87. );
  88. DWORD
  89. OfflineNetwork(
  90. IN char ** argv,
  91. IN int argc
  92. );
  93. DWORD
  94. SetNetworkPriority(
  95. IN char ** argv,
  96. IN int argc
  97. );
  98. DWORD
  99. GetInterfacePriority(
  100. IN char ** argv,
  101. IN int argc
  102. );
  103. DWORD
  104. SetInterfacePriority(
  105. IN char ** argv,
  106. IN int argc
  107. );
  108. DWORD
  109. GetNodeCommState(
  110. IN char ** argv,
  111. IN int argc
  112. );
  113. DWORD
  114. GetNetworkState(
  115. IN char ** argv,
  116. IN int argc
  117. );
  118. DWORD
  119. GetInterfaceState(
  120. IN char ** argv,
  121. IN int argc
  122. );
  123. DWORD
  124. TestEvents(
  125. IN char ** argv,
  126. IN int argc
  127. );
  128. DWORD
  129. SetMemLogging(
  130. IN char ** argv,
  131. IN int argc
  132. );
  133. DWORD
  134. SendPoisonPacket(
  135. IN char ** argv,
  136. IN int argc
  137. );
  138. DWORD
  139. GetMulticastReachableSet(
  140. IN char ** argv,
  141. IN int argc
  142. );
  143. #if DBG
  144. DWORD
  145. SetDebugMask(
  146. IN char ** argv,
  147. IN int argc
  148. );
  149. DWORD
  150. OnlinePendingInterface(
  151. IN char ** argv,
  152. IN int argc
  153. );
  154. DWORD
  155. OnlineInterface(
  156. IN char ** argv,
  157. IN int argc
  158. );
  159. DWORD
  160. OfflineInterface(
  161. IN char ** argv,
  162. IN int argc
  163. );
  164. DWORD
  165. FailInterface(
  166. IN char ** argv,
  167. IN int argc
  168. );
  169. DWORD
  170. SendMmMsg(
  171. IN char ** argv,
  172. IN int argc
  173. );
  174. DWORD
  175. MMgrForm(
  176. IN char ** argv,
  177. IN int argc
  178. );
  179. DWORD
  180. MMgrJoin(
  181. IN char ** argv,
  182. IN int argc
  183. );
  184. DWORD
  185. MMgrLeave(
  186. IN char ** argv,
  187. IN int argc
  188. );
  189. DWORD
  190. MMgrGetMembershipState(
  191. IN char ** argv,
  192. IN int argc
  193. );
  194. DWORD
  195. MMgrEject(
  196. IN char ** argv,
  197. IN int argc
  198. );
  199. #endif // DBG
  200. //
  201. // Local Types
  202. //
  203. typedef enum {
  204. OpcodeInvalid = 0,
  205. OpcodeInit,
  206. OpcodeShutdown,
  207. OpcodeSetDebugMask,
  208. OpcodeAdd,
  209. OpcodeDelete,
  210. OpcodeOnlinePending,
  211. OpcodeOnline,
  212. OpcodeOffline,
  213. OpcodeFail,
  214. OpcodeGetPriority,
  215. OpcodeSetPriority,
  216. OpcodeGetState,
  217. OpcodeSendMmMsg,
  218. #ifdef MM_IN_CLUSNET
  219. OpcodeMMgrForm,
  220. OpcodeMMgrJoin,
  221. OpcodeMMgrLeave,
  222. OpcodeMMgrGetMembershipState,
  223. OpcodeMMgrEject,
  224. #endif
  225. OpcodeTestEvents,
  226. OpcodeSetMemLogging,
  227. OpcodeSendPoisonPacket,
  228. OpcodeGetMulticastReachableSet
  229. } CN_OPCODE;
  230. typedef enum {
  231. ObjTypeInvalid = 0,
  232. ObjTypeNode,
  233. ObjTypeNetwork,
  234. ObjTypeInterface
  235. } CN_OBJTYPE;
  236. HANDLE Handle = NULL;
  237. //
  238. // Local Prototypes
  239. //
  240. void
  241. Usage(
  242. void
  243. );
  244. //
  245. // Main Function
  246. //
  247. int _cdecl
  248. main(int argc, char **argv)
  249. {
  250. DWORD status = ERROR_INVALID_PARAMETER;
  251. CN_OPCODE opcode = OpcodeInvalid;
  252. CN_OBJTYPE objtype = ObjTypeInvalid;
  253. BOOLEAN objTypeRequired = TRUE;
  254. if (argc < 2) {
  255. Usage();
  256. return(status);
  257. }
  258. //
  259. // Crack the operation.
  260. //
  261. if (strcmp(argv[1], "init") == 0) {
  262. opcode = OpcodeInit;
  263. objTypeRequired = FALSE;
  264. }
  265. else if (strcmp(argv[1], "shutdown") == 0) {
  266. opcode = OpcodeShutdown;
  267. objTypeRequired = FALSE;
  268. }
  269. else if (strcmp(argv[1], "setdebug") == 0) {
  270. opcode = OpcodeSetDebugMask;
  271. objTypeRequired = FALSE;
  272. }
  273. else if (strcmp(argv[1], "add") == 0) {
  274. opcode = OpcodeAdd;
  275. }
  276. else if (strcmp(argv[1], "del") == 0) {
  277. opcode = OpcodeDelete;
  278. }
  279. else if (strcmp(argv[1], "onpend") == 0) {
  280. opcode = OpcodeOnlinePending;
  281. }
  282. else if (strcmp(argv[1], "online") == 0) {
  283. opcode = OpcodeOnline;
  284. }
  285. else if (strcmp(argv[1], "offline") == 0) {
  286. opcode = OpcodeOffline;
  287. }
  288. else if (strcmp(argv[1], "fail") == 0) {
  289. opcode = OpcodeFail;
  290. }
  291. else if (strcmp(argv[1], "getpri") == 0) {
  292. opcode = OpcodeGetPriority;
  293. }
  294. else if (strcmp(argv[1], "setpri") == 0) {
  295. opcode = OpcodeSetPriority;
  296. }
  297. else if (strcmp(argv[1], "getstate") == 0) {
  298. opcode = OpcodeGetState;
  299. }
  300. else if (strcmp(argv[1], "send") == 0) {
  301. opcode = OpcodeSendMmMsg;
  302. objTypeRequired = FALSE;
  303. }
  304. #ifdef MM_IN_CLUSNET
  305. else if (strcmp(argv[1], "mmform") == 0) {
  306. opcode = OpcodeMMgrForm;
  307. objTypeRequired = FALSE;
  308. }
  309. else if (strcmp(argv[1], "mmjoin") == 0) {
  310. opcode = OpcodeMMgrJoin;
  311. objTypeRequired = FALSE;
  312. }
  313. else if (strcmp(argv[1], "mmleave") == 0) {
  314. opcode = OpcodeMMgrLeave;
  315. objTypeRequired = FALSE;
  316. }
  317. else if (strcmp(argv[1], "mmgetstate") == 0) {
  318. opcode = OpcodeMMgrGetMembershipState;
  319. objTypeRequired = FALSE;
  320. }
  321. else if (strcmp(argv[1], "mmeject") == 0) {
  322. opcode = OpcodeMMgrEject;
  323. objTypeRequired = FALSE;
  324. }
  325. #endif
  326. else if (strcmp(argv[1], "events") == 0) {
  327. opcode = OpcodeTestEvents;
  328. objTypeRequired = FALSE;
  329. }
  330. else if (strcmp(argv[1], "memlog") == 0) {
  331. opcode = OpcodeSetMemLogging;
  332. objTypeRequired = FALSE;
  333. }
  334. else if (strcmp(argv[1], "poison") == 0) {
  335. opcode = OpcodeSendPoisonPacket;
  336. objTypeRequired = FALSE;
  337. }
  338. else if (strcmp(argv[1], "getmcast") == 0) {
  339. opcode = OpcodeGetMulticastReachableSet;
  340. objTypeRequired = FALSE;
  341. }
  342. else {
  343. printf("invalid command %s\n", argv[1]);
  344. Usage();
  345. return(status);
  346. }
  347. //
  348. // Crack the object type
  349. //
  350. if (objTypeRequired) {
  351. if (strcmp(argv[2], "node") == 0) {
  352. objtype = ObjTypeNode;
  353. }
  354. else if (strcmp(argv[2], "network") == 0) {
  355. objtype = ObjTypeNetwork;
  356. }
  357. else if (strcmp(argv[2], "interface") == 0) {
  358. objtype = ObjTypeInterface;
  359. }
  360. else {
  361. printf("invalid object type %s\n", argv[2]);
  362. Usage();
  363. return(status);
  364. }
  365. }
  366. //
  367. // Open the driver
  368. //
  369. Handle = ClusnetOpenControlChannel(FILE_SHARE_READ);
  370. if (Handle == NULL) {
  371. printf("Unable to open driver, status %08X\n", GetLastError());
  372. return(GetLastError());
  373. }
  374. //
  375. // Gather remaining params and dispatch
  376. //
  377. switch (opcode) {
  378. case OpcodeInit:
  379. status = Initialize(argv + 2, argc - 2);
  380. break;
  381. case OpcodeShutdown:
  382. status = ClusnetShutdown(Handle);
  383. break;
  384. #if DBG
  385. case OpcodeSetDebugMask:
  386. status = SetDebugMask(argv + 2, argc - 2);
  387. break;
  388. #endif // DBG
  389. case OpcodeAdd:
  390. switch(objtype) {
  391. case ObjTypeNode:
  392. status = RegisterNode(argv + 3, argc - 3);
  393. break;
  394. case ObjTypeNetwork:
  395. status = RegisterNetwork(argv + 3, argc - 3);
  396. break;
  397. case ObjTypeInterface:
  398. status = RegisterInterface(argv + 3, argc - 3);
  399. break;
  400. default:
  401. break;
  402. }
  403. break;
  404. case OpcodeDelete:
  405. switch(objtype) {
  406. case ObjTypeNode:
  407. status = DeregisterNode(argv + 3, argc - 3);
  408. break;
  409. case ObjTypeNetwork:
  410. status = DeregisterNetwork(argv + 3, argc - 3);
  411. break;
  412. case ObjTypeInterface:
  413. status = DeregisterInterface(argv + 3, argc - 3);
  414. break;
  415. default:
  416. break;
  417. }
  418. break;
  419. #if DBG
  420. case OpcodeOnlinePending:
  421. switch(objtype) {
  422. case ObjTypeInterface:
  423. status = OnlinePendingInterface(argv + 3, argc - 3);
  424. break;
  425. default:
  426. break;
  427. }
  428. break;
  429. #endif // DBG
  430. case OpcodeOnline:
  431. switch(objtype) {
  432. case ObjTypeNode:
  433. status = OnlineNodeComm(argv + 3, argc - 3);
  434. break;
  435. case ObjTypeNetwork:
  436. status = OnlineNetwork(argv + 3, argc - 3);
  437. break;
  438. #if DBG
  439. case ObjTypeInterface:
  440. status = OnlineInterface(argv + 3, argc - 3);
  441. break;
  442. #endif // DBG
  443. default:
  444. break;
  445. }
  446. break;
  447. case OpcodeOffline:
  448. switch(objtype) {
  449. case ObjTypeNode:
  450. status = OfflineNodeComm(argv + 3, argc - 3);
  451. break;
  452. case ObjTypeNetwork:
  453. status = OfflineNetwork(argv + 3, argc - 3);
  454. break;
  455. #if DBG
  456. case ObjTypeInterface:
  457. status = OfflineInterface(argv + 3, argc - 3);
  458. break;
  459. #endif // DBG
  460. default:
  461. break;
  462. }
  463. break;
  464. #if DBG
  465. case OpcodeFail:
  466. switch(objtype) {
  467. case ObjTypeInterface:
  468. status = FailInterface(argv + 3, argc - 3);
  469. break;
  470. default:
  471. break;
  472. }
  473. break;
  474. #endif // DBG
  475. case OpcodeGetPriority:
  476. switch(objtype) {
  477. case ObjTypeNetwork:
  478. status = GetNetworkPriority(argv + 3, argc - 3);
  479. break;
  480. case ObjTypeInterface:
  481. status = GetInterfacePriority(argv + 3, argc - 3);
  482. break;
  483. default:
  484. break;
  485. }
  486. break;
  487. case OpcodeSetPriority:
  488. switch(objtype) {
  489. case ObjTypeNetwork:
  490. status = SetNetworkPriority(argv + 3, argc - 3);
  491. break;
  492. case ObjTypeInterface:
  493. status = SetInterfacePriority(argv + 3, argc - 3);
  494. break;
  495. default:
  496. break;
  497. }
  498. break;
  499. case OpcodeGetState:
  500. switch(objtype) {
  501. case ObjTypeNode:
  502. status = GetNodeCommState(argv + 3, argc - 3);
  503. break;
  504. case ObjTypeNetwork:
  505. status = GetNetworkState(argv + 3, argc - 3);
  506. break;
  507. case ObjTypeInterface:
  508. status = GetInterfaceState(argv + 3, argc - 3);
  509. break;
  510. default:
  511. break;
  512. }
  513. break;
  514. #if DBG
  515. case OpcodeSendMmMsg:
  516. status = SendMmMsg(argv + 2, argc - 2);
  517. break;
  518. #ifdef MM_IN_CLUSNET
  519. case OpcodeMMgrForm:
  520. status = MMgrForm(argv + 2, argc - 2);
  521. break;
  522. case OpcodeMMgrJoin:
  523. status = MMgrJoin(argv + 2, argc - 2);
  524. break;
  525. case OpcodeMMgrLeave:
  526. status = MMgrLeave(argv + 2, argc - 2);
  527. break;
  528. case OpcodeMMgrGetMembershipState:
  529. status = MMgrGetMembershipState(argv + 2, argc - 2);
  530. break;
  531. case OpcodeMMgrEject:
  532. status = MMgrEject(argv + 2, argc - 2);
  533. break;
  534. #endif // MM_IN_CLUSNET
  535. #endif // DBG
  536. case OpcodeTestEvents:
  537. status = TestEvents(argv + 2, argc - 2);
  538. break;
  539. case OpcodeSetMemLogging:
  540. status = SetMemLogging(argv + 2, argc - 2);
  541. break;
  542. case OpcodeSendPoisonPacket:
  543. status = SendPoisonPacket(argv + 2, argc - 2);
  544. break;
  545. case OpcodeGetMulticastReachableSet:
  546. status = GetMulticastReachableSet(argv + 2, argc - 2);
  547. break;
  548. default:
  549. break;
  550. }
  551. ClusnetCloseControlChannel(Handle);
  552. if (status != ERROR_SUCCESS) {
  553. if (status == ERROR_INVALID_PARAMETER) {
  554. Usage();
  555. }
  556. else {
  557. printf("Operation failed, status 0x%08X\n", status);
  558. }
  559. }
  560. return(status);
  561. }
  562. //
  563. // Support functions
  564. //
  565. void
  566. Usage(
  567. void
  568. )
  569. {
  570. printf("\n");
  571. printf("Usage: cntest <operation> <parameters>\n");
  572. printf("\n");
  573. printf("Operations:\n");
  574. printf(" init <local node id> <max nodes>\n");
  575. printf(" shutdown\n");
  576. printf(" add node <node id>\n");
  577. printf(" del node <node id>\n");
  578. printf(" add network <network id> <priority>\n");
  579. printf(" del network <network id>\n");
  580. printf(" add interface <node id> <network id> <priority> <IP address> <UDP port> [<adapter guid>]\n");
  581. printf(" del interface <node id> <network id>\n");
  582. printf(" online node <node id>\n");
  583. printf(" offline node <node id>\n");
  584. printf(" online network <network id> <xport device> <IP address> <UDP port> <adapter name>\n");
  585. printf(" offline network <network id>\n");
  586. printf(" getpri network <network id>\n");
  587. printf(" setpri network <network id> <priority>\n");
  588. printf(" getpri interface <node id> <network id>\n");
  589. printf(" setpri interface <node id> <network id> <priority>\n");
  590. printf(" getstate node <node id>\n");
  591. printf(" getstate network <network id>\n");
  592. printf(" getstate interface <node id> <network id>\n");
  593. printf(" memlog <# of entries - zero turns off logging>\n");
  594. #if DBG
  595. printf(" setdebug <hex mask>\n");
  596. printf(" onpend interface <node id> <network id>\n");
  597. printf(" online interface <node id> <network id>\n");
  598. printf(" offline interface <node id> <network id>\n");
  599. printf(" fail interface <node id> <network id>\n");
  600. printf(" send <node id> <4 byte hex pattern>\n");
  601. printf(" events <mask>\n");
  602. #ifdef MM_IN_CLUSNET
  603. printf(" mmform <node id> <clock period> <send HB rate> <recv HB rate>\n");
  604. printf(" mmjoin <node id> <phase #: 1-4> <join timeout>\n");
  605. printf(" mmleave\n");
  606. printf(" mmgetstate <node id>\n");
  607. printf(" mmeject <node id>\n");
  608. #endif
  609. #endif // DBG
  610. printf(" poison <node id> [number of poison packets]\n");
  611. printf(" getmcast <network id>\n");
  612. }
  613. DWORD
  614. Initialize(
  615. IN char ** argv,
  616. IN int argc
  617. )
  618. /*++
  619. Routine Description:
  620. Arguments:
  621. Return Value:
  622. ERROR_SUCCESS if the operation was successful.
  623. A Windows error code otherwise.
  624. --*/
  625. {
  626. DWORD status;
  627. CL_NODE_ID localNodeId;
  628. ULONG maxNodes;
  629. if (argc < 2) {
  630. return(ERROR_INVALID_PARAMETER);
  631. }
  632. localNodeId = strtoul(argv[0], NULL, 10);
  633. maxNodes = strtoul(argv[1], NULL, 10);
  634. status = ClusnetInitialize(
  635. Handle,
  636. localNodeId,
  637. maxNodes,
  638. NULL,
  639. NULL,
  640. NULL,
  641. NULL,
  642. NULL,
  643. NULL
  644. );
  645. return(status);
  646. }
  647. DWORD
  648. RegisterNode(
  649. IN char ** argv,
  650. IN int argc
  651. )
  652. /*++
  653. Routine Description:
  654. Arguments:
  655. Return Value:
  656. ERROR_SUCCESS if the operation was successful.
  657. A Windows error code otherwise.
  658. --*/
  659. {
  660. DWORD status;
  661. CL_NODE_ID nodeId;
  662. BOOLEAN isLocal;
  663. if (argc < 1) {
  664. return(ERROR_INVALID_PARAMETER);
  665. }
  666. nodeId = strtoul(argv[0], NULL, 10);
  667. status = ClusnetRegisterNode(Handle, nodeId);
  668. return(status);
  669. }
  670. DWORD
  671. DeregisterNode(
  672. IN char ** argv,
  673. IN int argc
  674. )
  675. /*++
  676. Routine Description:
  677. Arguments:
  678. Return Value:
  679. ERROR_SUCCESS if the operation was successful.
  680. A Windows error code otherwise.
  681. --*/
  682. {
  683. DWORD status;
  684. CL_NODE_ID nodeId;
  685. if (argc < 1) {
  686. return(ERROR_INVALID_PARAMETER);
  687. }
  688. nodeId = strtoul(argv[0], NULL, 10);
  689. status = ClusnetDeregisterNode(Handle, nodeId);
  690. return(status);
  691. }
  692. DWORD
  693. RegisterNetwork(
  694. IN char ** argv,
  695. IN int argc
  696. )
  697. /*++
  698. Routine Description:
  699. Arguments:
  700. Return Value:
  701. ERROR_SUCCESS if the operation was successful.
  702. A Windows error code otherwise.
  703. --*/
  704. {
  705. DWORD status;
  706. CL_NETWORK_ID networkId;
  707. ULONG priority;
  708. if (argc < 2) {
  709. return(ERROR_INVALID_PARAMETER);
  710. }
  711. networkId = strtoul(argv[0], NULL, 10);
  712. priority = strtoul(argv[1], NULL, 10);
  713. status = ClusnetRegisterNetwork(Handle, networkId, priority, FALSE);
  714. return(status);
  715. }
  716. DWORD
  717. DeregisterNetwork(
  718. IN char ** argv,
  719. IN int argc
  720. )
  721. /*++
  722. Routine Description:
  723. Arguments:
  724. Return Value:
  725. ERROR_SUCCESS if the operation was successful.
  726. A Windows error code otherwise.
  727. --*/
  728. {
  729. DWORD status;
  730. CL_NETWORK_ID networkId;
  731. if (argc < 1) {
  732. return(ERROR_INVALID_PARAMETER);
  733. }
  734. networkId = strtoul(argv[0], NULL, 10);
  735. status = ClusnetDeregisterNetwork(Handle, networkId);
  736. return(status);
  737. }
  738. DWORD
  739. RegisterInterface(
  740. IN char ** argv,
  741. IN int argc
  742. )
  743. /*++
  744. Routine Description:
  745. Arguments:
  746. Return Value:
  747. ERROR_SUCCESS if the operation was successful.
  748. A Windows error code otherwise.
  749. --*/
  750. {
  751. DWORD status;
  752. HANDLE handle;
  753. CL_NODE_ID nodeId;
  754. CL_NETWORK_ID networkId;
  755. ULONG ipAddress;
  756. USHORT udpPort;
  757. ULONG tempPort;
  758. ULONG priority;
  759. WCHAR adapterId[256];
  760. PTRANSPORT_ADDRESS tdiAddress = NULL;
  761. ULONG tdiAddressLength;
  762. ULONG mediaStatus;
  763. if (argc < 5) {
  764. return(ERROR_INVALID_PARAMETER);
  765. }
  766. nodeId = strtoul(argv[0], NULL, 10);
  767. networkId = strtoul(argv[1], NULL, 10);
  768. priority = strtoul(argv[2], NULL, 10);
  769. ipAddress = inet_addr(argv[3]);
  770. if (ipAddress == INADDR_NONE) {
  771. return(ERROR_INVALID_PARAMETER);
  772. }
  773. tempPort = strtoul(argv[4], NULL, 10);
  774. if (tempPort > 0xFFFF) {
  775. return(ERROR_INVALID_PARAMETER);
  776. }
  777. udpPort = htons((USHORT) tempPort);
  778. tdiAddress = BuildTdiAddressForIp(
  779. ipAddress,
  780. udpPort,
  781. &tdiAddressLength
  782. );
  783. if (tdiAddress == NULL) {
  784. status = ERROR_NOT_ENOUGH_MEMORY;
  785. goto error_exit;
  786. }
  787. if (argc < 6 || strlen(argv[5]) > 255) {
  788. swprintf(adapterId, L"{11111111-1111-1111-1111-111111111111}");
  789. } else {
  790. swprintf(adapterId, L"%S", argv[5]);
  791. }
  792. status = ClusnetRegisterInterface(
  793. Handle,
  794. nodeId,
  795. networkId,
  796. priority,
  797. adapterId,
  798. wcslen(adapterId) * sizeof(WCHAR),
  799. tdiAddress,
  800. tdiAddressLength,
  801. &mediaStatus
  802. );
  803. error_exit:
  804. if (tdiAddress != NULL) {
  805. LocalFree(tdiAddress);
  806. }
  807. return(status);
  808. }
  809. DWORD
  810. DeregisterInterface(
  811. IN char ** argv,
  812. IN int argc
  813. )
  814. /*++
  815. Routine Description:
  816. Arguments:
  817. Return Value:
  818. ERROR_SUCCESS if the operation was successful.
  819. A Windows error code otherwise.
  820. --*/
  821. {
  822. DWORD status;
  823. CL_NODE_ID nodeId;
  824. CL_NETWORK_ID networkId;
  825. if (argc < 2) {
  826. return(ERROR_INVALID_PARAMETER);
  827. }
  828. nodeId = strtoul(argv[0], NULL, 10);
  829. networkId = strtoul(argv[1], NULL, 10);
  830. status = ClusnetDeregisterInterface(Handle, nodeId, networkId);
  831. return(status);
  832. }
  833. DWORD
  834. OnlineNodeComm(
  835. IN char ** argv,
  836. IN int argc
  837. )
  838. /*++
  839. Routine Description:
  840. Arguments:
  841. Return Value:
  842. ERROR_SUCCESS if the operation was successful.
  843. A Windows error code otherwise.
  844. --*/
  845. {
  846. DWORD status;
  847. CL_NODE_ID nodeId;
  848. if (argc < 1) {
  849. return(ERROR_INVALID_PARAMETER);
  850. }
  851. nodeId = strtoul(argv[0], NULL, 10);
  852. status = ClusnetOnlineNodeComm(Handle, nodeId);
  853. return(status);
  854. }
  855. DWORD
  856. OfflineNodeComm(
  857. IN char ** argv,
  858. IN int argc
  859. )
  860. /*++
  861. Routine Description:
  862. Arguments:
  863. Return Value:
  864. ERROR_SUCCESS if the operation was successful.
  865. A Windows error code otherwise.
  866. --*/
  867. {
  868. DWORD status;
  869. CL_NODE_ID nodeId;
  870. if (argc < 1) {
  871. return(ERROR_INVALID_PARAMETER);
  872. }
  873. nodeId = strtoul(argv[0], NULL, 10);
  874. status = ClusnetOfflineNodeComm(Handle, nodeId);
  875. return(status);
  876. }
  877. DWORD
  878. OnlineNetwork(
  879. IN char ** argv,
  880. IN int argc
  881. )
  882. /*++
  883. Routine Description:
  884. Arguments:
  885. Return Value:
  886. ERROR_SUCCESS if the operation was successful.
  887. A Windows error code otherwise.
  888. --*/
  889. {
  890. DWORD status;
  891. CL_NETWORK_ID networkId;
  892. PWCHAR tdiProviderName = NULL;
  893. ULONG ipAddress;
  894. USHORT udpPort;
  895. ULONG tempPort;
  896. PTRANSPORT_ADDRESS tdiBindAddress = NULL;
  897. ULONG tdiBindAddressLength;
  898. PWCHAR adapterName = NULL;
  899. PUCHAR TdiAddressInfo[1024];
  900. ULONG TdiAddressInfoSize = sizeof( TdiAddressInfo );
  901. if (argc < 5) {
  902. return(ERROR_INVALID_PARAMETER);
  903. }
  904. networkId = strtoul(argv[0], NULL, 10);
  905. tdiProviderName = ConvertStringToUnicode(argv[1]);
  906. if (tdiProviderName == NULL) {
  907. return(ERROR_NOT_ENOUGH_MEMORY);
  908. }
  909. ipAddress = inet_addr(argv[2]);
  910. if (ipAddress == INADDR_NONE) {
  911. return(ERROR_INVALID_PARAMETER);
  912. }
  913. tempPort = strtoul(argv[3], NULL, 10);
  914. if (tempPort > 0xFFFF) {
  915. return(ERROR_INVALID_PARAMETER);
  916. }
  917. udpPort = htons((USHORT) tempPort);
  918. adapterName = ConvertStringToUnicode(argv[4]);
  919. if (adapterName == NULL) {
  920. return(ERROR_NOT_ENOUGH_MEMORY);
  921. }
  922. tdiBindAddress = BuildTdiAddressForIp(
  923. ipAddress,
  924. udpPort,
  925. &tdiBindAddressLength
  926. );
  927. if (tdiBindAddress == NULL) {
  928. status = ERROR_NOT_ENOUGH_MEMORY;
  929. goto error_exit;
  930. }
  931. status = ClusnetOnlineNetwork(
  932. Handle,
  933. networkId,
  934. tdiProviderName,
  935. tdiBindAddress,
  936. tdiBindAddressLength,
  937. adapterName,
  938. TdiAddressInfo,
  939. &TdiAddressInfoSize
  940. );
  941. error_exit:
  942. if (tdiProviderName != NULL) {
  943. LocalFree(tdiProviderName);
  944. }
  945. if (tdiBindAddress != NULL) {
  946. LocalFree(tdiBindAddress);
  947. }
  948. return(status);
  949. }
  950. DWORD
  951. OfflineNetwork(
  952. IN char ** argv,
  953. IN int argc
  954. )
  955. /*++
  956. Routine Description:
  957. Arguments:
  958. Return Value:
  959. ERROR_SUCCESS if the operation was successful.
  960. A Windows error code otherwise.
  961. --*/
  962. {
  963. DWORD status;
  964. CL_NETWORK_ID networkId;
  965. if (argc < 1) {
  966. return(ERROR_INVALID_PARAMETER);
  967. }
  968. networkId = strtoul(argv[0], NULL, 10);
  969. status = ClusnetOfflineNetwork(Handle, networkId);
  970. return(status);
  971. }
  972. DWORD
  973. GetNetworkPriority(
  974. IN char ** argv,
  975. IN int argc
  976. )
  977. /*++
  978. Routine Description:
  979. Arguments:
  980. Return Value:
  981. ERROR_SUCCESS if the operation was successful.
  982. A Windows error code otherwise.
  983. --*/
  984. {
  985. DWORD status;
  986. CL_NETWORK_ID networkId;
  987. ULONG priority;
  988. if (argc < 1) {
  989. return(ERROR_INVALID_PARAMETER);
  990. }
  991. networkId = strtoul(argv[0], NULL, 10);
  992. status = ClusnetGetNetworkPriority(Handle, networkId, &priority);
  993. if (status == ERROR_SUCCESS) {
  994. printf("Network priority = %u\n", priority);
  995. }
  996. return(status);
  997. }
  998. DWORD
  999. SetNetworkPriority(
  1000. IN char ** argv,
  1001. IN int argc
  1002. )
  1003. /*++
  1004. Routine Description:
  1005. Arguments:
  1006. Return Value:
  1007. ERROR_SUCCESS if the operation was successful.
  1008. A Windows error code otherwise.
  1009. --*/
  1010. {
  1011. DWORD status;
  1012. CL_NETWORK_ID networkId;
  1013. ULONG priority;
  1014. if (argc < 2) {
  1015. return(ERROR_INVALID_PARAMETER);
  1016. }
  1017. networkId = strtoul(argv[0], NULL, 10);
  1018. priority = strtoul(argv[1], NULL, 10);
  1019. status = ClusnetSetNetworkPriority(Handle, networkId, priority);
  1020. return(status);
  1021. }
  1022. DWORD
  1023. GetInterfacePriority(
  1024. IN char ** argv,
  1025. IN int argc
  1026. )
  1027. /*++
  1028. Routine Description:
  1029. Arguments:
  1030. Return Value:
  1031. ERROR_SUCCESS if the operation was successful.
  1032. A Windows error code otherwise.
  1033. --*/
  1034. {
  1035. DWORD status;
  1036. CL_NODE_ID nodeId;
  1037. CL_NETWORK_ID networkId;
  1038. ULONG networkPriority;
  1039. ULONG interfacePriority;
  1040. if (argc < 2) {
  1041. return(ERROR_INVALID_PARAMETER);
  1042. }
  1043. nodeId = strtoul(argv[0], NULL, 10);
  1044. networkId = strtoul(argv[1], NULL, 10);
  1045. status = ClusnetGetInterfacePriority(
  1046. Handle,
  1047. nodeId,
  1048. networkId,
  1049. &interfacePriority,
  1050. &networkPriority
  1051. );
  1052. if (status == ERROR_SUCCESS) {
  1053. printf("Interface priority = %u\n", interfacePriority);
  1054. printf("Network priority = %u\n", networkPriority);
  1055. }
  1056. return(status);
  1057. }
  1058. DWORD
  1059. SetInterfacePriority(
  1060. IN char ** argv,
  1061. IN int argc
  1062. )
  1063. /*++
  1064. Routine Description:
  1065. Arguments:
  1066. Return Value:
  1067. ERROR_SUCCESS if the operation was successful.
  1068. A Windows error code otherwise.
  1069. --*/
  1070. {
  1071. DWORD status;
  1072. CL_NODE_ID nodeId;
  1073. CL_NETWORK_ID networkId;
  1074. ULONG priority;
  1075. if (argc < 3) {
  1076. return(ERROR_INVALID_PARAMETER);
  1077. }
  1078. nodeId = strtoul(argv[0], NULL, 10);
  1079. networkId = strtoul(argv[1], NULL, 10);
  1080. priority = strtoul(argv[2], NULL, 10);
  1081. status = ClusnetSetInterfacePriority(Handle, nodeId, networkId, priority);
  1082. return(status);
  1083. }
  1084. DWORD
  1085. GetNodeCommState(
  1086. IN char ** argv,
  1087. IN int argc
  1088. )
  1089. /*++
  1090. Routine Description:
  1091. Arguments:
  1092. Return Value:
  1093. ERROR_SUCCESS if the operation was successful.
  1094. A Windows error code otherwise.
  1095. --*/
  1096. {
  1097. DWORD status;
  1098. CL_NODE_ID nodeId;
  1099. CLUSNET_NODE_COMM_STATE state;
  1100. if (argc < 1) {
  1101. return(ERROR_INVALID_PARAMETER);
  1102. }
  1103. nodeId = strtoul(argv[0], NULL, 10);
  1104. status = ClusnetGetNodeCommState(
  1105. Handle,
  1106. nodeId,
  1107. &state
  1108. );
  1109. if (status == ERROR_SUCCESS) {
  1110. printf("State = ");
  1111. switch(state) {
  1112. case ClusnetNodeCommStateOffline:
  1113. printf("Offline\n");
  1114. break;
  1115. case ClusnetNodeCommStateOfflinePending:
  1116. printf("Offline Pending\n");
  1117. break;
  1118. case ClusnetNodeCommStateOnlinePending:
  1119. printf("Online Pending\n");
  1120. break;
  1121. case ClusnetNodeCommStateOnline:
  1122. printf("Online\n");
  1123. break;
  1124. case ClusnetNodeCommStateUnreachable:
  1125. printf("Unreachable\n");
  1126. break;
  1127. default:
  1128. printf("Unknown %u)\n", state);
  1129. break;
  1130. }
  1131. }
  1132. return(status);
  1133. }
  1134. DWORD
  1135. GetNetworkState(
  1136. IN char ** argv,
  1137. IN int argc
  1138. )
  1139. /*++
  1140. Routine Description:
  1141. Arguments:
  1142. Return Value:
  1143. ERROR_SUCCESS if the operation was successful.
  1144. A Windows error code otherwise.
  1145. --*/
  1146. {
  1147. DWORD status;
  1148. CL_NETWORK_ID networkId;
  1149. CLUSNET_NETWORK_STATE state;
  1150. if (argc < 1) {
  1151. return(ERROR_INVALID_PARAMETER);
  1152. }
  1153. networkId = strtoul(argv[0], NULL, 10);
  1154. status = ClusnetGetNetworkState(
  1155. Handle,
  1156. networkId,
  1157. &state
  1158. );
  1159. if (status == ERROR_SUCCESS) {
  1160. printf("State = ");
  1161. switch(state) {
  1162. case ClusnetNetworkStateOffline:
  1163. printf("Offline\n");
  1164. break;
  1165. case ClusnetNetworkStateOfflinePending:
  1166. printf("Offline pending\n");
  1167. break;
  1168. case ClusnetNetworkStateOnlinePending:
  1169. printf("Online pending\n");
  1170. break;
  1171. case ClusnetNetworkStateOnline:
  1172. printf("Online\n");
  1173. break;
  1174. default:
  1175. printf("Unknown %u)\n", state);
  1176. break;
  1177. }
  1178. }
  1179. return(status);
  1180. }
  1181. DWORD
  1182. GetInterfaceState(
  1183. IN char ** argv,
  1184. IN int argc
  1185. )
  1186. /*++
  1187. Routine Description:
  1188. Arguments:
  1189. Return Value:
  1190. ERROR_SUCCESS if the operation was successful.
  1191. A Windows error code otherwise.
  1192. --*/
  1193. {
  1194. DWORD status;
  1195. CL_NODE_ID nodeId;
  1196. CL_NETWORK_ID networkId;
  1197. CLUSNET_INTERFACE_STATE state;
  1198. if (argc < 2) {
  1199. return(ERROR_INVALID_PARAMETER);
  1200. }
  1201. nodeId = strtoul(argv[0], NULL, 10);
  1202. networkId = strtoul(argv[1], NULL, 10);
  1203. status = ClusnetGetInterfaceState(
  1204. Handle,
  1205. nodeId,
  1206. networkId,
  1207. &state
  1208. );
  1209. if (status == ERROR_SUCCESS) {
  1210. printf("State = ");
  1211. switch(state) {
  1212. case ClusnetInterfaceStateOffline:
  1213. printf("Offline\n");
  1214. break;
  1215. case ClusnetInterfaceStateOfflinePending:
  1216. printf("Offline pending\n");
  1217. break;
  1218. case ClusnetInterfaceStateOnlinePending:
  1219. printf("Online pending\n");
  1220. break;
  1221. case ClusnetInterfaceStateOnline:
  1222. printf("Online\n");
  1223. break;
  1224. case ClusnetInterfaceStateUnreachable:
  1225. printf("Unreachable\n");
  1226. break;
  1227. default:
  1228. printf("Unknown %u)\n", state);
  1229. break;
  1230. }
  1231. }
  1232. return(status);
  1233. }
  1234. DWORD
  1235. TestEvents(
  1236. IN char ** argv,
  1237. IN int argc
  1238. )
  1239. /*++
  1240. Routine Description:
  1241. Arguments:
  1242. Return Value:
  1243. ERROR_SUCCESS if the operation was successful.
  1244. A Windows error code otherwise.
  1245. --*/
  1246. {
  1247. DWORD status;
  1248. DWORD Mask;
  1249. CLUSNET_EVENT Event;
  1250. if (argc < 1) {
  1251. return(ERROR_INVALID_PARAMETER);
  1252. }
  1253. Mask = strtoul(argv[0], NULL, 16);
  1254. status = ClusnetSetEventMask( Handle, Mask );
  1255. if ( status == ERROR_SUCCESS ) {
  1256. while ( 1 ) {
  1257. status = ClusnetGetNextEvent( Handle, &Event, NULL );
  1258. printf(
  1259. "Status = %d, Event Type = %d, Node Id = %d, Network Id = %d\n",
  1260. status, Event.EventType, Event.NodeId, Event.NetworkId );
  1261. }
  1262. }
  1263. return(status);
  1264. }
  1265. DWORD
  1266. SetMemLogging(
  1267. IN char ** argv,
  1268. IN int argc
  1269. )
  1270. /*++
  1271. Routine Description:
  1272. Arguments:
  1273. Return Value:
  1274. ERROR_SUCCESS if the operation was successful.
  1275. A Windows error code otherwise.
  1276. --*/
  1277. {
  1278. DWORD status;
  1279. DWORD NumEntries;
  1280. if (argc < 1) {
  1281. return(ERROR_INVALID_PARAMETER);
  1282. }
  1283. NumEntries = strtoul(argv[0], NULL, 10);
  1284. status = ClusnetSetMemLogging( Handle, NumEntries );
  1285. return(status);
  1286. }
  1287. #if DBG
  1288. DWORD
  1289. SetDebugMask(
  1290. IN char ** argv,
  1291. IN int argc
  1292. )
  1293. /*++
  1294. Routine Description:
  1295. Arguments:
  1296. Return Value:
  1297. ERROR_SUCCESS if the operation was successful.
  1298. A Windows error code otherwise.
  1299. --*/
  1300. {
  1301. DWORD status;
  1302. ULONG mask;
  1303. if (argc < 1) {
  1304. return(ERROR_INVALID_PARAMETER);
  1305. }
  1306. mask = strtoul(argv[0], NULL, 16);
  1307. status = ClusnetSetDebugMask(Handle, mask);
  1308. return(status);
  1309. }
  1310. DWORD
  1311. OnlinePendingInterface(
  1312. IN char ** argv,
  1313. IN int argc
  1314. )
  1315. /*++
  1316. Routine Description:
  1317. Arguments:
  1318. Return Value:
  1319. ERROR_SUCCESS if the operation was successful.
  1320. A Windows error code otherwise.
  1321. --*/
  1322. {
  1323. DWORD status;
  1324. CL_NODE_ID nodeId;
  1325. CL_NETWORK_ID networkId;
  1326. if (argc < 2) {
  1327. return(ERROR_INVALID_PARAMETER);
  1328. }
  1329. nodeId = strtoul(argv[0], NULL, 10);
  1330. networkId = strtoul(argv[1], NULL, 10);
  1331. status = ClusnetOnlinePendingInterface(Handle, nodeId, networkId);
  1332. return(status);
  1333. }
  1334. DWORD
  1335. OnlineInterface(
  1336. IN char ** argv,
  1337. IN int argc
  1338. )
  1339. /*++
  1340. Routine Description:
  1341. Arguments:
  1342. Return Value:
  1343. ERROR_SUCCESS if the operation was successful.
  1344. A Windows error code otherwise.
  1345. --*/
  1346. {
  1347. DWORD status;
  1348. CL_NODE_ID nodeId;
  1349. CL_NETWORK_ID networkId;
  1350. if (argc < 2) {
  1351. return(ERROR_INVALID_PARAMETER);
  1352. }
  1353. nodeId = strtoul(argv[0], NULL, 10);
  1354. networkId = strtoul(argv[1], NULL, 10);
  1355. status = ClusnetOnlineInterface(Handle, nodeId, networkId);
  1356. return(status);
  1357. }
  1358. DWORD
  1359. OfflineInterface(
  1360. IN char ** argv,
  1361. IN int argc
  1362. )
  1363. /*++
  1364. Routine Description:
  1365. Arguments:
  1366. Return Value:
  1367. ERROR_SUCCESS if the operation was successful.
  1368. A Windows error code otherwise.
  1369. --*/
  1370. {
  1371. DWORD status;
  1372. CL_NODE_ID nodeId;
  1373. CL_NETWORK_ID networkId;
  1374. if (argc < 2) {
  1375. return(ERROR_INVALID_PARAMETER);
  1376. }
  1377. nodeId = strtoul(argv[0], NULL, 10);
  1378. networkId = strtoul(argv[1], NULL, 10);
  1379. status = ClusnetOfflineInterface(Handle, nodeId, networkId);
  1380. return(status);
  1381. }
  1382. DWORD
  1383. FailInterface(
  1384. IN char ** argv,
  1385. IN int argc
  1386. )
  1387. /*++
  1388. Routine Description:
  1389. Arguments:
  1390. Return Value:
  1391. ERROR_SUCCESS if the operation was successful.
  1392. A Windows error code otherwise.
  1393. --*/
  1394. {
  1395. DWORD status;
  1396. CL_NODE_ID nodeId;
  1397. CL_NETWORK_ID networkId;
  1398. if (argc < 2) {
  1399. return(ERROR_INVALID_PARAMETER);
  1400. }
  1401. nodeId = strtoul(argv[0], NULL, 10);
  1402. networkId = strtoul(argv[1], NULL, 10);
  1403. status = ClusnetFailInterface(Handle, nodeId, networkId);
  1404. return(status);
  1405. }
  1406. DWORD
  1407. SendMmMsg(
  1408. IN char ** argv,
  1409. IN int argc
  1410. )
  1411. /*++
  1412. Routine Description:
  1413. Arguments:
  1414. Return Value:
  1415. ERROR_SUCCESS if the operation was successful.
  1416. A Windows error code otherwise.
  1417. --*/
  1418. {
  1419. DWORD status;
  1420. CL_NODE_ID nodeId;
  1421. ULONG pattern;
  1422. if (argc < 2) {
  1423. return(ERROR_INVALID_PARAMETER);
  1424. }
  1425. nodeId = strtoul(argv[0], NULL, 10);
  1426. pattern = strtoul(argv[1], NULL, 16);
  1427. status = ClusnetSendMmMsg(Handle, nodeId, pattern);
  1428. return(status);
  1429. }
  1430. #ifdef MM_IN_CLUSNET
  1431. DWORD
  1432. MMgrForm(
  1433. IN char ** argv,
  1434. IN int argc
  1435. )
  1436. /*++
  1437. Routine Description:
  1438. Arguments:
  1439. Return Value:
  1440. ERROR_SUCCESS if the operation was successful.
  1441. A Windows error code otherwise.
  1442. --*/
  1443. {
  1444. DWORD status;
  1445. CL_NODE_ID nodeId;
  1446. ULONG ClockPeriod;
  1447. ULONG SendHBRate;
  1448. ULONG RecvHBRate;
  1449. if (argc < 4) {
  1450. return(ERROR_INVALID_PARAMETER);
  1451. }
  1452. nodeId = strtoul(argv[0], NULL, 10);
  1453. ClockPeriod = strtoul(argv[1], NULL, 10);
  1454. SendHBRate = strtoul(argv[2], NULL, 10);
  1455. RecvHBRate = strtoul(argv[3], NULL, 10);
  1456. status = ClusnetFormCluster(Handle, ClockPeriod, SendHBRate, RecvHBRate );
  1457. return(status);
  1458. }
  1459. DWORD
  1460. MMgrJoin(
  1461. IN char ** argv,
  1462. IN int argc
  1463. )
  1464. /*++
  1465. Routine Description:
  1466. Arguments:
  1467. Return Value:
  1468. ERROR_SUCCESS if the operation was successful.
  1469. A Windows error code otherwise.
  1470. --*/
  1471. {
  1472. DWORD status;
  1473. CL_NODE_ID nodeId;
  1474. ULONG Phase;
  1475. ULONG JoinTimeout;
  1476. if (argc < 3) {
  1477. return(ERROR_INVALID_PARAMETER);
  1478. }
  1479. nodeId = strtoul(argv[0], NULL, 10);
  1480. Phase = strtoul(argv[1], NULL, 10);
  1481. JoinTimeout = strtoul(argv[2], NULL, 10);
  1482. #if 0
  1483. status = ClusnetJoinCluster(
  1484. Handle,
  1485. nodeId,
  1486. Phase,
  1487. JoinTimeout
  1488. );
  1489. #else
  1490. status = ERROR_CALL_NOT_IMPLEMENTED;
  1491. #endif
  1492. return(status);
  1493. }
  1494. DWORD
  1495. MMgrLeave(
  1496. IN char ** argv,
  1497. IN int argc
  1498. )
  1499. /*++
  1500. Routine Description:
  1501. Arguments:
  1502. Return Value:
  1503. ERROR_SUCCESS if the operation was successful.
  1504. A Windows error code otherwise.
  1505. --*/
  1506. {
  1507. DWORD status;
  1508. status = ClusnetLeaveCluster( Handle );
  1509. return(status);
  1510. }
  1511. DWORD
  1512. MMgrGetMembershipState(
  1513. IN char ** argv,
  1514. IN int argc
  1515. )
  1516. /*++
  1517. Routine Description:
  1518. Arguments:
  1519. Return Value:
  1520. ERROR_SUCCESS if the operation was successful.
  1521. A Windows error code otherwise.
  1522. --*/
  1523. {
  1524. DWORD status;
  1525. CL_NODE_ID nodeId;
  1526. CLUSTER_NODE_STATE State;
  1527. if (argc < 1) {
  1528. return(ERROR_INVALID_PARAMETER);
  1529. }
  1530. nodeId = strtoul(argv[0], NULL, 10);
  1531. status = ClusnetGetNodeMembershipState( Handle, nodeId, &State );
  1532. printf("Node state = ");
  1533. switch ( State ) {
  1534. case ClusterNodeUnavailable:
  1535. printf( "Unavailable" );
  1536. break;
  1537. case ClusterNodeUp:
  1538. printf( "Up" );
  1539. break;
  1540. case ClusterNodeDown:
  1541. printf( "Down" );
  1542. break;
  1543. case ClusterNodePaused:
  1544. printf( "Paused" );
  1545. break;
  1546. case ClusterNodeJoining:
  1547. printf( "Joining" );
  1548. break;
  1549. default:
  1550. printf( "Unknown" );
  1551. }
  1552. printf( "\n" );
  1553. return(status);
  1554. }
  1555. DWORD
  1556. MMgrEject(
  1557. IN char ** argv,
  1558. IN int argc
  1559. )
  1560. /*++
  1561. Routine Description:
  1562. Arguments:
  1563. Return Value:
  1564. ERROR_SUCCESS if the operation was successful.
  1565. A Windows error code otherwise.
  1566. --*/
  1567. {
  1568. DWORD status;
  1569. CL_NODE_ID nodeId;
  1570. if (argc < 1) {
  1571. return(ERROR_INVALID_PARAMETER);
  1572. }
  1573. nodeId = strtoul(argv[0], NULL, 10);
  1574. status = ClusnetEvictNode( Handle, nodeId );
  1575. return(status);
  1576. }
  1577. #endif // MM_IN_CLUSNET
  1578. #endif // DBG
  1579. DWORD
  1580. SendPoisonPacket(
  1581. IN char ** argv,
  1582. IN int argc
  1583. )
  1584. {
  1585. DWORD status;
  1586. CL_NODE_ID nodeId;
  1587. DWORD packets = 1, i;
  1588. if (argc < 1) {
  1589. return(ERROR_INVALID_PARAMETER);
  1590. }
  1591. nodeId = strtoul(argv[0], NULL, 10);
  1592. if (argc > 1) {
  1593. packets = strtoul(argv[1], NULL, 10);
  1594. packets = (packets > 100) ? 100 : packets;
  1595. }
  1596. for (i = 0; i < packets; i++) {
  1597. status = ClusnetSendPoisonPacket(Handle, nodeId);
  1598. // ignore status
  1599. }
  1600. return(status);
  1601. }
  1602. DWORD
  1603. GetMulticastReachableSet(
  1604. IN char ** argv,
  1605. IN int argc
  1606. )
  1607. {
  1608. DWORD status;
  1609. CL_NETWORK_ID networkId;
  1610. DWORD nodeScreen;
  1611. if (argc < 1) {
  1612. return(ERROR_INVALID_PARAMETER);
  1613. }
  1614. networkId = strtoul(argv[0], NULL, 10);
  1615. status = ClusnetGetMulticastReachableSet(Handle, networkId, &nodeScreen);
  1616. if (status == ERROR_SUCCESS) {
  1617. printf("Multicast reachable screen for network %u: %4x.\n",
  1618. networkId, nodeScreen
  1619. );
  1620. }
  1621. return(status);
  1622. }
  1623. PWCHAR
  1624. ConvertStringToUnicode(
  1625. PUCHAR String
  1626. )
  1627. {
  1628. ANSI_STRING ansiString;
  1629. UNICODE_STRING unicodeString;
  1630. DWORD status;
  1631. RtlInitAnsiString(&ansiString, String);
  1632. RtlInitUnicodeString(&unicodeString, NULL);
  1633. status = RtlAnsiStringToUnicodeString(&unicodeString, &ansiString, TRUE);
  1634. if (!NT_SUCCESS(status)) {
  1635. return(NULL);
  1636. }
  1637. return(unicodeString.Buffer);
  1638. }
  1639. PTRANSPORT_ADDRESS
  1640. BuildTdiAddressForIp(
  1641. IN ULONG Address,
  1642. IN USHORT Port,
  1643. OUT PULONG TdiAddressLength
  1644. )
  1645. /*++
  1646. Routine Description:
  1647. Arguments:
  1648. Return Value:
  1649. ERROR_SUCCESS if the operation was successful.
  1650. A Windows error code otherwise.
  1651. --*/
  1652. {
  1653. DWORD status;
  1654. PTA_IP_ADDRESS taIpAddress;
  1655. taIpAddress = LocalAlloc(LMEM_FIXED, sizeof(TA_IP_ADDRESS));
  1656. if (taIpAddress == NULL) {
  1657. return(NULL);
  1658. }
  1659. ZeroMemory(taIpAddress, sizeof(TA_IP_ADDRESS));
  1660. taIpAddress->TAAddressCount = 1;
  1661. taIpAddress->Address[0].AddressLength = sizeof(TDI_ADDRESS_IP);
  1662. taIpAddress->Address[0].AddressType = TDI_ADDRESS_TYPE_IP;
  1663. taIpAddress->Address[0].Address[0].in_addr = Address;
  1664. taIpAddress->Address[0].Address[0].sin_port = Port;
  1665. *TdiAddressLength = sizeof(TA_IP_ADDRESS);
  1666. return((PTRANSPORT_ADDRESS) taIpAddress);
  1667. }
  1668.