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.

818 lines
12 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1994 - 1999
  6. //
  7. // File: client.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #define SRVNAME_LEN 16
  11. #define CLIENT 1
  12. /************************************************************************/
  13. // Local function prototypes
  14. /************************************************************************/
  15. VOID
  16. Usage(
  17. IN PSZ PrgName
  18. );
  19. VOID
  20. Setup_Function_Pointers(
  21. );
  22. NTSTATUS
  23. Wait_For_Client_Threads(
  24. );
  25. NTSTATUS
  26. Parse_Cmd_Line(
  27. IN USHORT argc,
  28. IN PSZ argv[]
  29. );
  30. NTSTATUS
  31. Delay_Trigger_Wait(
  32. VOID
  33. );
  34. VOID
  35. CliService(
  36. IN PUSHORT pTindex
  37. );
  38. VOID
  39. Display_Results(
  40. );
  41. VOID
  42. Cleanup(
  43. );
  44. /************************************************************************/
  45. // Local functions required for SPX/IPX
  46. /************************************************************************/
  47. //***>begin changes mkj
  48. /**********************************************************************
  49. g e t _ h e x _ b y t e
  50. Converts the character passed in to a hexadecimal nibble.
  51. Arguments: char character to convert
  52. Returns: UCHAR hex nibble
  53. **************************************************************************/
  54. CHAR get_hex_byte(char ch)
  55. {
  56. if (ch >= '0' && ch <= '9')
  57. return (ch - '0');
  58. if (ch >= 'A' && ch <= 'F')
  59. return ((ch - 'A') + 0x0A);
  60. return -1;
  61. }
  62. /**********************************************************************
  63. g e t _ h e x _ s t r i n g
  64. Reads in a character string containing hex digits and converts
  65. it to a hexadecimal number.
  66. Arguments: LPSTR => source string
  67. LPSTR => destination for hex number
  68. int number of bytes to convert
  69. Returns: nothing
  70. **************************************************************************/
  71. CHAR get_hex_string(LPSTR src, LPSTR dest, int num)
  72. {
  73. LPSTR q = src;
  74. CHAR hexbyte1,hexbyte2;
  75. _strupr(q);
  76. while (num--)
  77. {hexbyte1 = get_hex_byte(*q++);
  78. hexbyte2 = get_hex_byte(*q++);
  79. if ( (hexbyte1 < 0) || (hexbyte2 < 0) )
  80. return -1;
  81. *dest++ = (hexbyte1 << 4) + hexbyte2;
  82. }
  83. return(0);
  84. }
  85. /*************************************************************************
  86. g e t _ n o d e _ n u m b e r
  87. Reads a node number from the given string.
  88. Arguments: LPSTR => string to read from
  89. Returns: LPSTR => hex node number
  90. **************************************************************************/
  91. LPSTR get_node_number(LPSTR cmd)
  92. {
  93. static char hex_num[6];
  94. memset(hex_num, 0, 6);
  95. if (strlen(cmd) != 12){
  96. hex_num[0] = 'X';
  97. return hex_num;
  98. }
  99. if (get_hex_string(cmd, hex_num, 6) < 0)
  100. hex_num[0] = 'X';
  101. return hex_num;
  102. }
  103. /**************************************************************************
  104. g e t _ n e t w o k _ n u m b e r
  105. Reads a network number from the given string.
  106. Arguments: LPSTR => string to read from
  107. Returns: LPSTR => hex network number
  108. **************************************************************************/
  109. LPSTR get_network_number(LPSTR cmd)
  110. {
  111. static char hex_num[4];
  112. memset(hex_num, 0, 4);
  113. if (strlen(cmd) != 8) {
  114. hex_num[0] = 'X';
  115. return(hex_num);
  116. }
  117. if (get_hex_string(cmd, hex_num, 4) < 0)
  118. hex_num[0] = 'X';
  119. return hex_num;
  120. }
  121. //***>end changes mkj
  122. /************************************************************************/
  123. // External function prototypes
  124. /************************************************************************/
  125. /*++
  126. For NamedPipe
  127. --*/
  128. extern
  129. NTSTATUS
  130. NMP_Initialize(
  131. IN USHORT NClients,
  132. IN PCHAR ServerName,
  133. IN USHORT SrvCli
  134. );
  135. extern
  136. NTSTATUS
  137. NMP_PerClientInit(
  138. IN USHORT CIndex,
  139. IN USHORT SrvCli
  140. );
  141. extern
  142. NTSTATUS
  143. NMP_Allocate_Memory(
  144. IN USHORT CIndex
  145. );
  146. extern
  147. NTSTATUS
  148. NMP_Deallocate_Memory(
  149. IN USHORT CIndex
  150. );
  151. extern
  152. NTSTATUS
  153. NMP_DoHandshake(
  154. IN USHORT CIndex,
  155. IN USHORT SrvCli
  156. );
  157. extern
  158. NTSTATUS
  159. NMP_Cleanup(
  160. VOID
  161. );
  162. extern
  163. NTSTATUS
  164. NMP_Connect_To_Server(
  165. IN USHORT CIndex
  166. );
  167. extern
  168. NTSTATUS
  169. NMP_Disconnect_From_Server(
  170. IN USHORT CIndex
  171. );
  172. extern
  173. NTSTATUS
  174. NMP_ReadFromIPC(
  175. IN USHORT CIndex,
  176. IN OUT PULONG pReadDone,
  177. IN USHORT SrvCli
  178. );
  179. extern
  180. NTSTATUS
  181. NMP_WriteToIPC(
  182. IN USHORT CIndex,
  183. IN OUT PULONG pWriteDone,
  184. IN USHORT SrvCli
  185. );
  186. extern
  187. NTSTATUS
  188. NMP_XactIO(
  189. IN USHORT CIndex,
  190. IN OUT PULONG pReadDone,
  191. IN OUT PULONG pWriteDone,
  192. IN USHORT SrvCli,
  193. IN BOOLEAN FirstIter
  194. );
  195. extern
  196. NTSTATUS
  197. NMP_ThreadCleanUp(
  198. IN USHORT CIndex
  199. );
  200. /*++**********************************************************************
  201. For NetBIOS
  202. --*/
  203. extern
  204. NTSTATUS
  205. NB_Initialize(
  206. IN USHORT NClients,
  207. IN PCHAR ServerName,
  208. IN USHORT SrvCli
  209. );
  210. extern
  211. NTSTATUS
  212. NB_PerClientInit(
  213. IN USHORT CIndex,
  214. IN USHORT SrvCli
  215. );
  216. extern
  217. NTSTATUS
  218. NB_Allocate_Memory(
  219. IN USHORT CIndex
  220. );
  221. extern
  222. NTSTATUS
  223. NB_Deallocate_Memory(
  224. IN USHORT CIndex
  225. );
  226. extern
  227. NTSTATUS
  228. NB_DoHandshake(
  229. IN USHORT CIndex,
  230. IN USHORT SrvCli
  231. );
  232. extern
  233. NTSTATUS
  234. NB_Connect_To_Server(
  235. IN USHORT CIndex
  236. );
  237. extern
  238. NTSTATUS
  239. NB_Disconnect_From_Server(
  240. IN USHORT CIndex
  241. );
  242. extern
  243. NTSTATUS
  244. NB_Cleanup(
  245. VOID
  246. );
  247. extern
  248. NTSTATUS
  249. NB_Wait_For_Client(
  250. IN USHORT CIndex
  251. );
  252. extern
  253. NTSTATUS
  254. NB_ReadFromIPC(
  255. IN USHORT CIndex,
  256. IN OUT PULONG pReadDone,
  257. IN USHORT SrvCli
  258. );
  259. extern
  260. NTSTATUS
  261. NB_WriteToIPC(
  262. IN USHORT CIndex,
  263. IN OUT PULONG pWriteDone,
  264. IN USHORT SrvCli
  265. );
  266. extern
  267. NTSTATUS
  268. NB_XactIO(
  269. IN USHORT CIndex,
  270. IN OUT PULONG pReadDone,
  271. IN OUT PULONG pWriteDone,
  272. IN USHORT SrvCli,
  273. IN BOOLEAN FirstIter
  274. );
  275. extern
  276. NTSTATUS
  277. NB_ThreadCleanUp(
  278. IN USHORT CIndex
  279. );
  280. /*++**********************************************************************
  281. For Sockets TCP/IP
  282. --*/
  283. extern
  284. NTSTATUS
  285. SCTCP_Initialize(
  286. IN USHORT NClients,
  287. IN PCHAR ServerName,
  288. IN USHORT SrvCli
  289. );
  290. extern
  291. NTSTATUS
  292. SCTCP_PerClientInit(
  293. IN USHORT CIndex,
  294. IN USHORT SrvCli
  295. );
  296. extern
  297. NTSTATUS
  298. SCTCP_Allocate_Memory(
  299. IN USHORT CIndex
  300. );
  301. extern
  302. NTSTATUS
  303. SCTCP_Deallocate_Memory(
  304. IN USHORT CIndex
  305. );
  306. extern
  307. NTSTATUS
  308. SCTCP_DoHandshake(
  309. IN USHORT CIndex,
  310. IN USHORT SrvCli
  311. );
  312. extern
  313. NTSTATUS
  314. SCTCP_Connect_To_Server(
  315. IN USHORT CIndex
  316. );
  317. extern
  318. NTSTATUS
  319. SCTCP_Disconnect_From_Server(
  320. IN USHORT CIndex
  321. );
  322. extern
  323. NTSTATUS
  324. SCTCP_Cleanup(
  325. VOID
  326. );
  327. extern
  328. NTSTATUS
  329. SCTCP_Wait_For_Client(
  330. IN USHORT CIndex
  331. );
  332. extern
  333. NTSTATUS
  334. SCTCP_ReadFromIPC(
  335. IN USHORT CIndex,
  336. IN OUT PULONG pReadDone,
  337. IN USHORT SrvCli
  338. );
  339. extern
  340. NTSTATUS
  341. SCTCP_WriteToIPC(
  342. IN USHORT CIndex,
  343. IN OUT PULONG pWriteDone,
  344. IN USHORT SrvCli
  345. );
  346. extern
  347. NTSTATUS
  348. SCTCP_XactIO(
  349. IN USHORT CIndex,
  350. IN OUT PULONG pReadDone,
  351. IN OUT PULONG pWriteDone,
  352. IN USHORT SrvCli,
  353. IN BOOLEAN FirstIter
  354. );
  355. extern
  356. NTSTATUS
  357. SCTCP_ThreadCleanUp(
  358. IN USHORT CIndex
  359. );
  360. /*++**********************************************************************
  361. For Sockets SPX(XNS)
  362. --*/
  363. extern
  364. NTSTATUS
  365. SCXNS_Initialize(
  366. IN USHORT NClients,
  367. IN PCHAR ServerName,
  368. IN USHORT SrvCli
  369. );
  370. extern
  371. NTSTATUS
  372. SCXNS_PerClientInit(
  373. IN USHORT CIndex,
  374. IN USHORT SrvCli
  375. );
  376. extern
  377. NTSTATUS
  378. SCXNS_Allocate_Memory(
  379. IN USHORT CIndex
  380. );
  381. extern
  382. NTSTATUS
  383. SCXNS_Deallocate_Memory(
  384. IN USHORT CIndex
  385. );
  386. extern
  387. NTSTATUS
  388. SCXNS_DoHandshake(
  389. IN USHORT CIndex,
  390. IN USHORT SrvCli
  391. );
  392. extern
  393. NTSTATUS
  394. SCXNS_Connect_To_Server(
  395. IN USHORT CIndex
  396. );
  397. extern
  398. NTSTATUS
  399. SCXNS_Disconnect_From_Server(
  400. IN USHORT CIndex
  401. );
  402. extern
  403. NTSTATUS
  404. SCXNS_Cleanup(
  405. VOID
  406. );
  407. extern
  408. NTSTATUS
  409. SCXNS_Wait_For_Client(
  410. IN USHORT CIndex
  411. );
  412. extern
  413. NTSTATUS
  414. SCXNS_ReadFromIPC(
  415. IN USHORT CIndex,
  416. IN OUT PULONG pReadDone,
  417. IN USHORT SrvCli
  418. );
  419. extern
  420. NTSTATUS
  421. SCXNS_WriteToIPC(
  422. IN USHORT CIndex,
  423. IN OUT PULONG pWriteDone,
  424. IN USHORT SrvCli
  425. );
  426. extern
  427. NTSTATUS
  428. SCXNS_XactIO(
  429. IN USHORT CIndex,
  430. IN OUT PULONG pReadDone,
  431. IN OUT PULONG pWriteDone,
  432. IN USHORT SrvCli,
  433. IN BOOLEAN FirstIter
  434. );
  435. extern
  436. NTSTATUS
  437. SCXNS_ThreadCleanUp(
  438. IN USHORT CIndex
  439. );
  440. /*++**********************************************************************
  441. For Sockets UDP
  442. --*/
  443. extern
  444. NTSTATUS
  445. SCUDP_Initialize(
  446. IN USHORT NClients,
  447. IN PCHAR ServerName,
  448. IN USHORT SrvCli
  449. );
  450. extern
  451. NTSTATUS
  452. SCUDP_PerClientInit(
  453. IN USHORT CIndex,
  454. IN USHORT SrvCli
  455. );
  456. extern
  457. NTSTATUS
  458. SCUDP_Allocate_Memory(
  459. IN USHORT CIndex
  460. );
  461. extern
  462. NTSTATUS
  463. SCUDP_Deallocate_Memory(
  464. IN USHORT CIndex
  465. );
  466. extern
  467. NTSTATUS
  468. SCUDP_DoHandshake(
  469. IN USHORT CIndex,
  470. IN USHORT SrvCli
  471. );
  472. extern
  473. NTSTATUS
  474. SCUDP_Cleanup(
  475. VOID
  476. );
  477. extern
  478. NTSTATUS
  479. SCUDP_Wait_For_Client(
  480. IN USHORT CIndex
  481. );
  482. extern
  483. NTSTATUS
  484. SCUDP_Connect_To_Server(
  485. IN USHORT CIndex
  486. );
  487. extern
  488. NTSTATUS
  489. SCUDP_Disconnect_From_Server(
  490. IN USHORT CIndex
  491. );
  492. extern
  493. NTSTATUS
  494. SCUDP_ReadFromIPC(
  495. IN USHORT CIndex,
  496. IN OUT PULONG pReadDone,
  497. IN USHORT SrvCli
  498. );
  499. extern
  500. NTSTATUS
  501. SCUDP_WriteToIPC(
  502. IN USHORT CIndex,
  503. IN OUT PULONG pWriteDone,
  504. IN USHORT SrvCli
  505. );
  506. extern
  507. NTSTATUS
  508. SCUDP_ThreadCleanUp(
  509. IN USHORT CIndex
  510. );
  511. /*++**********************************************************************
  512. For Sockets IPX
  513. --*/
  514. extern
  515. NTSTATUS
  516. SCIPX_Initialize(
  517. IN USHORT NClients,
  518. IN PCHAR ServerName,
  519. IN USHORT SrvCli
  520. );
  521. extern
  522. NTSTATUS
  523. SCIPX_PerClientInit(
  524. IN USHORT CIndex,
  525. IN USHORT SrvCli
  526. );
  527. extern
  528. NTSTATUS
  529. SCIPX_Allocate_Memory(
  530. IN USHORT CIndex
  531. );
  532. extern
  533. NTSTATUS
  534. SCIPX_Deallocate_Memory(
  535. IN USHORT CIndex
  536. );
  537. extern
  538. NTSTATUS
  539. SCIPX_DoHandshake(
  540. IN USHORT CIndex,
  541. IN USHORT SrvCli
  542. );
  543. extern
  544. NTSTATUS
  545. SCIPX_Cleanup(
  546. VOID
  547. );
  548. extern
  549. NTSTATUS
  550. SCIPX_Wait_For_Client(
  551. IN USHORT CIndex
  552. );
  553. extern
  554. NTSTATUS
  555. SCIPX_Connect_To_Server(
  556. IN USHORT CIndex
  557. );
  558. extern
  559. NTSTATUS
  560. SCIPX_Disconnect_From_Server(
  561. IN USHORT CIndex
  562. );
  563. extern
  564. NTSTATUS
  565. SCIPX_ReadFromIPC(
  566. IN USHORT CIndex,
  567. IN OUT PULONG pReadDone,
  568. IN USHORT SrvCli
  569. );
  570. extern
  571. NTSTATUS
  572. SCIPX_WriteToIPC(
  573. IN USHORT CIndex,
  574. IN OUT PULONG pWriteDone,
  575. IN USHORT SrvCli
  576. );
  577. extern
  578. NTSTATUS
  579. SCIPX_ThreadCleanUp(
  580. IN USHORT CIndex
  581. );
  582. /*++**********************************************************************
  583. For Datagram NetBIOS
  584. --*/
  585. extern
  586. NTSTATUS
  587. DGNB_Initialize(
  588. IN USHORT NClients,
  589. IN PCHAR ServerName,
  590. IN USHORT SrvCli
  591. );
  592. extern
  593. NTSTATUS
  594. DGNB_PerClientInit(
  595. IN USHORT CIndex,
  596. IN USHORT SrvCli
  597. );
  598. extern
  599. NTSTATUS
  600. DGNB_Allocate_Memory(
  601. IN USHORT CIndex
  602. );
  603. extern
  604. NTSTATUS
  605. DGNB_Deallocate_Memory(
  606. IN USHORT CIndex
  607. );
  608. extern
  609. NTSTATUS
  610. DGNB_DoHandshake(
  611. IN USHORT CIndex,
  612. IN USHORT SrvCli
  613. );
  614. extern
  615. NTSTATUS
  616. DGNB_Cleanup(
  617. VOID
  618. );
  619. extern
  620. NTSTATUS
  621. DGNB_Wait_For_Client(
  622. IN USHORT CIndex
  623. );
  624. extern
  625. NTSTATUS
  626. DGNB_Disconnect_Client(
  627. IN USHORT CIndex
  628. );
  629. extern
  630. NTSTATUS
  631. DGNB_ReadFromIPC(
  632. IN USHORT CIndex,
  633. IN OUT PULONG pReadDone,
  634. IN USHORT SrvCli
  635. );
  636. extern
  637. NTSTATUS
  638. DGNB_WriteToIPC(
  639. IN USHORT CIndex,
  640. IN OUT PULONG pWriteDone,
  641. IN USHORT SrvCli
  642. );
  643. extern
  644. NTSTATUS
  645. DGNB_XactIO(
  646. IN USHORT CIndex,
  647. IN OUT PULONG pReadDone,
  648. IN OUT PULONG pWriteDone,
  649. IN USHORT SrvCli,
  650. IN BOOLEAN FirstIter
  651. );
  652. extern
  653. NTSTATUS
  654. DGNB_ThreadCleanUp(
  655. IN USHORT CIndex
  656. );
  657. NTSTATUS
  658. DGNB_Connect_To_Server(
  659. IN USHORT CIndex
  660. );
  661. NTSTATUS
  662. DGNB_Disconnect_From_Server(
  663. IN USHORT CIndex
  664. );