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.

794 lines
21 KiB

  1. #include <nt.h>
  2. #include <ntrtl.h>
  3. #include <nturtl.h>
  4. #include <windows.h>
  5. #include <winsock2.h>
  6. #include <wsipx.h>
  7. #include <svcguid.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <rpc.h>
  11. #include <rpcdce.h>
  12. #include "..\..\dnslib\dnslib.h"
  13. VOID
  14. PrintRecord (
  15. IN PDNS_RECORD pDnsRecord );
  16. VOID
  17. PrintARecord (
  18. IN PDNS_RECORD pDnsRecord );
  19. VOID
  20. PrintSOARecord (
  21. IN PDNS_RECORD pDnsRecord );
  22. VOID
  23. PrintPTRRecord (
  24. IN PDNS_RECORD pDnsRecord );
  25. VOID
  26. PrintMINFORecord (
  27. IN PDNS_RECORD pDnsRecord );
  28. VOID
  29. PrintMXRecord (
  30. IN PDNS_RECORD pDnsRecord );
  31. VOID
  32. PrintHINFORecord (
  33. IN PDNS_RECORD pDnsRecord );
  34. VOID
  35. PrintNULLRecord (
  36. IN PDNS_RECORD pDnsRecord );
  37. VOID
  38. PrintWKSRecord (
  39. IN PDNS_RECORD pDnsRecord );
  40. VOID
  41. PrintAAAARecord (
  42. IN PDNS_RECORD pDnsRecord );
  43. VOID
  44. PrintSRVRecord (
  45. IN PDNS_RECORD pDnsRecord );
  46. VOID
  47. PrintATMARecord (
  48. IN PDNS_RECORD pDnsRecord );
  49. VOID
  50. PrintWINSRecord (
  51. IN PDNS_RECORD pDnsRecord );
  52. VOID
  53. PrintWINSRRecord (
  54. IN PDNS_RECORD pDnsRecord );
  55. VOID
  56. PrintDNSFlags (
  57. IN DNSREC_FLAGS Flags );
  58. VOID
  59. PrintIpAddress (
  60. IN DWORD dwIpAddress )
  61. {
  62. printf( " %d.%d.%d.%d\n",
  63. ((BYTE *) &dwIpAddress)[0],
  64. ((BYTE *) &dwIpAddress)[1],
  65. ((BYTE *) &dwIpAddress)[2],
  66. ((BYTE *) &dwIpAddress)[3] );
  67. }
  68. #define BUFFSIZE 3000
  69. GUID DnsRRGuidA = SVCID_DNS_TYPE_A;
  70. GUID DnsRRGuidNS = SVCID_DNS_TYPE_NS;
  71. GUID DnsRRGuidMD = SVCID_DNS_TYPE_MD;
  72. GUID DnsRRGuidMF = SVCID_DNS_TYPE_MF;
  73. GUID DnsRRGuidCNAME = SVCID_DNS_TYPE_CNAME;
  74. GUID DnsRRGuidSOA = SVCID_DNS_TYPE_SOA;
  75. GUID DnsRRGuidMB = SVCID_DNS_TYPE_MB;
  76. GUID DnsRRGuidMG = SVCID_DNS_TYPE_MG;
  77. GUID DnsRRGuidMR = SVCID_DNS_TYPE_MR;
  78. GUID DnsRRGuidNULL = SVCID_DNS_TYPE_NULL;
  79. GUID DnsRRGuidWKS = SVCID_DNS_TYPE_WKS;
  80. GUID DnsRRGuidPTR = SVCID_DNS_TYPE_PTR;
  81. GUID DnsRRGuidHINFO = SVCID_DNS_TYPE_HINFO;
  82. GUID DnsRRGuidMINFO = SVCID_DNS_TYPE_MINFO;
  83. GUID DnsRRGuidMX = SVCID_DNS_TYPE_MX;
  84. GUID DnsRRGuidTEXT = SVCID_DNS_TYPE_TEXT;
  85. GUID DnsRRGuidRP = SVCID_DNS_TYPE_RP;
  86. GUID DnsRRGuidAFSDB = SVCID_DNS_TYPE_AFSDB;
  87. GUID DnsRRGuidX25 = SVCID_DNS_TYPE_X25;
  88. GUID DnsRRGuidISDN = SVCID_DNS_TYPE_ISDN;
  89. GUID DnsRRGuidRT = SVCID_DNS_TYPE_RT;
  90. GUID DnsRRGuidNSAP = SVCID_DNS_TYPE_NSAP;
  91. GUID DnsRRGuidNSAPPTR = SVCID_DNS_TYPE_NSAPPTR;
  92. GUID DnsRRGuidSIG = SVCID_DNS_TYPE_SIG;
  93. GUID DnsRRGuidKEY = SVCID_DNS_TYPE_KEY;
  94. GUID DnsRRGuidPX = SVCID_DNS_TYPE_PX;
  95. GUID DnsRRGuidGPOS = SVCID_DNS_TYPE_GPOS;
  96. GUID DnsRRGuidAAAA = SVCID_DNS_TYPE_AAAA;
  97. GUID DnsRRGuidLOC = SVCID_DNS_TYPE_LOC;
  98. GUID DnsRRGuidNXT = SVCID_DNS_TYPE_NXT;
  99. GUID DnsRRGuidSRV = SVCID_DNS_TYPE_SRV;
  100. GUID DnsRRGuidATMA = SVCID_DNS_TYPE_ATMA;
  101. _cdecl
  102. main(int argc, char **argv)
  103. {
  104. WCHAR Buffer[BUFFSIZE];
  105. PWSAQUERYSETW Query = (PWSAQUERYSETW)Buffer;
  106. HANDLE hRnr;
  107. DWORD dwQuerySize = BUFFSIZE;
  108. WSADATA wsaData;
  109. LPGUID lpServiceGuid = NULL;
  110. DWORD iter;
  111. LONG cch;
  112. DWORD Status = NO_ERROR;
  113. WORD wType;
  114. WCHAR usName[1000];
  115. if ( argc != 3 )
  116. {
  117. printf( "\nUsage: ws2qry <DNS Name> <Type>\n" );
  118. printf( "\nWhere:\n" );
  119. printf( " DNS Name - Server_X.dbsd-test.microsoft.com\n" );
  120. printf( " Type - 1 | A, 2 | ns, 12 | Ptr, 33 | SRV, ...\n" );
  121. return(-1);
  122. }
  123. cch = MultiByteToWideChar(
  124. CP_ACP,
  125. 0L,
  126. argv[1],
  127. -1,
  128. usName,
  129. 1000
  130. );
  131. if (!cch)
  132. {
  133. Status = GetLastError();
  134. return (Status);
  135. }
  136. if ( Dns_NameCompare_A( "A", argv[2] ) )
  137. {
  138. wType = DNS_TYPE_A;
  139. lpServiceGuid = &DnsRRGuidA;
  140. }
  141. else if ( Dns_NameCompare_A( "NS", argv[2] ) )
  142. {
  143. wType = DNS_TYPE_NS;
  144. lpServiceGuid = &DnsRRGuidNS;
  145. }
  146. else if ( Dns_NameCompare_A( "MD", argv[2] ) )
  147. {
  148. wType = DNS_TYPE_MD;
  149. lpServiceGuid = &DnsRRGuidMD;
  150. }
  151. else if ( Dns_NameCompare_A( "MF", argv[2] ) )
  152. {
  153. wType = DNS_TYPE_MF;
  154. lpServiceGuid = &DnsRRGuidMF;
  155. }
  156. else if ( Dns_NameCompare_A( "CNAME", argv[2] ) )
  157. {
  158. wType = DNS_TYPE_CNAME;
  159. lpServiceGuid = &DnsRRGuidCNAME;
  160. }
  161. else if ( Dns_NameCompare_A( "SOA", argv[2] ) )
  162. {
  163. wType = DNS_TYPE_SOA;
  164. lpServiceGuid = &DnsRRGuidSOA;
  165. }
  166. else if ( Dns_NameCompare_A( "MB", argv[2] ) )
  167. {
  168. wType = DNS_TYPE_MB;
  169. lpServiceGuid = &DnsRRGuidMB;
  170. }
  171. else if ( Dns_NameCompare_A( "MG", argv[2] ) )
  172. {
  173. wType = DNS_TYPE_MG;
  174. lpServiceGuid = &DnsRRGuidMG;
  175. }
  176. else if ( Dns_NameCompare_A( "MR", argv[2] ) )
  177. {
  178. wType = DNS_TYPE_MR;
  179. lpServiceGuid = &DnsRRGuidMR;
  180. }
  181. else if ( Dns_NameCompare_A( "NULL", argv[2] ) )
  182. {
  183. wType = DNS_TYPE_NULL;
  184. lpServiceGuid = &DnsRRGuidNULL;
  185. }
  186. else if ( Dns_NameCompare_A( "WKS", argv[2] ) )
  187. {
  188. wType = DNS_TYPE_WKS;
  189. lpServiceGuid = &DnsRRGuidWKS;
  190. }
  191. else if ( Dns_NameCompare_A( "PTR", argv[2] ) )
  192. {
  193. wType = DNS_TYPE_PTR;
  194. lpServiceGuid = &DnsRRGuidPTR;
  195. }
  196. else if ( Dns_NameCompare_A( "HINFO", argv[2] ) )
  197. {
  198. wType = DNS_TYPE_HINFO;
  199. lpServiceGuid = &DnsRRGuidHINFO;
  200. }
  201. else if ( Dns_NameCompare_A( "MINFO", argv[2] ) )
  202. {
  203. wType = DNS_TYPE_MINFO;
  204. lpServiceGuid = &DnsRRGuidMINFO;
  205. }
  206. else if ( Dns_NameCompare_A( "MX", argv[2] ) )
  207. {
  208. wType = DNS_TYPE_MX;
  209. lpServiceGuid = &DnsRRGuidMX;
  210. }
  211. else if ( Dns_NameCompare_A( "TEXT", argv[2] ) )
  212. {
  213. wType = DNS_TYPE_TEXT;
  214. lpServiceGuid = &DnsRRGuidTEXT;
  215. }
  216. else if ( Dns_NameCompare_A( "RP", argv[2] ) )
  217. {
  218. wType = DNS_TYPE_RP;
  219. lpServiceGuid = &DnsRRGuidRP;
  220. }
  221. else if ( Dns_NameCompare_A( "AFSDB", argv[2] ) )
  222. {
  223. wType = DNS_TYPE_AFSDB;
  224. lpServiceGuid = &DnsRRGuidAFSDB;
  225. }
  226. else if ( Dns_NameCompare_A( "X25", argv[2] ) )
  227. {
  228. wType = DNS_TYPE_X25;
  229. lpServiceGuid = &DnsRRGuidX25;
  230. }
  231. else if ( Dns_NameCompare_A( "ISDN", argv[2] ) )
  232. {
  233. wType = DNS_TYPE_ISDN;
  234. lpServiceGuid = &DnsRRGuidISDN;
  235. }
  236. else if ( Dns_NameCompare_A( "RT", argv[2] ) )
  237. {
  238. wType = DNS_TYPE_RT;
  239. lpServiceGuid = &DnsRRGuidRT;
  240. }
  241. else if ( Dns_NameCompare_A( "NSAP", argv[2] ) )
  242. {
  243. wType = DNS_TYPE_NSAP;
  244. lpServiceGuid = &DnsRRGuidNSAP;
  245. }
  246. else if ( Dns_NameCompare_A( "NSAPPTR", argv[2] ) )
  247. {
  248. wType = DNS_TYPE_NSAPPTR;
  249. lpServiceGuid = &DnsRRGuidNSAPPTR;
  250. }
  251. else if ( Dns_NameCompare_A( "SIG", argv[2] ) )
  252. {
  253. wType = DNS_TYPE_SIG;
  254. lpServiceGuid = &DnsRRGuidSIG;
  255. }
  256. else if ( Dns_NameCompare_A( "KEY", argv[2] ) )
  257. {
  258. wType = DNS_TYPE_KEY;
  259. lpServiceGuid = &DnsRRGuidKEY;
  260. }
  261. else if ( Dns_NameCompare_A( "PX", argv[2] ) )
  262. {
  263. wType = DNS_TYPE_PX;
  264. lpServiceGuid = &DnsRRGuidPX;
  265. }
  266. else if ( Dns_NameCompare_A( "GPOS", argv[2] ) )
  267. {
  268. wType = DNS_TYPE_GPOS;
  269. lpServiceGuid = &DnsRRGuidGPOS;
  270. }
  271. else if ( Dns_NameCompare_A( "AAAA", argv[2] ) )
  272. {
  273. wType = DNS_TYPE_AAAA;
  274. lpServiceGuid = &DnsRRGuidAAAA;
  275. }
  276. else if ( Dns_NameCompare_A( "LOC", argv[2] ) )
  277. {
  278. wType = DNS_TYPE_LOC;
  279. lpServiceGuid = &DnsRRGuidLOC;
  280. }
  281. else if ( Dns_NameCompare_A( "NXT", argv[2] ) )
  282. {
  283. wType = DNS_TYPE_NXT;
  284. lpServiceGuid = &DnsRRGuidNXT;
  285. }
  286. else if ( Dns_NameCompare_A( "SRV", argv[2] ) )
  287. {
  288. wType = DNS_TYPE_SRV;
  289. lpServiceGuid = &DnsRRGuidSRV;
  290. }
  291. else if ( Dns_NameCompare_A( "ATMA", argv[2] ) )
  292. {
  293. wType = DNS_TYPE_ATMA;
  294. lpServiceGuid = &DnsRRGuidATMA;
  295. }
  296. else
  297. {
  298. wType = (WORD) atoi( argv[2] );
  299. }
  300. printf( "\nGoing to look up ( %S, %d ) ...\n\n",
  301. usName,
  302. wType );
  303. WSAStartup(MAKEWORD(2, 0), &wsaData);
  304. memset(Query, 0, sizeof(*Query));
  305. Query->lpszServiceInstanceName = usName;
  306. Query->dwSize = sizeof(*Query);
  307. Query->dwNameSpace = NS_DNS;
  308. Query->lpServiceClassId = lpServiceGuid;
  309. if( WSALookupServiceBeginW( Query,
  310. LUP_RETURN_ADDR |
  311. LUP_RETURN_ALIASES |
  312. LUP_RETURN_BLOB |
  313. LUP_RETURN_NAME,
  314. &hRnr ) == SOCKET_ERROR )
  315. {
  316. printf( "LookupBegin failed %d\n", GetLastError() );
  317. }
  318. while ( WSALookupServiceNextW( hRnr,
  319. 0,
  320. &dwQuerySize,
  321. Query ) == NO_ERROR )
  322. {
  323. printf( "Next got: \n" );
  324. printf( " dwSize = %d\n",
  325. Query->dwSize );
  326. printf( " dwOutputFlags = %d\n",
  327. Query->dwOutputFlags );
  328. printf( " lpszServiceInstanceName = %S\n",
  329. Query->lpszServiceInstanceName );
  330. if ( Query->lpVersion )
  331. {
  332. printf( " lpVersion->dwVersion = %d\n",
  333. Query->lpVersion->dwVersion );
  334. printf( " lpVersion->ecHow = %d\n",
  335. Query->lpVersion->ecHow );
  336. }
  337. if ( Query->lpszComment )
  338. {
  339. printf( " lpszComment = %ws\n",
  340. Query->lpszComment );
  341. }
  342. printf( " dwNameSpace = %d\n",
  343. Query->dwNameSpace );
  344. if ( Query->lpszContext )
  345. {
  346. printf( " lpszContext = %S\n",
  347. Query->lpszContext );
  348. }
  349. printf( " dwNumberOfCsAddrs = %d\n",
  350. Query->dwNumberOfCsAddrs );
  351. for ( iter = 0; iter < Query->dwNumberOfCsAddrs; iter++ )
  352. {
  353. if ( Query->lpcsaBuffer[iter].RemoteAddr.lpSockaddr->sa_data )
  354. {
  355. printf( " Address : " );
  356. PrintIpAddress( * ((DWORD*) &Query->lpcsaBuffer[iter].RemoteAddr.lpSockaddr->sa_data[2]) );
  357. }
  358. }
  359. if ( Query->lpBlob )
  360. {
  361. PDNS_RECORD pDNSRecord = NULL;
  362. PDNS_RECORD pTempDNSRecord = NULL;
  363. PDNS_MESSAGE_BUFFER pMsg =
  364. (PDNS_MESSAGE_BUFFER) Query->lpBlob->pBlobData;
  365. SWAP_COUNT_BYTES( &pMsg->MessageHead );
  366. printf( "Extracting record(s) from message buffer ...\n\n" );
  367. Status = DnsExtractRecordsFromMessage_W( pMsg,
  368. (WORD) Query->lpBlob->cbSize,
  369. &pDNSRecord );
  370. if ( Status )
  371. {
  372. printf( "DnsExtractRecordsFromMessage_W call failed with error: 0x%.8X\n", Status );
  373. pDNSRecord = NULL;
  374. }
  375. pTempDNSRecord = pDNSRecord;
  376. while ( pTempDNSRecord )
  377. {
  378. printf( " Record:\n" );
  379. printf( " -------------------------------------\n" );
  380. printf( " Name : %S\n", pTempDNSRecord->pName );
  381. printf( " Type : %d\n", pTempDNSRecord->wType );
  382. printf( " Data Length : %d\n", pTempDNSRecord->wDataLength );
  383. printf( " Ttl (mins) : %d\n", pTempDNSRecord->dwTtl/60 );
  384. printf( " Flags : 0x%X", pTempDNSRecord->Flags.DW );
  385. PrintDNSFlags( pTempDNSRecord->Flags.S );
  386. printf( "\n" );
  387. PrintRecord( pTempDNSRecord );
  388. pTempDNSRecord = pTempDNSRecord->pNext;
  389. }
  390. DnsFreeRRSet( pDNSRecord, TRUE );
  391. }
  392. }
  393. printf( "Next finished with %d\n", GetLastError() );
  394. if( WSALookupServiceEnd( hRnr ) )
  395. {
  396. printf( "ServiceEnd failed %d\n", GetLastError() );
  397. }
  398. WSACleanup();
  399. return(0);
  400. }
  401. VOID
  402. PrintRecord (
  403. IN PDNS_RECORD pDnsRecord )
  404. {
  405. switch( pDnsRecord->wType )
  406. {
  407. case DNS_TYPE_A :
  408. PrintARecord( pDnsRecord );
  409. break;
  410. case DNS_TYPE_SOA :
  411. PrintSOARecord( pDnsRecord );
  412. break;
  413. case DNS_TYPE_PTR :
  414. case DNS_TYPE_NS :
  415. case DNS_TYPE_CNAME :
  416. case DNS_TYPE_MB :
  417. case DNS_TYPE_MD :
  418. case DNS_TYPE_MF :
  419. case DNS_TYPE_MG :
  420. case DNS_TYPE_MR :
  421. PrintPTRRecord( pDnsRecord );
  422. break;
  423. case DNS_TYPE_MINFO :
  424. case DNS_TYPE_RP :
  425. PrintMINFORecord( pDnsRecord );
  426. break;
  427. case DNS_TYPE_MX :
  428. case DNS_TYPE_AFSDB :
  429. case DNS_TYPE_RT :
  430. PrintMXRecord( pDnsRecord );
  431. break;
  432. case DNS_TYPE_HINFO :
  433. case DNS_TYPE_ISDN :
  434. case DNS_TYPE_TEXT :
  435. case DNS_TYPE_X25 :
  436. PrintHINFORecord( pDnsRecord );
  437. break;
  438. case DNS_TYPE_NULL :
  439. PrintNULLRecord( pDnsRecord );
  440. break;
  441. case DNS_TYPE_WKS :
  442. PrintWKSRecord( pDnsRecord );
  443. break;
  444. case DNS_TYPE_AAAA :
  445. PrintAAAARecord( pDnsRecord );
  446. break;
  447. case DNS_TYPE_SRV :
  448. PrintSRVRecord( pDnsRecord );
  449. break;
  450. case DNS_TYPE_ATMA :
  451. PrintATMARecord( pDnsRecord );
  452. break;
  453. case DNS_TYPE_WINS :
  454. PrintWINSRecord( pDnsRecord );
  455. break;
  456. case DNS_TYPE_NBSTAT :
  457. PrintWINSRRecord( pDnsRecord );
  458. break;
  459. default :
  460. printf( "Don't know how to print record type %d\n",
  461. pDnsRecord->wType );
  462. }
  463. }
  464. VOID
  465. PrintARecord (
  466. IN PDNS_RECORD pDnsRecord )
  467. {
  468. printf( " A record :\n" );
  469. printf( " ipAddress = %d.%d.%d.%d\n",
  470. ((BYTE *) &pDnsRecord->Data.A.ipAddress)[0],
  471. ((BYTE *) &pDnsRecord->Data.A.ipAddress)[1],
  472. ((BYTE *) &pDnsRecord->Data.A.ipAddress)[2],
  473. ((BYTE *) &pDnsRecord->Data.A.ipAddress)[3] );
  474. printf( "\n" );
  475. }
  476. VOID
  477. PrintSOARecord (
  478. IN PDNS_RECORD pDnsRecord )
  479. {
  480. printf( " SOA record :\n" );
  481. printf( " pNamePrimaryServer = %S\n",
  482. pDnsRecord->Data.SOA.pNamePrimaryServer );
  483. printf( " pNameAdministrator = %S\n",
  484. pDnsRecord->Data.SOA.pNameAdministrator );
  485. printf( " dwSerialNo = %d\n",
  486. pDnsRecord->Data.SOA.dwSerialNo );
  487. printf( " dwRefresh = %d\n",
  488. pDnsRecord->Data.SOA.dwRefresh );
  489. printf( " dwRetry = %d\n",
  490. pDnsRecord->Data.SOA.dwRetry );
  491. printf( " dwExpire = %d\n",
  492. pDnsRecord->Data.SOA.dwExpire );
  493. printf( " dwDefaultTtl = %d\n",
  494. pDnsRecord->Data.SOA.dwDefaultTtl );
  495. printf( "\n" );
  496. }
  497. VOID
  498. PrintPTRRecord (
  499. IN PDNS_RECORD pDnsRecord )
  500. {
  501. printf( " PTR, NS, CNAME, MB, MD, MF, MG, MR record :\n" );
  502. printf( " pNameHost = %S\n",
  503. pDnsRecord->Data.PTR.pNameHost );
  504. printf( "\n" );
  505. }
  506. VOID
  507. PrintMINFORecord (
  508. IN PDNS_RECORD pDnsRecord )
  509. {
  510. printf( " MINFO, RP record :\n" );
  511. printf( " pNameMailbox = %S\n",
  512. pDnsRecord->Data.MINFO.pNameMailbox );
  513. printf( " pNameErrorsMailbox = %S\n",
  514. pDnsRecord->Data.MINFO.pNameErrorsMailbox );
  515. printf( "\n" );
  516. }
  517. VOID
  518. PrintMXRecord (
  519. IN PDNS_RECORD pDnsRecord )
  520. {
  521. printf( " MX, AFSDB, RT record :\n" );
  522. printf( " pNameExchange = %S\n",
  523. pDnsRecord->Data.MX.pNameExchange );
  524. printf( " wPreference = %d\n",
  525. pDnsRecord->Data.MX.wPreference );
  526. printf( " Pad = %d\n",
  527. pDnsRecord->Data.MX.Pad );
  528. printf( "\n" );
  529. }
  530. VOID
  531. PrintHINFORecord (
  532. IN PDNS_RECORD pDnsRecord )
  533. {
  534. DWORD iter;
  535. printf( " HINFO, ISDN, TEXT, X25 record :\n" );
  536. printf( " dwStringCount = %d\n",
  537. pDnsRecord->Data.HINFO.dwStringCount );
  538. for ( iter = 0; iter < pDnsRecord->Data.HINFO.dwStringCount; iter ++ )
  539. {
  540. printf( " pStringArray[%d] = %S\n",
  541. iter,
  542. pDnsRecord->Data.HINFO.pStringArray[iter] );
  543. }
  544. printf( "\n" );
  545. }
  546. VOID
  547. PrintNULLRecord (
  548. IN PDNS_RECORD pDnsRecord )
  549. {
  550. printf( " NULL record :\n" );
  551. printf( "\n" );
  552. }
  553. VOID
  554. PrintWKSRecord (
  555. IN PDNS_RECORD pDnsRecord )
  556. {
  557. printf( " WKS record :\n" );
  558. printf( " ipAddress = %d.%d.%d.%d\n",
  559. ((BYTE *) &pDnsRecord->Data.WKS.ipAddress)[0],
  560. ((BYTE *) &pDnsRecord->Data.WKS.ipAddress)[1],
  561. ((BYTE *) &pDnsRecord->Data.WKS.ipAddress)[2],
  562. ((BYTE *) &pDnsRecord->Data.WKS.ipAddress)[3] );
  563. printf( " chProtocol = %d\n",
  564. pDnsRecord->Data.WKS.chProtocol );
  565. printf( " bBitMask = %s\n",
  566. pDnsRecord->Data.WKS.bBitMask );
  567. printf( "\n" );
  568. }
  569. VOID
  570. PrintAAAARecord (
  571. IN PDNS_RECORD pDnsRecord )
  572. {
  573. printf( " AAAA record :\n" );
  574. printf( " ipAddress = %d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d\n",
  575. ((BYTE *) &pDnsRecord->Data.AAAA.ipv6Address)[0],
  576. ((BYTE *) &pDnsRecord->Data.AAAA.ipv6Address)[1],
  577. ((BYTE *) &pDnsRecord->Data.AAAA.ipv6Address)[2],
  578. ((BYTE *) &pDnsRecord->Data.AAAA.ipv6Address)[3],
  579. ((BYTE *) &pDnsRecord->Data.AAAA.ipv6Address)[4],
  580. ((BYTE *) &pDnsRecord->Data.AAAA.ipv6Address)[5],
  581. ((BYTE *) &pDnsRecord->Data.AAAA.ipv6Address)[6],
  582. ((BYTE *) &pDnsRecord->Data.AAAA.ipv6Address)[7],
  583. ((BYTE *) &pDnsRecord->Data.AAAA.ipv6Address)[8],
  584. ((BYTE *) &pDnsRecord->Data.AAAA.ipv6Address)[9],
  585. ((BYTE *) &pDnsRecord->Data.AAAA.ipv6Address)[10],
  586. ((BYTE *) &pDnsRecord->Data.AAAA.ipv6Address)[11],
  587. ((BYTE *) &pDnsRecord->Data.AAAA.ipv6Address)[12],
  588. ((BYTE *) &pDnsRecord->Data.AAAA.ipv6Address)[13],
  589. ((BYTE *) &pDnsRecord->Data.AAAA.ipv6Address)[14],
  590. ((BYTE *) &pDnsRecord->Data.AAAA.ipv6Address)[15] );
  591. printf( "\n" );
  592. }
  593. VOID
  594. PrintSRVRecord (
  595. IN PDNS_RECORD pDnsRecord )
  596. {
  597. printf( " SRV record :\n" );
  598. printf( " pNameTarget = %S\n",
  599. pDnsRecord->Data.SRV.pNameTarget );
  600. printf( " wPriority = %d\n",
  601. pDnsRecord->Data.SRV.wPriority );
  602. printf( " wWeight = %d\n",
  603. pDnsRecord->Data.SRV.wWeight );
  604. printf( " wPort = %d\n",
  605. pDnsRecord->Data.SRV.wPort );
  606. printf( " Pad = %d\n",
  607. pDnsRecord->Data.SRV.Pad );
  608. printf( "\n" );
  609. }
  610. VOID
  611. PrintATMARecord (
  612. IN PDNS_RECORD pDnsRecord )
  613. {
  614. printf( " ATMA record :\n" );
  615. printf( " Address Type = %d\n",
  616. pDnsRecord->Data.ATMA.AddressType );
  617. if ( pDnsRecord->Data.ATMA.Address &&
  618. pDnsRecord->Data.ATMA.AddressType == DNS_ATM_TYPE_E164 )
  619. {
  620. printf( " Address = %s\n",
  621. pDnsRecord->Data.ATMA.Address );
  622. }
  623. else
  624. {
  625. DWORD iter;
  626. printf( " Address =\n\t" );
  627. for ( iter = 0; iter < pDnsRecord->wDataLength; iter++ )
  628. {
  629. printf( "%02x", (UCHAR) pDnsRecord->Data.ATMA.Address[iter] );
  630. }
  631. printf( "\n" );
  632. }
  633. printf( "\n" );
  634. }
  635. VOID
  636. PrintWINSRecord (
  637. IN PDNS_RECORD pDnsRecord )
  638. {
  639. DWORD iter;
  640. printf( " WINS record :\n" );
  641. printf( " dwMappingFlag = %d\n",
  642. pDnsRecord->Data.WINS.dwMappingFlag );
  643. printf( " dwLookupTimeout = %d\n",
  644. pDnsRecord->Data.WINS.dwLookupTimeout );
  645. printf( " dwCacheTimeout = %d\n",
  646. pDnsRecord->Data.WINS.dwCacheTimeout );
  647. printf( " cWinsServerCount = %d\n",
  648. pDnsRecord->Data.WINS.cWinsServerCount );
  649. printf( " aipWinsServers =" );
  650. for ( iter = 0; iter < pDnsRecord->Data.WINS.cWinsServerCount; iter++ )
  651. {
  652. PrintIpAddress( pDnsRecord->Data.WINS.aipWinsServers[iter] );
  653. printf( " " );
  654. }
  655. printf( "\n\n" );
  656. }
  657. VOID
  658. PrintWINSRRecord (
  659. IN PDNS_RECORD pDnsRecord )
  660. {
  661. printf( " NBSTAT record :\n" );
  662. printf( " dwMappingFlag = %d\n",
  663. pDnsRecord->Data.WINSR.dwMappingFlag );
  664. printf( " dwLookupTimeout = %d\n",
  665. pDnsRecord->Data.WINSR.dwLookupTimeout );
  666. printf( " dwCacheTimeout = %d\n",
  667. pDnsRecord->Data.WINSR.dwCacheTimeout );
  668. printf( " pNameResultDomain = %S\n",
  669. pDnsRecord->Data.WINSR.pNameResultDomain );
  670. printf( "\n" );
  671. }
  672. VOID
  673. PrintDNSFlags (
  674. IN DNSREC_FLAGS Flags )
  675. {
  676. if ( Flags.Section == DNSREC_ANSWER )
  677. {
  678. printf( " Answer" );
  679. }
  680. if ( Flags.Section == DNSREC_AUTHORITY )
  681. {
  682. printf( " Authority" );
  683. }
  684. if ( Flags.Section == DNSREC_ADDITIONAL )
  685. {
  686. printf( " Additional" );
  687. }
  688. printf( "\n" );
  689. }