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.

366 lines
6.0 KiB

  1. /*++
  2. Copyright (c) 1998-2001 Microsoft Corporation
  3. Module Name:
  4. tdiutil.c
  5. Abstract:
  6. Utility functions for dumping various TDI structures.
  7. Author:
  8. Keith Moore (keithmo) 17-Jun-1998
  9. Environment:
  10. User Mode.
  11. Revision History:
  12. --*/
  13. #include "precomp.h"
  14. //
  15. // Private prototypes.
  16. //
  17. PSTR
  18. TransportAddressTypeToString(
  19. USHORT AddressType
  20. );
  21. PSTR
  22. NetbiosNameTypeToString(
  23. USHORT NetbiosNameType
  24. );
  25. //
  26. // Public functions.
  27. //
  28. VOID
  29. DumpTransportAddress(
  30. PCHAR Prefix,
  31. PTRANSPORT_ADDRESS Address,
  32. ULONG_PTR ActualAddress
  33. )
  34. /*++
  35. Routine Description:
  36. Dumps the specified TRANSPORT_ADDRESS structure.
  37. Arguments:
  38. Prefix - A character string prefix to display before each line. Used
  39. to make things pretty.
  40. Address - Points to the TRANSPORT_ADDRESS to dump.
  41. ActualAddress - The actual address where the structure resides on the
  42. debugee.
  43. Return Value:
  44. None.
  45. --*/
  46. {
  47. dprintf(
  48. "%sTRANSPORT_ADDRESS @ %p\n",
  49. Prefix,
  50. ActualAddress
  51. );
  52. dprintf(
  53. "%s AddressLength = %u\n",
  54. Prefix,
  55. Address->Address[0].AddressLength
  56. );
  57. dprintf(
  58. "%s AddressType = %u (%s)\n",
  59. Prefix,
  60. Address->Address[0].AddressType,
  61. TransportAddressTypeToString( Address->Address[0].AddressType )
  62. );
  63. switch( Address->Address[0].AddressType ) {
  64. case TDI_ADDRESS_TYPE_IP : {
  65. PTA_IP_ADDRESS ipAddress;
  66. ipAddress = (PTA_IP_ADDRESS)Address;
  67. dprintf(
  68. "%s sin_port = %u\n",
  69. Prefix,
  70. NTOHS(ipAddress->Address00.sin_port)
  71. );
  72. dprintf(
  73. "%s in_addr = %d.%d.%d.%d\n",
  74. Prefix,
  75. UC(ipAddress->Address00.in_addr >> 0),
  76. UC(ipAddress->Address00.in_addr >> 8),
  77. UC(ipAddress->Address00.in_addr >> 16),
  78. UC(ipAddress->Address00.in_addr >> 24)
  79. );
  80. }
  81. break;
  82. case TDI_ADDRESS_TYPE_IPX : {
  83. PTA_IPX_ADDRESS ipxAddress;
  84. ipxAddress = (PTA_IPX_ADDRESS)Address;
  85. dprintf(
  86. "%s NetworkAddress = %08lx\n",
  87. Prefix,
  88. ipxAddress->Address00.NetworkAddress
  89. );
  90. dprintf(
  91. "%s NodeAddress = %02X-%02X-%02X-%02X-%02X-%02X\n",
  92. Prefix,
  93. ipxAddress->Address00.NodeAddress[0],
  94. ipxAddress->Address00.NodeAddress[1],
  95. ipxAddress->Address00.NodeAddress[2],
  96. ipxAddress->Address00.NodeAddress[3],
  97. ipxAddress->Address00.NodeAddress[4],
  98. ipxAddress->Address00.NodeAddress[5]
  99. );
  100. dprintf(
  101. "%s Socket = %04X\n",
  102. Prefix,
  103. ipxAddress->Address00.Socket
  104. );
  105. }
  106. break;
  107. case TDI_ADDRESS_TYPE_NETBIOS : {
  108. PTA_NETBIOS_ADDRESS netbiosAddress;
  109. UCHAR netbiosName[17];
  110. netbiosAddress = (PTA_NETBIOS_ADDRESS)Address;
  111. dprintf(
  112. "%s NetbiosNameType = %04X (%s)\n",
  113. Prefix,
  114. netbiosAddress->Address00.NetbiosNameType,
  115. NetbiosNameTypeToString( netbiosAddress->Address00.NetbiosNameType )
  116. );
  117. RtlCopyMemory(
  118. netbiosName,
  119. netbiosAddress->Address00.NetbiosName,
  120. 16
  121. );
  122. netbiosName[16] = '\0';
  123. dprintf(
  124. "%s NetbiosName = %s\n",
  125. Prefix,
  126. netbiosName
  127. );
  128. }
  129. break;
  130. default :
  131. dprintf(
  132. "%s Unsupported address type\n",
  133. Prefix
  134. );
  135. break;
  136. }
  137. } // DumpAfdEndpoint
  138. //
  139. // Private functions.
  140. //
  141. PSTR
  142. TransportAddressTypeToString(
  143. USHORT AddressType
  144. )
  145. /*++
  146. Routine Description:
  147. Maps a transport address type to a displayable string.
  148. Arguments:
  149. AddressType - The transport address type to map.
  150. Return Value:
  151. PSTR - Points to the displayable form of the tranport address type.
  152. --*/
  153. {
  154. switch( AddressType ) {
  155. case TDI_ADDRESS_TYPE_UNSPEC :
  156. return "Unspecified";
  157. case TDI_ADDRESS_TYPE_UNIX :
  158. return "Unix";
  159. case TDI_ADDRESS_TYPE_IP :
  160. return "Ip";
  161. case TDI_ADDRESS_TYPE_IMPLINK :
  162. return "Implink";
  163. case TDI_ADDRESS_TYPE_PUP :
  164. return "Pup";
  165. case TDI_ADDRESS_TYPE_CHAOS :
  166. return "Chaos";
  167. case TDI_ADDRESS_TYPE_IPX :
  168. return "Ipx";
  169. case TDI_ADDRESS_TYPE_NBS :
  170. return "Nbs";
  171. case TDI_ADDRESS_TYPE_ECMA :
  172. return "Ecma";
  173. case TDI_ADDRESS_TYPE_DATAKIT :
  174. return "Datakit";
  175. case TDI_ADDRESS_TYPE_CCITT :
  176. return "Ccitt";
  177. case TDI_ADDRESS_TYPE_SNA :
  178. return "Sna";
  179. case TDI_ADDRESS_TYPE_DECnet :
  180. return "Decnet";
  181. case TDI_ADDRESS_TYPE_DLI :
  182. return "Dli";
  183. case TDI_ADDRESS_TYPE_LAT :
  184. return "Lat";
  185. case TDI_ADDRESS_TYPE_HYLINK :
  186. return "Hylink";
  187. case TDI_ADDRESS_TYPE_APPLETALK :
  188. return "Appletalk";
  189. case TDI_ADDRESS_TYPE_NETBIOS :
  190. return "Netbios";
  191. case TDI_ADDRESS_TYPE_8022 :
  192. return "8022";
  193. case TDI_ADDRESS_TYPE_OSI_TSAP :
  194. return "Osi Trap";
  195. case TDI_ADDRESS_TYPE_NETONE :
  196. return "Netone";
  197. }
  198. return "UNKNOWN";
  199. } // TransportAddressTypeToString
  200. PSTR
  201. NetbiosNameTypeToString(
  202. USHORT NetbiosNameType
  203. )
  204. /*++
  205. Routine Description:
  206. Maps a NetBIOS name type to a displayable string.
  207. Arguments:
  208. NetbiosNameType - The NetBIOS name type to map.
  209. Return Value:
  210. PSTR - Points to the displayable form of the NetBIOS name type.
  211. --*/
  212. {
  213. switch( NetbiosNameType ) {
  214. case TDI_ADDRESS_NETBIOS_TYPE_UNIQUE :
  215. return "Unique";
  216. case TDI_ADDRESS_NETBIOS_TYPE_GROUP :
  217. return "Group";
  218. case TDI_ADDRESS_NETBIOS_TYPE_QUICK_UNIQUE :
  219. return "Quick Unique";
  220. case TDI_ADDRESS_NETBIOS_TYPE_QUICK_GROUP :
  221. return "Quick Group";
  222. }
  223. return "UNKNOWN";
  224. } // NetbiosNameTypeToString