Leaked source code of windows server 2003
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.

3192 lines
79 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. dlcdebug.c
  5. Abstract:
  6. CCB dump routines for NT-level CCB
  7. Contents:
  8. GetAcslanDebugFlags
  9. SetAcslanDebugFlags
  10. AcslanDebugPrint
  11. AcslanDebugPrintString
  12. DumpCcb
  13. MapCcbRetcode
  14. DumpData
  15. (DefaultParameterTableDump)
  16. (DumpParameterTableHeader)
  17. (DumpBufferCreateParms)
  18. (DumpBufferFreeParms)
  19. (DumpBufferGetParms)
  20. (DumpDirInitializeParms)
  21. (DumpDirOpenAdapterParms)
  22. (MapEthernetType)
  23. (DumpDirOpenDirectParms)
  24. (DumpDirReadLogParms)
  25. (MapLogType)
  26. (DumpDirSetExceptionFlagsParms)
  27. (DumpDirSetFunctionalAddressParms)
  28. (DumpDirSetGroupAddressParms)
  29. (DumpDirStatusParms)
  30. (MapAdapterType)
  31. (DumpDirTimerCancelParms)
  32. (DumpDirTimerCancelGroupParms)
  33. (DumpDirTimerSetParms)
  34. (DumpDlcCloseSapParms)
  35. (DumpDlcCloseStationParms)
  36. (DumpDlcConnectStationParms)
  37. (DumpDlcFlowControlParms)
  38. (MapFlowControl)
  39. (DumpDlcModifyParms)
  40. (DumpDlcOpenSapParms)
  41. (DumpDlcOpenStationParms)
  42. (DumpDlcReallocateParms)
  43. (DumpDlcResetParms)
  44. (DumpDlcSetThresholdParms)
  45. (DumpDlcStatisticsParms)
  46. (DumpReadParms)
  47. (MapOptionIndicator)
  48. (MapReadEvent)
  49. (MapDlcStatus)
  50. (DumpReadCancelParms)
  51. (DumpReceiveParms)
  52. (MapRcvReadOption)
  53. (MapReceiveOptions)
  54. (DumpReceiveCancelParms)
  55. (DumpReceiveModifyParms)
  56. (DumpTransmitDirFrameParms)
  57. (DumpTransmitIFrameParms)
  58. (DumpTransmitTestCmdParms)
  59. (DumpTransmitUiFrameParms)
  60. (DumpTransmitXidCmdParms)
  61. (DumpTransmitXidRespFinalParms)
  62. (DumpTransmitXidRespNotFinalParms)
  63. (DumpTransmitFramesParms)
  64. (DumpTransmitParms)
  65. (DumpTransmitQueue)
  66. DumpReceiveDataBuffer
  67. (MapMessageType)
  68. Author:
  69. Richard L Firth (rfirth) 28-May-1992
  70. Revision History:
  71. --*/
  72. #if DBG
  73. #include <nt.h>
  74. #include <ntrtl.h> // ASSERT, DbgPrint
  75. #include <nturtl.h>
  76. #include <windows.h>
  77. #include <stdio.h>
  78. #include <stdlib.h>
  79. #include <stdarg.h>
  80. #include <string.h>
  81. #include <ctype.h>
  82. #include <dlcapi.h> // Official DLC API definition
  83. #include "dlcdebug.h"
  84. //
  85. // defines
  86. //
  87. #define DBGDBG 0
  88. //
  89. // macros
  90. //
  91. //
  92. // HEX_TO_NUM - converts an ASCII hex character (0-9A-Fa-f) to corresponding
  93. // number (0-15). Assumes c is hexadecimal digit on input
  94. //
  95. #define HEX_TO_NUM(c) ((c) - ('0' + (((c) <= '9') ? 0 : ((islower(c) ? 'a' : 'A') - ('9' + 1)))))
  96. //
  97. // local prototypes
  98. //
  99. VOID
  100. AcslanDebugPrintString(
  101. IN LPSTR String
  102. );
  103. PRIVATE
  104. VOID
  105. DefaultParameterTableDump(
  106. IN PVOID Parameters
  107. );
  108. PRIVATE
  109. VOID
  110. DumpParameterTableHeader(
  111. IN LPSTR CommandName,
  112. IN PVOID Table
  113. );
  114. PRIVATE
  115. VOID
  116. DumpBufferCreateParms(
  117. IN PVOID Parameters
  118. );
  119. PRIVATE
  120. VOID
  121. DumpBufferFreeParms(
  122. IN PVOID Parameters
  123. );
  124. PRIVATE
  125. VOID
  126. DumpBufferGetParms(
  127. IN PVOID Parameters
  128. );
  129. PRIVATE
  130. VOID
  131. DumpDirInitializeParms(
  132. IN PVOID Parameters
  133. );
  134. PRIVATE
  135. VOID
  136. DumpDirOpenAdapterParms(
  137. IN PVOID Parameters
  138. );
  139. PRIVATE
  140. LPSTR
  141. MapEthernetType(
  142. IN LLC_ETHERNET_TYPE EthernetType
  143. );
  144. PRIVATE
  145. VOID
  146. DumpDirOpenDirectParms(
  147. IN PVOID Parameters
  148. );
  149. PRIVATE
  150. VOID
  151. DumpDirReadLogParms(
  152. IN PVOID Parameters
  153. );
  154. PRIVATE
  155. LPSTR
  156. MapLogType(
  157. IN USHORT Type
  158. );
  159. PRIVATE
  160. VOID
  161. DumpDirSetExceptionFlagsParms(
  162. IN PVOID Parameters
  163. );
  164. PRIVATE
  165. VOID
  166. DumpDirSetFunctionalAddressParms(
  167. IN PVOID Parameters
  168. );
  169. PRIVATE
  170. VOID
  171. DumpDirSetGroupAddressParms(
  172. IN PVOID Parameters
  173. );
  174. PRIVATE
  175. VOID
  176. DumpDirStatusParms(
  177. IN PVOID Parameters
  178. );
  179. PRIVATE
  180. LPSTR
  181. MapAdapterType(
  182. IN USHORT AdapterType
  183. );
  184. PRIVATE
  185. VOID
  186. DumpDirTimerCancelParms(
  187. IN PVOID Parameters
  188. );
  189. PRIVATE
  190. VOID
  191. DumpDirTimerCancelGroupParms(
  192. IN PVOID Parameters
  193. );
  194. PRIVATE
  195. VOID
  196. DumpDirTimerSetParms(
  197. IN PVOID Parameters
  198. );
  199. PRIVATE
  200. VOID
  201. DumpDlcCloseSapParms(
  202. IN PVOID Parameters
  203. );
  204. PRIVATE
  205. VOID
  206. DumpDlcCloseStationParms(
  207. IN PVOID Parameters
  208. );
  209. PRIVATE
  210. VOID
  211. DumpDlcConnectStationParms(
  212. IN PVOID Parameters
  213. );
  214. PRIVATE
  215. VOID
  216. DumpDlcFlowControlParms(
  217. IN PVOID Parameters
  218. );
  219. PRIVATE
  220. LPSTR
  221. MapFlowControl(
  222. IN BYTE FlowControl
  223. );
  224. PRIVATE
  225. VOID
  226. DumpDlcModifyParms(
  227. IN PVOID Parameters
  228. );
  229. PRIVATE
  230. VOID
  231. DumpDlcOpenSapParms(
  232. IN PVOID Parameters
  233. );
  234. PRIVATE
  235. VOID
  236. DumpDlcOpenStationParms(
  237. IN PVOID Parameters
  238. );
  239. PRIVATE
  240. VOID
  241. DumpDlcReallocateParms(
  242. IN PVOID Parameters
  243. );
  244. PRIVATE
  245. VOID
  246. DumpDlcResetParms(
  247. IN PVOID Parameters
  248. );
  249. PRIVATE
  250. VOID
  251. DumpDlcSetThresholdParms(
  252. IN PVOID Parameters
  253. );
  254. PRIVATE
  255. VOID
  256. DumpDlcStatisticsParms(
  257. IN PVOID Parameters
  258. );
  259. PRIVATE
  260. VOID
  261. DumpReadParms(
  262. IN PVOID Parameters
  263. );
  264. PRIVATE
  265. LPSTR
  266. MapOptionIndicator(
  267. IN UCHAR OptionIndicator
  268. );
  269. PRIVATE
  270. LPSTR
  271. MapReadEvent(
  272. UCHAR Event
  273. );
  274. PRIVATE
  275. LPSTR
  276. MapDlcStatus(
  277. WORD Status
  278. );
  279. PRIVATE
  280. VOID
  281. DumpReadCancelParms(
  282. IN PVOID Parameters
  283. );
  284. PRIVATE
  285. VOID
  286. DumpReceiveParms(
  287. IN PVOID Parameters
  288. );
  289. PRIVATE
  290. LPSTR
  291. MapReceiveOptions(
  292. IN UCHAR Options
  293. );
  294. PRIVATE
  295. LPSTR
  296. MapRcvReadOption(
  297. IN UCHAR Option
  298. );
  299. PRIVATE
  300. VOID
  301. DumpReceiveCancelParms(
  302. IN PVOID Parameters
  303. );
  304. PRIVATE
  305. VOID
  306. DumpReceiveModifyParms(
  307. IN PVOID Parameters
  308. );
  309. PRIVATE
  310. VOID
  311. DumpTransmitDirFrameParms(
  312. IN PVOID Parameters
  313. );
  314. PRIVATE
  315. VOID
  316. DumpTransmitIFrameParms(
  317. IN PVOID Parameters
  318. );
  319. PRIVATE
  320. VOID
  321. DumpTransmitTestCmdParms(
  322. IN PVOID Parameters
  323. );
  324. PRIVATE
  325. VOID
  326. DumpTransmitUiFrameParms(
  327. IN PVOID Parameters
  328. );
  329. PRIVATE
  330. VOID
  331. DumpTransmitXidCmdParms(
  332. IN PVOID Parameters
  333. );
  334. PRIVATE
  335. VOID
  336. DumpTransmitXidRespFinalParms(
  337. IN PVOID Parameters
  338. );
  339. PRIVATE
  340. VOID
  341. DumpTransmitXidRespNotFinalParms(
  342. IN PVOID Parameters
  343. );
  344. PRIVATE
  345. VOID
  346. DumpTransmitFramesParms(
  347. IN PVOID Parameters
  348. );
  349. PRIVATE
  350. VOID
  351. DumpTransmitParms(
  352. IN PVOID Parameters
  353. );
  354. PRIVATE
  355. VOID
  356. DumpTransmitQueue(
  357. IN PLLC_XMIT_BUFFER Buffer
  358. );
  359. PRIVATE
  360. LPSTR
  361. MapXmitReadOption(
  362. IN UCHAR Option
  363. );
  364. VOID
  365. DumpReceiveDataBuffer(
  366. IN PVOID Buffer
  367. );
  368. PRIVATE
  369. LPSTR
  370. MapMessageType(
  371. UCHAR MessageType
  372. );
  373. //
  374. // explanations of error codes returned in CCB_RETCODE fields. Explanations
  375. // taken more-or-less verbatim from IBM Local Area Network Technical Reference
  376. // table B-1 ppB-2 to B-5. Includes all errors
  377. //
  378. static LPSTR CcbRetcodeExplanations[] = {
  379. "Success",
  380. "Invalid command code",
  381. "Duplicate command, one already outstanding",
  382. "Adapter open, should be closed",
  383. "Adapter closed, should be open",
  384. "Required parameter missing",
  385. "Invalid/incompatible option",
  386. "Command cancelled - unrecoverable failure",
  387. "Unauthorized access priority",
  388. "Adapter not initialized, should be",
  389. "Command cancelled by user request",
  390. "Command cancelled, adapter closed while command in progress",
  391. "Command completed Ok, adapter not open",
  392. "Invalid error code 0x0D",
  393. "Invalid error code 0x0E",
  394. "Invalid error code 0x0F",
  395. "Adapter open, NetBIOS not operational",
  396. "Error in DIR.TIMER.SET or DIR.TIMER.CANCEL",
  397. "Available work area exceeded",
  398. "Invalid LOG.ID",
  399. "Invalid shared RAM segment or size",
  400. "Lost log data, buffer too small, log reset",
  401. "Requested buffer size exceeds pool length",
  402. "Command invalid, NetBIOS operational",
  403. "Invalid buffer length",
  404. "Inadequate buffers available for request",
  405. "The CCB_PARM_TAB pointer is invalid",
  406. "A pointer in the CCB parameter table is invalid",
  407. "Invalid CCB_ADAPTER value",
  408. "Invalid functional address",
  409. "Invalid error code 0x1F",
  410. "Lost data on receive, no buffers available",
  411. "Lost data on receive, inadequate buffer space",
  412. "Error on frame transmission, check TRANSMIT.FS data",
  413. "Error on frame transmit or strip process",
  414. "Unauthorized MAC frame",
  415. "Maximum commands exceeded",
  416. "Unrecognized command correlator",
  417. "Link not transmitting I frames, state changed from link opened",
  418. "Invalid transmit frame length",
  419. "Invalid error code 0x29",
  420. "Invalid error code 0x2a",
  421. "Invalid error code 0x2b",
  422. "Invalid error code 0x2c",
  423. "Invalid error code 0x2d",
  424. "Invalid error code 0x2e",
  425. "Invalid error code 0x2f",
  426. "Inadequate receive buffers for adapter to open",
  427. "Invalid error code 0x31",
  428. "Invalid NODE_ADDRESS",
  429. "Invalid adapter receive buffer length defined",
  430. "Invalid adapter transmit buffer length defined",
  431. "Invalid error code 0x35",
  432. "Invalid error code 0x36",
  433. "Invalid error code 0x37",
  434. "Invalid error code 0x38",
  435. "Invalid error code 0x39",
  436. "Invalid error code 0x3a",
  437. "Invalid error code 0x3b",
  438. "Invalid error code 0x3c",
  439. "Invalid error code 0x3d",
  440. "Invalid error code 0x3e",
  441. "Invalid error code 0x3f",
  442. "Invalid STATION_ID",
  443. "Protocol error, link in invalid state for command",
  444. "Parameter exceeded maximum allowed",
  445. "Invalid SAP value or value already in use",
  446. "Invalid routing information field",
  447. "Requested group membership in non-existent group SAP",
  448. "Resources not available",
  449. "Sap cannot close unless all link stations are closed",
  450. "Group SAP cannot close, individual SAPs not closed",
  451. "Group SAP has reached maximum membership",
  452. "Sequence error, incompatible command in progress",
  453. "Station closed without remote acknowledgement",
  454. "Sequence error, cannot close, DLC commands outstanding",
  455. "Unsuccessful link station connection attempted",
  456. "Member SAP not found in group SAP list",
  457. "Invalid remote address, may not be a group address",
  458. "Invalid pointer in CCB_POINTER field",
  459. "Invalid error code 0x51",
  460. "Invalid application program ID",
  461. "Invalid application program key code",
  462. "Invalid system key code",
  463. "Buffer is smaller than buffer size given in DLC.OPEN.SAP",
  464. "Adapter's system process is not installed",
  465. "Inadequate stations available",
  466. "Invalid CCB_PARAMETER_1 parameter",
  467. "Inadequate queue elements to satisfy request",
  468. "Initialization failure, cannot open adapter",
  469. "Error detected in chained READ command",
  470. "Direct stations not assigned to application program",
  471. "Dd interface not installed",
  472. "Requested adapter is not installed",
  473. "Chained CCBs must all be for same adapter",
  474. "Adapter initializing, command not accepted",
  475. "Number of allowed application programs has been exceeded",
  476. "Command cancelled by system action",
  477. "Direct stations not available",
  478. "Invalid DDNAME parameter",
  479. "Inadequate GDT selectors to satisfy request",
  480. "Invalid error code 0x66",
  481. "Command cancelled, CCB resources purged",
  482. "Application program ID not valid for interface",
  483. "Segment associated with request cannot be locked",
  484. "Invalid error code 0x6a",
  485. "Invalid error code 0x6b",
  486. "Invalid error code 0x6c",
  487. "Invalid error code 0x6d",
  488. "Invalid error code 0x6e",
  489. "Invalid error code 0x6f",
  490. "Invalid error code 0x70",
  491. "Invalid error code 0x71",
  492. "Invalid error code 0x72",
  493. "Invalid error code 0x73",
  494. "Invalid error code 0x74",
  495. "Invalid error code 0x75",
  496. "Invalid error code 0x76",
  497. "Invalid error code 0x77",
  498. "Invalid error code 0x78",
  499. "Invalid error code 0x79",
  500. "Invalid error code 0x7a",
  501. "Invalid error code 0x7b",
  502. "Invalid error code 0x7c",
  503. "Invalid error code 0x7d",
  504. "Invalid error code 0x7e",
  505. "Invalid error code 0x7f",
  506. "Invalid buffer address",
  507. "Buffer already released",
  508. "Invalid error code 0x82",
  509. "Invalid error code 0x83",
  510. "Invalid error code 0x84",
  511. "Invalid error code 0x85",
  512. "Invalid error code 0x86",
  513. "Invalid error code 0x87",
  514. "Invalid error code 0x88",
  515. "Invalid error code 0x89",
  516. "Invalid error code 0x8a",
  517. "Invalid error code 0x8b",
  518. "Invalid error code 0x8c",
  519. "Invalid error code 0x8d",
  520. "Invalid error code 0x8e",
  521. "Invalid error code 0x8f",
  522. "Invalid error code 0x90",
  523. "Invalid error code 0x91",
  524. "Invalid error code 0x92",
  525. "Invalid error code 0x93",
  526. "Invalid error code 0x94",
  527. "Invalid error code 0x95",
  528. "Invalid error code 0x96",
  529. "Invalid error code 0x97",
  530. "Invalid error code 0x98",
  531. "Invalid error code 0x99",
  532. "Invalid error code 0x9a",
  533. "Invalid error code 0x9b",
  534. "Invalid error code 0x9c",
  535. "Invalid error code 0x9d",
  536. "Invalid error code 0x9e",
  537. "Invalid error code 0x9f",
  538. "BIND error",
  539. "Invalid version",
  540. "NT Error status"
  541. };
  542. #define NUMBER_OF_ERROR_MESSAGES ARRAY_ELEMENTS(CcbRetcodeExplanations)
  543. #define LAST_DLC_ERROR_CODE LAST_ELEMENT(CcbRetcodeExplanations)
  544. //
  545. // preset the debug flags to nothing, or to whatever is defined at compile-time
  546. //
  547. DWORD AcslanDebugFlags = ACSLAN_DEBUG_FLAGS;
  548. FILE* hDumpFile = NULL;
  549. BYTE AcslanDumpCcb[LLC_MAX_DLC_COMMAND];
  550. BOOL HaveCcbFilter = FALSE;
  551. VOID
  552. GetAcslanDebugFlags(
  553. VOID
  554. )
  555. /*++
  556. Routine Description:
  557. This routine is called whenever we have a DLL_PROCESS_ATTACH to the DLL
  558. checks if there is an environment variable called ACSLAN_DEBUG_FLAGS, and
  559. loads whatever it finds (as a 32-bit hex number) into AcslanDebugFlags
  560. checks if there is an environment variable called ACSLAN_DUMP_FILE. If
  561. there is, then output which otherwise would have gone to the terminal
  562. goes to the file. The file is opened in "w" mode by default - open for
  563. write. Current file is destroyed if it exists
  564. If there is an environment variable called ACSLAN_DUMP_FILTER then this is
  565. loaded into the AcslanDumpCcb array. This is a string of numbers, the
  566. position of which corresponds to the CCB command. For each position, 1
  567. means dump the CCB and 2 means dump the CCB and its parameters. This is an
  568. additional filter control over that contained in ACSLAN_DEBUG_FLAGS which
  569. allows control on a per CCB basis. Example:
  570. ACSLAN_DUMP_CCB=1x0221
  571. means:
  572. for CCB 0 (DIR.INTERRUPT) dump the CCB only (no parameter table anyway)
  573. 1 (???) don't do anything (x==0)
  574. 2 (???) don't do anything (x==0)
  575. 3 (DIR.OPEN.ADAPTER) dump the CCB and parameter table
  576. 4 (DIR.CLOSE.ADAPTER) dump the CCB and parameter table
  577. (no parameter table, doesn't matter)
  578. 5 (DIR.SET.MULTICAST.ADDRESS) dump the CCB
  579. etc. We currently recognize up to CCB command 0x36 (54, PURGE.RESOURCES)
  580. Arguments:
  581. None.
  582. Return Value:
  583. None.
  584. --*/
  585. {
  586. LPSTR envVar;
  587. SYSTEMTIME systemTime;
  588. if (envVar = getenv(ACSLAN_DEBUG_ENV_VAR)) {
  589. if (!_strnicmp(envVar, "0x", 2)) {
  590. envVar += 2;
  591. }
  592. for (AcslanDebugFlags = 0; isxdigit(*envVar); ++envVar) {
  593. AcslanDebugFlags = AcslanDebugFlags * 16 + HEX_TO_NUM(*envVar);
  594. // + (*envVar
  595. // - ('0' + ((*envVar <= '9') ? 0
  596. // : ((islower(*envVar) ? 'a' : 'A') - ('9' + 1)))));
  597. }
  598. }
  599. if (envVar = getenv(ACSLAN_DUMP_FILE_VAR)) {
  600. char* comma;
  601. static char openMode[3] = "w";
  602. if (comma = strchr(envVar, ',')) {
  603. strcpy(openMode, comma+1);
  604. *comma = 0;
  605. }
  606. if ((hDumpFile = fopen(envVar, openMode)) == NULL) {
  607. DbgPrint("Error: can't create dump file %s\n", envVar);
  608. } else {
  609. AcslanDebugFlags |= DEBUG_TO_FILE;
  610. AcslanDebugFlags &= ~DEBUG_TO_TERMINAL;
  611. }
  612. }
  613. #if DBGDBG
  614. IF_DEBUG(DLL_INFO) {
  615. PUT(("GetAcslanDebugFlags: AcslanDebugFlags = %#x\n", AcslanDebugFlags));
  616. }
  617. #endif
  618. if (envVar = getenv(ACSLAN_DUMP_FILTER_VAR)) {
  619. int i, len;
  620. BYTE ch;
  621. if (strlen(envVar) > sizeof(AcslanDumpCcb) - 1) {
  622. //
  623. // if there's too much info then inform the debugger but set up the
  624. // string anyway
  625. //
  626. PUT(("GetAcslanDebugFlags: Error: ACSLAN_DUMP_CCB variable too long: \"%s\"\n", envVar));
  627. strncpy(AcslanDumpCcb, envVar, sizeof(AcslanDumpCcb) - 1);
  628. AcslanDumpCcb[sizeof(AcslanDumpCcb) - 1] = 0;
  629. } else {
  630. strcpy(AcslanDumpCcb, envVar);
  631. }
  632. #if DBGDBG
  633. IF_DEBUG(DLL_INFO) {
  634. PUT(("GetAcslanDebugFlags: AcslanDumpCcb = %s\n", AcslanDumpCcb));
  635. }
  636. #endif
  637. //
  638. // if there are less characters in the string than CCB commands then
  639. // default the rest of the commands
  640. //
  641. len = strlen(AcslanDumpCcb);
  642. for (i = len; i < sizeof(AcslanDumpCcb); ++i) {
  643. AcslanDumpCcb[i] = 0xff;
  644. }
  645. AcslanDumpCcb[i] = 0;
  646. //
  647. // convert the ASCII characters to numbers
  648. //
  649. for (i = 0; i < len; ++i) {
  650. ch = AcslanDumpCcb[i];
  651. if (isxdigit(ch)) {
  652. ch = HEX_TO_NUM(ch);
  653. } else {
  654. ch = (BYTE)0xff;
  655. }
  656. AcslanDumpCcb[i] = ch;
  657. #if DBGDBG
  658. PUT(("Command %d: filter=%02x\n", i, ch));
  659. #endif
  660. }
  661. HaveCcbFilter = TRUE;
  662. }
  663. IF_DEBUG(DLL_INFO) {
  664. GetSystemTime(&systemTime);
  665. PUT(("PROCESS STARTED @ %02d:%02d:%02d\n",
  666. systemTime.wHour, systemTime.wMinute, systemTime.wSecond
  667. ));
  668. }
  669. }
  670. VOID
  671. SetAcslanDebugFlags(
  672. IN DWORD Flags
  673. )
  674. {
  675. AcslanDebugFlags = Flags;
  676. }
  677. VOID
  678. AcslanDebugPrint(
  679. IN LPSTR Format,
  680. IN ...
  681. )
  682. /*++
  683. Routine Description:
  684. Print the debug information to the terminal or debug terminal, depending
  685. on DEBUG_TO_TERMINAL flag (0x80000000)
  686. Arguments:
  687. Format - printf/DbgPrint style format string (ANSI)
  688. ... - optional parameters
  689. Return Value:
  690. None.
  691. --*/
  692. {
  693. char printBuffer[1024];
  694. va_list list;
  695. va_start(list, Format);
  696. vsprintf(printBuffer, Format, list);
  697. IF_DEBUG(TO_FILE) {
  698. fputs(printBuffer, hDumpFile);
  699. } else IF_DEBUG(TO_TERMINAL) {
  700. printf(printBuffer);
  701. } else {
  702. DbgPrint(printBuffer);
  703. }
  704. }
  705. VOID
  706. AcslanDebugPrintString(
  707. IN LPSTR String
  708. )
  709. /*++
  710. Routine Description:
  711. Print the debug information to the terminal or debug terminal, depending
  712. on DEBUG_TO_TERMINAL flag (0x80000000)
  713. Arguments:
  714. String - formatted string (ANSI)
  715. Return Value:
  716. None.
  717. --*/
  718. {
  719. IF_DEBUG(TO_FILE) {
  720. fputs(String, hDumpFile);
  721. } else IF_DEBUG(TO_TERMINAL) {
  722. printf(String);
  723. } else {
  724. DbgPrint(String);
  725. }
  726. }
  727. VOID
  728. DumpCcb(
  729. IN PLLC_CCB Ccb,
  730. IN BOOL DumpAll,
  731. IN BOOL CcbIsInput
  732. )
  733. /*++
  734. Routine Description:
  735. Dumps a CCB and any associated parameter table. Also displays the symbolic
  736. CCB command and an error code description if the CCB is being returned to
  737. the caller. Dumps NT format CCBs (flat 32-bit pointers)
  738. Arguments:
  739. Ccb - flat 32-bit pointer to CCB2 to dump
  740. DumpAll - if TRUE, dumps parameter tables and buffers, else just CCB
  741. CcbIsInput - if TRUE, CCB is from user: don't display error code explanation
  742. Return Value:
  743. None.
  744. --*/
  745. {
  746. LPSTR cmdname = "UNKNOWN CCB!";
  747. BOOL haveParms = FALSE;
  748. VOID (*DumpParms)(PVOID) = DefaultParameterTableDump;
  749. PVOID parameterTable = NULL;
  750. BOOL parmsInCcb = FALSE;
  751. BYTE command;
  752. DWORD numberOfTicks;
  753. BOOL ccbIsBad = FALSE;
  754. BOOL dumpInputParms = TRUE;
  755. BOOL dumpOutputParms = TRUE;
  756. static DWORD LastTicks;
  757. static BOOL FirstTimeFunctionCalled = TRUE;
  758. try {
  759. command = Ccb->uchDlcCommand;
  760. } except(1) {
  761. ccbIsBad = TRUE;
  762. }
  763. //
  764. // bomb out if we get a bad CCB address
  765. //
  766. if (ccbIsBad) {
  767. PUT(("*** Error: Bad Address for CCB @ %08x ***\n", Ccb));
  768. return;
  769. }
  770. #if DBGDBG
  771. PUT(("DumpCcb(%x, %d, %d)\n", Ccb, DumpAll, CcbIsInput));
  772. #endif
  773. IF_DEBUG(DUMP_TIME) {
  774. DWORD ticksNow = GetTickCount();
  775. if (FirstTimeFunctionCalled) {
  776. numberOfTicks = 0;
  777. FirstTimeFunctionCalled = FALSE;
  778. } else {
  779. numberOfTicks = ticksNow - LastTicks;
  780. }
  781. LastTicks = ticksNow;
  782. }
  783. switch (command) {
  784. case LLC_BUFFER_CREATE:
  785. cmdname = "BUFFER.CREATE";
  786. haveParms = TRUE;
  787. DumpParms = DumpBufferCreateParms;
  788. break;
  789. case LLC_BUFFER_FREE:
  790. cmdname = "BUFFER.FREE";
  791. haveParms = TRUE;
  792. DumpParms = DumpBufferFreeParms;
  793. break;
  794. case LLC_BUFFER_GET:
  795. cmdname = "BUFFER.GET";
  796. haveParms = TRUE;
  797. DumpParms = DumpBufferGetParms;
  798. break;
  799. case LLC_DIR_CLOSE_ADAPTER:
  800. cmdname = "DIR.CLOSE.ADAPTER";
  801. haveParms = FALSE;
  802. break;
  803. case LLC_DIR_CLOSE_DIRECT:
  804. cmdname = "DIR.CLOSE.DIRECT";
  805. haveParms = FALSE;
  806. break;
  807. case LLC_DIR_INITIALIZE:
  808. cmdname = "DIR.INITIALIZE";
  809. haveParms = TRUE;
  810. DumpParms = DumpDirInitializeParms;
  811. break;
  812. case LLC_DIR_INTERRUPT:
  813. cmdname = "DIR.INTERRUPT";
  814. haveParms = FALSE;
  815. break;
  816. case LLC_DIR_OPEN_ADAPTER:
  817. cmdname = "DIR.OPEN.ADAPTER";
  818. haveParms = TRUE;
  819. DumpParms = DumpDirOpenAdapterParms;
  820. break;
  821. case LLC_DIR_OPEN_DIRECT:
  822. cmdname = "DIR.OPEN.DIRECT";
  823. haveParms = TRUE;
  824. DumpParms = DumpDirOpenDirectParms;
  825. break;
  826. case LLC_DIR_READ_LOG:
  827. cmdname = "DIR.READ.LOG";
  828. haveParms = TRUE;
  829. DumpParms = DumpDirReadLogParms;
  830. break;
  831. case LLC_DIR_SET_EXCEPTION_FLAGS:
  832. cmdname = "DIR.SET.EXCEPTION.FLAGS";
  833. haveParms = TRUE;
  834. DumpParms = DumpDirSetExceptionFlagsParms;
  835. break;
  836. case LLC_DIR_SET_FUNCTIONAL_ADDRESS:
  837. cmdname = "DIR.SET.FUNCTIONAL.ADDRESS";
  838. haveParms = TRUE;
  839. DumpParms = DumpDirSetFunctionalAddressParms;
  840. parmsInCcb = TRUE;
  841. break;
  842. case LLC_DIR_SET_GROUP_ADDRESS:
  843. cmdname = "DIR.SET.GROUP.ADDRESS";
  844. haveParms = TRUE;
  845. DumpParms = DumpDirSetGroupAddressParms;
  846. parmsInCcb = TRUE;
  847. break;
  848. case LLC_DIR_STATUS:
  849. cmdname = "DIR.STATUS";
  850. haveParms = TRUE;
  851. DumpParms = DumpDirStatusParms;
  852. break;
  853. case LLC_DIR_TIMER_CANCEL:
  854. cmdname = "DIR.TIMER.CANCEL";
  855. haveParms = TRUE;
  856. DumpParms = DumpDirTimerCancelParms;
  857. parmsInCcb = TRUE;
  858. break;
  859. case LLC_DIR_TIMER_CANCEL_GROUP:
  860. cmdname = "DIR.TIMER.CANCEL.GROUP";
  861. haveParms = TRUE;
  862. DumpParms = DumpDirTimerCancelGroupParms;
  863. parmsInCcb = TRUE;
  864. break;
  865. case LLC_DIR_TIMER_SET:
  866. cmdname = "DIR.TIMER.SET";
  867. haveParms = TRUE;
  868. DumpParms = DumpDirTimerSetParms;
  869. parmsInCcb = TRUE;
  870. break;
  871. case LLC_DLC_CLOSE_SAP:
  872. cmdname = "DLC.CLOSE.SAP";
  873. haveParms = TRUE;
  874. DumpParms = DumpDlcCloseSapParms;
  875. parmsInCcb = TRUE;
  876. break;
  877. case LLC_DLC_CLOSE_STATION:
  878. cmdname = "DLC.CLOSE.STATION";
  879. haveParms = TRUE;
  880. DumpParms = DumpDlcCloseStationParms;
  881. parmsInCcb = TRUE;
  882. break;
  883. case LLC_DLC_CONNECT_STATION:
  884. cmdname = "DLC.CONNECT.STATION";
  885. haveParms = TRUE;
  886. DumpParms = DumpDlcConnectStationParms;
  887. break;
  888. case LLC_DLC_FLOW_CONTROL:
  889. cmdname = "DLC.FLOW.CONTROL";
  890. haveParms = TRUE;
  891. DumpParms = DumpDlcFlowControlParms;
  892. parmsInCcb = TRUE;
  893. break;
  894. case LLC_DLC_MODIFY:
  895. cmdname = "DLC.MODIFY";
  896. haveParms = TRUE;
  897. DumpParms = DumpDlcModifyParms;
  898. break;
  899. case LLC_DLC_OPEN_SAP:
  900. cmdname = "DLC.OPEN.SAP";
  901. haveParms = TRUE;
  902. DumpParms = DumpDlcOpenSapParms;
  903. break;
  904. case LLC_DLC_OPEN_STATION:
  905. cmdname = "DLC.OPEN.STATION";
  906. haveParms = TRUE;
  907. DumpParms = DumpDlcOpenStationParms;
  908. break;
  909. case LLC_DLC_REALLOCATE_STATIONS:
  910. cmdname = "DLC.REALLOCATE";
  911. haveParms = TRUE;
  912. DumpParms = DumpDlcReallocateParms;
  913. break;
  914. case LLC_DLC_RESET:
  915. cmdname = "DLC.RESET";
  916. break;
  917. case LLC_DLC_SET_THRESHOLD:
  918. cmdname = "DLC.SET.THRESHOLD";
  919. haveParms = TRUE;
  920. break;
  921. case LLC_DLC_STATISTICS:
  922. cmdname = "DLC.STATISTICS";
  923. haveParms = TRUE;
  924. DumpParms = DumpDlcStatisticsParms;
  925. break;
  926. case 0x25:
  927. //
  928. // not supported !
  929. //
  930. cmdname = "PDT.TRACE.OFF";
  931. break;
  932. case 0x24:
  933. //
  934. // not supported !
  935. //
  936. cmdname = "PDT.TRACE.ON";
  937. break;
  938. case LLC_READ:
  939. cmdname = "READ";
  940. haveParms = !CcbIsInput;
  941. DumpParms = DumpReadParms;
  942. dumpInputParms = FALSE;
  943. dumpOutputParms = !CcbIsInput && Ccb->uchDlcStatus == LLC_STATUS_SUCCESS;
  944. break;
  945. case LLC_READ_CANCEL:
  946. cmdname = "READ.CANCEL";
  947. break;
  948. case LLC_RECEIVE:
  949. cmdname = "RECEIVE";
  950. haveParms = TRUE;
  951. DumpParms = DumpReceiveParms;
  952. break;
  953. case LLC_RECEIVE_CANCEL:
  954. cmdname = "RECEIVE.CANCEL";
  955. haveParms = TRUE;
  956. DumpParms = DumpReceiveCancelParms;
  957. parmsInCcb = TRUE;
  958. break;
  959. case LLC_RECEIVE_MODIFY:
  960. cmdname = "RECEIVE.MODIFY";
  961. haveParms = TRUE;
  962. break;
  963. case LLC_TRANSMIT_FRAMES:
  964. cmdname = "TRANSMIT.FRAMES";
  965. haveParms = TRUE;
  966. DumpParms = DumpTransmitFramesParms;
  967. dumpOutputParms = FALSE;
  968. break;
  969. case LLC_TRANSMIT_DIR_FRAME:
  970. cmdname = "TRANSMIT.DIR.FRAME";
  971. haveParms = TRUE;
  972. DumpParms = DumpTransmitDirFrameParms;
  973. dumpOutputParms = FALSE;
  974. break;
  975. case LLC_TRANSMIT_I_FRAME:
  976. cmdname = "TRANSMIT.I.FRAME";
  977. haveParms = TRUE;
  978. DumpParms = DumpTransmitIFrameParms;
  979. dumpOutputParms = FALSE;
  980. break;
  981. case LLC_TRANSMIT_TEST_CMD:
  982. cmdname = "TRANSMIT.TEST.CMD";
  983. haveParms = TRUE;
  984. DumpParms = DumpTransmitTestCmdParms;
  985. dumpOutputParms = FALSE;
  986. break;
  987. case LLC_TRANSMIT_UI_FRAME:
  988. cmdname = "TRANSMIT.UI.FRAME";
  989. haveParms = TRUE;
  990. DumpParms = DumpTransmitUiFrameParms;
  991. break;
  992. case LLC_TRANSMIT_XID_CMD:
  993. cmdname = "TRANSMIT.XID.CMD";
  994. haveParms = TRUE;
  995. DumpParms = DumpTransmitXidCmdParms;
  996. dumpOutputParms = FALSE;
  997. break;
  998. case LLC_TRANSMIT_XID_RESP_FINAL:
  999. cmdname = "TRANSMIT.XID.RESP.FINAL";
  1000. haveParms = TRUE;
  1001. DumpParms = DumpTransmitXidRespFinalParms;
  1002. dumpOutputParms = FALSE;
  1003. break;
  1004. case LLC_TRANSMIT_XID_RESP_NOT_FINAL:
  1005. cmdname = "TRANSMIT.XID.RESP.NOT.FINAL";
  1006. haveParms = TRUE;
  1007. DumpParms = DumpTransmitXidRespNotFinalParms;
  1008. dumpOutputParms = FALSE;
  1009. break;
  1010. }
  1011. if (HaveCcbFilter) {
  1012. BYTE filter = AcslanDumpCcb[command];
  1013. #if DBGDBG
  1014. PUT(("filter = %02x\n", filter));
  1015. #endif
  1016. if (filter == 0xff) {
  1017. //
  1018. // do nothing - 0xff means use default in ACSLAN_DEBUG_FLAGS
  1019. //
  1020. } else {
  1021. if (CcbIsInput) {
  1022. if (!(filter & CF_DUMP_CCB_IN)) {
  1023. //
  1024. // not interested in this input CCB
  1025. //
  1026. return;
  1027. }
  1028. DumpAll = filter & CF_DUMP_PARMS_IN;
  1029. } else {
  1030. if (!(filter & CF_DUMP_CCB_OUT)) {
  1031. //
  1032. // not interested in this output CCB
  1033. //
  1034. return;
  1035. }
  1036. DumpAll = filter & CF_DUMP_PARMS_OUT;
  1037. }
  1038. }
  1039. }
  1040. PUT(("\n==============================================================================\n"));
  1041. IF_DEBUG(DUMP_TIME) {
  1042. PUT(("%sPUT CCB @ 0x%08x +%d mSec\n",
  1043. CcbIsInput ? "IN" : "OUT",
  1044. Ccb,
  1045. numberOfTicks
  1046. ));
  1047. } else {
  1048. PUT(("%sPUT CCB @ 0x%08x\n",
  1049. CcbIsInput ? "IN" : "OUT",
  1050. Ccb
  1051. ));
  1052. }
  1053. PUT(("Adapter . . . . %02x\n"
  1054. "Command . . . . %02x [%s]\n"
  1055. "Status. . . . . %02x [%s]\n"
  1056. "Reserved. . . . %02x\n"
  1057. "Next. . . . . . %08x\n"
  1058. "CompletionFlag. %08x\n",
  1059. Ccb->uchAdapterNumber,
  1060. Ccb->uchDlcCommand,
  1061. cmdname,
  1062. Ccb->uchDlcStatus,
  1063. CcbIsInput ? "" : MapCcbRetcode(Ccb->uchDlcStatus),
  1064. Ccb->uchReserved1,
  1065. Ccb->pNext,
  1066. Ccb->ulCompletionFlag
  1067. ));
  1068. if (haveParms) {
  1069. if (parmsInCcb) {
  1070. DumpParms(Ccb->u.pParameterTable);
  1071. } else {
  1072. parameterTable = Ccb->u.pParameterTable;
  1073. PUT(("Parameters. . . %08x\n", parameterTable));
  1074. }
  1075. } else {
  1076. PUT(("Parameters. . . %08x\n", Ccb->u.pParameterTable));
  1077. }
  1078. PUT(("CompletionEvent %08x\n"
  1079. "Reserved. . . . %02x\n"
  1080. "ReadFlag. . . . %02x\n"
  1081. "Reserved. . . . %04x\n",
  1082. Ccb->hCompletionEvent,
  1083. Ccb->uchReserved2,
  1084. Ccb->uchReadFlag,
  1085. Ccb->usReserved3
  1086. ));
  1087. if (parameterTable && DumpAll) {
  1088. if ((CcbIsInput && dumpInputParms) || (!CcbIsInput && dumpOutputParms)) {
  1089. DumpParms(parameterTable);
  1090. }
  1091. }
  1092. }
  1093. LPSTR
  1094. MapCcbRetcode(
  1095. IN BYTE Retcode
  1096. )
  1097. /*++
  1098. Routine Description:
  1099. Returns string describing error code
  1100. Arguments:
  1101. Retcode - CCB_RETCODE
  1102. Return Value:
  1103. LPSTR
  1104. --*/
  1105. {
  1106. static char errbuf[128];
  1107. if (Retcode == LLC_STATUS_PENDING) {
  1108. return "Command in progress";
  1109. } else if (Retcode > NUMBER_OF_ERROR_MESSAGES) {
  1110. sprintf(errbuf, "*** Invalid error code 0x%2x ***", Retcode);
  1111. return errbuf;
  1112. }
  1113. return CcbRetcodeExplanations[Retcode];
  1114. }
  1115. VOID
  1116. DumpData(
  1117. IN LPSTR Title,
  1118. IN PBYTE Address,
  1119. IN DWORD Length,
  1120. IN DWORD Options,
  1121. IN DWORD Indent
  1122. )
  1123. {
  1124. char dumpBuf[80];
  1125. char* bufptr;
  1126. int i, n, iterations;
  1127. char* hexptr;
  1128. //
  1129. // the usual dump style: 16 columns of hex bytes, followed by 16 columns
  1130. // of corresponding ASCII characters, or '.' where the character is < 0x20
  1131. // (space) or > 0x7f (del?)
  1132. //
  1133. if (Options & DD_LINE_BEFORE) {
  1134. AcslanDebugPrintString("\n");
  1135. }
  1136. try {
  1137. iterations = 0;
  1138. while (Length) {
  1139. bufptr = dumpBuf;
  1140. if (Title && !iterations) {
  1141. strcpy(bufptr, Title);
  1142. bufptr = strchr(bufptr, 0);
  1143. }
  1144. if (Indent && ((Options & DD_INDENT_ALL) || iterations)) {
  1145. int indentLen = (!iterations && Title)
  1146. ? ((INT)(Indent - strlen(Title)) < 0)
  1147. ? 1
  1148. : Indent - strlen(Title)
  1149. : Indent;
  1150. memset(bufptr, ' ', indentLen);
  1151. bufptr += indentLen;
  1152. }
  1153. if (!(Options & DD_NO_ADDRESS)) {
  1154. bufptr += sprintf(bufptr, "%p: ", Address);
  1155. }
  1156. n = (Length < 16) ? Length : 16;
  1157. hexptr = bufptr;
  1158. for (i = 0; i < n; ++i) {
  1159. bufptr += sprintf(bufptr, "%02x", Address[i]);
  1160. *bufptr++ = (i == 7) ? '-' : ' ';
  1161. }
  1162. if (Options & DD_UPPER_CASE) {
  1163. _strupr(hexptr);
  1164. }
  1165. if (!(Options & DD_NO_ASCII)) {
  1166. if (n < 16) {
  1167. for (i = 0; i < 16-n; ++i) {
  1168. bufptr += sprintf(bufptr, Options & DD_DOT_DOT_SPACE ? ".. " : " ");
  1169. }
  1170. }
  1171. bufptr += sprintf(bufptr, " ");
  1172. for (i = 0; i < n; ++i) {
  1173. *bufptr++ = (Address[i] < 0x20 || Address[i] > 0x7f) ? '.' : Address[i];
  1174. }
  1175. }
  1176. *bufptr++ = '\n';
  1177. *bufptr = 0;
  1178. AcslanDebugPrintString(dumpBuf);
  1179. Length -= n;
  1180. Address += n;
  1181. ++iterations;
  1182. }
  1183. if (Options & DD_LINE_AFTER) {
  1184. AcslanDebugPrintString("\n");
  1185. }
  1186. } except(1) {
  1187. PUT(("*** Error: Bad Data @ %x, length %d ***\n", Address, Length));
  1188. }
  1189. }
  1190. PRIVATE
  1191. VOID
  1192. DefaultParameterTableDump(
  1193. IN PVOID Parameters
  1194. )
  1195. /*++
  1196. Routine Description:
  1197. Displays default message for CCBs which have parameter tables that don't
  1198. have a dump routine yet
  1199. Arguments:
  1200. Parameters - pointer to parameter table
  1201. Return Value:
  1202. None.
  1203. --*/
  1204. {
  1205. PUT(("Parameter table dump not implemented for this CCB\n"));
  1206. }
  1207. PRIVATE
  1208. VOID
  1209. DumpParameterTableHeader(
  1210. IN LPSTR CommandName,
  1211. IN PVOID Table
  1212. )
  1213. /*++
  1214. Routine Description:
  1215. Displays header for parameter table dump
  1216. Arguments:
  1217. CommandName - name of command which owns parameter table
  1218. Table - flat 32-bit address of parameter table
  1219. Return Value:
  1220. None.
  1221. --*/
  1222. {
  1223. PUT(("\n%s parameter table @ 0x%08x\n", CommandName, Table));
  1224. }
  1225. PRIVATE
  1226. VOID
  1227. DumpBufferCreateParms(
  1228. IN PVOID Parameters
  1229. )
  1230. {
  1231. PLLC_BUFFER_CREATE_PARMS parms = (PLLC_BUFFER_CREATE_PARMS)Parameters;
  1232. DumpParameterTableHeader("BUFFER.CREATE", Parameters);
  1233. PUT(("Buf Pool Handle %08x\n"
  1234. "Buf Pool Addr . %08x\n"
  1235. "Buffer Size . . %08x\n"
  1236. "Minimum Size. . %08x\n",
  1237. parms->hBufferPool,
  1238. parms->pBuffer,
  1239. parms->cbBufferSize,
  1240. parms->cbMinimumSizeThreshold
  1241. ));
  1242. }
  1243. PRIVATE
  1244. VOID
  1245. DumpBufferFreeParms(
  1246. IN PVOID Parameters
  1247. )
  1248. {
  1249. PLLC_BUFFER_FREE_PARMS parms = (PLLC_BUFFER_FREE_PARMS)Parameters;
  1250. DumpParameterTableHeader("BUFFER.FREE", Parameters);
  1251. PUT(("reserved. . . . %04x\n"
  1252. "buffers left. . %04x\n"
  1253. "reserved. . . . %02x %02x %02x %02x\n"
  1254. "first buffer. . %08x\n",
  1255. parms->usReserved1,
  1256. parms->cBuffersLeft,
  1257. ((PBYTE)&(parms->ulReserved))[0],
  1258. ((PBYTE)&(parms->ulReserved))[1],
  1259. ((PBYTE)&(parms->ulReserved))[2],
  1260. ((PBYTE)&(parms->ulReserved))[3],
  1261. parms->pFirstBuffer
  1262. ));
  1263. }
  1264. PRIVATE
  1265. VOID
  1266. DumpBufferGetParms(
  1267. IN PVOID Parameters
  1268. )
  1269. {
  1270. PLLC_BUFFER_GET_PARMS parms = (PLLC_BUFFER_GET_PARMS)Parameters;
  1271. DumpParameterTableHeader("BUFFER.GET", Parameters);
  1272. PUT(("reserved. . . . %04x\n"
  1273. "buffers left. . %04x\n"
  1274. "buffers to get. %04x\n"
  1275. "buffer size . . %04x\n"
  1276. "first buffer. . %08x\n",
  1277. parms->usReserved1,
  1278. parms->cBuffersLeft,
  1279. parms->cBuffersToGet,
  1280. parms->cbBufferSize,
  1281. parms->pFirstBuffer
  1282. ));
  1283. }
  1284. PRIVATE
  1285. VOID
  1286. DumpDirInitializeParms(
  1287. IN PVOID Parameters
  1288. )
  1289. {
  1290. PLLC_DIR_INITIALIZE_PARMS parms = (PLLC_DIR_INITIALIZE_PARMS)Parameters;
  1291. DumpParameterTableHeader("DIR.INITIALIZE", Parameters);
  1292. PUT(("Bring Ups . . . %04x\n"
  1293. "Reserved. . . . %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n"
  1294. " %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n"
  1295. " %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
  1296. parms->usBringUps,
  1297. parms->Reserved[ 0],
  1298. parms->Reserved[ 1],
  1299. parms->Reserved[ 2],
  1300. parms->Reserved[ 3],
  1301. parms->Reserved[ 4],
  1302. parms->Reserved[ 5],
  1303. parms->Reserved[ 6],
  1304. parms->Reserved[ 7],
  1305. parms->Reserved[ 8],
  1306. parms->Reserved[ 9],
  1307. parms->Reserved[10],
  1308. parms->Reserved[11],
  1309. parms->Reserved[12],
  1310. parms->Reserved[13],
  1311. parms->Reserved[14],
  1312. parms->Reserved[15],
  1313. parms->Reserved[16],
  1314. parms->Reserved[17],
  1315. parms->Reserved[18],
  1316. parms->Reserved[19],
  1317. parms->Reserved[20],
  1318. parms->Reserved[21],
  1319. parms->Reserved[22],
  1320. parms->Reserved[23],
  1321. parms->Reserved[24],
  1322. parms->Reserved[25],
  1323. parms->Reserved[26],
  1324. parms->Reserved[27],
  1325. parms->Reserved[28],
  1326. parms->Reserved[29]
  1327. ));
  1328. }
  1329. PRIVATE
  1330. VOID
  1331. DumpDirOpenAdapterParms(
  1332. IN PVOID Parameters
  1333. )
  1334. {
  1335. PLLC_DIR_OPEN_ADAPTER_PARMS parms = (PLLC_DIR_OPEN_ADAPTER_PARMS)Parameters;
  1336. PLLC_ADAPTER_OPEN_PARMS pAdapterParms = parms->pAdapterParms;
  1337. PLLC_EXTENDED_ADAPTER_PARMS pExtendedParms = parms->pExtendedParms;
  1338. PLLC_DLC_PARMS pDlcParms = parms->pDlcParms;
  1339. DumpParameterTableHeader("DIR.OPEN.ADAPTER", Parameters);
  1340. PUT(("adapter parms . %08x\n"
  1341. "extended parms. %08x\n"
  1342. "DLC parms . . . %08x\n"
  1343. "reserved. . . . %08x\n",
  1344. pAdapterParms,
  1345. pExtendedParms,
  1346. pDlcParms,
  1347. parms->pReserved1
  1348. ));
  1349. if (pAdapterParms) {
  1350. PUT(("\n"
  1351. "Adapter Parms @ %08x\n"
  1352. "open error. . . %04x\n"
  1353. "open options. . %04x\n"
  1354. "node address. . %02x-%02x-%02x-%02x-%02x-%02x\n"
  1355. "group address . %08x\n"
  1356. "func. address . %08x\n"
  1357. "Reserved 1. . . %04x\n"
  1358. "Reserved 2. . . %04x\n"
  1359. "max frame size %04x\n"
  1360. "Reserved 3. . . %04x %04x %04x %04x\n"
  1361. "bring ups . . . %04x\n"
  1362. "init warnings . %04x\n"
  1363. "Reserved 4. . . %04x %04x %04x\n",
  1364. pAdapterParms,
  1365. pAdapterParms->usOpenErrorCode,
  1366. pAdapterParms->usOpenOptions,
  1367. pAdapterParms->auchNodeAddress[0],
  1368. pAdapterParms->auchNodeAddress[1],
  1369. pAdapterParms->auchNodeAddress[2],
  1370. pAdapterParms->auchNodeAddress[3],
  1371. pAdapterParms->auchNodeAddress[4],
  1372. pAdapterParms->auchNodeAddress[5],
  1373. *(DWORD UNALIGNED *)(&pAdapterParms->auchGroupAddress),
  1374. *(DWORD UNALIGNED *)(&pAdapterParms->auchFunctionalAddress),
  1375. pAdapterParms->usReserved1,
  1376. pAdapterParms->usReserved2,
  1377. pAdapterParms->usMaxFrameSize,
  1378. pAdapterParms->usReserved3[0],
  1379. pAdapterParms->usReserved3[1],
  1380. pAdapterParms->usReserved3[2],
  1381. pAdapterParms->usReserved3[3],
  1382. pAdapterParms->usBringUps, // blooargh
  1383. pAdapterParms->InitWarnings,
  1384. pAdapterParms->usReserved4[0],
  1385. pAdapterParms->usReserved4[1],
  1386. pAdapterParms->usReserved4[2]
  1387. ));
  1388. }
  1389. if (pExtendedParms) {
  1390. PUT(("\n"
  1391. "Extended Parms @ %08x\n"
  1392. "hBufferPool . . %08x\n"
  1393. "pSecurityDesc . %08x\n"
  1394. "EthernetType. . %08x [%s]\n",
  1395. pExtendedParms,
  1396. pExtendedParms->hBufferPool,
  1397. pExtendedParms->pSecurityDescriptor,
  1398. pExtendedParms->LlcEthernetType,
  1399. MapEthernetType(pExtendedParms->LlcEthernetType)
  1400. ));
  1401. }
  1402. if (pDlcParms) {
  1403. PUT(("\n"
  1404. "DLC Parms @ %08x\n"
  1405. "max SAPs. . . . %02x\n"
  1406. "max links . . . %02x\n"
  1407. "max group SAPs. %02x\n"
  1408. "max group membs %02x\n"
  1409. "T1 Tick 1 . . . %02x\n"
  1410. "T2 Tick 1 . . . %02x\n"
  1411. "Ti Tick 1 . . . %02x\n"
  1412. "T1 Tick 2 . . . %02x\n"
  1413. "T2 Tick 2 . . . %02x\n"
  1414. "Ti Tick 2 . . . %02x\n",
  1415. pDlcParms,
  1416. pDlcParms->uchDlcMaxSaps,
  1417. pDlcParms->uchDlcMaxStations,
  1418. pDlcParms->uchDlcMaxGroupSaps,
  1419. pDlcParms->uchDlcMaxGroupMembers,
  1420. pDlcParms->uchT1_TickOne,
  1421. pDlcParms->uchT2_TickOne,
  1422. pDlcParms->uchTi_TickOne,
  1423. pDlcParms->uchT1_TickTwo,
  1424. pDlcParms->uchT2_TickTwo,
  1425. pDlcParms->uchTi_TickTwo
  1426. ));
  1427. }
  1428. }
  1429. PRIVATE
  1430. LPSTR
  1431. MapEthernetType(
  1432. IN LLC_ETHERNET_TYPE EthernetType
  1433. )
  1434. {
  1435. switch (EthernetType) {
  1436. case LLC_ETHERNET_TYPE_DEFAULT:
  1437. return "DEFAULT";
  1438. case LLC_ETHERNET_TYPE_AUTO:
  1439. return "AUTO";
  1440. case LLC_ETHERNET_TYPE_802_3:
  1441. return "802.3";
  1442. case LLC_ETHERNET_TYPE_DIX:
  1443. return "DIX";
  1444. }
  1445. return "*** Unknown Ethernet Type ***";
  1446. }
  1447. PRIVATE
  1448. VOID
  1449. DumpDirOpenDirectParms(
  1450. IN PVOID Parameters
  1451. )
  1452. {
  1453. PLLC_DIR_OPEN_DIRECT_PARMS parms = (PLLC_DIR_OPEN_DIRECT_PARMS)Parameters;
  1454. DumpParameterTableHeader("DIR.OPEN.DIRECT", Parameters);
  1455. PUT(("reserved. . . . %04x %04x %04x %04x\n"
  1456. "open options. . %04x\n"
  1457. "ethernet type . %04x\n"
  1458. "protocol mask . %08x\n"
  1459. "protocol match. %08x\n"
  1460. "protocol offset %04x\n",
  1461. parms->Reserved[0],
  1462. parms->Reserved[1],
  1463. parms->Reserved[2],
  1464. parms->Reserved[3],
  1465. parms->usOpenOptions,
  1466. parms->usEthernetType,
  1467. parms->ulProtocolTypeMask,
  1468. parms->ulProtocolTypeMatch,
  1469. parms->usProtocolTypeOffset
  1470. ));
  1471. }
  1472. PRIVATE
  1473. VOID
  1474. DumpDirReadLogParms(
  1475. IN PVOID Parameters
  1476. )
  1477. {
  1478. PLLC_DIR_READ_LOG_PARMS parms = (PLLC_DIR_READ_LOG_PARMS)Parameters;
  1479. DumpParameterTableHeader("DIR.READ.LOG", Parameters);
  1480. PUT(("type id . . . . %04x [%s]\n"
  1481. "log buf len . . %04x\n"
  1482. "log buf ptr . . %08x\n"
  1483. "act. log. len.. %04x\n",
  1484. parms->usTypeId,
  1485. MapLogType(parms->usTypeId),
  1486. parms->cbLogBuffer,
  1487. parms->pLogBuffer,
  1488. parms->cbActualLength
  1489. ));
  1490. }
  1491. PRIVATE
  1492. LPSTR
  1493. MapLogType(
  1494. IN USHORT Type
  1495. )
  1496. {
  1497. switch (Type) {
  1498. case 0:
  1499. return "Adapter Error Log";
  1500. case 1:
  1501. return "Direct Interface Error Log";
  1502. case 2:
  1503. return "Adapter & Direct Interface Error Logs";
  1504. }
  1505. return "*** Unknown Log Type ***";
  1506. }
  1507. PRIVATE
  1508. VOID
  1509. DumpDirSetExceptionFlagsParms(
  1510. IN PVOID Parameters
  1511. )
  1512. {
  1513. PLLC_DIR_SET_EFLAG_PARMS parms = (PLLC_DIR_SET_EFLAG_PARMS)Parameters;
  1514. DumpParameterTableHeader("DIR.SET.EXCEPTION.FLAGS", Parameters);
  1515. PUT(("Adapter Check Flag. %08x\n"
  1516. "Network Status Flag %08x\n"
  1517. "PC Error Flag . . . %08x\n"
  1518. "System Action Flag. %08x\n",
  1519. parms->ulAdapterCheckFlag,
  1520. parms->ulNetworkStatusFlag,
  1521. parms->ulPcErrorFlag,
  1522. parms->ulSystemActionFlag
  1523. ));
  1524. }
  1525. PRIVATE
  1526. VOID
  1527. DumpDirSetFunctionalAddressParms(
  1528. IN PVOID Parameters
  1529. )
  1530. {
  1531. PUT(("Functional addr %08x\n", Parameters));
  1532. }
  1533. PRIVATE
  1534. VOID
  1535. DumpDirSetGroupAddressParms(
  1536. IN PVOID Parameters
  1537. )
  1538. {
  1539. PUT(("Group addr. . . %08x\n", Parameters));
  1540. }
  1541. PRIVATE
  1542. VOID
  1543. DumpDirStatusParms(
  1544. IN PVOID Parameters
  1545. )
  1546. {
  1547. PLLC_DIR_STATUS_PARMS parms = (PLLC_DIR_STATUS_PARMS)Parameters;
  1548. DumpParameterTableHeader("DIR.STATUS", Parameters);
  1549. PUT(("perm node addr. %02x-%02x-%02x-%02x-%02x-%02x\n"
  1550. "local node addr %02x-%02x-%02x-%02x-%02x-%02x\n"
  1551. "group addr. . . %08lx\n"
  1552. "functional addr %08lx\n"
  1553. "max SAPs. . . . %02x\n"
  1554. "open SAPs . . . %02x\n"
  1555. "max stations. . %02x\n"
  1556. "open stations . %02x\n"
  1557. "avail stations. %02x\n"
  1558. "adapter config. %02x\n"
  1559. "reserved 1. . . %02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x\n"
  1560. "reserved 2. . . %08x\n"
  1561. "reserved 3. . . %08x\n"
  1562. "max frame len . %08x\n"
  1563. "last NW status. %04x\n"
  1564. "adapter type. . %04x [%s]\n",
  1565. parms->auchPermanentAddress[0],
  1566. parms->auchPermanentAddress[1],
  1567. parms->auchPermanentAddress[2],
  1568. parms->auchPermanentAddress[3],
  1569. parms->auchPermanentAddress[4],
  1570. parms->auchPermanentAddress[5],
  1571. parms->auchNodeAddress[0],
  1572. parms->auchNodeAddress[1],
  1573. parms->auchNodeAddress[2],
  1574. parms->auchNodeAddress[3],
  1575. parms->auchNodeAddress[4],
  1576. parms->auchNodeAddress[5],
  1577. *(LPDWORD)(&parms->auchGroupAddress),
  1578. *(LPDWORD)(&parms->auchFunctAddr),
  1579. parms->uchMaxSap,
  1580. parms->uchOpenSaps,
  1581. parms->uchMaxStations,
  1582. parms->uchOpenStation,
  1583. parms->uchAvailStations,
  1584. parms->uchAdapterConfig,
  1585. parms->auchReserved1[0],
  1586. parms->auchReserved1[1],
  1587. parms->auchReserved1[2],
  1588. parms->auchReserved1[3],
  1589. parms->auchReserved1[4],
  1590. parms->auchReserved1[5],
  1591. parms->auchReserved1[6],
  1592. parms->auchReserved1[7],
  1593. parms->auchReserved1[8],
  1594. parms->auchReserved1[9],
  1595. parms->ulReserved1,
  1596. parms->ulReserved2,
  1597. parms->ulMaxFrameLength,
  1598. parms->usLastNetworkStatus,
  1599. parms->usAdapterType,
  1600. MapAdapterType(parms->usAdapterType)
  1601. ));
  1602. }
  1603. PRIVATE
  1604. LPSTR
  1605. MapAdapterType(
  1606. IN USHORT AdapterType
  1607. )
  1608. {
  1609. switch (AdapterType) {
  1610. case 0x0001:
  1611. return "Token Ring Network PC Adapter";
  1612. case 0x0002:
  1613. return "Token Ring Network PC Adapter II";
  1614. case 0x0004:
  1615. return "Token Ring Network Adapter/A";
  1616. case 0x0008:
  1617. return "Token Ring Network PC Adapter II";
  1618. case 0x0020:
  1619. return "Token Ring Network 16/4 Adapter";
  1620. case 0x0040:
  1621. return "Token Ring Network 16/4 Adapter/A";
  1622. case 0x0080:
  1623. return "Token Ring Network Adapter/A";
  1624. case 0x0100:
  1625. return "Ethernet Adapter";
  1626. case 0x4000:
  1627. return "PC Network Adapter";
  1628. case 0x8000:
  1629. return "PC Network Adapter/A";
  1630. }
  1631. return "*** Unknown Adapter Type ***";
  1632. }
  1633. PRIVATE
  1634. VOID
  1635. DumpDirTimerCancelParms(
  1636. IN PVOID Parameters
  1637. )
  1638. {
  1639. PUT(("timer addr. . . %08x\n", Parameters));
  1640. }
  1641. PRIVATE
  1642. VOID
  1643. DumpDirTimerCancelGroupParms(
  1644. IN PVOID Parameters
  1645. )
  1646. {
  1647. PUT(("timer cmpl flag %08x\n", Parameters));
  1648. }
  1649. PRIVATE
  1650. VOID
  1651. DumpDirTimerSetParms(
  1652. IN PVOID Parameters
  1653. )
  1654. {
  1655. PUT(("time value. . . %04x\n", HIWORD(Parameters)));
  1656. }
  1657. PRIVATE
  1658. VOID
  1659. DumpDlcCloseSapParms(
  1660. IN PVOID Parameters
  1661. )
  1662. {
  1663. PUT(("station id %04x\n"
  1664. "reserved. . . . %02x %02x\n",
  1665. HIWORD(Parameters),
  1666. HIBYTE(LOWORD(Parameters)),
  1667. LOBYTE(LOWORD(Parameters))
  1668. ));
  1669. }
  1670. PRIVATE
  1671. VOID
  1672. DumpDlcCloseStationParms(
  1673. IN PVOID Parameters
  1674. )
  1675. {
  1676. PUT(("station id. . . %04x\n"
  1677. "reserved. . . . %02x %02x\n",
  1678. HIWORD(Parameters),
  1679. HIBYTE(LOWORD(Parameters)),
  1680. LOBYTE(LOWORD(Parameters))
  1681. ));
  1682. }
  1683. PRIVATE
  1684. VOID
  1685. DumpDlcConnectStationParms(
  1686. IN PVOID Parameters
  1687. )
  1688. {
  1689. PLLC_DLC_CONNECT_PARMS parms = (PLLC_DLC_CONNECT_PARMS)Parameters;
  1690. LPBYTE routing = parms->pRoutingInfo;
  1691. int i, n;
  1692. DumpParameterTableHeader("DLC.CONNECT.STATION", Parameters);
  1693. PUT(("station id. . . %04x\n"
  1694. "reserved. . . . %04x\n"
  1695. "routing addr. . %08x [",
  1696. parms->usStationId,
  1697. parms->usReserved,
  1698. routing
  1699. ));
  1700. if (routing) {
  1701. n = (int)(routing[0] & 0x1f);
  1702. for (i=0; i<n-1; ++i) {
  1703. PUT(("%02x ", routing[i]));
  1704. }
  1705. PUT(("%02x", routing[i]));
  1706. }
  1707. PUT(("]\n"));
  1708. if (routing) {
  1709. char broadcastIndicators = routing[0] & 0xe0;
  1710. char length = routing[0] & 0x1f;
  1711. char direction = routing[1] & 0x80;
  1712. char largestFrame = routing[1] & 0x70;
  1713. PUT(("Routing Info Description: "));
  1714. if ((broadcastIndicators & 0x80) == 0) {
  1715. PUT(("Non Broadcast "));
  1716. } else if ((broadcastIndicators & 0xc0) == 0x80) {
  1717. PUT(("All Routes Broadcast "));
  1718. } else if ((broadcastIndicators & 0xc0) == 0xc0) {
  1719. PUT(("Single Route Broadcast "));
  1720. }
  1721. PUT(("Length = %d ", length));
  1722. if (direction) {
  1723. PUT(("interpret right-to-left "));
  1724. } else {
  1725. PUT(("interpret left-to-right "));
  1726. }
  1727. switch (largestFrame) {
  1728. case 0x00:
  1729. PUT(("<= 516 bytes in I-field "));
  1730. break;
  1731. case 0x10:
  1732. PUT(("<= 1500 bytes in I-field "));
  1733. break;
  1734. case 0x20:
  1735. PUT(("<= 2052 bytes in I-field "));
  1736. break;
  1737. case 0x30:
  1738. PUT(("<= 4472 bytes in I-field "));
  1739. break;
  1740. case 0x40:
  1741. PUT(("<= 8144 bytes in I-field "));
  1742. break;
  1743. case 0x50:
  1744. PUT(("<= 11407 bytes in I-field "));
  1745. break;
  1746. case 0x60:
  1747. PUT(("<= 17800 bytes in I-field "));
  1748. break;
  1749. case 0x70:
  1750. PUT(("All-Routes Broadcast Frame "));
  1751. break;
  1752. }
  1753. PUT(("\n"));
  1754. }
  1755. }
  1756. PRIVATE
  1757. VOID
  1758. DumpDlcFlowControlParms(
  1759. IN PVOID Parameters
  1760. )
  1761. {
  1762. PUT(("station id. . . %04x\n"
  1763. "flow control. . %02x [%s]\n",
  1764. HIWORD(Parameters),
  1765. HIBYTE(LOWORD(Parameters)),
  1766. MapFlowControl(HIBYTE(LOWORD(Parameters)))
  1767. ));
  1768. }
  1769. PRIVATE
  1770. LPSTR
  1771. MapFlowControl(
  1772. IN BYTE FlowControl
  1773. )
  1774. {
  1775. if (FlowControl & 0x80) {
  1776. if (FlowControl & 0x40) {
  1777. return "RESET LOCAL BUSY - BUFFER";
  1778. } else {
  1779. return "RESET LOCAL BUSY - USER";
  1780. }
  1781. } else {
  1782. return "Enter LOCAL BUSY state";
  1783. }
  1784. }
  1785. PRIVATE
  1786. VOID
  1787. DumpDlcModifyParms(
  1788. IN PVOID Parameters
  1789. )
  1790. {
  1791. PLLC_DLC_MODIFY_PARMS parms = (PLLC_DLC_MODIFY_PARMS)Parameters;
  1792. DumpParameterTableHeader("DLC.MODIFY", Parameters);
  1793. PUT(("reserved. . . . %04x\n"
  1794. "station id. . . %04x\n"
  1795. "timer T1. . . . %02x\n"
  1796. "timer T2. . . . %02x\n"
  1797. "timer Ti. . . . %02x\n"
  1798. "maxout. . . . . %02x\n"
  1799. "maxin . . . . . %02x\n"
  1800. "maxout incr . . %02x\n"
  1801. "max retry count %02x\n"
  1802. "reserved. . . . %02x\n"
  1803. "max info field. %02x\n"
  1804. "access priority %02x\n"
  1805. "reserved. . . . %02x %02x %02x %02x\n"
  1806. "group count . . %02x\n"
  1807. "group list. . . %08x ",
  1808. parms->usRes,
  1809. parms->usStationId,
  1810. parms->uchT1,
  1811. parms->uchT2,
  1812. parms->uchTi,
  1813. parms->uchMaxOut,
  1814. parms->uchMaxIn,
  1815. parms->uchMaxOutIncr,
  1816. parms->uchMaxRetryCnt,
  1817. parms->uchReserved1,
  1818. parms->usMaxInfoFieldLength,
  1819. parms->uchAccessPriority,
  1820. parms->auchReserved3[0],
  1821. parms->auchReserved3[1],
  1822. parms->auchReserved3[2],
  1823. parms->auchReserved3[3],
  1824. parms->cGroupCount,
  1825. parms->pGroupList
  1826. ));
  1827. if (parms->pGroupList) {
  1828. DumpData(NULL,
  1829. parms->pGroupList,
  1830. parms->cGroupCount,
  1831. DD_NO_ADDRESS | DD_NO_ASCII | DD_UPPER_CASE,
  1832. DEFAULT_FIELD_WIDTH + 8 + 1
  1833. );
  1834. }
  1835. PUT(("\n"));
  1836. }
  1837. PRIVATE
  1838. VOID
  1839. DumpDlcOpenSapParms(
  1840. IN PVOID Parameters
  1841. )
  1842. {
  1843. PLLC_DLC_OPEN_SAP_PARMS parms = (PLLC_DLC_OPEN_SAP_PARMS)Parameters;
  1844. DumpParameterTableHeader("DLC.OPEN.SAP", Parameters);
  1845. PUT(("station id. . . %04x\n"
  1846. "user stat . . . %04x\n"
  1847. "T1. . . . . . . %02x\n"
  1848. "T2. . . . . . . %02x\n"
  1849. "Ti. . . . . . . %02x\n"
  1850. "max out . . . . %02x\n"
  1851. "max in . . . . %02x\n"
  1852. "max out incr. . %02x\n"
  1853. "max retry count %02x\n"
  1854. "max members . . %02x\n"
  1855. "max I field . . %04x\n"
  1856. "SAP value . . . %02x\n"
  1857. "options/pri . . %02x\n"
  1858. "link count. . . %02x\n"
  1859. "reserved. . . . %02x %02x\n"
  1860. "group count . . %02x\n"
  1861. "group list. . . %08x\n"
  1862. "status flags. . %08x\n"
  1863. "reserved. . . . %02x %02x %02x %02x %02x %02x %02x %02x\n"
  1864. "links available %02x\n",
  1865. parms->usStationId,
  1866. parms->usUserStatValue,
  1867. parms->uchT1,
  1868. parms->uchT2,
  1869. parms->uchTi,
  1870. parms->uchMaxOut,
  1871. parms->uchMaxIn,
  1872. parms->uchMaxOutIncr,
  1873. parms->uchMaxRetryCnt,
  1874. parms->uchMaxMembers,
  1875. parms->usMaxI_Field,
  1876. parms->uchSapValue,
  1877. parms->uchOptionsPriority,
  1878. parms->uchcStationCount,
  1879. parms->uchReserved2[0],
  1880. parms->uchReserved2[1],
  1881. parms->cGroupCount,
  1882. parms->pGroupList,
  1883. parms->DlcStatusFlags,
  1884. parms->uchReserved3[0],
  1885. parms->uchReserved3[1],
  1886. parms->uchReserved3[2],
  1887. parms->uchReserved3[3],
  1888. parms->uchReserved3[4],
  1889. parms->uchReserved3[5],
  1890. parms->uchReserved3[6],
  1891. parms->uchReserved3[7],
  1892. parms->cLinkStationsAvail
  1893. ));
  1894. }
  1895. PRIVATE
  1896. VOID
  1897. DumpDlcOpenStationParms(
  1898. IN PVOID Parameters
  1899. )
  1900. {
  1901. PLLC_DLC_OPEN_STATION_PARMS parms = (PLLC_DLC_OPEN_STATION_PARMS)Parameters;
  1902. LPBYTE dest = parms->pRemoteNodeAddress;
  1903. char destAddr[19];
  1904. DumpParameterTableHeader("DLC.OPEN.STATION", Parameters);
  1905. destAddr[0] = 0;
  1906. if (dest) {
  1907. sprintf(destAddr, "%02x-%02x-%02x-%02x-%02x-%02x",
  1908. dest[0],
  1909. dest[1],
  1910. dest[2],
  1911. dest[3],
  1912. dest[4],
  1913. dest[5]
  1914. );
  1915. }
  1916. PUT(("SAP station . . %04x\n"
  1917. "link station. . %04x\n"
  1918. "T1. . . . . . . %02x\n"
  1919. "T2. . . . . . . %02x\n"
  1920. "Ti. . . . . . . %02x\n"
  1921. "max out . . . . %02x\n"
  1922. "max in. . . . . %02x\n"
  1923. "max out incr. . %02x\n"
  1924. "max retry count %02x\n"
  1925. "remote SAP. . . %02x\n"
  1926. "max I field . . %04x\n"
  1927. "access priority %02x\n"
  1928. "remote node . . %08x [%s]\n",
  1929. parms->usSapStationId,
  1930. parms->usLinkStationId,
  1931. parms->uchT1,
  1932. parms->uchT2,
  1933. parms->uchTi,
  1934. parms->uchMaxOut,
  1935. parms->uchMaxIn,
  1936. parms->uchMaxOutIncr,
  1937. parms->uchMaxRetryCnt,
  1938. parms->uchRemoteSap,
  1939. parms->usMaxI_Field,
  1940. parms->uchAccessPriority,
  1941. dest,
  1942. destAddr
  1943. ));
  1944. }
  1945. PRIVATE
  1946. VOID
  1947. DumpDlcReallocateParms(
  1948. IN PVOID Parameters
  1949. )
  1950. {
  1951. PLLC_DLC_REALLOCATE_PARMS parms = (PLLC_DLC_REALLOCATE_PARMS)Parameters;
  1952. DumpParameterTableHeader("DLC.REALLOCATE", Parameters);
  1953. PUT(("station id. . . %04x\n"
  1954. "option. . . . . %02x [%screase link stations]\n"
  1955. "station count . %02x\n"
  1956. "adapter stns. . %02x\n"
  1957. "SAP stations. . %02x\n"
  1958. "adapter total . %02x\n"
  1959. "SAP total . . . %02x\n",
  1960. parms->usStationId,
  1961. parms->uchOption,
  1962. parms->uchOption & 0x80 ? "De" : "In",
  1963. parms->uchStationCount,
  1964. parms->uchStationsAvailOnAdapter,
  1965. parms->uchStationsAvailOnSap,
  1966. parms->uchTotalStationsOnAdapter,
  1967. parms->uchTotalStationsOnSap
  1968. ));
  1969. }
  1970. PRIVATE
  1971. VOID
  1972. DumpDlcResetParms(
  1973. IN PVOID Parameters
  1974. )
  1975. {
  1976. PUT(("station id. . . %04x\n", HIWORD(Parameters)));
  1977. }
  1978. PRIVATE
  1979. VOID
  1980. DumpDlcSetThresholdParms(
  1981. IN PVOID Parameters
  1982. )
  1983. {
  1984. PLLC_DLC_SET_THRESHOLD_PARMS parms = (PLLC_DLC_SET_THRESHOLD_PARMS)Parameters;
  1985. DumpParameterTableHeader("DLC.SET.THRESHOLD", Parameters);
  1986. PUT(("station id. . . %04x\n"
  1987. "buf threshold . %04x\n"
  1988. "event . . . . . %08x\n",
  1989. parms->usStationId,
  1990. parms->cBufferThreshold,
  1991. parms->AlertEvent
  1992. ));
  1993. }
  1994. PRIVATE
  1995. VOID
  1996. DumpDlcStatisticsParms(
  1997. IN PVOID Parameters
  1998. )
  1999. {
  2000. PLLC_DLC_STATISTICS_PARMS parms = (PLLC_DLC_STATISTICS_PARMS)Parameters;
  2001. DumpParameterTableHeader("DLC.STATISTICS", Parameters);
  2002. PUT(("station id. . . %04x\n"
  2003. "log buf size. . %04x\n"
  2004. "log buffer. . . %08x\n"
  2005. "actual log len. %04x\n"
  2006. "options . . . . %02x [%s]\n",
  2007. parms->usStationId,
  2008. parms->cbLogBufSize,
  2009. parms->pLogBuf,
  2010. parms->usActLogLength,
  2011. parms->uchOptions,
  2012. parms->uchOptions & 0x80 ? "Reset counters" : ""
  2013. ));
  2014. }
  2015. PRIVATE
  2016. VOID
  2017. DumpReadParms(
  2018. IN PVOID Parameters
  2019. )
  2020. {
  2021. PLLC_READ_PARMS parms = (PLLC_READ_PARMS)Parameters;
  2022. DumpParameterTableHeader("READ", Parameters);
  2023. try {
  2024. PUT(("station id. . . %04x\n"
  2025. "option ind. . . %02x [%s]\n"
  2026. "event set . . . %02x\n"
  2027. "event . . . . . %02x [%s]\n"
  2028. "crit. subset. . %02x\n"
  2029. "notify flag . . %08x\n",
  2030. parms->usStationId,
  2031. parms->uchOptionIndicator,
  2032. MapOptionIndicator(parms->uchOptionIndicator),
  2033. parms->uchEventSet,
  2034. parms->uchEvent,
  2035. MapReadEvent(parms->uchEvent),
  2036. parms->uchCriticalSubset,
  2037. parms->ulNotificationFlag
  2038. ));
  2039. //
  2040. // rest of table interpreted differently depending on whether status change
  2041. //
  2042. if (parms->uchEvent & 0x38) {
  2043. PUT(("station id. . . %04x\n"
  2044. "status code . . %04x [%s]\n"
  2045. "FRMR data . . . %02x %02x %02x %02x %02x\n"
  2046. "access pri. . . %02x\n"
  2047. "remote addr . . %02x-%02x-%02x-%02x-%02x-%02x\n"
  2048. "remote SAP. . . %02x\n"
  2049. "reserved. . . . %02x\n"
  2050. "user stat . . . %04x\n",
  2051. parms->Type.Status.usStationId,
  2052. parms->Type.Status.usDlcStatusCode,
  2053. MapDlcStatus(parms->Type.Status.usDlcStatusCode),
  2054. parms->Type.Status.uchFrmrData[0],
  2055. parms->Type.Status.uchFrmrData[1],
  2056. parms->Type.Status.uchFrmrData[2],
  2057. parms->Type.Status.uchFrmrData[3],
  2058. parms->Type.Status.uchFrmrData[4],
  2059. parms->Type.Status.uchAccessPritority,
  2060. parms->Type.Status.uchRemoteNodeAddress[0],
  2061. parms->Type.Status.uchRemoteNodeAddress[1],
  2062. parms->Type.Status.uchRemoteNodeAddress[2],
  2063. parms->Type.Status.uchRemoteNodeAddress[3],
  2064. parms->Type.Status.uchRemoteNodeAddress[4],
  2065. parms->Type.Status.uchRemoteNodeAddress[5],
  2066. parms->Type.Status.uchRemoteSap,
  2067. parms->Type.Status.uchReserved,
  2068. parms->Type.Status.usUserStatusValue
  2069. ));
  2070. } else {
  2071. PUT(("CCB count . . . %04x\n"
  2072. "CCB list. . . . %08x\n"
  2073. "buffer count. . %04x\n"
  2074. "buffer list . . %08x\n"
  2075. "frame count . . %04x\n"
  2076. "frame list. . . %08x\n"
  2077. "error code. . . %04x\n"
  2078. "error data. . . %04x %04x %04x\n",
  2079. parms->Type.Event.usCcbCount,
  2080. parms->Type.Event.pCcbCompletionList,
  2081. parms->Type.Event.usBufferCount,
  2082. parms->Type.Event.pFirstBuffer,
  2083. parms->Type.Event.usReceivedFrameCount,
  2084. parms->Type.Event.pReceivedFrame,
  2085. parms->Type.Event.usEventErrorCode,
  2086. parms->Type.Event.usEventErrorData[0],
  2087. parms->Type.Event.usEventErrorData[1],
  2088. parms->Type.Event.usEventErrorData[2]
  2089. ));
  2090. IF_DEBUG(DUMP_ASYNC_CCBS) {
  2091. if (parms->Type.Event.usCcbCount) {
  2092. DumpCcb(parms->Type.Event.pCcbCompletionList,
  2093. TRUE, // DumpAll
  2094. FALSE // CcbIsInput
  2095. );
  2096. }
  2097. }
  2098. IF_DEBUG(DUMP_RX_INFO) {
  2099. if (parms->Type.Event.usReceivedFrameCount) {
  2100. DumpReceiveDataBuffer(parms->Type.Event.pReceivedFrame);
  2101. }
  2102. }
  2103. }
  2104. } except(1) {
  2105. PUT(("*** Error: Bad READ Parameter Table @ %x ***\n", parms));
  2106. }
  2107. }
  2108. PRIVATE
  2109. LPSTR
  2110. MapOptionIndicator(
  2111. IN UCHAR OptionIndicator
  2112. )
  2113. {
  2114. switch (OptionIndicator) {
  2115. case 0:
  2116. return "Match READ command using station id nnss";
  2117. case 1:
  2118. return "Match READ command using SAP number nn00";
  2119. case 2:
  2120. return "Match READ command using all events";
  2121. }
  2122. return "*** Unknown READ Option Indicator ***";
  2123. }
  2124. PRIVATE LPSTR MapReadEvent(UCHAR Event) {
  2125. switch (Event) {
  2126. case 0x80:
  2127. return "Reserved Event!";
  2128. case 0x40:
  2129. return "System Action (non-critical)";
  2130. case 0x20:
  2131. return "Network Status (non-critical)";
  2132. case 0x10:
  2133. return "Critical Exception";
  2134. case 0x8:
  2135. return "DLC Status Change";
  2136. case 0x4:
  2137. return "Receive Data";
  2138. case 0x2:
  2139. return "Transmit Completion";
  2140. case 0x1:
  2141. return "Command Completion";
  2142. }
  2143. return "*** Unknown READ Event ***";
  2144. }
  2145. PRIVATE LPSTR MapDlcStatus(WORD Status) {
  2146. if (Status & 0x8000) {
  2147. return "Link lost";
  2148. } else if (Status & 0x4000) {
  2149. return "DM/DISC Received -or- DISC ack'd";
  2150. } else if (Status & 0x2000) {
  2151. return "FRMR Received";
  2152. } else if (Status & 0x1000) {
  2153. return "FRMR Sent";
  2154. } else if (Status & 0x0800) {
  2155. return "SABME Received for open link station";
  2156. } else if (Status & 0x0400) {
  2157. return "SABME Received - link station opened";
  2158. } else if (Status & 0x0200) {
  2159. return "REMOTE Busy Entered";
  2160. } else if (Status & 0x0100) {
  2161. return "REMOTE Busy Left";
  2162. } else if (Status & 0x0080) {
  2163. return "Ti EXPIRED";
  2164. } else if (Status & 0x0040) {
  2165. return "DLC counter overflow - issue DLC.STATISTICS";
  2166. } else if (Status & 0x0020) {
  2167. return "Access Priority lowered";
  2168. } else if (Status & 0x001e) {
  2169. return "*** ERROR - INVALID STATUS ***";
  2170. } else if (Status & 0x0001) {
  2171. return "Entered LOCAL Busy";
  2172. }
  2173. return "*** Unknown DLC Status ***";
  2174. }
  2175. PRIVATE
  2176. VOID
  2177. DumpReadCancelParms(
  2178. IN PVOID Parameters
  2179. )
  2180. {
  2181. }
  2182. PRIVATE
  2183. VOID
  2184. DumpReceiveParms(
  2185. IN PVOID Parameters
  2186. )
  2187. {
  2188. PLLC_RECEIVE_PARMS parms = (PLLC_RECEIVE_PARMS)Parameters;
  2189. DumpParameterTableHeader("RECEIVE", Parameters);
  2190. PUT(("station id. . . %04x\n"
  2191. "user length . . %04x\n"
  2192. "receive flag. . %08x\n"
  2193. "first buffer. . %08x\n"
  2194. "options . . . . %02x [%s]\n"
  2195. "reserved. . . . %02x %02x %02x\n"
  2196. "rcv read optns. %02x [%s]\n",
  2197. parms->usStationId,
  2198. parms->usUserLength,
  2199. parms->ulReceiveFlag,
  2200. parms->pFirstBuffer,
  2201. parms->uchOptions,
  2202. MapReceiveOptions(parms->uchOptions),
  2203. parms->auchReserved1[0],
  2204. parms->auchReserved1[1],
  2205. parms->auchReserved1[2],
  2206. parms->uchRcvReadOption,
  2207. MapRcvReadOption(parms->uchRcvReadOption)
  2208. ));
  2209. }
  2210. PRIVATE
  2211. LPSTR
  2212. MapReceiveOptions(
  2213. IN UCHAR Options
  2214. )
  2215. {
  2216. static char buf[80];
  2217. BOOL space = FALSE;
  2218. buf[0] = 0;
  2219. if (Options & 0x80) {
  2220. strcat(buf, "Contiguous MAC");
  2221. Options &= 0x7f;
  2222. space = TRUE;
  2223. }
  2224. if (Options & 0x40) {
  2225. if (space) {
  2226. strcat(buf, " ");
  2227. }
  2228. strcat(buf, "Contiguous DATA");
  2229. Options &= 0xbf;
  2230. space = TRUE;
  2231. }
  2232. if (Options & 0x20) {
  2233. if (space) {
  2234. strcat(buf, " ");
  2235. }
  2236. strcat(buf, "Break");
  2237. Options &= 0xdf;
  2238. space = TRUE;
  2239. }
  2240. if (Options) {
  2241. if (space) {
  2242. strcat(buf, " ");
  2243. }
  2244. strcat(buf, "*** Invalid options ***");
  2245. }
  2246. return buf;
  2247. }
  2248. PRIVATE
  2249. LPSTR
  2250. MapRcvReadOption(
  2251. IN UCHAR Option
  2252. )
  2253. {
  2254. switch (Option) {
  2255. case 0:
  2256. return "Receive frames not chained";
  2257. case 1:
  2258. return "Chain receive frames for link station";
  2259. case 2:
  2260. return "Chain receive frames for SAP";
  2261. }
  2262. return "*** Unknown option ***";
  2263. }
  2264. PRIVATE
  2265. VOID
  2266. DumpReceiveCancelParms(
  2267. IN PVOID Parameters
  2268. )
  2269. {
  2270. PUT(("station id. . . %04x\n", HIWORD(Parameters)));
  2271. }
  2272. PRIVATE
  2273. VOID
  2274. DumpReceiveModifyParms(
  2275. IN PVOID Parameters
  2276. )
  2277. {
  2278. }
  2279. PRIVATE
  2280. VOID
  2281. DumpTransmitDirFrameParms(
  2282. IN PVOID Parameters
  2283. )
  2284. {
  2285. DumpParameterTableHeader("TRANSMIT.DIR.FRAME", Parameters);
  2286. DumpTransmitParms(Parameters);
  2287. }
  2288. PRIVATE
  2289. VOID
  2290. DumpTransmitIFrameParms(
  2291. IN PVOID Parameters
  2292. )
  2293. {
  2294. DumpParameterTableHeader("TRANSMIT.I.FRAME", Parameters);
  2295. DumpTransmitParms(Parameters);
  2296. }
  2297. PRIVATE
  2298. VOID
  2299. DumpTransmitTestCmdParms(
  2300. IN PVOID Parameters
  2301. )
  2302. {
  2303. DumpParameterTableHeader("TRANSMIT.TEST.CMD", Parameters);
  2304. DumpTransmitParms(Parameters);
  2305. }
  2306. PRIVATE
  2307. VOID
  2308. DumpTransmitUiFrameParms(
  2309. IN PVOID Parameters
  2310. )
  2311. {
  2312. DumpParameterTableHeader("TRANSMIT.UI.FRAME", Parameters);
  2313. DumpTransmitParms(Parameters);
  2314. }
  2315. PRIVATE
  2316. VOID
  2317. DumpTransmitXidCmdParms(
  2318. IN PVOID Parameters
  2319. )
  2320. {
  2321. DumpParameterTableHeader("TRANSMIT.XID.CMD", Parameters);
  2322. DumpTransmitParms(Parameters);
  2323. }
  2324. PRIVATE
  2325. VOID
  2326. DumpTransmitXidRespFinalParms(
  2327. IN PVOID Parameters
  2328. )
  2329. {
  2330. DumpParameterTableHeader("TRANSMIT.XID.RESP.FINAL", Parameters);
  2331. DumpTransmitParms(Parameters);
  2332. }
  2333. PRIVATE
  2334. VOID
  2335. DumpTransmitXidRespNotFinalParms(
  2336. IN PVOID Parameters
  2337. )
  2338. {
  2339. DumpParameterTableHeader("TRANSMIT.XID.RESP.NOT.FINAL", Parameters);
  2340. DumpTransmitParms(Parameters);
  2341. }
  2342. PRIVATE
  2343. VOID
  2344. DumpTransmitFramesParms(
  2345. IN PVOID Parameters
  2346. )
  2347. {
  2348. DumpParameterTableHeader("TRANSMIT.FRAMES", Parameters);
  2349. // DumpTransmitParms(Parameters);
  2350. }
  2351. PRIVATE
  2352. VOID
  2353. DumpTransmitParms(
  2354. IN PVOID Parameters
  2355. )
  2356. {
  2357. PLLC_TRANSMIT_PARMS parms = (PLLC_TRANSMIT_PARMS)Parameters;
  2358. try {
  2359. PUT(("StationId . . . %04x\n"
  2360. "Transmit FS . . %02x\n"
  2361. "Remote SAP. . . %02x\n"
  2362. "Xmit Queue 1. . %08x\n"
  2363. "Xmit Queue 2. . %08x\n"
  2364. "Buffer Length 1 %02x\n"
  2365. "Buffer Length 2 %02x\n"
  2366. "Buffer 1. . . . %08x\n"
  2367. "Buffer 2. . . . %08x\n"
  2368. "Xmt Read Option %02x [%s]\n"
  2369. "\n",
  2370. parms->usStationId,
  2371. parms->uchTransmitFs,
  2372. parms->uchRemoteSap,
  2373. parms->pXmitQueue1,
  2374. parms->pXmitQueue2,
  2375. parms->cbBuffer1,
  2376. parms->cbBuffer2,
  2377. parms->pBuffer1,
  2378. parms->pBuffer2,
  2379. parms->uchXmitReadOption,
  2380. MapXmitReadOption(parms->uchXmitReadOption)
  2381. ));
  2382. IF_DEBUG(DUMP_TX_INFO) {
  2383. if (parms->pXmitQueue1) {
  2384. PUT(("XMIT_QUEUE_ONE:\n"));
  2385. DumpTransmitQueue(parms->pXmitQueue1);
  2386. }
  2387. if (parms->pXmitQueue2) {
  2388. PUT(("XMIT_QUEUE_TWO:\n"));
  2389. DumpTransmitQueue(parms->pXmitQueue2);
  2390. }
  2391. }
  2392. IF_DEBUG(DUMP_TX_DATA) {
  2393. if (parms->cbBuffer1) {
  2394. DumpData("BUFFER_ONE. . . ",
  2395. (PBYTE)parms->pBuffer1,
  2396. (DWORD)parms->cbBuffer1,
  2397. DD_NO_ADDRESS
  2398. | DD_LINE_AFTER
  2399. | DD_INDENT_ALL
  2400. | DD_UPPER_CASE
  2401. | DD_DOT_DOT_SPACE,
  2402. DEFAULT_FIELD_WIDTH
  2403. );
  2404. }
  2405. if (parms->cbBuffer2) {
  2406. DumpData("BUFFER_TWO. . . ",
  2407. (PBYTE)parms->pBuffer2,
  2408. (DWORD)parms->cbBuffer2,
  2409. DD_NO_ADDRESS
  2410. | DD_LINE_AFTER
  2411. | DD_INDENT_ALL
  2412. | DD_UPPER_CASE
  2413. | DD_DOT_DOT_SPACE,
  2414. DEFAULT_FIELD_WIDTH
  2415. );
  2416. }
  2417. }
  2418. } except(1) {
  2419. PUT(("*** Error: Bad Transmit Parameter Table @ %x ***\n", parms));
  2420. }
  2421. }
  2422. PRIVATE
  2423. VOID
  2424. DumpTransmitQueue(
  2425. IN PLLC_XMIT_BUFFER Buffer
  2426. )
  2427. {
  2428. try {
  2429. while (Buffer) {
  2430. PUT(("Next. . . . . . %08x\n"
  2431. "Reserved. . . . %04x\n"
  2432. "Data In Buffer. %04x\n"
  2433. "User Data . . . %04x\n"
  2434. "User Length . . %04x\n"
  2435. "\n",
  2436. Buffer->pNext,
  2437. Buffer->usReserved1,
  2438. Buffer->cbBuffer,
  2439. Buffer->usReserved2,
  2440. Buffer->cbUserData
  2441. ));
  2442. IF_DEBUG(DUMP_TX_DATA) {
  2443. DumpData(NULL,
  2444. (PBYTE)Buffer->auchData,
  2445. (DWORD)Buffer->cbBuffer + (DWORD)Buffer->cbUserData,
  2446. DD_DEFAULT_OPTIONS,
  2447. DEFAULT_FIELD_WIDTH
  2448. );
  2449. }
  2450. Buffer = Buffer->pNext;
  2451. }
  2452. } except(1) {
  2453. PUT(("*** Error: Bad Transmit Queue/Buffer @ %x ***\n", Buffer));
  2454. }
  2455. }
  2456. PRIVATE
  2457. LPSTR
  2458. MapXmitReadOption(
  2459. IN UCHAR Option
  2460. )
  2461. {
  2462. switch (Option) {
  2463. case 0:
  2464. return "Chain this Transmit on Link station basis";
  2465. case 1:
  2466. return "Do not chain this Transmit completion";
  2467. case 2:
  2468. return "Chain this Transmit on SAP station basis";
  2469. }
  2470. return "*** Unknown XMIT_READ_OPTION ***";
  2471. }
  2472. VOID
  2473. DumpReceiveDataBuffer(
  2474. IN PVOID Buffer
  2475. )
  2476. {
  2477. PLLC_BUFFER pBuf = (PLLC_BUFFER)Buffer;
  2478. BOOL contiguous;
  2479. WORD userLength;
  2480. WORD dataLength;
  2481. WORD userOffset;
  2482. try {
  2483. contiguous = pBuf->Contiguous.uchOptions & 0xc0;
  2484. userLength = pBuf->Next.cbUserData;
  2485. dataLength = pBuf->Next.cbBuffer;
  2486. userOffset = pBuf->Next.offUserData;
  2487. } except(1) {
  2488. PUT(("*** Error: Bad received data buffer address %x ***\n", pBuf));
  2489. return;
  2490. }
  2491. //
  2492. // Buffer 1: [not] contiguous MAC/DATA
  2493. //
  2494. try {
  2495. PUT(("\n"
  2496. "%sContiguous MAC/DATA frame @%08x\n"
  2497. "next buffer . . %08x\n"
  2498. "frame length. . %04x\n"
  2499. "data length . . %04x\n"
  2500. "user offset . . %04x\n"
  2501. "user length . . %04x\n"
  2502. "station id. . . %04x\n"
  2503. "options . . . . %02x\n"
  2504. "message type. . %02x [%s]\n"
  2505. "buffers left. . %04x\n"
  2506. "rcv FS. . . . . %02x\n"
  2507. "adapter num . . %02x\n"
  2508. "next frame. . . %08x\n",
  2509. contiguous ? "" : "Not",
  2510. pBuf,
  2511. pBuf->Contiguous.pNextBuffer,
  2512. pBuf->Contiguous.cbFrame,
  2513. pBuf->Contiguous.cbBuffer,
  2514. pBuf->Contiguous.offUserData,
  2515. pBuf->Contiguous.cbUserData,
  2516. pBuf->Contiguous.usStationId,
  2517. pBuf->Contiguous.uchOptions,
  2518. pBuf->Contiguous.uchMsgType,
  2519. MapMessageType(pBuf->Contiguous.uchMsgType),
  2520. pBuf->Contiguous.cBuffersLeft,
  2521. pBuf->Contiguous.uchRcvFS,
  2522. pBuf->Contiguous.uchAdapterNumber,
  2523. pBuf->Contiguous.pNextFrame
  2524. ));
  2525. if (!contiguous) {
  2526. //
  2527. // dump NotContiguous header
  2528. //
  2529. DWORD cbLanHeader = (DWORD)pBuf->NotContiguous.cbLanHeader;
  2530. DWORD cbDlcHeader = (DWORD)pBuf->NotContiguous.cbDlcHeader;
  2531. PUT(("LAN hdr len . . %02x\n"
  2532. "DLC hdr len . . %02x\n",
  2533. cbLanHeader,
  2534. cbDlcHeader
  2535. ));
  2536. DumpData("LAN header. . . ",
  2537. pBuf->NotContiguous.auchLanHeader,
  2538. cbLanHeader,
  2539. DD_NO_ADDRESS | DD_NO_ASCII | DD_UPPER_CASE | DD_INDENT_ALL,
  2540. DEFAULT_FIELD_WIDTH
  2541. );
  2542. DumpData("DLC header. . . ",
  2543. pBuf->NotContiguous.auchDlcHeader,
  2544. cbDlcHeader,
  2545. DD_NO_ADDRESS | DD_NO_ASCII | DD_UPPER_CASE | DD_INDENT_ALL,
  2546. DEFAULT_FIELD_WIDTH
  2547. );
  2548. if (userLength) {
  2549. DumpData("user space. . . ",
  2550. (PBYTE)pBuf + userOffset,
  2551. userLength,
  2552. DD_NO_ADDRESS | DD_UPPER_CASE | DD_INDENT_ALL,
  2553. DEFAULT_FIELD_WIDTH
  2554. );
  2555. } else {
  2556. PUT(("user space. . . \n"));
  2557. }
  2558. IF_DEBUG(DUMP_RX_DATA) {
  2559. if (dataLength) {
  2560. DumpData("rcvd data . . . ",
  2561. (PBYTE)pBuf + userOffset + userLength,
  2562. dataLength,
  2563. DD_NO_ADDRESS | DD_UPPER_CASE | DD_INDENT_ALL | DD_DOT_DOT_SPACE,
  2564. DEFAULT_FIELD_WIDTH
  2565. );
  2566. } else {
  2567. PUT(("rcvd data . . . \n"));
  2568. }
  2569. }
  2570. } else {
  2571. //
  2572. // dump Contiguous header
  2573. //
  2574. // data length is size of frame in contiguous buffer?
  2575. //
  2576. if (userLength) {
  2577. DumpData("user space. . . ",
  2578. (PBYTE)pBuf + userOffset,
  2579. userLength,
  2580. DD_NO_ADDRESS | DD_UPPER_CASE | DD_INDENT_ALL | DD_DOT_DOT_SPACE,
  2581. DEFAULT_FIELD_WIDTH
  2582. );
  2583. } else {
  2584. PUT(("user space. . . \n"));
  2585. }
  2586. IF_DEBUG(DUMP_RX_DATA) {
  2587. dataLength = pBuf->Contiguous.cbFrame;
  2588. if (dataLength) {
  2589. DumpData("rcvd data . . . ",
  2590. (PBYTE)pBuf + userOffset + userLength,
  2591. dataLength,
  2592. DD_NO_ADDRESS | DD_UPPER_CASE | DD_INDENT_ALL | DD_DOT_DOT_SPACE,
  2593. DEFAULT_FIELD_WIDTH
  2594. );
  2595. } else {
  2596. PUT(("rcvd data . . . \n"));
  2597. }
  2598. }
  2599. }
  2600. //
  2601. // dump second & subsequent buffers
  2602. //
  2603. IF_DEBUG(DUMP_DATA_CHAIN) {
  2604. for (pBuf = pBuf->pNext; pBuf; pBuf = pBuf->pNext) {
  2605. userLength = pBuf->Next.cbUserData;
  2606. dataLength = pBuf->Next.cbBuffer;
  2607. PUT(("\n"
  2608. "Buffer 2/Subsequent @%08x\n"
  2609. "next buffer . . %08x\n"
  2610. "frame length. . %04x\n"
  2611. "data length . . %04x\n"
  2612. "user offset . . %04x\n"
  2613. "user length . . %04x\n",
  2614. pBuf,
  2615. pBuf->pNext,
  2616. pBuf->Next.cbFrame,
  2617. dataLength,
  2618. pBuf->Next.offUserData,
  2619. userLength
  2620. ));
  2621. if (userLength) {
  2622. DumpData("user space. . . ",
  2623. (PBYTE)&pBuf + pBuf->Next.offUserData,
  2624. userLength,
  2625. DD_NO_ADDRESS | DD_UPPER_CASE | DD_INDENT_ALL | DD_DOT_DOT_SPACE,
  2626. DEFAULT_FIELD_WIDTH
  2627. );
  2628. } else {
  2629. PUT(("user space. . . \n"));
  2630. }
  2631. IF_DEBUG(DUMP_RX_DATA) {
  2632. //
  2633. // there must be received data
  2634. //
  2635. DumpData("rcvd data . . . ",
  2636. (PBYTE)pBuf + pBuf->Next.offUserData + userLength,
  2637. dataLength,
  2638. DD_NO_ADDRESS | DD_UPPER_CASE | DD_INDENT_ALL | DD_DOT_DOT_SPACE,
  2639. DEFAULT_FIELD_WIDTH
  2640. );
  2641. }
  2642. }
  2643. }
  2644. if (((PLLC_BUFFER)Buffer)->Contiguous.pNextFrame) {
  2645. DumpReceiveDataBuffer(((PLLC_BUFFER)Buffer)->Contiguous.pNextFrame);
  2646. }
  2647. } except(1) {
  2648. PUT(("*** Error: Bad Receive Data Buffer @ %x ***\n", Buffer));
  2649. }
  2650. }
  2651. PRIVATE
  2652. LPSTR
  2653. MapMessageType(
  2654. IN UCHAR MessageType
  2655. )
  2656. {
  2657. switch (MessageType) {
  2658. case 0x00:
  2659. return "Direct Transmit Frame";
  2660. case 0x02:
  2661. return "MAC Frame (Direct Station on Token Ring only)";
  2662. case 0x04:
  2663. return "I-Frame";
  2664. case 0x06:
  2665. return "UI-Frame";
  2666. case 0x08:
  2667. return "XID Command (POLL)";
  2668. case 0x0a:
  2669. return "XID Command (not POLL)";
  2670. case 0x0c:
  2671. return "XID Response (FINAL)";
  2672. case 0x0e:
  2673. return "XID Response (not FINAL)";
  2674. case 0x10:
  2675. return "TEST Response (FINAL)";
  2676. case 0x12:
  2677. return "TEST Response (not FINAL)";
  2678. case 0x14:
  2679. return "Direct 802.2/OTHER - non-MAC frame (Direct Station only)";
  2680. case 0x16:
  2681. return "TEST Command (POLL)";
  2682. case 0x18:
  2683. return "Direct Ethernet Frame";
  2684. case 0x1a:
  2685. return "Last Frame Type";
  2686. // case 0x5dd:
  2687. // return "First Ethernet Frame Type";
  2688. default:
  2689. return "*** BAD FRAME TYPE ***";
  2690. }
  2691. }
  2692. //PRIVATE
  2693. //VOID
  2694. //DumpData(
  2695. // IN PBYTE Address,
  2696. // IN DWORD Length
  2697. // )
  2698. //{
  2699. // char dumpBuf[80];
  2700. // char* bufptr;
  2701. // int i, n;
  2702. //
  2703. // //
  2704. // // the usual dump style: 16 columns of hex bytes, followed by 16 columns
  2705. // // of corresponding ASCII characters, or '.' where the character is < 0x20
  2706. // // (space) or > 0x7f (del?)
  2707. // //
  2708. //
  2709. // while (Length) {
  2710. // bufptr = dumpBuf;
  2711. // bufptr += sprintf(bufptr, "%08x: ", Address);
  2712. // if (Length < 16) {
  2713. // n = Length;
  2714. // } else {
  2715. // n = 16;
  2716. // }
  2717. // for (i = 0; i < n; ++i) {
  2718. // bufptr += sprintf(bufptr, "%02x", Address[i]);
  2719. // if (i == 7) {
  2720. // *bufptr = '-';
  2721. // } else {
  2722. // *bufptr = ' ';
  2723. // }
  2724. // ++bufptr;
  2725. // }
  2726. // if (n < 16) {
  2727. // for (i = 0; i < 16-n; ++i) {
  2728. // bufptr += sprintf(bufptr, " ");
  2729. // }
  2730. // }
  2731. // bufptr += sprintf(bufptr, " ");
  2732. // for (i = 0; i < n; ++i) {
  2733. // if (Address[i] < 0x20 || Address[i] > 0x7f) {
  2734. // *bufptr++ = '.';
  2735. // } else {
  2736. // *bufptr++ = Address[i];
  2737. // }
  2738. // }
  2739. // *bufptr++ = '\n';
  2740. // *bufptr = 0;
  2741. // PUT((dumpBuf));
  2742. // Length -= n;
  2743. // Address += n;
  2744. // }
  2745. // PUT(("\n"));
  2746. //}
  2747. #endif