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.

985 lines
23 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. tdiutil.c
  5. Abstract:
  6. Utility functions for dumping various TDI structures.
  7. Author:
  8. Keith Moore (keithmo) 19-Apr-1995
  9. Environment:
  10. User Mode.
  11. Revision History:
  12. --*/
  13. #include "afdkdp.h"
  14. #pragma hdrstop
  15. //
  16. // Private prototypes.
  17. //
  18. PSTR
  19. TransportAddressTypeToString(
  20. USHORT AddressType
  21. );
  22. PSTR
  23. NetbiosNameTypeToString(
  24. USHORT NetbiosNameType
  25. );
  26. PSTR
  27. NetbiosNameTypeToStringBrief(
  28. USHORT NetbiosNameType
  29. );
  30. typedef struct in6_addr {
  31. union {
  32. UCHAR Byte[16];
  33. USHORT Word[8];
  34. } u;
  35. } IN6_ADDR, *PIN6_ADDR;
  36. #define s6_bytes u.Byte
  37. #define s6_words u.Word
  38. INT
  39. MyIp6AddressToString (
  40. PIN6_ADDR Addr,
  41. PCHAR S,
  42. INT L
  43. );
  44. //
  45. // Remove once ATM defs are moved to tdi.h
  46. //
  47. #define AFD_TDI_ADDRESS_TYPE_ATM 22
  48. #define AFD_ATM_NSAP 0
  49. #define AFD_ATM_E164 1
  50. #define AFD_SAP_FIELD_ABSENT ((ULONG)0xfffffffe)
  51. #define AFD_SAP_FIELD_ANY ((ULONG)0xffffffff)
  52. #define AFD_SAP_FIELD_ANY_AESA_SEL ((ULONG)0xfffffffa) // SEL is wild-carded
  53. #define AFD_SAP_FIELD_ANY_AESA_REST ((ULONG)0xfffffffb) // All of the address
  54. // except SEL, is wild-carded
  55. typedef struct _AFD_TDI_ADDRESS_ATM {
  56. ULONG AddressType;
  57. ULONG NumberOfDigits;
  58. UCHAR Address[20];
  59. } AFD_TDI_ADDRESS_ATM, *PAFD_TDI_ADDRESS_ATM;
  60. //
  61. // Public functions.
  62. //
  63. VOID
  64. DumpTransportAddress(
  65. PCHAR Prefix,
  66. PTRANSPORT_ADDRESS Address,
  67. ULONG64 ActualAddress
  68. )
  69. /*++
  70. Routine Description:
  71. Dumps the specified TRANSPORT_ADDRESS structure.
  72. Arguments:
  73. Prefix - A character string prefix to display before each line. Used
  74. to make things pretty.
  75. Address - Points to the TRANSPORT_ADDRESS to dump.
  76. ActualAddress - The actual address where the structure resides on the
  77. debugee.
  78. Return Value:
  79. None.
  80. --*/
  81. {
  82. dprintf(
  83. "%sTRANSPORT_ADDRESS @ %p\n",
  84. Prefix,
  85. ActualAddress
  86. );
  87. dprintf(
  88. "%s AddressLength = %u\n",
  89. Prefix,
  90. Address->Address[0].AddressLength
  91. );
  92. dprintf(
  93. "%s AddressType = %u (%s)\n",
  94. Prefix,
  95. Address->Address[0].AddressType,
  96. TransportAddressTypeToString( Address->Address[0].AddressType )
  97. );
  98. switch( Address->Address[0].AddressType ) {
  99. case TDI_ADDRESS_TYPE_IP : {
  100. PTA_IP_ADDRESS ipAddress;
  101. ipAddress = (PTA_IP_ADDRESS)Address;
  102. dprintf(
  103. "%s sin_port = %u\n",
  104. Prefix,
  105. NTOHS(ipAddress->Address00.sin_port)
  106. );
  107. dprintf(
  108. "%s in_addr = %d.%d.%d.%d\n",
  109. Prefix,
  110. UC(ipAddress->Address00.in_addr >> 0),
  111. UC(ipAddress->Address00.in_addr >> 8),
  112. UC(ipAddress->Address00.in_addr >> 16),
  113. UC(ipAddress->Address00.in_addr >> 24)
  114. );
  115. }
  116. break;
  117. case TDI_ADDRESS_TYPE_IP6: {
  118. PTA_IP6_ADDRESS ip6Address;
  119. CHAR buffer[MAX_ADDRESS_STRING];
  120. ip6Address = (PTA_IP6_ADDRESS)Address;
  121. dprintf(
  122. "%s sin6_port = %u\n",
  123. Prefix,
  124. NTOHS(ip6Address->Address00.sin6_port)
  125. );
  126. MyIp6AddressToString (
  127. (PIN6_ADDR)&ip6Address->Address[0].Address[0].sin6_addr,
  128. buffer,
  129. sizeof (buffer));
  130. dprintf(
  131. "%s sin6_addr = %s\n",
  132. Prefix,
  133. buffer
  134. );
  135. dprintf(
  136. "%s sin6_scope_id = %u\n",
  137. Prefix,
  138. ip6Address->Address00.sin6_scope_id
  139. );
  140. }
  141. break;
  142. case TDI_ADDRESS_TYPE_IPX : {
  143. PTA_IPX_ADDRESS ipxAddress;
  144. ipxAddress = (PTA_IPX_ADDRESS)Address;
  145. dprintf(
  146. "%s NetworkAddress = %08.8lx\n",
  147. Prefix,
  148. ipxAddress->Address00.NetworkAddress
  149. );
  150. dprintf(
  151. "%s NodeAddress = %02.2X-%02.2X-%02.2X-%02.2X-%02.2X-%02.2X\n",
  152. Prefix,
  153. ipxAddress->Address00.NodeAddress[0],
  154. ipxAddress->Address00.NodeAddress[1],
  155. ipxAddress->Address00.NodeAddress[2],
  156. ipxAddress->Address00.NodeAddress[3],
  157. ipxAddress->Address00.NodeAddress[4],
  158. ipxAddress->Address00.NodeAddress[5]
  159. );
  160. dprintf(
  161. "%s Socket = %04.4X\n",
  162. Prefix,
  163. ipxAddress->Address00.Socket
  164. );
  165. }
  166. break;
  167. case TDI_ADDRESS_TYPE_NETBIOS : {
  168. PTA_NETBIOS_ADDRESS netbiosAddress;
  169. UCHAR netbiosName[16];
  170. INT i;
  171. netbiosAddress = (PTA_NETBIOS_ADDRESS)Address;
  172. dprintf(
  173. "%s NetbiosNameType = %04.4X (%s)\n",
  174. Prefix,
  175. netbiosAddress->Address00.NetbiosNameType,
  176. NetbiosNameTypeToString( netbiosAddress->Address00.NetbiosNameType )
  177. );
  178. RtlCopyMemory(
  179. netbiosName,
  180. netbiosAddress->Address00.NetbiosName,
  181. 15
  182. );
  183. netbiosName[15] = 0;
  184. dprintf(
  185. "%s NetbiosName = %s:0x%2.2x (%2.2X",
  186. Prefix,
  187. netbiosName,
  188. (UCHAR)netbiosAddress->Address00.NetbiosName[0],
  189. (UCHAR)netbiosAddress->Address00.NetbiosName[0]
  190. );
  191. for (i=1;i<sizeof(netbiosAddress->Address00.NetbiosName) ;i++) {
  192. dprintf ("-%2.2X", (UCHAR)netbiosAddress->Address00.NetbiosName[i]);
  193. }
  194. dprintf (")\n");
  195. }
  196. break;
  197. case TDI_ADDRESS_TYPE_NBS: // matches AF_OSI
  198. case TDI_ADDRESS_TYPE_OSI_TSAP : {
  199. PTDI_ADDRESS_OSI_TSAP osiAddress;
  200. INT i;
  201. osiAddress = (PTDI_ADDRESS_OSI_TSAP)&Address->Address[0].Address;
  202. dprintf(
  203. "%s Type = %d\n",
  204. Prefix,
  205. osiAddress->tp_addr_type
  206. );
  207. i = 0;
  208. if (osiAddress->tp_tsel_len>0) {
  209. dprintf(
  210. "%s Selector = %02.2X",
  211. Prefix,
  212. osiAddress->tp_addr[i++]
  213. );
  214. for (; i<osiAddress->tp_tsel_len; i++) {
  215. if (CheckControlC ())
  216. break;
  217. dprintf ("-%02.2X", osiAddress->tp_addr[i]);
  218. }
  219. dprintf ("\n");
  220. }
  221. if (osiAddress->tp_taddr_len>i) {
  222. INT j = i;
  223. dprintf(
  224. "%s Address = %02.2Xn",
  225. Prefix,
  226. osiAddress->tp_addr[j++]
  227. );
  228. for ( ; j<osiAddress->tp_taddr_len; j++) {
  229. if (CheckControlC ())
  230. break;
  231. dprintf ("-%02.2X", osiAddress->tp_addr[j]);
  232. }
  233. dprintf ("(");
  234. for (; i<osiAddress->tp_taddr_len; i++) {
  235. if (CheckControlC ())
  236. break;
  237. if (isprint (osiAddress->tp_addr[i])) {
  238. dprintf ("%c", osiAddress->tp_addr[i]);
  239. }
  240. else {
  241. dprintf (".");
  242. }
  243. }
  244. dprintf (")\n");
  245. }
  246. }
  247. break;
  248. case AFD_TDI_ADDRESS_TYPE_ATM : {
  249. AFD_TDI_ADDRESS_ATM UNALIGNED *atmAddress;
  250. UINT i;
  251. atmAddress = (AFD_TDI_ADDRESS_ATM UNALIGNED *)&Address->Address[0].Address[2];
  252. dprintf(
  253. "%s Type = ",
  254. Prefix
  255. );
  256. if (atmAddress->AddressType==AFD_ATM_E164) {
  257. dprintf ("E164");
  258. }
  259. else {
  260. switch (atmAddress->AddressType) {
  261. case AFD_ATM_NSAP:
  262. dprintf ("NSAP");
  263. break;
  264. case AFD_SAP_FIELD_ABSENT:
  265. dprintf ("SAP_FIELD_ABSENT");
  266. break;
  267. case AFD_SAP_FIELD_ANY:
  268. dprintf ("SAP_FIELD_ANY");
  269. break;
  270. case AFD_SAP_FIELD_ANY_AESA_SEL:
  271. dprintf ("SAP_FIELD_ANY_AESA_SEL");
  272. break;
  273. case AFD_SAP_FIELD_ANY_AESA_REST:
  274. dprintf ("SAP_FIELD_ANY_AESA_REST");
  275. break;
  276. }
  277. }
  278. dprintf (" (%lx)\n",
  279. atmAddress->AddressType);
  280. dprintf(
  281. "%s Address = ",
  282. Prefix
  283. );
  284. if (atmAddress->AddressType==AFD_ATM_E164) {
  285. dprintf ("+");
  286. for (i=0; i<atmAddress->NumberOfDigits; i++) {
  287. if (CheckControlC ())
  288. break;
  289. if (isdigit (atmAddress->Address[i])) {
  290. dprintf ("%c",atmAddress->Address[i]);
  291. }
  292. else {
  293. dprintf ("<%02.2X>", atmAddress->Address[i]);
  294. }
  295. }
  296. }
  297. else {
  298. for (i=0; i<atmAddress->NumberOfDigits; i++) {
  299. UCHAR val;
  300. if (CheckControlC ())
  301. break;
  302. val = atmAddress->Address[i]>>4;
  303. dprintf ("%c", (val<=9) ? val+'0' : val+('A'-10));
  304. val = atmAddress->Address[i]&0xF;
  305. dprintf ("%c", (val<=9) ? val+'0' : val+('A'-10));
  306. }
  307. }
  308. dprintf ("\n");
  309. }
  310. break;
  311. default :
  312. dprintf(
  313. "%s Unsupported address type\n",
  314. Prefix
  315. );
  316. break;
  317. }
  318. } // DumpTransportAddress
  319. INT
  320. MyIp6AddressToString (
  321. PIN6_ADDR Addr,
  322. PCHAR S,
  323. INT L
  324. )
  325. {
  326. int maxFirst, maxLast;
  327. int curFirst, curLast;
  328. int i;
  329. int endHex = 8, n = 0;
  330. // Check for IPv6-compatible, IPv4-mapped, and IPv4-translated
  331. // addresses
  332. if ((Addr->s6_words[0] == 0) && (Addr->s6_words[1] == 0) &&
  333. (Addr->s6_words[2] == 0) && (Addr->s6_words[3] == 0) &&
  334. (Addr->s6_words[6] != 0)) {
  335. if ((Addr->s6_words[4] == 0) &&
  336. ((Addr->s6_words[5] == 0) || (Addr->s6_words[5] == 0xffff)))
  337. {
  338. // compatible or mapped
  339. n += _snprintf(&S[n], L-1-n, "::%s%u.%u.%u.%u",
  340. Addr->s6_words[5] == 0 ? "" : "ffff:",
  341. Addr->s6_bytes[12], Addr->s6_bytes[13],
  342. Addr->s6_bytes[14], Addr->s6_bytes[15]);
  343. S[n]=0;
  344. return n;
  345. }
  346. else if ((Addr->s6_words[4] == 0xffff) && (Addr->s6_words[5] == 0)) {
  347. // translated
  348. n += _snprintf(&S[n], L-1-n, "::ffff:0:%u.%u.%u.%u",
  349. Addr->s6_bytes[12], Addr->s6_bytes[13],
  350. Addr->s6_bytes[14], Addr->s6_bytes[15]);
  351. S[n]=0;
  352. return n;
  353. }
  354. }
  355. // Find largest contiguous substring of zeroes
  356. // A substring is [First, Last), so it's empty if First == Last.
  357. maxFirst = maxLast = 0;
  358. curFirst = curLast = 0;
  359. // ISATAP EUI64 starts with 00005EFE (or 02005EFE)...
  360. if (((Addr->s6_words[4] & 0xfffd) == 0) && (Addr->s6_words[5] == 0xfe5e)) {
  361. endHex = 6;
  362. }
  363. for (i = 0; i < endHex; i++) {
  364. if (Addr->s6_words[i] == 0) {
  365. // Extend current substring
  366. curLast = i+1;
  367. // Check if current is now largest
  368. if (curLast - curFirst > maxLast - maxFirst) {
  369. maxFirst = curFirst;
  370. maxLast = curLast;
  371. }
  372. }
  373. else {
  374. // Start a new substring
  375. curFirst = curLast = i+1;
  376. }
  377. }
  378. // Ignore a substring of length 1.
  379. if (maxLast - maxFirst <= 1)
  380. maxFirst = maxLast = 0;
  381. // Write colon-separated words.
  382. // A double-colon takes the place of the longest string of zeroes.
  383. // All zeroes is just "::".
  384. for (i = 0; i < endHex; i++) {
  385. // Skip over string of zeroes
  386. if ((maxFirst <= i) && (i < maxLast)) {
  387. n += _snprintf(&S[n], L-1-n, "::");
  388. i = maxLast-1;
  389. continue;
  390. }
  391. // Need colon separator if not at beginning
  392. if ((i != 0) && (i != maxLast))
  393. n += _snprintf(&S[n], L-1-n, ":");
  394. n += _snprintf(&S[n], L-1-n, "%x", RtlUshortByteSwap(Addr->s6_words[i]));
  395. }
  396. if (endHex < 8) {
  397. n += _snprintf(&S[n], L-1-n, ":%u.%u.%u.%u",
  398. Addr->s6_bytes[12], Addr->s6_bytes[13],
  399. Addr->s6_bytes[14], Addr->s6_bytes[15]);
  400. }
  401. S[n] = 0;
  402. return n;
  403. }
  404. LPSTR
  405. TransportAddressToString(
  406. PTRANSPORT_ADDRESS Address,
  407. ULONG64 ActualAddress
  408. )
  409. /*++
  410. Routine Description:
  411. Converts specified transport address to string
  412. Arguments:
  413. Address - Points to the TRANSPORT_ADDRESS to dump.
  414. Return Value:
  415. None.
  416. --*/
  417. {
  418. static CHAR buffer[MAX_ADDRESS_STRING];
  419. INT n;
  420. switch( Address->Address[0].AddressType ) {
  421. case TDI_ADDRESS_TYPE_IP : {
  422. PTA_IP_ADDRESS ipAddress;
  423. ipAddress = (PTA_IP_ADDRESS)Address;
  424. _snprintf (buffer, sizeof (buffer)-1, "%d.%d.%d.%d:%d",
  425. UC(ipAddress->Address00.in_addr >> 0),
  426. UC(ipAddress->Address00.in_addr >> 8),
  427. UC(ipAddress->Address00.in_addr >> 16),
  428. UC(ipAddress->Address00.in_addr >> 24),
  429. NTOHS(ipAddress->Address00.sin_port)
  430. );
  431. buffer[sizeof(buffer)-1] = 0;
  432. }
  433. break;
  434. case TDI_ADDRESS_TYPE_IP6: {
  435. PTA_IP6_ADDRESS ip6Address;
  436. ip6Address = (PTA_IP6_ADDRESS)Address;
  437. n = 1;
  438. buffer[0] = '[';
  439. n += MyIp6AddressToString (
  440. (PIN6_ADDR)&ip6Address->Address[0].Address[0].sin6_addr,
  441. &buffer[n],
  442. sizeof (buffer)-n);
  443. if (ip6Address->Address00.sin6_scope_id != 0)
  444. n += _snprintf(&buffer[n], sizeof (buffer)-1-n, "%%%u", ip6Address->Address00.sin6_scope_id);
  445. _snprintf (&buffer[n], sizeof (buffer)-1-n, "]:%d",NTOHS(ip6Address->Address00.sin6_port));
  446. buffer[sizeof(buffer)-1] = 0;
  447. }
  448. break;
  449. case TDI_ADDRESS_TYPE_IPX : {
  450. PTA_IPX_ADDRESS ipxAddress;
  451. ipxAddress = (PTA_IPX_ADDRESS)Address;
  452. _snprintf (buffer, sizeof (buffer)-1,
  453. "%8.8x:%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x:%4.4x",
  454. NTOHL(ipxAddress->Address00.NetworkAddress),
  455. ipxAddress->Address00.NodeAddress[0],
  456. ipxAddress->Address00.NodeAddress[1],
  457. ipxAddress->Address00.NodeAddress[2],
  458. ipxAddress->Address00.NodeAddress[3],
  459. ipxAddress->Address00.NodeAddress[4],
  460. ipxAddress->Address00.NodeAddress[5],
  461. NTOHS(ipxAddress->Address00.Socket)
  462. );
  463. buffer[sizeof(buffer)-1] = 0;
  464. }
  465. break;
  466. case TDI_ADDRESS_TYPE_NETBIOS : {
  467. PTA_NETBIOS_ADDRESS netbiosAddress;
  468. UCHAR netbiosName[16];
  469. INT i;
  470. BOOLEAN doascii = FALSE;
  471. netbiosAddress = (PTA_NETBIOS_ADDRESS)Address;
  472. for (i=0; i<15; i++) {
  473. if (netbiosAddress->Address00.NetbiosName[i]==0)
  474. break;
  475. else if (isprint (netbiosAddress->Address00.NetbiosName[i])) {
  476. doascii = TRUE;
  477. }
  478. else {
  479. doascii = FALSE;
  480. break;
  481. }
  482. }
  483. n = _snprintf (buffer, sizeof (buffer)-1, "%s:",
  484. NetbiosNameTypeToString( netbiosAddress->Address00.NetbiosNameType));
  485. if (doascii) {
  486. RtlCopyMemory(
  487. netbiosName,
  488. netbiosAddress->Address00.NetbiosName,
  489. 15
  490. );
  491. netbiosName[15] = 0;
  492. _snprintf (&buffer[n], sizeof (buffer)-1-n, "%s:0x%2.2x",
  493. netbiosName,
  494. netbiosAddress->Address00.NetbiosName[15]
  495. );
  496. }
  497. else {
  498. n = 0;
  499. for (i=0; i<sizeof (netbiosAddress->Address00.NetbiosName); i++) {
  500. n += _snprintf (&buffer[n], sizeof (buffer)-1-n,
  501. "%2.2x", (UCHAR)netbiosAddress->Address00.NetbiosName[i]);
  502. }
  503. }
  504. buffer[sizeof(buffer)-1] = 0;
  505. }
  506. break;
  507. case AFD_TDI_ADDRESS_TYPE_ATM : {
  508. AFD_TDI_ADDRESS_ATM UNALIGNED *atmAddress;
  509. UINT i;
  510. atmAddress = (AFD_TDI_ADDRESS_ATM UNALIGNED *)&Address->Address[0].Address[2];
  511. n = 0;
  512. if (atmAddress->AddressType==AFD_ATM_E164) {
  513. buffer [n++]= '+';
  514. for (i=0; i<atmAddress->NumberOfDigits; i++) {
  515. if (CheckControlC ())
  516. break;
  517. if (isdigit (atmAddress->Address[i])) {
  518. n += _snprintf (&buffer[n], sizeof (buffer)-1-n, "%c",atmAddress->Address[i]);
  519. }
  520. else {
  521. n += _snprintf (&buffer[n], sizeof (buffer)-1-n, "<%02.2X>", atmAddress->Address[i]);
  522. }
  523. }
  524. }
  525. else {
  526. for (i=0; i<atmAddress->NumberOfDigits; i++) {
  527. UCHAR val;
  528. if (CheckControlC ())
  529. break;
  530. val = atmAddress->Address[i]>>4;
  531. n += _snprintf (&buffer[n], sizeof (buffer)-1-n, "%c", (val<=9) ? val+'0' : val+('A'-10));
  532. val = atmAddress->Address[i]&0xF;
  533. n += _snprintf (&buffer[n], sizeof (buffer)-1-n, "%c", (val<=9) ? val+'0' : val+('A'-10));
  534. }
  535. }
  536. buffer[sizeof(buffer)-1] = 0;
  537. }
  538. default :
  539. _snprintf(buffer, sizeof (buffer)-1, "@ %I64x", DISP_PTR(ActualAddress));
  540. buffer[sizeof(buffer)-1] = 0;
  541. break;
  542. }
  543. return buffer;
  544. } // TransportAddressToString
  545. LPSTR
  546. TransportPortToString(
  547. PTRANSPORT_ADDRESS Address,
  548. ULONG64 ActualAddress
  549. )
  550. /*++
  551. Routine Description:
  552. Converts specified transport address to string
  553. Arguments:
  554. Address - Points to the TRANSPORT_ADDRESS to dump.
  555. Return Value:
  556. None.
  557. --*/
  558. {
  559. static CHAR buffer[8];
  560. switch( Address->Address[0].AddressType ) {
  561. case TDI_ADDRESS_TYPE_IP : {
  562. PTA_IP_ADDRESS ipAddress;
  563. ipAddress = (PTA_IP_ADDRESS)Address;
  564. _snprintf (buffer, sizeof (buffer)-1, "%5u",
  565. NTOHS(ipAddress->Address00.sin_port)
  566. );
  567. buffer[sizeof(buffer)-1] = 0;
  568. }
  569. break;
  570. case TDI_ADDRESS_TYPE_IP6: {
  571. PTA_IP6_ADDRESS ip6Address;
  572. ip6Address = (PTA_IP6_ADDRESS)Address;
  573. _snprintf (buffer, sizeof (buffer)-1, "%5u",
  574. NTOHS(ip6Address->Address00.sin6_port));
  575. buffer[sizeof(buffer)-1] = 0;
  576. }
  577. break;
  578. case TDI_ADDRESS_TYPE_IPX : {
  579. PTA_IPX_ADDRESS ipxAddress;
  580. ipxAddress = (PTA_IPX_ADDRESS)Address;
  581. _snprintf (buffer, sizeof (buffer)-1, "x%4.4x",
  582. NTOHS(ipxAddress->Address00.Socket)
  583. );
  584. buffer[sizeof(buffer)-1] = 0;
  585. }
  586. break;
  587. case TDI_ADDRESS_TYPE_NETBIOS : {
  588. PTA_NETBIOS_ADDRESS netbiosAddress;
  589. netbiosAddress = (PTA_NETBIOS_ADDRESS)Address;
  590. _snprintf (buffer, sizeof (buffer)-1, "x%4.4x",
  591. netbiosAddress->Address00.NetbiosName[15]
  592. );
  593. buffer[sizeof(buffer)-1] = 0;
  594. }
  595. break;
  596. default :
  597. _snprintf(buffer, sizeof (buffer)-1, "?????");
  598. buffer[sizeof(buffer)-1] = 0;
  599. break;
  600. }
  601. return buffer;
  602. } // TransportPortToString
  603. //
  604. // Private functions.
  605. //
  606. PSTR
  607. TransportAddressTypeToString(
  608. USHORT AddressType
  609. )
  610. /*++
  611. Routine Description:
  612. Maps a transport address type to a displayable string.
  613. Arguments:
  614. AddressType - The transport address type to map.
  615. Return Value:
  616. PSTR - Points to the displayable form of the tranport address type.
  617. --*/
  618. {
  619. switch( AddressType ) {
  620. case TDI_ADDRESS_TYPE_UNSPEC :
  621. return "Unspecified";
  622. case TDI_ADDRESS_TYPE_UNIX :
  623. return "Unix";
  624. case TDI_ADDRESS_TYPE_IP :
  625. return "Ip";
  626. case TDI_ADDRESS_TYPE_IP6 :
  627. return "Ip6";
  628. case TDI_ADDRESS_TYPE_IMPLINK :
  629. return "Implink";
  630. case TDI_ADDRESS_TYPE_PUP :
  631. return "Pup";
  632. case TDI_ADDRESS_TYPE_CHAOS :
  633. return "Chaos";
  634. case TDI_ADDRESS_TYPE_IPX :
  635. return "Ipx";
  636. case TDI_ADDRESS_TYPE_NBS :
  637. return "Nbs (or AF_OSI)";
  638. case TDI_ADDRESS_TYPE_ECMA :
  639. return "Ecma";
  640. case TDI_ADDRESS_TYPE_DATAKIT :
  641. return "Datakit";
  642. case TDI_ADDRESS_TYPE_CCITT :
  643. return "Ccitt";
  644. case TDI_ADDRESS_TYPE_SNA :
  645. return "Sna";
  646. case TDI_ADDRESS_TYPE_DECnet :
  647. return "Decnet";
  648. case TDI_ADDRESS_TYPE_DLI :
  649. return "Dli";
  650. case TDI_ADDRESS_TYPE_LAT :
  651. return "Lat";
  652. case TDI_ADDRESS_TYPE_HYLINK :
  653. return "Hylink";
  654. case TDI_ADDRESS_TYPE_APPLETALK :
  655. return "Appletalk";
  656. case TDI_ADDRESS_TYPE_NETBIOS :
  657. return "Netbios";
  658. case TDI_ADDRESS_TYPE_8022 :
  659. return "8022";
  660. case TDI_ADDRESS_TYPE_OSI_TSAP :
  661. return "OSI TSAP";
  662. case TDI_ADDRESS_TYPE_NETONE :
  663. return "Netone";
  664. case AFD_TDI_ADDRESS_TYPE_ATM :
  665. return "ATM";
  666. }
  667. return "UNKNOWN";
  668. } // TransportAddressTypeToString
  669. PSTR
  670. NetbiosNameTypeToStringBrief(
  671. USHORT NetbiosNameType
  672. )
  673. /*++
  674. Routine Description:
  675. Maps a NetBIOS name type to a displayable string.
  676. Arguments:
  677. NetbiosNameType - The NetBIOS name type to map.
  678. Return Value:
  679. PSTR - Points to the displayable form of the NetBIOS name type.
  680. --*/
  681. {
  682. switch( NetbiosNameType ) {
  683. case TDI_ADDRESS_NETBIOS_TYPE_UNIQUE :
  684. return "U";
  685. case TDI_ADDRESS_NETBIOS_TYPE_GROUP :
  686. return "G";
  687. case TDI_ADDRESS_NETBIOS_TYPE_QUICK_UNIQUE :
  688. return "QU";
  689. case TDI_ADDRESS_NETBIOS_TYPE_QUICK_GROUP :
  690. return "QG";
  691. }
  692. return "?";
  693. } // NetbiosNameTypeToStringBrief
  694. PSTR
  695. NetbiosNameTypeToString(
  696. USHORT NetbiosNameType
  697. )
  698. /*++
  699. Routine Description:
  700. Maps a NetBIOS name type to a displayable string.
  701. Arguments:
  702. NetbiosNameType - The NetBIOS name type to map.
  703. Return Value:
  704. PSTR - Points to the displayable form of the NetBIOS name type.
  705. --*/
  706. {
  707. switch( NetbiosNameType ) {
  708. case TDI_ADDRESS_NETBIOS_TYPE_UNIQUE :
  709. return "Unique";
  710. case TDI_ADDRESS_NETBIOS_TYPE_GROUP :
  711. return "Group";
  712. case TDI_ADDRESS_NETBIOS_TYPE_QUICK_UNIQUE :
  713. return "Quick Unique";
  714. case TDI_ADDRESS_NETBIOS_TYPE_QUICK_GROUP :
  715. return "Quick Group";
  716. }
  717. return "UNKNOWN";
  718. } // NetbiosNameTypeToString