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.

229 lines
5.3 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. debug.c
  5. Abstract:
  6. This component of netbios runs in the kernel and logs through the
  7. kernel debugger.
  8. Author:
  9. Colin Watson (ColinW) 24-Jun-91
  10. Revision History:
  11. --*/
  12. #if DBG
  13. #include <nb.h>
  14. VOID
  15. HexDumpLine(
  16. PCHAR pch,
  17. ULONG len,
  18. PCHAR s,
  19. PCHAR t
  20. );
  21. LONG NetbiosMaxDump = 128;
  22. // Macro used in DisplayNcb
  23. #define DISPLAY_COMMAND( cmd ) \
  24. case cmd: NbPrint(( #cmd )); break;
  25. VOID
  26. NbDisplayNcb(
  27. IN PDNCB pdncb
  28. )
  29. /*++
  30. Routine Description:
  31. This routine displays on the standard output stream the contents
  32. of the Ncb.
  33. Arguments:
  34. IN PDNCB - Supplies the NCB to be displayed.
  35. Return Value:
  36. none.
  37. --*/
  38. {
  39. NbPrint(( "PDNCB %#010lx\n", pdncb));
  40. NbPrint(( "ncb_command %#04x ", pdncb->ncb_command));
  41. switch ( pdncb->ncb_command & ~ASYNCH ) {
  42. DISPLAY_COMMAND( NCBCALL );
  43. DISPLAY_COMMAND( NCBLISTEN );
  44. DISPLAY_COMMAND( NCBHANGUP );
  45. DISPLAY_COMMAND( NCBSEND );
  46. DISPLAY_COMMAND( NCBRECV );
  47. DISPLAY_COMMAND( NCBRECVANY );
  48. DISPLAY_COMMAND( NCBCHAINSEND );
  49. DISPLAY_COMMAND( NCBDGSEND );
  50. DISPLAY_COMMAND( NCBDGRECV );
  51. DISPLAY_COMMAND( NCBDGSENDBC );
  52. DISPLAY_COMMAND( NCBDGRECVBC );
  53. DISPLAY_COMMAND( NCBADDNAME );
  54. DISPLAY_COMMAND( NCBDELNAME );
  55. DISPLAY_COMMAND( NCBRESET );
  56. DISPLAY_COMMAND( NCBASTAT );
  57. DISPLAY_COMMAND( NCBSSTAT );
  58. DISPLAY_COMMAND( NCBCANCEL );
  59. DISPLAY_COMMAND( NCBADDGRNAME );
  60. DISPLAY_COMMAND( NCBENUM );
  61. DISPLAY_COMMAND( NCBUNLINK );
  62. DISPLAY_COMMAND( NCBSENDNA );
  63. DISPLAY_COMMAND( NCBCHAINSENDNA );
  64. DISPLAY_COMMAND( NCBLANSTALERT );
  65. DISPLAY_COMMAND( NCBFINDNAME );
  66. DISPLAY_COMMAND( NCBACTION );
  67. DISPLAY_COMMAND( NCBQUICKADDNAME );
  68. DISPLAY_COMMAND( NCBQUICKADDGRNAME );
  69. DISPLAY_COMMAND( NCALLNIU );
  70. case NCBADDRESERVED: NbPrint(( "Add reserved address(Internal)" )); break;
  71. case NCBADDBROADCAST: NbPrint(( "Add Broadcast address(Internal)" )); break;
  72. default: NbPrint(( " Unknown type")); break;
  73. }
  74. if ( pdncb->ncb_command & ASYNCH ) {
  75. NbPrint(( " | ASYNCH"));
  76. }
  77. NbPrint(( "\nncb_retcode %#04x\n", pdncb->ncb_retcode));
  78. NbPrint(( "ncb_lsn %#04x\n", pdncb->ncb_lsn));
  79. NbPrint(( "ncb_num %#04x\n", pdncb->ncb_num));
  80. NbPrint(( "ncb_buffer %#010lx\n",pdncb->ncb_buffer));
  81. NbPrint(( "ncb_length %#06x\n", pdncb->ncb_length));
  82. if ((( pdncb->ncb_command & ~ASYNCH ) == NCBCALL) ||
  83. (( pdncb->ncb_command & ~ASYNCH ) == NCALLNIU) ||
  84. (( pdncb->ncb_command & ~ASYNCH ) == NCBDGSEND) ||
  85. (( pdncb->ncb_command & ~ASYNCH ) == NCBDGRECV) ||
  86. (( pdncb->ncb_command & ~ASYNCH ) == NCBDGSENDBC) ||
  87. (( pdncb->ncb_command & ~ASYNCH ) == NCBDGRECVBC) ||
  88. (( pdncb->ncb_command & ~ASYNCH ) == NCBADDNAME) ||
  89. (( pdncb->ncb_command & ~ASYNCH ) == NCBADDGRNAME) ||
  90. (( pdncb->ncb_command & ~ASYNCH ) == NCBLISTEN)) {
  91. NbPrint(( "\nncb_callname and ncb->name\n"));
  92. NbFormattedDump( pdncb->ncb_callname, NCBNAMSZ );
  93. NbFormattedDump( pdncb->ncb_name, NCBNAMSZ );
  94. NbPrint(( "ncb_rto %#04x\n", pdncb->ncb_rto));
  95. NbPrint(( "ncb_sto %#04x\n", pdncb->ncb_sto));
  96. }
  97. NbPrint(( "ncb_post %lx\n", pdncb->ncb_post));
  98. NbPrint(( "ncb_lana_num %#04x\n", pdncb->ncb_lana_num));
  99. NbPrint(( "ncb_cmd_cplt %#04x\n\n", pdncb->ncb_cmd_cplt));
  100. }
  101. void
  102. NbFormattedDump(
  103. PCHAR far_p,
  104. LONG len
  105. )
  106. /*++
  107. Routine Description:
  108. This routine outputs a buffer in lines of text containing hex and
  109. printable characters.
  110. Arguments:
  111. IN far_p - Supplies buffer to be displayed.
  112. IN len - Supplies the length of the buffer in bytes.
  113. Return Value:
  114. none.
  115. --*/
  116. {
  117. ULONG l;
  118. char s[80], t[80];
  119. if ( len > NetbiosMaxDump ) {
  120. len = NetbiosMaxDump;
  121. }
  122. while (len) {
  123. l = len < 16 ? len : 16;
  124. NbPrint( ("%lx ", far_p));
  125. HexDumpLine (far_p, l, s, t);
  126. NbPrint( ("%s%.*s%s\n", s, 1 + ((16 - l) * 3), "", t));
  127. len -= l;
  128. far_p += l;
  129. }
  130. }
  131. VOID
  132. HexDumpLine(
  133. PCHAR pch,
  134. ULONG len,
  135. PCHAR s,
  136. PCHAR t
  137. )
  138. /*++
  139. Routine Description:
  140. This routine builds a line of text containing hex and printable characters.
  141. Arguments:
  142. IN pch - Supplies buffer to be displayed.
  143. IN len - Supplies the length of the buffer in bytes.
  144. IN s - Supplies the start of the buffer to be loaded with the string
  145. of hex characters.
  146. IN t - Supplies the start of the buffer to be loaded with the string
  147. of printable ascii characters.
  148. Return Value:
  149. none.
  150. --*/
  151. {
  152. static UCHAR rghex[] = "0123456789ABCDEF";
  153. UCHAR c;
  154. UCHAR *hex, *asc;
  155. hex = s;
  156. asc = t;
  157. *(asc++) = '*';
  158. while (len--) {
  159. c = *(pch++);
  160. *(hex++) = rghex [c >> 4] ;
  161. *(hex++) = rghex [c & 0x0F];
  162. *(hex++) = ' ';
  163. *(asc++) = (c < ' ' || c > '~') ? (CHAR )'.' : c;
  164. }
  165. *(asc++) = '*';
  166. *asc = 0;
  167. *hex = 0;
  168. }
  169. #endif
  170.