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.

4069 lines
109 KiB

  1. /*++
  2. Copyright (c) 1995-2000 Microsoft Corporation
  3. Module Name:
  4. print.c
  5. Abstract:
  6. Domain Name System (DNS) Server RPC Library
  7. Print routines for RPC types
  8. Author:
  9. Jim Gilroy (jamesg) September 1995
  10. Revision History:
  11. --*/
  12. #include "dnsclip.h"
  13. #include <time.h>
  14. #define DNS_NOT_APPLICABLE "N/A"
  15. #define DNS_NOT_APPLICABLE_W L"N/A"
  16. #define DNS_NOT_PERFORMED "not since restart"
  17. //
  18. // Winsock version: copied from socket.c
  19. //
  20. #ifndef DNS_WINSOCK2
  21. #define DNS_WINSOCK_VERSION (0x0101) // Winsock 1.1
  22. #else // Winsock2
  23. #define DNS_WINSOCK_VERSION (0x0002) // Winsock 2.0
  24. #endif
  25. //
  26. // Tagged memory stat strings
  27. //
  28. // NT5 shipped version
  29. //
  30. LPSTR MemTagStringsNT5[] =
  31. {
  32. MEMTAG_NAME_NONE ,
  33. MEMTAG_NAME_RECORD ,
  34. MEMTAG_NAME_NODE ,
  35. MEMTAG_NAME_NAME ,
  36. MEMTAG_NAME_ZONE ,
  37. MEMTAG_NAME_UPDATE ,
  38. MEMTAG_NAME_TIMEOUT ,
  39. MEMTAG_NAME_STUFF ,
  40. MEMTAG_NAME_NODEHASH ,
  41. MEMTAG_NAME_DS_DN ,
  42. MEMTAG_NAME_DS_MOD ,
  43. MEMTAG_NAME_DS_RECORD ,
  44. MEMTAG_NAME_NODE_COPY ,
  45. MEMTAG_NAME_PACKET_UDP ,
  46. MEMTAG_NAME_PACKET_TCP ,
  47. MEMTAG_NAME_DNSLIB ,
  48. MEMTAG_NAME_TABLE ,
  49. MEMTAG_NAME_SOCKET ,
  50. MEMTAG_NAME_CONNECTION ,
  51. MEMTAG_NAME_REGISTRY ,
  52. MEMTAG_NAME_RPC ,
  53. MEMTAG_NAME_NBSTAT ,
  54. MEMTAG_NAME_FILEBUF ,
  55. MEMTAG_NAME_DS_OTHER ,
  56. MEMTAG_NAME_THREAD ,
  57. MEMTAG_NAME_UPDATE_LIST ,
  58. MEMTAG_NAME_SAFE ,
  59. NULL, // safety
  60. NULL,
  61. NULL,
  62. NULL
  63. };
  64. // NT5 SP1 version
  65. LPSTR MemTagStrings[] =
  66. {
  67. MEMTAG_NAME_NONE ,
  68. MEMTAG_NAME_PACKET_UDP ,
  69. MEMTAG_NAME_PACKET_TCP ,
  70. MEMTAG_NAME_NAME ,
  71. MEMTAG_NAME_ZONE ,
  72. MEMTAG_NAME_UPDATE ,
  73. MEMTAG_NAME_UPDATE_LIST ,
  74. MEMTAG_NAME_TIMEOUT ,
  75. MEMTAG_NAME_NODEHASH ,
  76. MEMTAG_NAME_DS_DN ,
  77. MEMTAG_NAME_DS_MOD , // 10
  78. MEMTAG_NAME_DS_RECORD ,
  79. MEMTAG_NAME_DS_OTHER ,
  80. MEMTAG_NAME_THREAD ,
  81. MEMTAG_NAME_NBSTAT ,
  82. MEMTAG_NAME_DNSLIB ,
  83. MEMTAG_NAME_TABLE ,
  84. MEMTAG_NAME_SOCKET ,
  85. MEMTAG_NAME_CONNECTION ,
  86. MEMTAG_NAME_REGISTRY ,
  87. MEMTAG_NAME_RPC , // 20
  88. MEMTAG_NAME_STUFF ,
  89. MEMTAG_NAME_FILEBUF ,
  90. MEMTAG_NAME_REMOTE ,
  91. MEMTAG_NAME_SAFE ,
  92. MEMTAG_NAME_RECORD ,
  93. MEMTAG_NAME_RECORD_FILE ,
  94. MEMTAG_NAME_RECORD_DS ,
  95. MEMTAG_NAME_RECORD_AXFR ,
  96. MEMTAG_NAME_RECORD_IXFR ,
  97. MEMTAG_NAME_RECORD_DYNUP , // 30
  98. MEMTAG_NAME_RECORD_ADMIN ,
  99. MEMTAG_NAME_RECORD_AUTO ,
  100. MEMTAG_NAME_RECORD_CACHE ,
  101. MEMTAG_NAME_RECORD_NOEXIST ,
  102. MEMTAG_NAME_RECORD_WINS ,
  103. MEMTAG_NAME_RECORD_WINSPTR ,
  104. MEMTAG_NAME_RECORD_COPY ,
  105. MEMTAG_NAME_NODE ,
  106. MEMTAG_NAME_NODE_FILE ,
  107. MEMTAG_NAME_NODE_DS , // 40
  108. MEMTAG_NAME_NODE_AXFR ,
  109. MEMTAG_NAME_NODE_IXFR ,
  110. MEMTAG_NAME_NODE_DYNUP ,
  111. MEMTAG_NAME_NODE_ADMIN ,
  112. MEMTAG_NAME_NODE_AUTO ,
  113. MEMTAG_NAME_NODE_CACHE ,
  114. MEMTAG_NAME_NODE_NOEXIST ,
  115. MEMTAG_NAME_NODE_WINS ,
  116. MEMTAG_NAME_NODE_WINSPTR ,
  117. MEMTAG_NAME_NODE_COPY ,
  118. NULL, // safety
  119. NULL,
  120. NULL,
  121. NULL
  122. };
  123. VOID
  124. Dns_SystemHourToSystemTime(
  125. IN DWORD dwHourTime,
  126. IN OUT PSYSTEMTIME pSystemTime
  127. )
  128. /*++
  129. Routine Description:
  130. Converts system time in hours to SYSTEMTIME format.
  131. Arguments:
  132. dwHourTime -- system time in hours (hours since 1601)
  133. pSystemTime -- ptr to SYSTEMTIME to set
  134. Return Value:
  135. None
  136. --*/
  137. {
  138. #define FILE_TIME_INTERVALS_IN_HOUR (36000000000)
  139. LONGLONG fileTime;
  140. fileTime = (LONGLONG)dwHourTime * FILE_TIME_INTERVALS_IN_HOUR;
  141. FileTimeToSystemTime( (PFILETIME)&fileTime, pSystemTime );
  142. }
  143. //
  144. // Print server info
  145. //
  146. VOID
  147. DnsPrint_RpcServerInfo(
  148. IN PRINT_ROUTINE PrintRoutine,
  149. IN OUT PPRINT_CONTEXT pPrintContext,
  150. IN LPSTR pszHeader,
  151. IN PDNS_RPC_SERVER_INFO pServerInfo
  152. )
  153. {
  154. char szTime[ 80 ] = DNS_NOT_PERFORMED;
  155. DnsPrint_Lock();
  156. if ( pszHeader )
  157. {
  158. PrintRoutine( pPrintContext, pszHeader );
  159. }
  160. if ( ! pServerInfo )
  161. {
  162. PrintRoutine( pPrintContext, "NULL server info ptr.\n" );
  163. }
  164. else
  165. {
  166. int majorVer = pServerInfo->dwVersion & 0x000000FF;
  167. int minorVer = ( pServerInfo->dwVersion & 0x0000FF00 ) >> 8;
  168. int buildNum = pServerInfo->dwVersion >> 16;
  169. PrintRoutine( pPrintContext,
  170. "Server info\n"
  171. "\tserver name = %s\n",
  172. pServerInfo->pszServerName );
  173. //
  174. // Sanitize build number for older versions where build number is wacked.
  175. //
  176. if ( buildNum < 1 || buildNum > 5000 )
  177. {
  178. PrintRoutine( pPrintContext,
  179. "\tversion = %08lX (%d.%d)\n",
  180. pServerInfo->dwVersion,
  181. majorVer,
  182. minorVer );
  183. }
  184. else
  185. {
  186. PrintRoutine( pPrintContext,
  187. "\tversion = %08lX (%d.%d build %d)\n",
  188. pServerInfo->dwVersion,
  189. majorVer,
  190. minorVer,
  191. buildNum );
  192. }
  193. PrintRoutine( pPrintContext,
  194. "\tDS container = %S\n"
  195. "\tforest name = %s\n"
  196. "\tdomain name = %s\n",
  197. pServerInfo->pszDsContainer ?
  198. pServerInfo->pszDsContainer : DNS_NOT_APPLICABLE_W,
  199. pServerInfo->pszForestName ?
  200. pServerInfo->pszForestName : DNS_NOT_APPLICABLE,
  201. pServerInfo->pszDomainName ?
  202. pServerInfo->pszDomainName : DNS_NOT_APPLICABLE );
  203. PrintRoutine( pPrintContext,
  204. "\tbuiltin domain partition = %s\n"
  205. "\tbuiltin forest partition = %s\n",
  206. pServerInfo->pszDomainDirectoryPartition ?
  207. pServerInfo->pszDomainDirectoryPartition : DNS_NOT_APPLICABLE,
  208. pServerInfo->pszForestDirectoryPartition ?
  209. pServerInfo->pszForestDirectoryPartition : DNS_NOT_APPLICABLE );
  210. #if DBG
  211. PrintRoutine( pPrintContext,
  212. "\tAD forest behavior ver = %2d (appears in DEBUG output only)\n"
  213. "\tAD domain behavior ver = %2d (appears in DEBUG output only)\n"
  214. "\tAD DSA behavior ver = %2d (appears in DEBUG output only)\n",
  215. pServerInfo->dwAdForestVersion,
  216. pServerInfo->dwAdDomainVersion,
  217. pServerInfo->dwAdDsaVersion );
  218. #endif
  219. if ( pServerInfo->dwLastScavengeTime )
  220. {
  221. time_t t = pServerInfo->dwLastScavengeTime;
  222. strcpy( szTime, ctime( &t ) );
  223. szTime[ strlen( szTime ) - 1 ] = '\0';
  224. }
  225. PrintRoutine( pPrintContext,
  226. "\tlast scavenge cycle = %s (%d)\n",
  227. szTime,
  228. pServerInfo->dwLastScavengeTime );
  229. PrintRoutine( pPrintContext,
  230. " Configuration:\n"
  231. "\tdwLogLevel = %p\n"
  232. "\tdwDebugLevel = %p\n"
  233. "\tdwRpcProtocol = %p\n"
  234. "\tdwNameCheckFlag = %p\n"
  235. "\tcAddressAnswerLimit = %d\n"
  236. "\tdwRecursionRetry = %d\n"
  237. "\tdwRecursionTimeout = %d\n"
  238. "\tdwDsPollingInterval = %d\n",
  239. pServerInfo->dwLogLevel,
  240. pServerInfo->dwDebugLevel,
  241. pServerInfo->dwRpcProtocol,
  242. pServerInfo->dwNameCheckFlag,
  243. pServerInfo->cAddressAnswerLimit,
  244. pServerInfo->dwRecursionRetry,
  245. pServerInfo->dwRecursionTimeout,
  246. pServerInfo->dwDsPollingInterval );
  247. PrintRoutine( pPrintContext,
  248. " Configuration Flags:\n"
  249. "\tfBootMethod = %d\n"
  250. "\tfAdminConfigured = %d\n"
  251. "\tfAllowUpdate = %d\n"
  252. "\tfDsAvailable = %d\n"
  253. "\tfAutoReverseZones = %d\n"
  254. "\tfAutoCacheUpdate = %d\n"
  255. "\tfSlave = %d\n"
  256. "\tfNoRecursion = %d\n"
  257. "\tfRoundRobin = %d\n"
  258. "\tfStrictFileParsing = %d\n"
  259. "\tfLooseWildcarding = %d\n"
  260. "\tfBindSecondaries = %d\n"
  261. "\tfWriteAuthorityNs = %d\n"
  262. "\tfLocalNetPriority = %d\n",
  263. pServerInfo->fBootMethod,
  264. pServerInfo->fAdminConfigured,
  265. pServerInfo->fAllowUpdate,
  266. pServerInfo->fDsAvailable,
  267. pServerInfo->fAutoReverseZones,
  268. pServerInfo->fAutoCacheUpdate,
  269. pServerInfo->fSlave,
  270. pServerInfo->fNoRecursion,
  271. pServerInfo->fRoundRobin,
  272. pServerInfo->fStrictFileParsing,
  273. pServerInfo->fLooseWildcarding,
  274. pServerInfo->fBindSecondaries,
  275. pServerInfo->fWriteAuthorityNs,
  276. pServerInfo->fLocalNetPriority );
  277. PrintRoutine(
  278. pPrintContext,
  279. " Aging Configuration:\n"
  280. "\tScavengingInterval = %d\n"
  281. "\tDefaultAgingState = %d\n"
  282. "\tDefaultRefreshInterval = %d\n"
  283. "\tDefaultNoRefreshInterval = %d\n",
  284. pServerInfo->dwScavengingInterval,
  285. pServerInfo->fDefaultAgingState,
  286. pServerInfo->dwDefaultRefreshInterval,
  287. pServerInfo->dwDefaultNoRefreshInterval
  288. );
  289. DnsPrint_IpArray(
  290. PrintRoutine,
  291. pPrintContext,
  292. " ServerAddresses:\n",
  293. "\tAddr",
  294. pServerInfo->aipServerAddrs );
  295. DnsPrint_IpArray(
  296. PrintRoutine,
  297. pPrintContext,
  298. " ListenAddresses:\n",
  299. "\tAddr",
  300. pServerInfo->aipListenAddrs );
  301. DnsPrint_IpArray(
  302. PrintRoutine,
  303. pPrintContext,
  304. " Forwarders:\n",
  305. "\tAddr",
  306. pServerInfo->aipForwarders );
  307. PrintRoutine(
  308. pPrintContext,
  309. "\tforward timeout = %d\n"
  310. "\tslave = %d\n",
  311. pServerInfo->dwForwardTimeout,
  312. pServerInfo->fSlave );
  313. }
  314. DnsPrint_Unlock();
  315. }
  316. //
  317. // Print zone Zone debug utilities
  318. //
  319. PSTR
  320. truncateStringA(
  321. PSTR pszSource,
  322. PSTR pszDest,
  323. int iDestLength )
  324. {
  325. if ( pszSource )
  326. {
  327. int len = strlen( pszSource );
  328. if ( len < iDestLength )
  329. {
  330. strcpy( pszDest, pszSource );
  331. }
  332. else
  333. {
  334. strncpy( pszDest, pszSource, iDestLength - 4 );
  335. strcpy( pszDest + iDestLength - 4, "..." );
  336. }
  337. }
  338. else
  339. {
  340. *pszDest = '\0';
  341. }
  342. return pszDest;
  343. }
  344. PWSTR
  345. truncateStringW(
  346. PWSTR pwszSource,
  347. PWSTR pwszDest,
  348. int iDestLength )
  349. {
  350. if ( pwszSource )
  351. {
  352. int len = wcslen( pwszSource );
  353. if ( len < iDestLength )
  354. {
  355. wcscpy( pwszDest, pwszSource );
  356. }
  357. else
  358. {
  359. wcsncpy( pwszDest, pwszSource, iDestLength - 4 );
  360. wcscpy( pwszDest + iDestLength - 4, L"..." );
  361. pwszDest[ iDestLength - 1 ] = '\0';
  362. }
  363. }
  364. else
  365. {
  366. *pwszDest = L'\0';
  367. }
  368. return pwszDest;
  369. }
  370. #define DNS_DPDISP_REAL_CUSTOM_NAME 0x0001
  371. #define DNS_DPDISP_BLANK_STRING_FOR_LEGACY 0x0002
  372. LPSTR
  373. partitionDisplayName(
  374. IN DWORD dwPartitionFlags,
  375. IN LPSTR pszPartitionFqdn,
  376. IN DWORD dwNameBuffLen,
  377. OUT LPSTR pszNameBuff,
  378. IN DWORD dwFlags
  379. )
  380. /*++
  381. Routine Description:
  382. Formats directory partition for display. If the flags indicate that
  383. the partition is a built-in partition, the name will be substituted
  384. for a descriptive string.
  385. Arguments:
  386. dwPartitionFlags -- DP flags from the DNS server
  387. pszPartitionFqdn -- FQDN of the partition
  388. dwNameBuffLen -- length of the output name buffer
  389. pszNameBuff -- pointer to the output name buffer
  390. dwFlags - use DNS_DPDISP_XXX constants
  391. Return Value:
  392. Pointer to pszNameBuff
  393. --*/
  394. {
  395. //
  396. // Substitute name if this is a built-in partition.
  397. //
  398. if ( dwPartitionFlags & DNS_DP_DOMAIN_DEFAULT )
  399. {
  400. pszPartitionFqdn = "AD-Domain";
  401. }
  402. else if ( dwPartitionFlags & DNS_DP_FOREST_DEFAULT )
  403. {
  404. pszPartitionFqdn = "AD-Forest";
  405. }
  406. else if ( dwPartitionFlags & DNS_DP_LEGACY || !pszPartitionFqdn )
  407. {
  408. pszPartitionFqdn =
  409. ( dwFlags & DNS_DPDISP_BLANK_STRING_FOR_LEGACY ) ? "" : "AD-Legacy";
  410. }
  411. else if ( !( dwFlags & DNS_DPDISP_REAL_CUSTOM_NAME ) )
  412. {
  413. pszPartitionFqdn = "AD-Custom";
  414. }
  415. truncateStringA( pszPartitionFqdn, pszNameBuff, dwNameBuffLen );
  416. return pszNameBuff;
  417. } // partitionDisplayName
  418. LPSTR
  419. zoneTypeString(
  420. IN DWORD dwZoneType,
  421. IN DWORD dwOutBuffLen,
  422. OUT LPSTR pszOutBuff
  423. )
  424. /*++
  425. Routine Description:
  426. Convert DWORD zone type into display string.
  427. Arguments:
  428. dwZoneType -- zone type
  429. dwOutBuffLen -- length of the output name buffer
  430. pszOutBuff -- pointer to the output name buffer
  431. Return Value:
  432. Pointer to pszOutBuff
  433. --*/
  434. {
  435. PSTR pszZoneType = NULL;
  436. CHAR szBuff[ 10 ];
  437. switch ( dwZoneType )
  438. {
  439. case DNS_ZONE_TYPE_CACHE:
  440. pszZoneType = "Cache";
  441. break;
  442. case DNS_ZONE_TYPE_PRIMARY:
  443. pszZoneType = "Primary";
  444. break;
  445. case DNS_ZONE_TYPE_SECONDARY:
  446. pszZoneType = "Secondary";
  447. break;
  448. case DNS_ZONE_TYPE_STUB:
  449. pszZoneType = "Stub";
  450. break;
  451. case DNS_ZONE_TYPE_FORWARDER:
  452. pszZoneType = "Forwarder";
  453. break;
  454. default:
  455. _itoa( dwZoneType, szBuff, 10 );
  456. pszZoneType = szBuff;
  457. break;
  458. }
  459. truncateStringA( pszZoneType, pszOutBuff, dwOutBuffLen );
  460. return pszOutBuff;
  461. } // zoneTypeString
  462. VOID
  463. DnsPrint_RpcZone(
  464. IN PRINT_ROUTINE PrintRoutine,
  465. IN OUT PPRINT_CONTEXT pPrintContext,
  466. IN LPSTR pszHeader,
  467. IN PDNS_RPC_ZONE pZone
  468. )
  469. {
  470. if ( ! pZone )
  471. {
  472. PrintRoutine( pPrintContext,
  473. "%sNULL zone info ptr.\n",
  474. ( pszHeader ? pszHeader : "" ) );
  475. }
  476. else
  477. {
  478. CHAR szpartition[ 15 ];
  479. CHAR sztype[ 10 ];
  480. // print zone per line
  481. if ( pszHeader && *pszHeader )
  482. {
  483. PrintRoutine( pPrintContext,
  484. "%s\n",
  485. pszHeader ? pszHeader : "" );
  486. }
  487. PrintRoutine( pPrintContext, " %-30S", pZone->pszZoneName );
  488. if ( pZone->Flags.DsIntegrated )
  489. {
  490. partitionDisplayName(
  491. pZone->dwDpFlags,
  492. pZone->pszDpFqdn,
  493. sizeof( szpartition ),
  494. szpartition,
  495. 0 );
  496. }
  497. else
  498. {
  499. strcpy( szpartition, "File" );
  500. }
  501. PrintRoutine( pPrintContext,
  502. " %-9s %-14s %s%s%s%s%s\n",
  503. zoneTypeString(
  504. pZone->ZoneType,
  505. sizeof( sztype ),
  506. sztype ),
  507. szpartition,
  508. pZone->Flags.Update == 2 ?
  509. "Secure " :
  510. ( pZone->Flags.Update == 1 ?
  511. "Update " : "" ),
  512. pZone->Flags.Reverse ? "Rev " : "",
  513. pZone->Flags.AutoCreated ? "Auto " : "",
  514. pZone->Flags.Aging ? "Aging " : "",
  515. pZone->Flags.Paused ? "Paused " : "",
  516. pZone->Flags.Shutdown ? "Down " : "" );
  517. }
  518. }
  519. VOID
  520. DNS_API_FUNCTION
  521. DnsPrint_RpcZoneList(
  522. IN PRINT_ROUTINE PrintRoutine,
  523. IN OUT PPRINT_CONTEXT pPrintContext,
  524. IN LPSTR pszHeader,
  525. IN PDNS_RPC_ZONE_LIST pZoneList
  526. )
  527. {
  528. DWORD i;
  529. DnsPrint_Lock();
  530. if ( pszHeader )
  531. {
  532. PrintRoutine( pPrintContext, "%s\n", pszHeader );
  533. }
  534. if ( !pZoneList )
  535. {
  536. PrintRoutine( pPrintContext, "NULL zone list pointer.\n" );
  537. }
  538. else
  539. {
  540. PrintRoutine( pPrintContext, "\tZone count = %d\n\n", pZoneList->dwZoneCount );
  541. PrintRoutine( pPrintContext,
  542. " Zone name Type Storage Properties\n\n" );
  543. if ( pZoneList->dwZoneCount )
  544. {
  545. DnsPrint_RpcZone(
  546. PrintRoutine, pPrintContext,
  547. NULL, // print default header
  548. pZoneList->ZoneArray[0] );
  549. }
  550. for ( i=1; i<pZoneList->dwZoneCount; i++ )
  551. {
  552. DnsPrint_RpcZone(
  553. PrintRoutine, pPrintContext,
  554. NULL, // print default header
  555. pZoneList->ZoneArray[i] );
  556. }
  557. PrintRoutine( pPrintContext, "\n" );
  558. }
  559. DnsPrint_Unlock();
  560. }
  561. //
  562. // Directory parition debug utilities
  563. //
  564. VOID
  565. DnsPrint_RpcDpEnum(
  566. IN PRINT_ROUTINE PrintRoutine,
  567. IN OUT PPRINT_CONTEXT pPrintContext,
  568. IN LPSTR pszHeader,
  569. IN PDNS_RPC_DP_ENUM pDp
  570. )
  571. {
  572. DnsPrint_Lock();
  573. if ( !pDp )
  574. {
  575. PrintRoutine( pPrintContext, "NULL DP enum ptr\n" );
  576. }
  577. else
  578. {
  579. PrintRoutine( pPrintContext,
  580. " %-40s %s%s%s%s%s%s\n",
  581. pDp->pszDpFqdn,
  582. pDp->dwFlags & DNS_DP_ENLISTED ? "Enlisted " : "Not-Enlisted ",
  583. pDp->dwFlags & DNS_DP_DELETED ? "Deleted " : "",
  584. pDp->dwFlags & DNS_DP_AUTOCREATED ? "Auto " : "",
  585. pDp->dwFlags & DNS_DP_LEGACY ? "Legacy " : "",
  586. pDp->dwFlags & DNS_DP_DOMAIN_DEFAULT ? "Domain " : "",
  587. pDp->dwFlags & DNS_DP_FOREST_DEFAULT ? "Forest " : "" );
  588. }
  589. DnsPrint_Unlock();
  590. } // DnsPrint_RpcDpEnum
  591. VOID
  592. DnsPrint_RpcDpInfo(
  593. IN PRINT_ROUTINE PrintRoutine,
  594. IN OUT PPRINT_CONTEXT pPrintContext,
  595. IN LPSTR pszHeader,
  596. IN PDNS_RPC_DP_INFO pDp,
  597. IN BOOL fTruncateLongStrings
  598. )
  599. {
  600. DnsPrint_Lock();
  601. if ( !pDp )
  602. {
  603. PrintRoutine( pPrintContext,
  604. "%sNULL DP info ptr.\n",
  605. ( pszHeader ? pszHeader : "" ) );
  606. }
  607. else
  608. {
  609. WCHAR wsz[ 80 ];
  610. PrintRoutine( pPrintContext,
  611. "%s\n"
  612. " DNS root: %s\n"
  613. " Flags: 0x%X %s%s%s%s%s%s\n"
  614. " Zone count: %d\n"
  615. " DP head: %S\n"
  616. " Crossref: ",
  617. pszHeader ? pszHeader : "",
  618. pDp->pszDpFqdn,
  619. pDp->dwFlags,
  620. pDp->dwFlags & DNS_DP_ENLISTED ? "Enlisted " : "Not-Enlisted ",
  621. pDp->dwFlags & DNS_DP_DELETED ? "Deleted " : "",
  622. pDp->dwFlags & DNS_DP_AUTOCREATED ? "Auto " : "",
  623. pDp->dwFlags & DNS_DP_LEGACY ? "Legacy " : "",
  624. pDp->dwFlags & DNS_DP_DOMAIN_DEFAULT ? "Domain " : "",
  625. pDp->dwFlags & DNS_DP_FOREST_DEFAULT ? "Forest " : "",
  626. pDp->dwZoneCount,
  627. pDp->pszDpDn,
  628. pDp->pszCrDn );
  629. if ( fTruncateLongStrings )
  630. {
  631. truncateStringW( pDp->pszCrDn, wsz, 64 );
  632. PrintRoutine( pPrintContext, "%S", wsz );
  633. }
  634. else
  635. {
  636. PrintRoutine( pPrintContext, "%S", pDp->pszCrDn );
  637. }
  638. PrintRoutine( pPrintContext,
  639. "\n Replicas: %d\n",
  640. pDp->dwReplicaCount );
  641. if ( pDp->dwReplicaCount && pDp->ReplicaArray )
  642. {
  643. DWORD i;
  644. for ( i = 0;
  645. i < pDp->dwReplicaCount && pDp->ReplicaArray[ i ];
  646. ++i )
  647. {
  648. if ( fTruncateLongStrings )
  649. {
  650. truncateStringW(
  651. pDp->ReplicaArray[ i ]->pszReplicaDn,
  652. wsz,
  653. 74 );
  654. PrintRoutine( pPrintContext, " %S\n", wsz );
  655. }
  656. else
  657. {
  658. PrintRoutine( pPrintContext, " %S\n",
  659. pDp->ReplicaArray[ i ]->pszReplicaDn ?
  660. pDp->ReplicaArray[ i ]->pszReplicaDn : L"NULL" );
  661. }
  662. }
  663. }
  664. }
  665. DnsPrint_Unlock();
  666. } // DnsPrint_RpcDpInfo
  667. VOID
  668. DNS_API_FUNCTION
  669. DnsPrint_RpcDpList(
  670. IN PRINT_ROUTINE PrintRoutine,
  671. IN OUT PPRINT_CONTEXT pPrintContext,
  672. IN LPSTR pszHeader,
  673. IN PDNS_RPC_DP_LIST pDpList
  674. )
  675. {
  676. DWORD i;
  677. DnsPrint_Lock();
  678. if ( pszHeader )
  679. {
  680. PrintRoutine( pPrintContext, "%s\n", pszHeader );
  681. }
  682. if ( !pDpList )
  683. {
  684. PrintRoutine( pPrintContext, "NULL directory partition list pointer.\n" );
  685. }
  686. else
  687. {
  688. PrintRoutine( pPrintContext, "\tDirectory partition count = %d\n\n", pDpList->dwDpCount );
  689. for ( i = 0; i < pDpList->dwDpCount && pDpList->DpArray[ i ]; ++i )
  690. {
  691. DnsPrint_RpcDpEnum(
  692. PrintRoutine, pPrintContext,
  693. NULL, // print default header
  694. pDpList->DpArray[ i ] );
  695. }
  696. PrintRoutine( pPrintContext, "\n" );
  697. }
  698. DnsPrint_Unlock();
  699. } // DnsPrint_RpcDpList
  700. VOID
  701. DnsPrint_RpcZoneInfo(
  702. IN PRINT_ROUTINE PrintRoutine,
  703. IN OUT PPRINT_CONTEXT pPrintContext,
  704. IN LPSTR pszHeader,
  705. IN PDNS_RPC_ZONE_INFO pZoneInfo
  706. )
  707. {
  708. CHAR szdpName[ 300 ]; // don't want truncation
  709. DnsPrint_Lock();
  710. PrintRoutine( pPrintContext, (pszHeader ? pszHeader : "") );
  711. if ( ! pZoneInfo )
  712. {
  713. PrintRoutine( pPrintContext, "NULL zone info ptr.\n" );
  714. }
  715. else
  716. {
  717. PrintRoutine( pPrintContext,
  718. "Zone info:\n"
  719. "\tptr = %p\n"
  720. "\tzone name = %s\n"
  721. "\tzone type = %d\n"
  722. "\tupdate = %d\n"
  723. "\tDS integrated = %d\n"
  724. "\tdata file = %s\n"
  725. "\tusing WINS = %d\n"
  726. "\tusing Nbstat = %d\n"
  727. "\taging = %d\n"
  728. "\t refresh interval = %lu\n"
  729. "\t no refresh = %lu\n"
  730. "\t scavenge available = %lu\n",
  731. pZoneInfo,
  732. pZoneInfo->pszZoneName,
  733. pZoneInfo->dwZoneType,
  734. pZoneInfo->fAllowUpdate,
  735. pZoneInfo->fUseDatabase,
  736. pZoneInfo->pszDataFile,
  737. pZoneInfo->fUseWins,
  738. pZoneInfo->fUseNbstat,
  739. pZoneInfo->fAging,
  740. pZoneInfo->dwRefreshInterval,
  741. pZoneInfo->dwNoRefreshInterval,
  742. pZoneInfo->dwAvailForScavengeTime
  743. );
  744. DnsPrint_IpArray(
  745. PrintRoutine, pPrintContext,
  746. "\tZone Masters\n",
  747. "\tMaster",
  748. pZoneInfo->aipMasters );
  749. if ( pZoneInfo->dwZoneType == DNS_ZONE_TYPE_STUB )
  750. {
  751. DnsPrint_IpArray(
  752. PrintRoutine, pPrintContext,
  753. "\tZone Local Masters\n",
  754. "\tLocal Master",
  755. pZoneInfo->aipLocalMasters );
  756. }
  757. DnsPrint_IpArray(
  758. PrintRoutine, pPrintContext,
  759. "\tZone Secondaries\n",
  760. "\tSecondary",
  761. pZoneInfo->aipSecondaries );
  762. PrintRoutine( pPrintContext,
  763. "\tsecure secs = %d\n",
  764. pZoneInfo->fSecureSecondaries );
  765. if ( pZoneInfo->fUseDatabase )
  766. {
  767. PrintRoutine( pPrintContext,
  768. "\tdirectory partition = %s flags %08X\n",
  769. partitionDisplayName(
  770. pZoneInfo->dwDpFlags,
  771. pZoneInfo->pszDpFqdn,
  772. sizeof( szdpName ),
  773. szdpName,
  774. DNS_DPDISP_REAL_CUSTOM_NAME ),
  775. pZoneInfo->dwDpFlags );
  776. }
  777. if ( pZoneInfo->aipScavengeServers )
  778. {
  779. DnsPrint_IpArray(
  780. PrintRoutine, pPrintContext,
  781. "\tScavenge Servers\n",
  782. "\tServer",
  783. pZoneInfo->aipScavengeServers );
  784. }
  785. if ( pZoneInfo->dwZoneType == DNS_ZONE_TYPE_FORWARDER )
  786. {
  787. PrintRoutine( pPrintContext,
  788. "\tforwarder timeout = %d\n"
  789. "\tforwarder slave = %d\n",
  790. pZoneInfo->dwForwarderTimeout,
  791. pZoneInfo->fForwarderSlave );
  792. }
  793. if ( pZoneInfo->dwZoneType == DNS_ZONE_TYPE_SECONDARY ||
  794. pZoneInfo->dwZoneType == DNS_ZONE_TYPE_STUB )
  795. {
  796. char szTime1[ 60 ] = DNS_NOT_PERFORMED;
  797. char szTime2[ 60 ] = DNS_NOT_PERFORMED;
  798. if ( pZoneInfo->dwLastSuccessfulXfr )
  799. {
  800. time_t t = pZoneInfo->dwLastSuccessfulXfr;
  801. strcpy( szTime1, ctime( &t ) );
  802. szTime1[ strlen( szTime1 ) - 1 ] = '\0';
  803. }
  804. if ( pZoneInfo->dwLastSuccessfulSoaCheck )
  805. {
  806. time_t t = pZoneInfo->dwLastSuccessfulSoaCheck;
  807. strcpy( szTime2, ctime( &t ) );
  808. szTime2[ strlen( szTime2 ) - 1 ] = '\0';
  809. }
  810. PrintRoutine( pPrintContext,
  811. "\tlast successful xfr = %s (%d)\n"
  812. "\tlast SOA check = %s (%d)\n",
  813. szTime1,
  814. pZoneInfo->dwLastSuccessfulXfr,
  815. szTime2,
  816. pZoneInfo->dwLastSuccessfulSoaCheck );
  817. }
  818. }
  819. DnsPrint_Unlock();
  820. }
  821. VOID
  822. DnsPrint_RpcZoneInfoList(
  823. IN PRINT_ROUTINE PrintRoutine,
  824. IN OUT PPRINT_CONTEXT pPrintContext,
  825. IN LPSTR pszHeader,
  826. IN DWORD dwZoneCount,
  827. IN PDNS_RPC_ZONE_INFO apZoneInfo[]
  828. )
  829. {
  830. DWORD i;
  831. DnsPrint_Lock();
  832. PrintRoutine( pPrintContext, (pszHeader ? pszHeader : "") );
  833. PrintRoutine( pPrintContext, "Zone Count = %d\n", dwZoneCount );
  834. if ( dwZoneCount != 0 && apZoneInfo != NULL )
  835. {
  836. for (i=0; i<dwZoneCount; i++)
  837. {
  838. PrintRoutine( pPrintContext, "\n[%d]", i );
  839. DnsPrint_RpcZoneInfo(
  840. PrintRoutine, pPrintContext,
  841. NULL,
  842. apZoneInfo[i] );
  843. }
  844. }
  845. DnsPrint_Unlock();
  846. }
  847. //
  848. // Print domain node and record buffers
  849. //
  850. VOID
  851. DnssrvCopyRpcNameToBuffer(
  852. IN PSTR pResult,
  853. IN PDNS_RPC_NAME pName
  854. )
  855. /*++
  856. Routine Description:
  857. Copy RPC name to buffer.
  858. Arguments:
  859. pResult -- result buffer; assumed to be at least DNS_MAX_NAME_LENGTH
  860. pName -- RPC name
  861. Return Value:
  862. None
  863. --*/
  864. {
  865. DWORD length = pName->cchNameLength;
  866. strncpy( pResult, pName->achName, length );
  867. pResult[ length ] = 0;
  868. }
  869. VOID
  870. DnsPrint_RpcName(
  871. IN PRINT_ROUTINE PrintRoutine,
  872. IN OUT PPRINT_CONTEXT pPrintContext,
  873. IN LPSTR pszHeader,
  874. IN PDNS_RPC_NAME pName,
  875. IN LPSTR pszTrailer
  876. )
  877. /*++
  878. Routine Description:
  879. Prints RPC name.
  880. Arguments:
  881. PrintRoutine -- printf like routine to print with
  882. pszHeader -- header string
  883. pName -- RPC name
  884. pszTrailer -- trailer string
  885. Return Value:
  886. None
  887. --*/
  888. {
  889. //
  890. // print name to given length
  891. //
  892. DnsPrint_Lock();
  893. if ( !pszHeader )
  894. {
  895. pszHeader = "";
  896. }
  897. if ( !pszTrailer )
  898. {
  899. pszTrailer = "";
  900. }
  901. if ( ! pName )
  902. {
  903. PrintRoutine( pPrintContext,
  904. "%s"
  905. "(NULL DNS name ptr)"
  906. "%s",
  907. pszHeader,
  908. pszTrailer );
  909. }
  910. else
  911. {
  912. #if 0
  913. PrintRoutine( pPrintContext,
  914. "%s"
  915. "(%d) %.*s"
  916. "%s",
  917. pszHeader,
  918. pName->cchNameLength,
  919. pName->cchNameLength,
  920. pName->achName,
  921. pszTrailer );
  922. #endif
  923. if ( pName->cchNameLength > 0 )
  924. {
  925. PrintRoutine( pPrintContext,
  926. "%s"
  927. "%.*s"
  928. "%s",
  929. pszHeader,
  930. pName->cchNameLength,
  931. pName->achName,
  932. pszTrailer );
  933. }
  934. else // use "@ for empty node name
  935. {
  936. PrintRoutine( pPrintContext,
  937. "%s"
  938. "%@"
  939. "%s",
  940. pszHeader,
  941. pszTrailer );
  942. }
  943. }
  944. DnsPrint_Unlock();
  945. }
  946. VOID
  947. DnsPrint_RpcNode(
  948. IN PRINT_ROUTINE PrintRoutine,
  949. IN OUT PPRINT_CONTEXT pPrintContext,
  950. IN LPSTR pszHeader,
  951. IN PDNS_RPC_NODE pNode
  952. )
  953. /*++
  954. Routine Description:
  955. Prints RPC node.
  956. Arguments:
  957. PrintRoutine -- printf like routine to print with
  958. pszHeader -- header string
  959. pNode -- RPC node to print
  960. Return Value:
  961. None
  962. --*/
  963. {
  964. DnsPrint_Lock();
  965. PrintRoutine( pPrintContext, (pszHeader ? pszHeader : "RPC Node:") );
  966. if ( ! pNode )
  967. {
  968. PrintRoutine( pPrintContext, "NULL RPC node ptr.\n" );
  969. }
  970. else
  971. {
  972. PrintRoutine( pPrintContext,
  973. "\n"
  974. "\tptr = %p\n"
  975. "\twLength = %d\n"
  976. "\twRecordCount = %d\n"
  977. "\tdwChildCount = %d\n"
  978. "\tdwFlags = %p\n",
  979. pNode,
  980. pNode->wLength,
  981. pNode->wRecordCount,
  982. pNode->dwChildCount,
  983. pNode->dwFlags );
  984. DnsPrint_RpcName(
  985. PrintRoutine,
  986. pPrintContext,
  987. "\tNode Name = ",
  988. & pNode->dnsNodeName,
  989. "\n" );
  990. }
  991. DnsPrint_Unlock();
  992. }
  993. VOID
  994. DnsPrint_RpcRecord(
  995. IN PRINT_ROUTINE PrintRoutine,
  996. IN OUT PPRINT_CONTEXT pPrintContext,
  997. IN LPSTR pszHeader,
  998. IN BOOL fDetail,
  999. IN PDNS_FLAT_RECORD pRecord
  1000. )
  1001. /*++
  1002. Routine Description:
  1003. Prints RPC record.
  1004. Arguments:
  1005. PrintRoutine -- printf like routine to print with
  1006. pszHeader -- header string
  1007. fDetail -- if TRUE print detailed record info
  1008. pRecord -- RPC record to print
  1009. Return Value:
  1010. None
  1011. --*/
  1012. {
  1013. PCHAR ptypeString;
  1014. PDNS_RPC_RECORD_DATA pdata;
  1015. WORD type;
  1016. WORD dataLength;
  1017. SYSTEMTIME sysTime;
  1018. CHAR szBuff[ 5000 ];
  1019. DnsPrint_Lock();
  1020. PrintRoutine( pPrintContext, (pszHeader ? pszHeader : "" ) );
  1021. if ( ! pRecord )
  1022. {
  1023. PrintRoutine( pPrintContext, "NULL record ptr.\n" );
  1024. goto Done;
  1025. }
  1026. //
  1027. // record fixed fields
  1028. //
  1029. type = pRecord->wType;
  1030. ptypeString = Dns_RecordStringForType( type );
  1031. if ( !ptypeString )
  1032. {
  1033. ptypeString = "UNKNOWN";
  1034. }
  1035. pdata = &pRecord->Data;
  1036. dataLength = pRecord->wDataLength;
  1037. if ( fDetail )
  1038. {
  1039. Dns_SystemHourToSystemTime(
  1040. pRecord->dwTimeStamp,
  1041. &sysTime );
  1042. PrintRoutine( pPrintContext,
  1043. " %s Record info:\n"
  1044. "\tptr = %p\n"
  1045. "\twType = %s (%u)\n"
  1046. "\twDataLength = %u\n"
  1047. "\tdwFlags = %lx\n"
  1048. "\trank = %x\n"
  1049. "\tdwSerial = %p\n"
  1050. "\tdwTtlSeconds = %u\n"
  1051. "\tdwTimeStamp = %lu ([%2d:%2d:%2d] [%2d/%2d/%2d])\n",
  1052. ptypeString,
  1053. pRecord,
  1054. ptypeString,
  1055. type,
  1056. pRecord->wDataLength,
  1057. pRecord->dwFlags,
  1058. (UCHAR)(pRecord->dwFlags & DNS_RPC_FLAG_RANK),
  1059. pRecord->dwSerial,
  1060. pRecord->dwTtlSeconds,
  1061. pRecord->dwTimeStamp,
  1062. sysTime.wHour,
  1063. sysTime.wMinute,
  1064. sysTime.wSecond,
  1065. sysTime.wMonth,
  1066. sysTime.wDay,
  1067. sysTime.wYear
  1068. );
  1069. }
  1070. //
  1071. // print record type and data
  1072. // - as single line data where possible
  1073. if ( !fDetail )
  1074. {
  1075. if ( pRecord->dwTimeStamp )
  1076. {
  1077. PrintRoutine( pPrintContext,
  1078. " [Aging:%lu]",
  1079. pRecord->dwTimeStamp );
  1080. }
  1081. PrintRoutine( pPrintContext,
  1082. " %lu",
  1083. pRecord->dwTtlSeconds );
  1084. }
  1085. PrintRoutine( pPrintContext,
  1086. " %s\t",
  1087. ptypeString );
  1088. //
  1089. // print type data
  1090. //
  1091. switch ( type )
  1092. {
  1093. case DNS_TYPE_A:
  1094. PrintRoutine( pPrintContext,
  1095. "%d.%d.%d.%d\n",
  1096. * ( (PUCHAR) &(pdata->A) + 0 ),
  1097. * ( (PUCHAR) &(pdata->A) + 1 ),
  1098. * ( (PUCHAR) &(pdata->A) + 2 ),
  1099. * ( (PUCHAR) &(pdata->A) + 3 )
  1100. );
  1101. break;
  1102. case DNS_TYPE_PTR:
  1103. case DNS_TYPE_NS:
  1104. case DNS_TYPE_CNAME:
  1105. case DNS_TYPE_MD:
  1106. case DNS_TYPE_MB:
  1107. case DNS_TYPE_MF:
  1108. case DNS_TYPE_MG:
  1109. case DNS_TYPE_MR:
  1110. //
  1111. // these RRs contain single indirection
  1112. //
  1113. DnsPrint_RpcName(
  1114. PrintRoutine, pPrintContext,
  1115. NULL,
  1116. & pdata->NS.nameNode,
  1117. "\n" );
  1118. break;
  1119. case DNS_TYPE_MX:
  1120. case DNS_TYPE_RT:
  1121. case DNS_TYPE_AFSDB:
  1122. //
  1123. // these RR contain
  1124. // - one preference value
  1125. // - one domain name
  1126. //
  1127. PrintRoutine( pPrintContext,
  1128. "%d ",
  1129. pdata->MX.wPreference
  1130. );
  1131. DnsPrint_RpcName(
  1132. PrintRoutine, pPrintContext,
  1133. NULL,
  1134. & pdata->MX.nameExchange,
  1135. "\n" );
  1136. break;
  1137. case DNS_TYPE_SOA:
  1138. if ( fDetail )
  1139. {
  1140. DnsPrint_RpcName(
  1141. PrintRoutine, pPrintContext,
  1142. "\n\tPrimaryNameServer: ",
  1143. & pdata->SOA.namePrimaryServer,
  1144. "\n" );
  1145. // responsible party name, immediately follows primary server name
  1146. DnsPrint_RpcName(
  1147. PrintRoutine, pPrintContext,
  1148. "\tResponsibleParty: ",
  1149. (PDNS_RPC_NAME)
  1150. (pdata->SOA.namePrimaryServer.achName
  1151. + pdata->SOA.namePrimaryServer.cchNameLength),
  1152. "\n" );
  1153. PrintRoutine( pPrintContext,
  1154. "\tSerialNo = %lu\n"
  1155. "\tRefresh = %lu\n"
  1156. "\tRetry = %lu\n"
  1157. "\tExpire = %lu\n"
  1158. "\tMinimumTTL = %lu\n",
  1159. pdata->SOA.dwSerialNo,
  1160. pdata->SOA.dwRefresh,
  1161. pdata->SOA.dwRetry,
  1162. pdata->SOA.dwExpire,
  1163. pdata->SOA.dwMinimumTtl );
  1164. break;
  1165. }
  1166. else
  1167. {
  1168. DnsPrint_RpcName(
  1169. PrintRoutine, pPrintContext,
  1170. NULL,
  1171. & pdata->SOA.namePrimaryServer,
  1172. NULL );
  1173. // responsible party name, immediately follows primary server name
  1174. DnsPrint_RpcName(
  1175. PrintRoutine, pPrintContext,
  1176. " ",
  1177. (PDNS_RPC_NAME)
  1178. (pdata->SOA.namePrimaryServer.achName
  1179. + pdata->SOA.namePrimaryServer.cchNameLength),
  1180. NULL );
  1181. PrintRoutine( pPrintContext,
  1182. " %lu"
  1183. " %lu"
  1184. " %lu"
  1185. " %lu"
  1186. " %lu\n",
  1187. pdata->SOA.dwSerialNo,
  1188. pdata->SOA.dwRefresh,
  1189. pdata->SOA.dwRetry,
  1190. pdata->SOA.dwExpire,
  1191. pdata->SOA.dwMinimumTtl );
  1192. break;
  1193. }
  1194. case DNS_TYPE_AAAA:
  1195. {
  1196. CHAR ip6String[ IPV6_ADDRESS_STRING_LENGTH+1 ];
  1197. Dns_Ip6AddressToString_A(
  1198. ip6String,
  1199. &pdata->AAAA.ipv6Address
  1200. );
  1201. PrintRoutine( pPrintContext,
  1202. "%s\n",
  1203. ip6String );
  1204. }
  1205. break;
  1206. case DNS_TYPE_HINFO:
  1207. case DNS_TYPE_ISDN:
  1208. case DNS_TYPE_X25:
  1209. case DNS_TYPE_TEXT:
  1210. {
  1211. //
  1212. // all these are simply text string(s)
  1213. //
  1214. // TXT strings will be printed one per line
  1215. //
  1216. PCHAR pch = (PCHAR) &pdata->TXT.stringData;
  1217. PCHAR pchStop = pch + dataLength;
  1218. UCHAR cch;
  1219. while ( pch < pchStop )
  1220. {
  1221. cch = (UCHAR) *pch++;
  1222. if ( type == DNS_TYPE_TEXT )
  1223. {
  1224. PrintRoutine( pPrintContext,
  1225. "\t%.*s\n",
  1226. cch,
  1227. pch );
  1228. }
  1229. else
  1230. {
  1231. PrintRoutine( pPrintContext,
  1232. "\"%.*s\" ",
  1233. cch,
  1234. pch );
  1235. }
  1236. pch += cch;
  1237. }
  1238. if ( type != DNS_TYPE_TEXT )
  1239. {
  1240. PrintRoutine( pPrintContext,"\n");
  1241. }
  1242. ASSERT( pch == pchStop );
  1243. break;
  1244. }
  1245. case DNS_TYPE_MINFO:
  1246. case DNS_TYPE_RP:
  1247. //
  1248. // these RRs contain two domain names
  1249. //
  1250. DnsPrint_RpcName(
  1251. PrintRoutine, pPrintContext,
  1252. NULL,
  1253. & pdata->MINFO.nameMailBox,
  1254. NULL );
  1255. // errors to mailbox name, immediately follows mail box
  1256. DnsPrint_RpcName(
  1257. PrintRoutine, pPrintContext,
  1258. " ",
  1259. (PDNS_RPC_NAME)
  1260. ( pdata->MINFO.nameMailBox.achName
  1261. + pdata->MINFO.nameMailBox.cchNameLength ),
  1262. "\n" );
  1263. break;
  1264. case DNS_TYPE_WKS:
  1265. {
  1266. INT i;
  1267. if ( fDetail )
  1268. {
  1269. PrintRoutine( pPrintContext,
  1270. "WKS: Address %d.%d.%d.%d\n"
  1271. "\tProtocol %d\n"
  1272. "\tBitmask\n",
  1273. * ( (PUCHAR) &(pdata->WKS.ipAddress) + 0 ),
  1274. * ( (PUCHAR) &(pdata->WKS.ipAddress) + 1 ),
  1275. * ( (PUCHAR) &(pdata->WKS.ipAddress) + 2 ),
  1276. * ( (PUCHAR) &(pdata->WKS.ipAddress) + 3 ),
  1277. pdata->WKS.chProtocol
  1278. );
  1279. for ( i = 0;
  1280. i < (INT)( dataLength
  1281. - sizeof( pdata->WKS.ipAddress )
  1282. - sizeof( pdata->WKS.chProtocol ) );
  1283. i++ )
  1284. {
  1285. PrintRoutine( pPrintContext,
  1286. "\t\tbyte[%d] = %x\n",
  1287. i,
  1288. (UCHAR) pdata->WKS.bBitMask[i] );
  1289. }
  1290. break;
  1291. }
  1292. else
  1293. {
  1294. DNS_STATUS status;
  1295. struct protoent * pProtoent;
  1296. WSADATA wsaData;
  1297. PrintRoutine( pPrintContext,
  1298. "%d.%d.%d.%d ",
  1299. * ( (PUCHAR) &(pdata->WKS.ipAddress) + 0 ),
  1300. * ( (PUCHAR) &(pdata->WKS.ipAddress) + 1 ),
  1301. * ( (PUCHAR) &(pdata->WKS.ipAddress) + 2 ),
  1302. * ( (PUCHAR) &(pdata->WKS.ipAddress) + 3 )
  1303. );
  1304. //
  1305. // get protocol number:
  1306. //
  1307. // start winsock:
  1308. status = WSAStartup( DNS_WINSOCK_VERSION, &wsaData );
  1309. if ( status == SOCKET_ERROR )
  1310. {
  1311. status = WSAGetLastError();
  1312. SetLastError( status );
  1313. PrintRoutine( pPrintContext,
  1314. "ERROR: WSAGetLastError()\n"
  1315. );
  1316. ASSERT(FALSE);
  1317. }
  1318. pProtoent = getprotobynumber( pdata->WKS.chProtocol );
  1319. if ( ! pProtoent || pProtoent->p_proto >= MAXUCHAR )
  1320. {
  1321. status = WSAGetLastError();
  1322. SetLastError( status );
  1323. PrintRoutine( pPrintContext, "ERROR: getprotobyname()\n" );
  1324. ASSERT(FALSE);
  1325. }
  1326. PrintRoutine( pPrintContext,
  1327. "%s\t",
  1328. pProtoent->p_name
  1329. );
  1330. //bBitMask[0] : string length, not printed:
  1331. for ( i = 1;
  1332. i < (INT)( dataLength
  1333. - sizeof( pdata->WKS.ipAddress )
  1334. - sizeof( pdata->WKS.chProtocol ) );
  1335. i++ )
  1336. {
  1337. PrintRoutine( pPrintContext,
  1338. "%c",
  1339. (UCHAR) pdata->WKS.bBitMask[i] );
  1340. }
  1341. PrintRoutine( pPrintContext,"\n");
  1342. break;
  1343. }
  1344. }
  1345. case DNS_TYPE_NULL:
  1346. {
  1347. INT i;
  1348. for ( i = 0; i < dataLength; i++ )
  1349. {
  1350. // print one DWORD per line
  1351. if ( !(i%16) )
  1352. {
  1353. PrintRoutine( pPrintContext, "\n\t" );
  1354. }
  1355. PrintRoutine( pPrintContext,
  1356. "%02x ",
  1357. (UCHAR) pdata->Null.bData[i] );
  1358. }
  1359. PrintRoutine( pPrintContext, "\n" );
  1360. break;
  1361. }
  1362. case DNS_TYPE_SRV:
  1363. //
  1364. // SRV <priority> <weight> <port> <target host>
  1365. //
  1366. PrintRoutine( pPrintContext,
  1367. "%d %d %d ",
  1368. pdata->SRV.wPriority,
  1369. pdata->SRV.wWeight,
  1370. pdata->SRV.wPort
  1371. );
  1372. DnsPrint_RpcName(
  1373. PrintRoutine, pPrintContext,
  1374. NULL,
  1375. & pdata->SRV.nameTarget,
  1376. "\n" );
  1377. break;
  1378. case DNS_TYPE_WINS:
  1379. {
  1380. DWORD i;
  1381. CHAR flagName[ WINS_FLAG_MAX_LENGTH ];
  1382. //
  1383. // WINS
  1384. // - scope/domain mapping flag
  1385. // - WINS server list
  1386. //
  1387. Dns_WinsRecordFlagString(
  1388. pdata->WINS.dwMappingFlag,
  1389. flagName );
  1390. PrintRoutine( pPrintContext,
  1391. "%s %d %d ",
  1392. flagName,
  1393. //pdata->WINS.dwMappingFlag,
  1394. pdata->WINS.dwLookupTimeout,
  1395. pdata->WINS.dwCacheTimeout
  1396. );
  1397. if ( fDetail )
  1398. {
  1399. PrintRoutine( pPrintContext, " WINS Servers:\n" );
  1400. }
  1401. for( i=0; i<pdata->WINS.cWinsServerCount; i++ )
  1402. {
  1403. PrintRoutine( pPrintContext,
  1404. "%d.%d.%d.%d%c",
  1405. * ( (PUCHAR) &(pdata->WINS.aipWinsServers[i]) + 0 ),
  1406. * ( (PUCHAR) &(pdata->WINS.aipWinsServers[i]) + 1 ),
  1407. * ( (PUCHAR) &(pdata->WINS.aipWinsServers[i]) + 2 ),
  1408. * ( (PUCHAR) &(pdata->WINS.aipWinsServers[i]) + 3 ),
  1409. fDetail ? '\n' : ' '
  1410. );
  1411. }
  1412. if ( !fDetail )
  1413. {
  1414. PrintRoutine( pPrintContext, "\n" );
  1415. }
  1416. break;
  1417. }
  1418. case DNS_TYPE_NBSTAT:
  1419. {
  1420. CHAR flagName[ WINS_FLAG_MAX_LENGTH ];
  1421. //
  1422. // NBSTAT
  1423. // - scope/domain mapping flag
  1424. // - optionally a result domain
  1425. //
  1426. Dns_WinsRecordFlagString(
  1427. pdata->WINS.dwMappingFlag,
  1428. flagName );
  1429. PrintRoutine( pPrintContext,
  1430. "%s %d %d ",
  1431. flagName,
  1432. //pdata->WINS.dwMappingFlag,
  1433. pdata->NBSTAT.dwLookupTimeout,
  1434. pdata->NBSTAT.dwCacheTimeout
  1435. );
  1436. if ( dataLength > sizeof(pdata->NBSTAT.dwMappingFlag) )
  1437. {
  1438. DnsPrint_RpcName(
  1439. PrintRoutine, pPrintContext,
  1440. NULL,
  1441. & pdata->NBSTAT.nameResultDomain,
  1442. "\n" );
  1443. }
  1444. break;
  1445. }
  1446. case DNS_TYPE_KEY:
  1447. {
  1448. int keyLength = dataLength - SIZEOF_KEY_FIXED_DATA;
  1449. PrintRoutine( pPrintContext,
  1450. "0x%04X %d %d ",
  1451. ( int ) pdata->KEY.wFlags,
  1452. ( int ) pdata->KEY.chProtocol,
  1453. ( int ) pdata->KEY.chAlgorithm );
  1454. if ( keyLength > 0 && keyLength < sizeof( szBuff ) / 2 )
  1455. {
  1456. PCHAR p = Dns_SecurityKeyToBase64String(
  1457. ( PBYTE ) pdata + SIZEOF_KEY_FIXED_DATA,
  1458. keyLength,
  1459. szBuff );
  1460. if ( p )
  1461. {
  1462. *p = '\0'; // NULL terminate key string
  1463. }
  1464. PrintRoutine( pPrintContext, szBuff );
  1465. }
  1466. else
  1467. {
  1468. PrintRoutine( pPrintContext, "KEY = %d bytes", keyLength );
  1469. }
  1470. PrintRoutine( pPrintContext, "\n" );
  1471. break;
  1472. }
  1473. case DNS_TYPE_SIG:
  1474. {
  1475. CHAR szSigExp[ 30 ];
  1476. CHAR szSigInc[ 30 ];
  1477. INT sigOffset =
  1478. SIZEOF_SIG_FIXED_DATA +
  1479. pdata->SIG.nameSigner.cchNameLength +
  1480. sizeof( pdata->SIG.nameSigner.cchNameLength );
  1481. INT sigLength = dataLength - sigOffset;
  1482. ptypeString = Dns_RecordStringForType( pdata->SIG.wTypeCovered );
  1483. if ( !ptypeString )
  1484. {
  1485. ptypeString = "UNKNOWN-TYPE";
  1486. }
  1487. PrintRoutine( pPrintContext,
  1488. "%s %d %d %d %s %s %d ",
  1489. ptypeString,
  1490. ( int ) pdata->SIG.chAlgorithm,
  1491. ( int ) pdata->SIG.chLabelCount,
  1492. ( int ) pdata->SIG.dwOriginalTtl,
  1493. Dns_SigTimeString(
  1494. pdata->SIG.dwSigExpiration,
  1495. szSigExp ),
  1496. Dns_SigTimeString(
  1497. pdata->SIG.dwSigInception,
  1498. szSigInc ),
  1499. ( int ) pdata->SIG.wKeyTag );
  1500. DnsPrint_RpcName(
  1501. PrintRoutine, pPrintContext,
  1502. NULL,
  1503. &pdata->SIG.nameSigner,
  1504. " " );
  1505. if ( sigLength > 0 && sigLength < sizeof( szBuff ) / 2 )
  1506. {
  1507. PCHAR p = Dns_SecurityKeyToBase64String(
  1508. ( PBYTE ) pdata + sigOffset,
  1509. sigLength,
  1510. szBuff );
  1511. if ( p )
  1512. {
  1513. *p = '\0'; // NULL terminate key string
  1514. }
  1515. PrintRoutine( pPrintContext, szBuff );
  1516. }
  1517. else
  1518. {
  1519. PrintRoutine( pPrintContext, "SIG = %d bytes", sigLength );
  1520. }
  1521. PrintRoutine( pPrintContext, "\n" );
  1522. break;
  1523. }
  1524. case DNS_TYPE_NXT:
  1525. {
  1526. INT typeIdx;
  1527. DnsPrint_RpcName(
  1528. PrintRoutine, pPrintContext,
  1529. NULL,
  1530. ( PDNS_RPC_NAME ) ( ( PBYTE ) &pdata->NXT +
  1531. ( pdata->NXT.wNumTypeWords + 1 ) * sizeof( WORD ) ),
  1532. NULL );
  1533. for ( typeIdx = 0; typeIdx < pdata->NXT.wNumTypeWords; ++typeIdx )
  1534. {
  1535. ptypeString =
  1536. Dns_RecordStringForType( pdata->NXT.wTypeWords[ typeIdx ] );
  1537. if ( !ptypeString )
  1538. {
  1539. ptypeString = "UNKNOWN-TYPE";
  1540. }
  1541. PrintRoutine( pPrintContext,
  1542. " %s",
  1543. ptypeString );
  1544. }
  1545. PrintRoutine( pPrintContext, "\n" );
  1546. break;
  1547. }
  1548. default:
  1549. PrintRoutine( pPrintContext,
  1550. "Unknown resource record type (%d) at %p.\n",
  1551. type,
  1552. pRecord );
  1553. break;
  1554. }
  1555. Done:
  1556. DnsPrint_Unlock();
  1557. }
  1558. PDNS_RPC_NAME
  1559. DNS_API_FUNCTION
  1560. DnsPrint_RpcRecordsInBuffer(
  1561. IN PRINT_ROUTINE PrintRoutine,
  1562. IN OUT PPRINT_CONTEXT pPrintContext,
  1563. IN LPSTR pszHeader,
  1564. IN BOOL fDetail,
  1565. IN DWORD dwBufferLength,
  1566. IN BYTE abBuffer[]
  1567. )
  1568. /*++
  1569. Routine Description:
  1570. Prints RPC buffer.
  1571. Arguments:
  1572. PrintRoutine -- printf like routine to print with
  1573. pszHeader -- header string
  1574. fDetail -- if TRUE print detailed record info
  1575. dwBufferLength -- buffer length
  1576. abBuffer -- ptr to RPC buffer
  1577. Return Value:
  1578. Ptr to last RPC node name in buffer.
  1579. NULL on error.
  1580. --*/
  1581. {
  1582. PBYTE pcurrent;
  1583. PBYTE pstop;
  1584. PDNS_RPC_NAME plastName = NULL;
  1585. INT recordCount;
  1586. PCHAR precordHeader;
  1587. DnsPrint_Lock();
  1588. PrintRoutine( pPrintContext, (pszHeader ? pszHeader : "") );
  1589. if ( !abBuffer )
  1590. {
  1591. PrintRoutine( pPrintContext, "NULL record buffer ptr.\n" );
  1592. goto Done;
  1593. }
  1594. #if 0
  1595. else
  1596. {
  1597. PrintRoutine( pPrintContext,
  1598. "Record buffer of length %d at %p:\n",
  1599. dwBufferLength,
  1600. abBuffer );
  1601. }
  1602. #endif
  1603. //
  1604. // find stop byte
  1605. //
  1606. ASSERT( DNS_IS_DWORD_ALIGNED(abBuffer) );
  1607. pstop = abBuffer + dwBufferLength;
  1608. pcurrent = abBuffer;
  1609. //
  1610. // loop until out of nodes
  1611. //
  1612. while ( pcurrent < pstop )
  1613. {
  1614. //
  1615. // print owner node
  1616. // - if NOT printing detail and no records
  1617. // (essentially domain nodes) then no node print
  1618. //
  1619. plastName = &((PDNS_RPC_NODE)pcurrent)->dnsNodeName;
  1620. recordCount = ((PDNS_RPC_NODE)pcurrent)->wRecordCount;
  1621. if ( fDetail )
  1622. {
  1623. DnsPrint_RpcNode(
  1624. PrintRoutine, pPrintContext,
  1625. NULL,
  1626. (PDNS_RPC_NODE)pcurrent );
  1627. if ( recordCount == 0 )
  1628. {
  1629. PrintRoutine( pPrintContext,"\n");
  1630. }
  1631. }
  1632. else
  1633. {
  1634. #ifndef DBG
  1635. if ( recordCount != 0 )
  1636. #endif
  1637. {
  1638. DnsPrint_RpcName(
  1639. PrintRoutine, pPrintContext,
  1640. NULL,
  1641. plastName,
  1642. NULL );
  1643. #ifdef DBG
  1644. if ( recordCount == 0 )
  1645. {
  1646. PrintRoutine( pPrintContext, "\t\t(node)\n" );
  1647. }
  1648. #endif
  1649. }
  1650. }
  1651. pcurrent += ((PDNS_RPC_NODE)pcurrent)->wLength;
  1652. pcurrent = DNS_NEXT_DWORD_PTR(pcurrent);
  1653. //
  1654. // for each node, print all records in list
  1655. //
  1656. if ( !recordCount )
  1657. {
  1658. continue;
  1659. }
  1660. precordHeader = "";
  1661. while( recordCount-- )
  1662. {
  1663. if ( pcurrent >= pstop )
  1664. {
  1665. PrintRoutine( pPrintContext,
  1666. "ERROR: Bogus buffer at %p\n"
  1667. "\tExpect record at %p past buffer end at %p\n"
  1668. "\twith %d records remaining.\n",
  1669. abBuffer,
  1670. (PDNS_RPC_RECORD) pcurrent,
  1671. pstop,
  1672. recordCount+1 );
  1673. ASSERT( FALSE );
  1674. break;
  1675. }
  1676. DnsPrint_RpcRecord(
  1677. PrintRoutine, pPrintContext,
  1678. precordHeader,
  1679. fDetail,
  1680. (PDNS_RPC_RECORD)pcurrent );
  1681. precordHeader = "\t\t";
  1682. pcurrent += ((PDNS_RPC_RECORD)pcurrent)->wDataLength
  1683. + SIZEOF_DNS_RPC_RECORD_HEADER;
  1684. pcurrent = DNS_NEXT_DWORD_PTR(pcurrent);
  1685. }
  1686. }
  1687. Done:
  1688. DnsPrint_Unlock();
  1689. return( plastName );
  1690. }
  1691. VOID
  1692. DNS_API_FUNCTION
  1693. DnsPrint_Node(
  1694. IN PRINT_ROUTINE PrintRoutine,
  1695. IN OUT PPRINT_CONTEXT pPrintContext,
  1696. IN LPSTR pszHeader,
  1697. IN PDNS_NODE pNode,
  1698. IN BOOLEAN fPrintRecords
  1699. )
  1700. {
  1701. DnsPrint_Lock();
  1702. PrintRoutine( pPrintContext, (pszHeader ? pszHeader : "") );
  1703. if ( !pNode )
  1704. {
  1705. PrintRoutine( pPrintContext, " NULL DNS node ptr.\n" );
  1706. goto Unlock;
  1707. }
  1708. else
  1709. {
  1710. PrintRoutine( pPrintContext,
  1711. "%s\n"
  1712. "\tName = %s%S\n"
  1713. "\tPtr = %p, pNext = %p\n"
  1714. "\tFlags = %p\n"
  1715. "\tRec ptr = %p\n",
  1716. pszHeader ? "" : "DNS node",
  1717. (LPSTR) (pNode->Flags.S.Unicode ? "" : (PSTR) pNode->pName),
  1718. (LPWSTR) (pNode->Flags.S.Unicode ? pNode->pName : L""),
  1719. pNode,
  1720. pNode->pNext,
  1721. pNode->Flags.W,
  1722. pNode->pRecord );
  1723. }
  1724. //
  1725. // if desired print record list
  1726. //
  1727. if ( pNode->pRecord && fPrintRecords )
  1728. {
  1729. DnsPrint_RecordSet(
  1730. PrintRoutine, pPrintContext,
  1731. "\trecords:\n",
  1732. pNode->pRecord );
  1733. }
  1734. Unlock:
  1735. DnsPrint_Unlock();
  1736. }
  1737. VOID
  1738. DNS_API_FUNCTION
  1739. DnsPrint_NodeList(
  1740. IN PRINT_ROUTINE PrintRoutine,
  1741. IN OUT PPRINT_CONTEXT pPrintContext,
  1742. IN LPSTR pszHeader,
  1743. IN PDNS_NODE pNode,
  1744. IN BOOLEAN fPrintRecords
  1745. )
  1746. {
  1747. DnsPrint_Lock();
  1748. PrintRoutine( pPrintContext, (pszHeader ? pszHeader : "") );
  1749. if ( !pNode )
  1750. {
  1751. PrintRoutine( pPrintContext, " NULL node list pointer.\n" );
  1752. }
  1753. else
  1754. {
  1755. do
  1756. {
  1757. DnsPrint_Node(
  1758. PrintRoutine, pPrintContext,
  1759. NULL,
  1760. pNode,
  1761. fPrintRecords );
  1762. }
  1763. while ( pNode = pNode->pNext );
  1764. }
  1765. DnsPrint_Unlock();
  1766. }
  1767. //
  1768. // RPC Type union printing
  1769. //
  1770. VOID
  1771. DnsPrint_RpcIpArrayPlusParameters(
  1772. IN PRINT_ROUTINE PrintRoutine,
  1773. IN OUT PPRINT_CONTEXT pPrintContext,
  1774. IN LPSTR pszHeader,
  1775. IN LPSTR pszStructureName,
  1776. IN LPSTR pszParam1Name,
  1777. IN DWORD dwParam1,
  1778. IN LPSTR pszParam2Name,
  1779. IN DWORD dwParam2,
  1780. IN LPSTR pszIpArrayHeader,
  1781. IN PIP_ARRAY pIpArray
  1782. )
  1783. /*++
  1784. Routine Description:
  1785. Print info that contains up to two params and IP_ARRAY.
  1786. This is kludgy, but there are several RPC types that contain an
  1787. IP array and some flags. This does the right thing for all those
  1788. cases.
  1789. Arguments:
  1790. pszParam1Name -- name of parameter;
  1791. pszParam2Name -- name of parameter; serves as flag as to whether
  1792. param2 is printed
  1793. pszIpArrayHeader -- name of IP array, passed to DnsPrint_IpArray
  1794. as header; should be full header line
  1795. ex. "\tMasters:\n"
  1796. Return Value:
  1797. None.
  1798. --*/
  1799. {
  1800. if ( !pszHeader )
  1801. {
  1802. pszHeader = "";
  1803. }
  1804. DnsPrint_Lock();
  1805. PrintRoutine( pPrintContext,
  1806. "%s%s\n"
  1807. "\t%s = %d (%p)\n",
  1808. pszHeader,
  1809. pszStructureName,
  1810. pszParam1Name,
  1811. dwParam1, dwParam1 );
  1812. if ( pszParam2Name )
  1813. {
  1814. PrintRoutine( pPrintContext,
  1815. "\t%s = %d (%p)\n",
  1816. pszParam2Name,
  1817. dwParam2, dwParam2 );
  1818. }
  1819. DnsPrint_IpArray(
  1820. PrintRoutine, pPrintContext,
  1821. pszIpArrayHeader,
  1822. "\t\t",
  1823. pIpArray );
  1824. DnsPrint_Unlock();
  1825. }
  1826. VOID
  1827. DnsPrint_RpcUnion(
  1828. IN PRINT_ROUTINE PrintRoutine,
  1829. IN OUT PPRINT_CONTEXT pPrintContext,
  1830. IN LPSTR pszHeader,
  1831. IN DWORD dwTypeId,
  1832. IN PVOID pData
  1833. )
  1834. {
  1835. if ( !pszHeader )
  1836. {
  1837. pszHeader = "";
  1838. }
  1839. if ( !pData &&
  1840. dwTypeId != DNSSRV_TYPEID_NULL &&
  1841. dwTypeId != DNSSRV_TYPEID_DWORD )
  1842. {
  1843. PrintRoutine( pPrintContext,
  1844. "%sNull RPC data ptr of type %d.\n",
  1845. pszHeader,
  1846. dwTypeId );
  1847. return;
  1848. }
  1849. switch ( dwTypeId )
  1850. {
  1851. case DNSSRV_TYPEID_NULL:
  1852. PrintRoutine( pPrintContext,
  1853. "%sPointer: %p\n",
  1854. pszHeader,
  1855. pData );
  1856. break;
  1857. case DNSSRV_TYPEID_DWORD:
  1858. PrintRoutine( pPrintContext,
  1859. "%sDword: %d (%p)\n",
  1860. pszHeader,
  1861. (DWORD)(UINT_PTR)pData, pData );
  1862. break;
  1863. case DNSSRV_TYPEID_LPSTR:
  1864. PrintRoutine( pPrintContext,
  1865. "%sString: %s\n",
  1866. pszHeader,
  1867. (LPSTR)pData );
  1868. break;
  1869. case DNSSRV_TYPEID_LPWSTR:
  1870. PrintRoutine( pPrintContext,
  1871. "%sWideString: %S\n",
  1872. pszHeader,
  1873. (LPWSTR)pData );
  1874. break;
  1875. case DNSSRV_TYPEID_IPARRAY:
  1876. DnsPrint_IpArray(
  1877. PrintRoutine, pPrintContext,
  1878. pszHeader,
  1879. NULL,
  1880. (PIP_ARRAY) pData );
  1881. break;
  1882. case DNSSRV_TYPEID_BUFFER:
  1883. PrintRoutine( pPrintContext,
  1884. "%sBuffer: length = %d, data ptr = %p\n",
  1885. pszHeader,
  1886. ((PDNS_RPC_BUFFER) pData)->dwLength,
  1887. ((PDNS_RPC_BUFFER) pData)->Buffer );
  1888. break;
  1889. case DNSSRV_TYPEID_SERVER_INFO:
  1890. DnsPrint_RpcServerInfo(
  1891. PrintRoutine, pPrintContext,
  1892. pszHeader,
  1893. (PDNS_RPC_SERVER_INFO) pData );
  1894. break;
  1895. case DNSSRV_TYPEID_STATS:
  1896. DnsPrint_RpcSingleStat(
  1897. PrintRoutine, pPrintContext,
  1898. pszHeader,
  1899. (PDNSSRV_STAT) pData );
  1900. break;
  1901. case DNSSRV_TYPEID_ZONE:
  1902. PrintRoutine( pPrintContext,
  1903. "%s\n",
  1904. pszHeader);
  1905. DnsPrint_RpcZone(
  1906. PrintRoutine, pPrintContext,
  1907. NULL, //print default header
  1908. (PDNS_RPC_ZONE) pData );
  1909. break;
  1910. case DNSSRV_TYPEID_FORWARDERS:
  1911. DnsPrint_RpcIpArrayPlusParameters(
  1912. PrintRoutine, pPrintContext,
  1913. pszHeader,
  1914. "Forwarders Info:",
  1915. "Slave",
  1916. ((PDNS_RPC_FORWARDERS)pData)->fSlave,
  1917. "Timeout",
  1918. ((PDNS_RPC_FORWARDERS)pData)->dwForwardTimeout,
  1919. "\tForwarders:\n",
  1920. ((PDNS_RPC_FORWARDERS)pData)->aipForwarders );
  1921. break;
  1922. case DNSSRV_TYPEID_ZONE_INFO:
  1923. DnsPrint_RpcZoneInfo(
  1924. PrintRoutine, pPrintContext,
  1925. pszHeader,
  1926. (PDNS_RPC_ZONE_INFO) pData );
  1927. break;
  1928. case DNSSRV_TYPEID_ZONE_SECONDARIES:
  1929. DnsPrint_RpcIpArrayPlusParameters(
  1930. PrintRoutine, pPrintContext,
  1931. pszHeader,
  1932. "Zone Secondary Info:",
  1933. "Secure Secondaries",
  1934. ((PDNS_RPC_ZONE_SECONDARIES)pData)->fSecureSecondaries,
  1935. NULL,
  1936. 0,
  1937. "\tSecondaries:\n",
  1938. ((PDNS_RPC_ZONE_SECONDARIES)pData)->aipSecondaries );
  1939. break;
  1940. case DNSSRV_TYPEID_ZONE_TYPE_RESET:
  1941. DnsPrint_RpcIpArrayPlusParameters(
  1942. PrintRoutine, pPrintContext,
  1943. pszHeader,
  1944. "Zone Type Reset Info:",
  1945. "ZoneType",
  1946. ((PDNS_RPC_ZONE_TYPE_RESET)pData)->dwZoneType,
  1947. NULL,
  1948. 0,
  1949. "\tMasters:\n",
  1950. ((PDNS_RPC_ZONE_TYPE_RESET)pData)->aipMasters );
  1951. break;
  1952. case DNSSRV_TYPEID_ZONE_DATABASE:
  1953. PrintRoutine( pPrintContext,
  1954. "%sZone Dbase Info:\n"
  1955. "\tDS Integrated = %d\n"
  1956. "\tFile Name = %s\n",
  1957. pszHeader,
  1958. ((PDNS_RPC_ZONE_DATABASE)pData)->fDsIntegrated,
  1959. ((PDNS_RPC_ZONE_DATABASE)pData)->pszFileName );
  1960. break;
  1961. case DNSSRV_TYPEID_ZONE_CREATE:
  1962. PrintRoutine( pPrintContext,
  1963. "%sZone Create Info:\n"
  1964. "\tZone Name = %s\n"
  1965. "\tType = %d\n"
  1966. "\tAllow Update = %d\n"
  1967. "\tDS Integrated = %d\n"
  1968. "\tFile Name = %s\n"
  1969. "\tLoad Existing = %d\n"
  1970. "\tFlags = 0x%08X\n"
  1971. "\tAdmin Name = %s\n"
  1972. "\tDirPart Flags = 0x%08X\n"
  1973. "\tDirPart FQDN = %s\n",
  1974. pszHeader,
  1975. ((PDNS_RPC_ZONE_CREATE_INFO)pData)->pszZoneName,
  1976. ((PDNS_RPC_ZONE_CREATE_INFO)pData)->dwZoneType,
  1977. ((PDNS_RPC_ZONE_CREATE_INFO)pData)->fAllowUpdate,
  1978. ((PDNS_RPC_ZONE_CREATE_INFO)pData)->fDsIntegrated,
  1979. ((PDNS_RPC_ZONE_CREATE_INFO)pData)->pszDataFile,
  1980. ((PDNS_RPC_ZONE_CREATE_INFO)pData)->fLoadExisting,
  1981. ((PDNS_RPC_ZONE_CREATE_INFO)pData)->dwFlags,
  1982. ((PDNS_RPC_ZONE_CREATE_INFO)pData)->pszAdmin,
  1983. ((PDNS_RPC_ZONE_CREATE_INFO)pData)->dwDpFlags,
  1984. ((PDNS_RPC_ZONE_CREATE_INFO)pData)->pszDpFqdn );
  1985. break;
  1986. case DNSSRV_TYPEID_NAME_AND_PARAM:
  1987. PrintRoutine( pPrintContext,
  1988. "%sName and Parameter:\n"
  1989. "\tParam = %d (%p)\n"
  1990. "\tName = %s\n",
  1991. pszHeader,
  1992. ((PDNS_RPC_NAME_AND_PARAM)pData)->dwParam,
  1993. ((PDNS_RPC_NAME_AND_PARAM)pData)->dwParam,
  1994. ((PDNS_RPC_NAME_AND_PARAM)pData)->pszNodeName );
  1995. break;
  1996. case DNSSRV_TYPEID_ZONE_LIST:
  1997. DnsPrint_RpcZoneList(
  1998. PrintRoutine, pPrintContext,
  1999. NULL,
  2000. (PDNS_RPC_ZONE_LIST)pData );
  2001. break;
  2002. default:
  2003. PrintRoutine( pPrintContext,
  2004. "%s\n"
  2005. "WARNING: Unknown RPC structure typeid = %d at %p\n",
  2006. pszHeader,
  2007. dwTypeId,
  2008. pData );
  2009. break;
  2010. }
  2011. }
  2012. //
  2013. // Stat validity table.
  2014. //
  2015. // Contains match of stat ID and lengths as of this build of RPC client.
  2016. //
  2017. typedef struct StatsValidityTableEntry
  2018. {
  2019. DWORD Id;
  2020. WORD wLength;
  2021. };
  2022. struct StatsValidityTableEntry StatsValidityTable[] =
  2023. {
  2024. DNSSRV_STATID_TIME, sizeof(DNSSRV_TIME_STATS),
  2025. DNSSRV_STATID_QUERY, sizeof(DNSSRV_QUERY_STATS),
  2026. DNSSRV_STATID_QUERY2, sizeof(DNSSRV_QUERY2_STATS),
  2027. DNSSRV_STATID_RECURSE, sizeof(DNSSRV_RECURSE_STATS),
  2028. DNSSRV_STATID_MASTER, sizeof(DNSSRV_MASTER_STATS),
  2029. DNSSRV_STATID_SECONDARY, sizeof(DNSSRV_SECONDARY_STATS),
  2030. DNSSRV_STATID_WINS, sizeof(DNSSRV_WINS_STATS),
  2031. DNSSRV_STATID_NBSTAT, sizeof(DNSSRV_NBSTAT_STATS),
  2032. DNSSRV_STATID_WIRE_UPDATE, sizeof(DNSSRV_UPDATE_STATS),
  2033. DNSSRV_STATID_NONWIRE_UPDATE, sizeof(DNSSRV_UPDATE_STATS),
  2034. DNSSRV_STATID_SKWANSEC, sizeof(DNSSRV_SKWANSEC_STATS),
  2035. DNSSRV_STATID_DS, sizeof(DNSSRV_DS_STATS),
  2036. DNSSRV_STATID_MEMORY, sizeof(DNSSRV_MEMORY_STATS),
  2037. DNSSRV_STATID_PACKET, sizeof(DNSSRV_PACKET_STATS),
  2038. DNSSRV_STATID_DBASE, sizeof(DNSSRV_DBASE_STATS),
  2039. DNSSRV_STATID_RECORD, sizeof(DNSSRV_RECORD_STATS),
  2040. DNSSRV_STATID_TIMEOUT, sizeof(DNSSRV_TIMEOUT_STATS),
  2041. DNSSRV_STATID_ERRORS, sizeof(DNSSRV_ERROR_STATS),
  2042. DNSSRV_STATID_CACHE, sizeof(DNSSRV_CACHE_STATS),
  2043. DNSSRV_STATID_PRIVATE, sizeof(DNSSRV_PRIVATE_STATS),
  2044. 0, 0, // termination
  2045. };
  2046. DNS_STATUS
  2047. DNS_API_FUNCTION
  2048. DnssrvValidityCheckStatistic(
  2049. IN PDNSSRV_STAT pStat
  2050. )
  2051. /*++
  2052. Routine Description:
  2053. Validity check stat struct received from server.
  2054. Arguments:
  2055. pStat -- ptr to stat buffer
  2056. Return Value:
  2057. ERROR_SUCCESS if valid.
  2058. DNS_ERROR_INVALID_TYPE if unknown stat id.
  2059. ERROR_INVALID_DATA if invalid data.
  2060. --*/
  2061. {
  2062. DWORD i;
  2063. DWORD id;
  2064. //
  2065. // find stat ID in table, and verify length match
  2066. //
  2067. i = 0;
  2068. while ( id = StatsValidityTable[i].Id )
  2069. {
  2070. if ( pStat->Header.StatId == id )
  2071. {
  2072. if ( pStat->Header.wLength ==
  2073. StatsValidityTable[i].wLength - sizeof(DNSSRV_STAT_HEADER) )
  2074. {
  2075. return( ERROR_SUCCESS );
  2076. }
  2077. return( ERROR_INVALID_DATA );
  2078. }
  2079. i++;
  2080. }
  2081. return( DNS_ERROR_INVALID_TYPE );
  2082. }
  2083. //
  2084. // Stat printing.
  2085. //
  2086. VOID
  2087. DnsPrint_RpcStatRaw(
  2088. IN PRINT_ROUTINE PrintRoutine,
  2089. IN OUT PPRINT_CONTEXT pPrintContext,
  2090. IN LPSTR pszHeader,
  2091. IN PDNSSRV_STAT pStat,
  2092. IN DNS_STATUS Status
  2093. )
  2094. /*++
  2095. Routine Description:
  2096. Debug print flat stat structure.
  2097. Arguments:
  2098. PrintRoutine -- printf like print routine to use
  2099. pszHeader -- header message to print
  2100. pStat -- ptr to stat buffer
  2101. Status -- status result of validity check; if not ERROR_SUCCESS,
  2102. appropriate error message is printed
  2103. Return Value:
  2104. None.
  2105. --*/
  2106. {
  2107. PDWORD pdword;
  2108. INT i;
  2109. PCHAR pstatEnd;
  2110. DnsPrint_Lock();
  2111. if ( pszHeader )
  2112. {
  2113. PrintRoutine( pPrintContext, pszHeader );
  2114. }
  2115. //
  2116. // validity check stat
  2117. //
  2118. if ( Status != ERROR_SUCCESS )
  2119. {
  2120. if ( Status == DNS_ERROR_INVALID_TYPE )
  2121. {
  2122. PrintRoutine( pPrintContext,
  2123. "Stat ID = %p, is not valid for version of the DNS RPC client.\n",
  2124. pStat->Header.StatId );
  2125. }
  2126. else if ( Status == ERROR_INVALID_DATA )
  2127. {
  2128. PrintRoutine( pPrintContext,
  2129. "Stat data length %d is invalid for stat ID = %p\n",
  2130. pStat->Header.wLength,
  2131. pStat->Header.StatId );
  2132. }
  2133. PrintRoutine( pPrintContext,
  2134. "WARNING: DNS RPC client must match version of server for statistics\n"
  2135. "\tprinting to be formatted appropriately.\n"
  2136. "Update this tool or the DNS server as necessary to match versions.\n" );
  2137. }
  2138. //
  2139. // print stat buffer raw
  2140. //
  2141. PrintRoutine( pPrintContext,
  2142. "Stat ID %p:\n",
  2143. pStat->Header.StatId );
  2144. pdword = (PDWORD) pStat->Buffer;
  2145. pstatEnd = pStat->Header.wLength + (PCHAR)pdword;
  2146. i = 0;
  2147. while ( (PCHAR)pdword < pstatEnd )
  2148. {
  2149. PrintRoutine( pPrintContext,
  2150. " stat[%d] = %10lu\n",
  2151. i,
  2152. *pdword );
  2153. pdword++;
  2154. i++;
  2155. }
  2156. DnsPrint_Unlock();
  2157. }
  2158. VOID
  2159. DnsPrint_RpcStatsBuffer(
  2160. IN PRINT_ROUTINE PrintRoutine,
  2161. IN OUT PPRINT_CONTEXT pPrintContext,
  2162. IN LPSTR pszHeader,
  2163. IN PDNS_RPC_BUFFER pBuffer
  2164. )
  2165. /*++
  2166. Routine Description:
  2167. Debug print stats buffer.
  2168. Arguments:
  2169. pBuffer -- buffer containing stats to print
  2170. Return Value:
  2171. None.
  2172. --*/
  2173. {
  2174. PDNSSRV_STAT pstat;
  2175. PCHAR pch;
  2176. PCHAR pchstop;
  2177. DnsPrint_Lock();
  2178. if ( pszHeader )
  2179. {
  2180. PrintRoutine( pPrintContext, pszHeader );
  2181. }
  2182. pch = pBuffer->Buffer;
  2183. pchstop = pch + pBuffer->dwLength;
  2184. while ( pch < pchstop )
  2185. {
  2186. pstat = (PDNSSRV_STAT) pch;
  2187. pch = (PCHAR) GET_NEXT_STAT_IN_BUFFER( pstat );
  2188. if ( pch > pchstop )
  2189. {
  2190. PrintRoutine( pPrintContext, "ERROR: invalid stats buffer!!!\n" );
  2191. break;
  2192. }
  2193. DnsPrint_RpcSingleStat(
  2194. PrintRoutine, pPrintContext,
  2195. NULL,
  2196. pstat );
  2197. }
  2198. PrintRoutine( pPrintContext, "\n\n" );
  2199. DnsPrint_Unlock();
  2200. }
  2201. VOID
  2202. printStatTypeArray(
  2203. IN PRINT_ROUTINE PrintRoutine,
  2204. IN OUT PPRINT_CONTEXT pPrintContext,
  2205. IN LPSTR pszHeader,
  2206. IN PDWORD pArray
  2207. )
  2208. /*++
  2209. Routine Description:
  2210. Debug print stats type array.
  2211. Arguments:
  2212. Return Value:
  2213. None.
  2214. --*/
  2215. {
  2216. register DWORD i;
  2217. PrintRoutine( pPrintContext,
  2218. "%s\n",
  2219. pszHeader );
  2220. //
  2221. // print counts for all types
  2222. // - skip mixed and unknown bins until end
  2223. //
  2224. for ( i=0; i<STATS_TYPE_MAX; i++ )
  2225. {
  2226. if ( i == STATS_TYPE_MIXED || i == STATS_TYPE_UNKNOWN )
  2227. {
  2228. continue;
  2229. }
  2230. PrintRoutine( pPrintContext,
  2231. " %-10s = %d\n",
  2232. Dns_RecordStringForType( (WORD)i ),
  2233. pArray[i] );
  2234. }
  2235. PrintRoutine( pPrintContext,
  2236. " %-10s = %d\n",
  2237. "Unknown",
  2238. pArray[STATS_TYPE_UNKNOWN] );
  2239. PrintRoutine( pPrintContext,
  2240. " %-10s = %d\n"
  2241. "\n",
  2242. "Mixed",
  2243. pArray[STATS_TYPE_MIXED] );
  2244. }
  2245. VOID
  2246. DnsPrint_RpcSingleStat(
  2247. IN PRINT_ROUTINE PrintRoutine,
  2248. IN OUT PPRINT_CONTEXT pPrintContext,
  2249. IN LPSTR pszHeader,
  2250. IN PDNSSRV_STAT pStat
  2251. )
  2252. /*++
  2253. Routine Description:
  2254. Debug print stats structure.
  2255. Arguments:
  2256. None.
  2257. Return Value:
  2258. None.
  2259. --*/
  2260. {
  2261. DNS_STATUS status;
  2262. //
  2263. // validity check stat
  2264. //
  2265. status = DnssrvValidityCheckStatistic( pStat );
  2266. if ( status != ERROR_SUCCESS )
  2267. {
  2268. DnsPrint_RpcStatRaw(
  2269. PrintRoutine, pPrintContext,
  2270. pszHeader,
  2271. pStat,
  2272. status );
  2273. return;
  2274. }
  2275. DnsPrint_Lock();
  2276. if ( pszHeader )
  2277. {
  2278. PrintRoutine( pPrintContext, pszHeader );
  2279. }
  2280. //
  2281. // switch on stats type
  2282. //
  2283. switch ( pStat->Header.StatId )
  2284. {
  2285. case DNSSRV_STATID_TIME:
  2286. {
  2287. PDNSSRV_TIME_STATS pstat = (PDNSSRV_TIME_STATS)pStat;
  2288. SYSTEMTIME localTime;
  2289. CHAR szdate[30];
  2290. CHAR sztime[20];
  2291. SystemTimeToTzSpecificLocalTime(
  2292. NULL, // use local time
  2293. (PSYSTEMTIME) & pstat->ServerStartTime,
  2294. & localTime );
  2295. GetDateFormat(
  2296. LOCALE_SYSTEM_DEFAULT,
  2297. LOCALE_NOUSEROVERRIDE,
  2298. // (PSYSTEMTIME) &pstat->ServerStartTime,
  2299. & localTime,
  2300. NULL,
  2301. szdate,
  2302. 30 );
  2303. GetTimeFormat(
  2304. LOCALE_SYSTEM_DEFAULT,
  2305. LOCALE_NOUSEROVERRIDE,
  2306. // (PSYSTEMTIME) &pstat->ServerStartTime,
  2307. & localTime,
  2308. NULL,
  2309. sztime,
  2310. 20 );
  2311. PrintRoutine( pPrintContext,
  2312. "\n"
  2313. "DNS Server Time Statistics\n"
  2314. "--------------------------\n"
  2315. "Server start time %s %s\n"
  2316. "Seconds since start %10lu\n",
  2317. szdate,
  2318. sztime,
  2319. pstat->SecondsSinceServerStart
  2320. );
  2321. SystemTimeToTzSpecificLocalTime(
  2322. NULL, // use local time
  2323. (PSYSTEMTIME) & pstat->LastClearTime,
  2324. & localTime );
  2325. GetDateFormat(
  2326. LOCALE_SYSTEM_DEFAULT,
  2327. LOCALE_NOUSEROVERRIDE,
  2328. // (PSYSTEMTIME) &pstat->LastClearTime,
  2329. & localTime,
  2330. NULL,
  2331. szdate,
  2332. 30 );
  2333. GetTimeFormat(
  2334. LOCALE_SYSTEM_DEFAULT,
  2335. LOCALE_NOUSEROVERRIDE,
  2336. // (PSYSTEMTIME) &pstat->LastClearTime,
  2337. & localTime,
  2338. NULL,
  2339. sztime,
  2340. 20 );
  2341. PrintRoutine( pPrintContext,
  2342. "Stats last cleared %s %s\n"
  2343. "Seconds since clear %10lu\n",
  2344. szdate,
  2345. sztime,
  2346. pstat->SecondsSinceLastClear
  2347. );
  2348. break;
  2349. }
  2350. case DNSSRV_STATID_QUERY:
  2351. {
  2352. PDNSSRV_QUERY_STATS pstat = (PDNSSRV_QUERY_STATS)pStat;
  2353. PrintRoutine( pPrintContext,
  2354. "\n"
  2355. "Queries and Responses:\n"
  2356. "----------------------\n"
  2357. "Total:\n"
  2358. " Queries Received = %10lu\n"
  2359. " Responses Sent = %10lu\n"
  2360. "UDP:\n"
  2361. " Queries Recvd = %10lu\n"
  2362. " Responses Sent = %10lu\n"
  2363. " Queries Sent = %10lu\n"
  2364. " Responses Recvd = %10lu\n"
  2365. "TCP:\n"
  2366. " Client Connects = %10lu\n"
  2367. " Queries Recvd = %10lu\n"
  2368. " Responses Sent = %10lu\n"
  2369. " Queries Sent = %10lu\n"
  2370. " Responses Recvd = %10lu\n",
  2371. pstat->UdpQueries + pstat->TcpQueries,
  2372. pstat->UdpResponses + pstat->TcpResponses,
  2373. pstat->UdpQueries,
  2374. pstat->UdpResponses,
  2375. pstat->UdpQueriesSent,
  2376. pstat->UdpResponsesReceived,
  2377. pstat->TcpClientConnections,
  2378. pstat->TcpQueries,
  2379. pstat->TcpResponses,
  2380. pstat->TcpQueriesSent,
  2381. pstat->TcpResponsesReceived
  2382. );
  2383. break;
  2384. }
  2385. case DNSSRV_STATID_QUERY2:
  2386. {
  2387. PDNSSRV_QUERY2_STATS pstat = (PDNSSRV_QUERY2_STATS)pStat;
  2388. PrintRoutine( pPrintContext,
  2389. "\n"
  2390. "Queries:\n"
  2391. "--------\n"
  2392. "Total = %10lu\n"
  2393. " Notify = %10lu\n"
  2394. " Update = %10lu\n"
  2395. " TKeyNego = %10lu\n"
  2396. " Standard = %10lu\n"
  2397. " A = %10lu\n"
  2398. " NS = %10lu\n"
  2399. " SOA = %10lu\n"
  2400. " MX = %10lu\n"
  2401. " PTR = %10lu\n"
  2402. " SRV = %10lu\n"
  2403. " ALL = %10lu\n"
  2404. " IXFR = %10lu\n"
  2405. " AXFR = %10lu\n"
  2406. " OTHER = %10lu\n",
  2407. pstat->TotalQueries,
  2408. pstat->Notify,
  2409. pstat->Update,
  2410. pstat->TKeyNego,
  2411. pstat->Standard,
  2412. pstat->TypeA,
  2413. pstat->TypeNs,
  2414. pstat->TypeSoa,
  2415. pstat->TypeMx,
  2416. pstat->TypePtr,
  2417. pstat->TypeSrv,
  2418. pstat->TypeAll,
  2419. pstat->TypeIxfr,
  2420. pstat->TypeAxfr,
  2421. pstat->TypeOther
  2422. );
  2423. break;
  2424. }
  2425. case DNSSRV_STATID_RECURSE:
  2426. {
  2427. PDNSSRV_RECURSE_STATS pstat = (PDNSSRV_RECURSE_STATS)pStat;
  2428. PrintRoutine( pPrintContext,
  2429. "\n"
  2430. "Recursion:\n"
  2431. "----------\n"
  2432. "Query:\n"
  2433. " Queries Recursed = %10lu\n"
  2434. " Original Questions = %10lu\n"
  2435. " Additional Question = %10lu\n"
  2436. " Total Questions = %10lu\n"
  2437. " Retries = %10lu\n"
  2438. " Total Passes = %10lu\n"
  2439. " ToForwarders = %10lu\n"
  2440. " Sends = %10lu\n",
  2441. pstat->QueriesRecursed,
  2442. pstat->OriginalQuestionRecursed,
  2443. pstat->AdditionalRecursed,
  2444. pstat->TotalQuestionsRecursed,
  2445. pstat->Retries,
  2446. pstat->LookupPasses,
  2447. pstat->Forwards,
  2448. pstat->Sends );
  2449. PrintRoutine( pPrintContext,
  2450. "\n"
  2451. "Response:\n"
  2452. " TotalResponses = %10lu\n"
  2453. " Unmatched = %10lu\n"
  2454. " Mismatched = %10lu\n"
  2455. " FromForwarder = %10lu\n"
  2456. " Authoritative = %10lu\n"
  2457. " NotAuthoritative = %10lu\n"
  2458. " Answer = %10lu\n"
  2459. " Empty = %10lu\n"
  2460. " NameError = %10lu\n"
  2461. " Rcode = %10lu\n"
  2462. " Delegation = %10lu\n"
  2463. " NonZoneData = %10lu\n"
  2464. " Unsecure = %10lu\n"
  2465. " BadPacket = %10lu\n"
  2466. "Process Response:\n"
  2467. " Forward Response = %10lu\n"
  2468. " Continue Recursion = %10lu\n"
  2469. " Continue Lookup = %10lu\n"
  2470. " Next Lookup = %10lu\n",
  2471. pstat->Responses,
  2472. pstat->ResponseUnmatched,
  2473. pstat->ResponseMismatched,
  2474. pstat->ResponseFromForwarder,
  2475. pstat->ResponseAuthoritative,
  2476. pstat->ResponseNotAuth,
  2477. pstat->ResponseAnswer,
  2478. pstat->ResponseEmpty,
  2479. pstat->ResponseNameError,
  2480. pstat->ResponseRcode,
  2481. pstat->ResponseDelegation,
  2482. pstat->ResponseNonZoneData,
  2483. pstat->ResponseUnsecure,
  2484. pstat->ResponseBadPacket,
  2485. pstat->SendResponseDirect,
  2486. pstat->ContinueCurrentRecursion,
  2487. pstat->ContinueCurrentLookup,
  2488. pstat->ContinueNextLookup );
  2489. PrintRoutine( pPrintContext,
  2490. "\n"
  2491. "Timeouts:\n"
  2492. " Send Timeouts = %10lu\n"
  2493. " Final Queued = %10lu\n"
  2494. " Final Expired = %10lu\n"
  2495. "\n"
  2496. "Failures:\n"
  2497. " Recurse Failures = %10lu\n"
  2498. " Into Authority = %10lu\n"
  2499. " Previous Zone = %10lu\n"
  2500. " Retry Limit = %10lu\n"
  2501. " Partial (HaveAnswer) = %10lu\n"
  2502. " Cache Update = %10lu\n"
  2503. " Server Failure Resp = %10lu\n"
  2504. " Total Failures = %10lu\n",
  2505. pstat->PacketTimeout,
  2506. pstat->FinalTimeoutQueued,
  2507. pstat->FinalTimeoutExpired,
  2508. pstat->RecursePassFailure,
  2509. pstat->FailureReachAuthority,
  2510. pstat->FailureReachPreviousResponse,
  2511. pstat->FailureRetryCount,
  2512. pstat->PartialFailure,
  2513. pstat->CacheUpdateFailure,
  2514. pstat->ServerFailure,
  2515. pstat->Failures
  2516. );
  2517. PrintRoutine( pPrintContext,
  2518. "\n"
  2519. "TCP Recursion:\n"
  2520. " Try = %10lu\n"
  2521. " Query = %10lu\n"
  2522. " Response = %10lu\n"
  2523. " Disconnects = %10lu\n"
  2524. "\n"
  2525. "Cache Update Queries:\n"
  2526. " Query = %10lu\n"
  2527. " Response = %10lu\n"
  2528. " Retry = %10lu\n"
  2529. " Free = %10lu\n"
  2530. " Root NS Query = %10lu\n"
  2531. " Root NS Response = %10lu\n"
  2532. " Suspended Query = %10lu\n"
  2533. " Resume Suspended = %10lu\n"
  2534. "\n",
  2535. pstat->TcpTry,
  2536. pstat->TcpQuery,
  2537. pstat->TcpResponse,
  2538. pstat->TcpDisconnect,
  2539. pstat->CacheUpdateAlloc,
  2540. pstat->CacheUpdateResponse,
  2541. pstat->CacheUpdateRetry,
  2542. pstat->CacheUpdateFree,
  2543. pstat->RootNsQuery,
  2544. pstat->RootNsResponse,
  2545. pstat->SuspendedQuery,
  2546. pstat->ResumeSuspendedQuery );
  2547. PrintRoutine( pPrintContext,
  2548. "\n"
  2549. "Other:\n"
  2550. " Discarded duplicates = %10lu\n"
  2551. "\n",
  2552. pstat->DiscardedDuplicateQueries );
  2553. break;
  2554. }
  2555. case DNSSRV_STATID_MASTER:
  2556. {
  2557. PDNSSRV_MASTER_STATS pstat = (PDNSSRV_MASTER_STATS)pStat;
  2558. PrintRoutine( pPrintContext,
  2559. "\n"
  2560. "Master Stats:\n"
  2561. "-------------\n"
  2562. "Notifies Sent = %10lu\n"
  2563. "\n"
  2564. "Requests = %10lu\n"
  2565. " NameError = %10lu\n"
  2566. " FormError = %10lu\n"
  2567. " Refused = %10lu\n"
  2568. " AxfrLimit = %10lu\n"
  2569. " Security = %10lu\n"
  2570. " Shutdown = %10lu\n"
  2571. " ZoneLocked = %10lu\n"
  2572. " ServerFailure = %10lu\n"
  2573. " Failure = %10lu\n"
  2574. " Success = %10lu\n"
  2575. "\n"
  2576. "AXFR Request = %10lu\n"
  2577. " Success = %10lu\n"
  2578. " In IXFR = %10lu\n"
  2579. "\n"
  2580. "IXFR Request = %10lu\n"
  2581. " Success Update = %10lu\n"
  2582. " UDP Request = %10lu\n"
  2583. " Success = %10lu\n"
  2584. " Force TCP = %10lu\n"
  2585. " Force Full = %10lu\n"
  2586. " TCP Request = %10lu\n"
  2587. " Success = %10lu\n"
  2588. " Do Full = %10lu\n"
  2589. "\n",
  2590. pstat->NotifySent,
  2591. pstat->Request,
  2592. pstat->NameError,
  2593. pstat->FormError,
  2594. pstat->Refused,
  2595. pstat->AxfrLimit,
  2596. pstat->RefuseSecurity,
  2597. pstat->RefuseShutdown,
  2598. pstat->RefuseZoneLocked,
  2599. pstat->RefuseServerFailure,
  2600. pstat->Failure,
  2601. (pstat->AxfrSuccess + pstat->IxfrUpdateSuccess),
  2602. pstat->AxfrRequest,
  2603. pstat->AxfrSuccess,
  2604. pstat->IxfrAxfr,
  2605. pstat->IxfrRequest,
  2606. pstat->IxfrUpdateSuccess,
  2607. pstat->IxfrUdpRequest,
  2608. pstat->IxfrUdpSuccess,
  2609. pstat->IxfrUdpForceTcp,
  2610. pstat->IxfrUdpForceAxfr,
  2611. pstat->IxfrTcpRequest,
  2612. pstat->IxfrTcpSuccess,
  2613. pstat->IxfrAxfr
  2614. );
  2615. break;
  2616. }
  2617. case DNSSRV_STATID_SECONDARY:
  2618. {
  2619. PDNSSRV_SECONDARY_STATS pstat = (PDNSSRV_SECONDARY_STATS)pStat;
  2620. PrintRoutine( pPrintContext,
  2621. "\n"
  2622. "Secondary Stats:\n"
  2623. "----------------\n"
  2624. "NOTIFY:\n"
  2625. " Received = %10lu\n"
  2626. " Invalid = %10lu\n"
  2627. " Primary = %10lu\n"
  2628. " No Version = %10lu\n"
  2629. " New Version = %10lu\n"
  2630. " Current Version = %10lu\n"
  2631. " Old Version = %10lu\n"
  2632. " Master Unknown = %10lu\n"
  2633. "\n"
  2634. "SOA Query:\n"
  2635. " Request = %10lu\n"
  2636. " Response = %10lu\n"
  2637. " Invalid = %10lu\n"
  2638. " NameError = %10lu\n"
  2639. "\n"
  2640. "AXFR:\n"
  2641. " AXFR Request = %10lu\n"
  2642. " AXFR in IXFR = %10lu\n"
  2643. " Response = %10lu\n"
  2644. " Success = %10lu\n"
  2645. " Refused = %10lu\n"
  2646. " Invalid = %10lu\n"
  2647. "\n"
  2648. "Stub zone AXFR:\n"
  2649. " Stub AXFR Request = %10lu\n"
  2650. " Response = %10lu\n"
  2651. " Success = %10lu\n"
  2652. " Refused = %10lu\n"
  2653. " Invalid = %10lu\n"
  2654. "\n"
  2655. "IXFR UDP:\n"
  2656. " Request = %10lu\n"
  2657. " Response = %10lu\n"
  2658. " Success = %10lu\n"
  2659. " UseTcp = %10lu\n"
  2660. " UseAxfr = %10lu\n"
  2661. " New Primary = %10lu\n"
  2662. " Refused = %10lu\n"
  2663. " Wrong Server = %10lu\n"
  2664. " FormError = %10lu\n"
  2665. " Invalid = %10lu\n"
  2666. "\n"
  2667. "IXFR TCP:\n"
  2668. " Request = %10lu\n"
  2669. " Response = %10lu\n"
  2670. " Success = %10lu\n"
  2671. " AXFR = %10lu\n"
  2672. " FormError = %10lu\n"
  2673. " Refused = %10lu\n"
  2674. " Invalid = %10lu\n"
  2675. "\n",
  2676. pstat->NotifyReceived,
  2677. pstat->NotifyInvalid,
  2678. pstat->NotifyPrimary,
  2679. pstat->NotifyNoVersion,
  2680. pstat->NotifyNewVersion,
  2681. pstat->NotifyCurrentVersion,
  2682. pstat->NotifyOldVersion,
  2683. pstat->NotifyMasterUnknown,
  2684. pstat->SoaRequest,
  2685. pstat->SoaResponse,
  2686. pstat->SoaResponseInvalid,
  2687. pstat->SoaResponseNameError,
  2688. pstat->AxfrRequest,
  2689. pstat->IxfrTcpAxfr,
  2690. pstat->AxfrResponse,
  2691. pstat->AxfrSuccess,
  2692. pstat->AxfrRefused,
  2693. pstat->AxfrInvalid,
  2694. pstat->StubAxfrRequest,
  2695. pstat->StubAxfrResponse,
  2696. pstat->StubAxfrSuccess,
  2697. pstat->StubAxfrRefused,
  2698. pstat->StubAxfrInvalid,
  2699. pstat->IxfrUdpRequest,
  2700. pstat->IxfrUdpResponse,
  2701. pstat->IxfrUdpSuccess,
  2702. pstat->IxfrUdpUseTcp,
  2703. pstat->IxfrUdpUseAxfr,
  2704. pstat->IxfrUdpNewPrimary,
  2705. pstat->IxfrUdpRefused,
  2706. pstat->IxfrUdpWrongServer,
  2707. pstat->IxfrUdpFormerr,
  2708. pstat->IxfrUdpInvalid,
  2709. pstat->IxfrTcpRequest,
  2710. pstat->IxfrTcpResponse,
  2711. pstat->IxfrTcpSuccess,
  2712. pstat->IxfrTcpAxfr,
  2713. pstat->IxfrTcpFormerr,
  2714. pstat->IxfrTcpRefused,
  2715. pstat->IxfrTcpInvalid
  2716. );
  2717. break;
  2718. }
  2719. case DNSSRV_STATID_WINS:
  2720. {
  2721. PDNSSRV_WINS_STATS pstat = (PDNSSRV_WINS_STATS)pStat;
  2722. PrintRoutine( pPrintContext,
  2723. "\n"
  2724. "WINS Referrals:\n"
  2725. "---------------\n"
  2726. "Forward:\n"
  2727. " Lookups = %10lu\n"
  2728. " Responses = %10lu\n"
  2729. "Reverse:\n"
  2730. " Lookups = %10lu\n"
  2731. " Responses = %10lu\n",
  2732. pstat->WinsLookups,
  2733. pstat->WinsResponses,
  2734. pstat->WinsReverseLookups,
  2735. pstat->WinsReverseResponses
  2736. );
  2737. break;
  2738. }
  2739. case DNSSRV_STATID_NBSTAT:
  2740. {
  2741. PDNSSRV_NBSTAT_STATS pstat = (PDNSSRV_NBSTAT_STATS)pStat;
  2742. PrintRoutine( pPrintContext,
  2743. "\n"
  2744. "Nbstat Memory Usage:\n"
  2745. "--------------------\n"
  2746. "Nbstat Buffers:\n"
  2747. " Alloc = %10lu\n"
  2748. " Free = %10lu\n"
  2749. " NetAllocs = %10lu\n"
  2750. " Memory = %10lu\n"
  2751. " Used = %10lu\n"
  2752. " Returned = %10lu\n"
  2753. " InUse = %10lu\n"
  2754. " InFreeList = %10lu\n"
  2755. "\n",
  2756. pstat->NbstatAlloc,
  2757. pstat->NbstatFree,
  2758. pstat->NbstatNetAllocs,
  2759. pstat->NbstatMemory,
  2760. pstat->NbstatUsed,
  2761. pstat->NbstatReturn,
  2762. pstat->NbstatInUse,
  2763. pstat->NbstatInFreeList
  2764. );
  2765. break;
  2766. }
  2767. case DNSSRV_STATID_WIRE_UPDATE:
  2768. case DNSSRV_STATID_NONWIRE_UPDATE:
  2769. {
  2770. PDNSSRV_UPDATE_STATS pstat = (PDNSSRV_UPDATE_STATS)pStat;
  2771. PrintRoutine( pPrintContext,
  2772. "\n"
  2773. "%s:\n"
  2774. "--------------------------\n"
  2775. "Updates Received = %10lu\n"
  2776. " Forwarded = %10lu\n"
  2777. " Empty (PreCon Only) = %10lu\n"
  2778. " NoOps (Dups) = %10lu\n"
  2779. " Rejected = %10lu\n"
  2780. " Completed = %10lu\n"
  2781. " Timed Out = %10lu\n"
  2782. " In Queue = %10lu\n"
  2783. "\n"
  2784. "Updates Rejected = %10lu\n"
  2785. " FormError = %10lu\n"
  2786. " NameError = %10lu\n"
  2787. " NotImpl = %10lu (Non-Update Zone)\n"
  2788. " Refused = %10lu\n"
  2789. " NonSecure Packet = %10lu\n"
  2790. " AccessDenied = %10lu\n"
  2791. " YxDomain = %10lu\n"
  2792. " YxRRSet = %10lu\n"
  2793. " NxRRSet = %10lu\n"
  2794. " NotAuth = %10lu\n"
  2795. " NotZone = %10lu\n"
  2796. "\n"
  2797. #if 0 // unused counters
  2798. "Update Collisions = %10lu\n"
  2799. " Read = %10lu\n"
  2800. " Write = %10lu\n"
  2801. " In LDAP = %10lu\n"
  2802. "\n"
  2803. #endif
  2804. "Queue\n"
  2805. " Queued = %10lu\n"
  2806. " Retried = %10lu\n"
  2807. " Timeout = %10lu\n"
  2808. " In Queue = %10lu\n"
  2809. "\n"
  2810. "Secure Update\n"
  2811. " Success = %10lu\n"
  2812. " Continue = %10lu\n"
  2813. " Failure = %10lu\n"
  2814. " DS Write Failure = %10lu\n"
  2815. "\n"
  2816. "Update Forwarding\n"
  2817. " Forwards = %10lu\n"
  2818. " TCP Forwards = %10lu\n"
  2819. " Responses = %10lu\n"
  2820. " Timed Out = %10lu\n"
  2821. " In Queue = %10lu\n"
  2822. "\n",
  2823. pStat->Header.StatId == DNSSRV_STATID_WIRE_UPDATE ?
  2824. "Packet Dynamic Update" :
  2825. "Internal Dynamic Update",
  2826. pstat->Received,
  2827. pstat->Forwards,
  2828. pstat->Empty,
  2829. pstat->NoOps,
  2830. pstat->Rejected,
  2831. pstat->Completed,
  2832. pstat->Timeout,
  2833. pstat->InQueue,
  2834. pstat->Rejected,
  2835. pstat->FormErr,
  2836. pstat->NxDomain,
  2837. pstat->NotImpl,
  2838. pstat->Refused,
  2839. pstat->RefusedNonSecure,
  2840. pstat->RefusedAccessDenied,
  2841. pstat->YxDomain,
  2842. pstat->YxRrset,
  2843. pstat->NxRrset,
  2844. pstat->NotAuth,
  2845. pstat->NotZone,
  2846. #if 0 // unused counters
  2847. pstat->Collisions,
  2848. pstat->CollisionsRead,
  2849. pstat->CollisionsWrite,
  2850. pstat->CollisionsDsWrite,
  2851. #endif
  2852. pstat->Queued,
  2853. pstat->Retry,
  2854. pstat->Timeout,
  2855. pstat->InQueue,
  2856. pstat->SecureSuccess,
  2857. pstat->SecureContinue,
  2858. pstat->SecureFailure,
  2859. pstat->SecureDsWriteFailure,
  2860. pstat->Forwards,
  2861. pstat->TcpForwards,
  2862. pstat->ForwardResponses,
  2863. pstat->ForwardTimeouts,
  2864. pstat->ForwardInQueue
  2865. );
  2866. printStatTypeArray(
  2867. PrintRoutine, pPrintContext,
  2868. "Update Types:",
  2869. pstat->UpdateType );
  2870. break;
  2871. }
  2872. case DNSSRV_STATID_DS:
  2873. {
  2874. PDNSSRV_DS_STATS pstat = (PDNSSRV_DS_STATS)pStat;
  2875. PrintRoutine( pPrintContext,
  2876. "\n"
  2877. "DS Integration:\n"
  2878. "---------------\n"
  2879. "DS Reads:\n"
  2880. " Nodes Read Total = %10lu\n"
  2881. " Records Read Total = %10lu\n"
  2882. " Nodes Loaded = %10lu\n"
  2883. " Records Loaded = %10lu\n"
  2884. "\n"
  2885. " Update Searches = %10lu\n"
  2886. " Update Nodes Read = %10lu\n"
  2887. " Update Records Read = %10lu\n"
  2888. "\n"
  2889. "DS Writes:\n"
  2890. " Nodes Added = %10lu\n"
  2891. " Nodes Modified = %10lu\n"
  2892. " Nodes Tombstoned = %10lu\n"
  2893. " Nodes Final Delete = %10lu\n"
  2894. " Node Write Suppressed = %10lu\n"
  2895. " RR Sets Added = %10lu\n"
  2896. " RR Sets Replaced = %10lu\n"
  2897. " Serial Writes = %10lu\n"
  2898. "\n"
  2899. " Update Lists = %10lu\n"
  2900. " Update Nodes = %10lu\n"
  2901. " Suppressed = %10lu\n"
  2902. " Writes = %10lu\n"
  2903. " Tombstones = %10lu\n"
  2904. " Write causes:\n"
  2905. " Record Change = %10lu\n"
  2906. " Aging Refresh = %10lu\n"
  2907. " Aging On = %10lu\n"
  2908. " Aging Off = %10lu\n"
  2909. " Write sources:\n"
  2910. " Packet = %10lu\n"
  2911. " Precon Only = %10lu\n"
  2912. " Admin = %10lu\n"
  2913. " Auto Config = %10lu\n"
  2914. " Scavenge = %10lu\n",
  2915. pstat->DsTotalNodesRead,
  2916. pstat->DsTotalRecordsRead,
  2917. pstat->DsNodesLoaded,
  2918. pstat->DsRecordsLoaded,
  2919. pstat->DsUpdateSearches,
  2920. pstat->DsUpdateNodesRead,
  2921. pstat->DsUpdateRecordsRead,
  2922. pstat->DsNodesAdded,
  2923. pstat->DsNodesModified,
  2924. pstat->DsNodesTombstoned,
  2925. pstat->DsNodesDeleted,
  2926. pstat->DsWriteSuppressed,
  2927. pstat->DsRecordsAdded,
  2928. pstat->DsRecordsReplaced,
  2929. pstat->DsSerialWrites,
  2930. pstat->UpdateLists,
  2931. pstat->UpdateNodes,
  2932. pstat->UpdateSuppressed,
  2933. pstat->UpdateWrites,
  2934. pstat->UpdateTombstones,
  2935. pstat->UpdateRecordChange,
  2936. pstat->UpdateAgingRefresh,
  2937. pstat->UpdateAgingOn,
  2938. pstat->UpdateAgingOff,
  2939. pstat->UpdatePacket,
  2940. pstat->UpdatePacketPrecon,
  2941. pstat->UpdateAdmin,
  2942. pstat->UpdateAutoConfig,
  2943. pstat->UpdateScavenge
  2944. );
  2945. PrintRoutine( pPrintContext,
  2946. "\n"
  2947. "Tombstones:\n"
  2948. " Written = %10lu\n"
  2949. " Read = %10lu\n"
  2950. " Deleted = %10lu\n"
  2951. "\n"
  2952. "Write Performance:\n"
  2953. " Total = %10lu\n"
  2954. " Total Time = %10lu\n"
  2955. " Average = %10lu\n"
  2956. " < 10ms = %10lu\n"
  2957. " < 100ms = %10lu\n"
  2958. " < 1s = %10lu\n"
  2959. " < 10s = %10lu\n"
  2960. " < 100s = %10lu\n"
  2961. " > 100s = %10lu\n"
  2962. " Max = %10lu\n"
  2963. "Search Performance:\n"
  2964. " Total (ms) = %10lu\n"
  2965. "\n"
  2966. "Failures:\n"
  2967. " FailedDeleteDsEntries = %10lu\n"
  2968. " FailedReadRecords = %10lu\n"
  2969. " FailedLdapModify = %10lu\n"
  2970. " FailedLdapAdd = %10lu\n"
  2971. "\n"
  2972. "Polling:\n"
  2973. " PollingPassesWithErrors = %10lu\n"
  2974. "\n",
  2975. pstat->DsNodesTombstoned,
  2976. pstat->DsTombstonesRead,
  2977. pstat->DsNodesDeleted,
  2978. pstat->LdapTimedWrites,
  2979. pstat->LdapWriteTimeTotal,
  2980. pstat->LdapWriteAverage,
  2981. pstat->LdapWriteBucket0,
  2982. pstat->LdapWriteBucket1,
  2983. pstat->LdapWriteBucket2,
  2984. pstat->LdapWriteBucket3,
  2985. pstat->LdapWriteBucket4,
  2986. pstat->LdapWriteBucket5,
  2987. pstat->LdapWriteMax,
  2988. pstat->LdapSearchTime,
  2989. pstat->FailedDeleteDsEntries,
  2990. pstat->FailedReadRecords,
  2991. pstat->FailedLdapModify,
  2992. pstat->FailedLdapAdd,
  2993. pstat->PollingPassesWithDsErrors
  2994. );
  2995. printStatTypeArray(
  2996. PrintRoutine, pPrintContext,
  2997. "DS Write Types:",
  2998. pstat->DsWriteType );
  2999. break;
  3000. }
  3001. case DNSSRV_STATID_SKWANSEC:
  3002. {
  3003. PDNSSRV_SKWANSEC_STATS pstat = (PDNSSRV_SKWANSEC_STATS)pStat;
  3004. PrintRoutine( pPrintContext,
  3005. "\n"
  3006. "SkwanSec Stats:\n"
  3007. "---------------\n"
  3008. "\n"
  3009. "Security Context:\n"
  3010. " Create = %10lu\n"
  3011. " Free = %10lu\n"
  3012. " Timeout = %10lu\n"
  3013. " Queue Length = %10lu\n"
  3014. " Queued = %10lu\n"
  3015. " In Nego = %10lu\n"
  3016. " Nego Complete = %10lu\n"
  3017. " DeQueued = %10lu\n"
  3018. "\n"
  3019. "Security Packet Contexts:\n"
  3020. " Alloc = %10lu\n"
  3021. " Free = %10lu\n"
  3022. "\n"
  3023. "TKEY:\n"
  3024. " Invalid = %10lu\n"
  3025. " BadTime = %10lu\n"
  3026. "\n"
  3027. "TSIG:\n"
  3028. " Formerr = %10lu\n"
  3029. " Echo = %10lu\n"
  3030. " BadKey = %10lu\n"
  3031. " Verify Success = %10lu\n"
  3032. " Verify Failed = %10lu\n"
  3033. "\n",
  3034. pstat->SecContextCreate,
  3035. pstat->SecContextFree,
  3036. pstat->SecContextTimeout,
  3037. pstat->SecContextQueueLength,
  3038. pstat->SecContextQueue,
  3039. pstat->SecContextQueueInNego,
  3040. pstat->SecContextQueueNegoComplete,
  3041. pstat->SecContextDequeue,
  3042. pstat->SecPackAlloc,
  3043. pstat->SecPackFree,
  3044. pstat->SecTkeyInvalid,
  3045. pstat->SecTkeyBadTime,
  3046. pstat->SecTsigFormerr,
  3047. pstat->SecTsigEcho,
  3048. pstat->SecTsigBadKey,
  3049. pstat->SecTsigVerifySuccess,
  3050. pstat->SecTsigVerifyFailed
  3051. );
  3052. break;
  3053. }
  3054. case DNSSRV_STATID_MEMORY:
  3055. {
  3056. PDNSSRV_MEMORY_STATS pstat = (PDNSSRV_MEMORY_STATS) pStat;
  3057. DWORD i;
  3058. LPSTR * pnameArray;
  3059. DWORD count;
  3060. pnameArray = MemTagStrings;
  3061. count = MEMTAG_COUNT;
  3062. PrintRoutine( pPrintContext,
  3063. "\n"
  3064. "Memory Stats:\n"
  3065. "-------------\n"
  3066. "Memory:\n"
  3067. " Total Memory = %10lu\n"
  3068. " Alloc Count = %10lu\n"
  3069. " Free Count = %10lu\n"
  3070. "\n"
  3071. "Standard Allocs:\n"
  3072. " Used = %10lu\n"
  3073. " Returned = %10lu\n"
  3074. " InUse = %10lu\n"
  3075. " Memory = %10lu\n"
  3076. "\n"
  3077. "Standard To Heap:\n"
  3078. " Alloc = %10lu\n"
  3079. " Free = %10lu\n"
  3080. " InUse = %10lu\n"
  3081. " Memory = %10lu\n"
  3082. "\n"
  3083. "Standard Blocks:\n"
  3084. " Alloc = %10lu\n"
  3085. " Used = %10lu\n"
  3086. " Returned = %10lu\n"
  3087. " InUse = %10lu\n"
  3088. " FreeList = %10lu\n"
  3089. " FreeList Memory = %10lu\n"
  3090. " Total Memory = %10lu\n"
  3091. "\n"
  3092. "Tagged Allocations:\n",
  3093. pstat->Memory,
  3094. pstat->Alloc,
  3095. pstat->Free,
  3096. pstat->StdUsed,
  3097. pstat->StdReturn,
  3098. pstat->StdInUse,
  3099. pstat->StdMemory,
  3100. pstat->StdToHeapAlloc,
  3101. pstat->StdToHeapFree,
  3102. pstat->StdToHeapInUse,
  3103. pstat->StdToHeapMemory,
  3104. pstat->StdBlockAlloc,
  3105. pstat->StdBlockUsed,
  3106. pstat->StdBlockReturn,
  3107. pstat->StdBlockInUse,
  3108. pstat->StdBlockFreeList,
  3109. pstat->StdBlockFreeListMemory,
  3110. pstat->StdBlockMemory
  3111. );
  3112. for ( i=0; i<count; i++ )
  3113. {
  3114. PrintRoutine( pPrintContext,
  3115. " %s\n"
  3116. " Alloc = %10lu\n"
  3117. " Free = %10lu\n"
  3118. " InUse = %10lu\n"
  3119. " Mem = %10lu\n",
  3120. pnameArray[ i ],
  3121. pstat->MemTags[ i ].Alloc,
  3122. pstat->MemTags[ i ].Free,
  3123. pstat->MemTags[ i ].Alloc - pstat->MemTags[i].Free,
  3124. pstat->MemTags[ i ].Memory );
  3125. }
  3126. break;
  3127. }
  3128. case DNSSRV_STATID_DBASE:
  3129. {
  3130. PDNSSRV_DBASE_STATS pstat = (PDNSSRV_DBASE_STATS)pStat;
  3131. PrintRoutine( pPrintContext,
  3132. "\n"
  3133. "Database Nodes:\n"
  3134. "---------------\n"
  3135. "Nodes:\n"
  3136. " Used = %10lu\n"
  3137. " Returned = %10lu\n"
  3138. " InUse = %10lu\n"
  3139. " Memory = %10lu\n"
  3140. "\n",
  3141. pstat->NodeUsed,
  3142. pstat->NodeReturn,
  3143. pstat->NodeInUse,
  3144. pstat->NodeMemory
  3145. );
  3146. break;
  3147. }
  3148. case DNSSRV_STATID_RECORD:
  3149. {
  3150. PDNSSRV_RECORD_STATS pstat = (PDNSSRV_RECORD_STATS)pStat;
  3151. PrintRoutine( pPrintContext,
  3152. "\n"
  3153. "Records:\n"
  3154. "--------\n"
  3155. "Flow:\n"
  3156. " Used = %10lu\n"
  3157. " Returned = %10lu\n"
  3158. " InUse = %10lu\n"
  3159. " SlowFree Queued = %10lu\n"
  3160. " SlowFree Completed = %10lu\n"
  3161. " Memory = %10lu\n"
  3162. "\n"
  3163. "Caching:\n"
  3164. " Total = %10lu\n"
  3165. " Timeouts = %10lu\n"
  3166. " In Use = %10lu\n"
  3167. "\n",
  3168. pstat->Used,
  3169. pstat->Return,
  3170. pstat->InUse,
  3171. pstat->SlowFreeQueued,
  3172. pstat->SlowFreeFinished,
  3173. pstat->Memory,
  3174. pstat->CacheTotal,
  3175. pstat->CacheTimeouts,
  3176. pstat->CacheCurrent );
  3177. break;
  3178. }
  3179. case DNSSRV_STATID_PACKET:
  3180. {
  3181. PDNSSRV_PACKET_STATS pstat = (PDNSSRV_PACKET_STATS)pStat;
  3182. PrintRoutine( pPrintContext,
  3183. "\n"
  3184. "Packet Memory Usage:\n"
  3185. "--------------------\n"
  3186. "UDP Messages:\n"
  3187. " Alloc = %10lu\n"
  3188. " Free = %10lu\n"
  3189. " NetAllocs = %10lu\n"
  3190. " Memory = %10lu\n"
  3191. " Used = %10lu\n"
  3192. " Returned = %10lu\n"
  3193. " InUse = %10lu\n"
  3194. " InFreeList = %10lu\n",
  3195. pstat->UdpAlloc,
  3196. pstat->UdpFree,
  3197. pstat->UdpNetAllocs,
  3198. pstat->UdpMemory,
  3199. pstat->UdpUsed,
  3200. pstat->UdpReturn,
  3201. pstat->UdpInUse,
  3202. pstat->UdpInFreeList
  3203. );
  3204. //
  3205. // NS List stats added after Whistler beta 2.
  3206. //
  3207. PrintRoutine( pPrintContext,
  3208. " NsListUsed = %10lu\n"
  3209. " NsListReturned = %10lu\n"
  3210. " NsListInUse = %10lu\n",
  3211. pstat->UdpPacketsForNsListUsed,
  3212. pstat->UdpPacketsForNsListReturned,
  3213. pstat->UdpPacketsForNsListInUse );
  3214. PrintRoutine( pPrintContext,
  3215. "\n"
  3216. "TCP Messages:\n"
  3217. " Alloc = %10lu\n"
  3218. " Realloc = %10lu\n"
  3219. " Free = %10lu\n"
  3220. " NetAllocs = %10lu\n"
  3221. " Memory = %10lu\n"
  3222. "\n"
  3223. "Recursion Messages:\n"
  3224. " Used = %10lu\n"
  3225. " Returned = %10lu\n"
  3226. "\n",
  3227. pstat->TcpAlloc,
  3228. pstat->TcpRealloc,
  3229. pstat->TcpFree,
  3230. pstat->TcpNetAllocs,
  3231. pstat->TcpMemory,
  3232. pstat->RecursePacketUsed,
  3233. pstat->RecursePacketReturn
  3234. );
  3235. break;
  3236. }
  3237. case DNSSRV_STATID_TIMEOUT:
  3238. {
  3239. PDNSSRV_TIMEOUT_STATS pstat = (PDNSSRV_TIMEOUT_STATS)pStat;
  3240. PrintRoutine( pPrintContext,
  3241. "\n"
  3242. "Timeout:\n"
  3243. "--------\n"
  3244. "Nodes Queued\n"
  3245. " Total = %10lu\n"
  3246. " Direct = %10lu\n"
  3247. " FromReference = %10lu\n"
  3248. " FromChildDelete = %10lu\n"
  3249. " Dup Already Queued = %10lu\n"
  3250. "Nodes Checked\n"
  3251. " Total = %10lu\n"
  3252. " RecentAccess = %10lu\n"
  3253. " ActiveRecord = %10lu\n"
  3254. " CanNotDelete = %10lu\n"
  3255. " Deleted = %10lu\n"
  3256. "TimeoutBlocks\n"
  3257. " Created = %10lu\n"
  3258. " Deleted = %10lu\n"
  3259. "Delayed Frees\n"
  3260. " Queued = %10lu\n"
  3261. " WithFunction = %10lu\n"
  3262. " Executed = %10lu\n"
  3263. " WithFunction = %10lu\n",
  3264. pstat->SetTotal,
  3265. pstat->SetDirect,
  3266. pstat->SetFromDereference,
  3267. pstat->SetFromChildDelete,
  3268. pstat->AlreadyInSystem,
  3269. pstat->Checks,
  3270. pstat->RecentAccess,
  3271. pstat->ActiveRecord,
  3272. pstat->CanNotDelete,
  3273. pstat->Deleted,
  3274. pstat->ArrayBlocksCreated,
  3275. pstat->ArrayBlocksDeleted,
  3276. pstat->DelayedFreesQueued,
  3277. pstat->DelayedFreesQueuedWithFunction,
  3278. pstat->DelayedFreesExecuted,
  3279. pstat->DelayedFreesExecutedWithFunction
  3280. );
  3281. break;
  3282. }
  3283. case DNSSRV_STATID_ERRORS:
  3284. {
  3285. PDNSSRV_ERROR_STATS pstat = (PDNSSRV_ERROR_STATS)pStat;
  3286. PrintRoutine( pPrintContext,
  3287. "\n"
  3288. "Error Stats:\n"
  3289. "--------------\n"
  3290. "\n"
  3291. " NoError = %10lu\n"
  3292. " FormError = %10lu\n"
  3293. " ServFail = %10lu\n"
  3294. " NxDomain = %10lu\n"
  3295. " NotImpl = %10lu\n"
  3296. " Refused = %10lu\n"
  3297. " YxDomain = %10lu\n"
  3298. " YxRRSet = %10lu\n"
  3299. " NxRRSet = %10lu\n"
  3300. " NotAuth = %10lu\n"
  3301. " NotZone = %10lu\n"
  3302. " Max = %10lu\n"
  3303. " BadSig = %10lu\n"
  3304. " BadKey = %10lu\n"
  3305. " BadTime = %10lu\n"
  3306. " UnknownError = %10lu\n"
  3307. "\n",
  3308. pstat->NoError,
  3309. pstat->FormError,
  3310. pstat->ServFail,
  3311. pstat->NxDomain,
  3312. pstat->NotImpl,
  3313. pstat->Refused,
  3314. pstat->YxDomain,
  3315. pstat->YxRRSet,
  3316. pstat->NxRRSet,
  3317. pstat->NotAuth,
  3318. pstat->NotZone,
  3319. pstat->Max,
  3320. pstat->BadSig,
  3321. pstat->BadKey,
  3322. pstat->BadTime,
  3323. pstat->UnknownError
  3324. );
  3325. break;
  3326. }
  3327. case DNSSRV_STATID_CACHE:
  3328. {
  3329. PDNSSRV_CACHE_STATS pstat = ( PDNSSRV_CACHE_STATS ) pStat;
  3330. PrintRoutine( pPrintContext,
  3331. "\n"
  3332. "Cache Stats:\n"
  3333. "------------\n"
  3334. " Checks where cache exceeded limit = %10lu\n"
  3335. " Successful cache enforcement passes = %10lu\n"
  3336. " Failed cache enforcement passes = %10lu\n"
  3337. " Passes that required aggressive free = %10lu\n"
  3338. " Passes where nothing was freed = %10lu\n\n",
  3339. pstat->CacheExceededLimitChecks,
  3340. pstat->SuccessfulFreePasses,
  3341. pstat->FailedFreePasses,
  3342. pstat->PassesRequiringAggressiveFree,
  3343. pstat->PassesWithNoFrees );
  3344. break;
  3345. }
  3346. case DNSSRV_STATID_PRIVATE:
  3347. {
  3348. PDNSSRV_PRIVATE_STATS pstat = (PDNSSRV_PRIVATE_STATS)pStat;
  3349. PrintRoutine( pPrintContext,
  3350. "\n"
  3351. "Private Stats:\n"
  3352. "--------------\n"
  3353. "\n"
  3354. "Record Sources:\n"
  3355. " RR File = %10lu\n"
  3356. " RR File Free = %10lu\n"
  3357. " RR DS = %10lu\n"
  3358. " RR DS Free = %10lu\n"
  3359. " RR Admin = %10lu\n"
  3360. " RR Admin Free = %10lu\n"
  3361. " RR DynUp = %10lu\n"
  3362. " RR DynUp Free = %10lu\n"
  3363. " RR Axfr = %10lu\n"
  3364. " RR Axfr Free = %10lu\n"
  3365. " RR Ixfr = %10lu\n"
  3366. " RR Ixfr Free = %10lu\n"
  3367. " RR Copy = %10lu\n"
  3368. " RR Copy Free = %10lu\n"
  3369. " RR Cache = %10lu\n"
  3370. " RR Cache Free = %10lu\n"
  3371. #if 0
  3372. " RR NoExist = %10lu\n"
  3373. " RR NoExist Free = %10lu\n"
  3374. " RR Wins = %10lu\n"
  3375. " RR Wins Free = %10lu\n"
  3376. " RR WinsPtr = %10lu\n"
  3377. " RR WinsPtr Free = %10lu\n"
  3378. " RR Auto = %10lu\n"
  3379. " RR Auto Free = %10lu\n"
  3380. " RR Unknown = %10lu\n"
  3381. " RR Unknown Free = %10lu\n"
  3382. #endif
  3383. "\n"
  3384. "UDP Sockets:\n"
  3385. " PnP Socket Delete = %10lu\n"
  3386. " Recvfrom Failure = %10lu\n"
  3387. " ConnResets = %10lu\n"
  3388. " ConnReset Overflow = %10lu\n"
  3389. " GQCS Failure = %10lu\n"
  3390. " GQCS Failure wCntxt = %10lu\n"
  3391. " GQCS ConnReset = %10lu\n"
  3392. " Indicate Recv Fail = %10lu\n"
  3393. " Restart Recv Pass = %10lu\n"
  3394. "\n"
  3395. "TCP Connections:\n"
  3396. " ConnectAttempt = %10lu\n"
  3397. " ConnectFailure = %10lu\n"
  3398. " Connect = %10lu\n"
  3399. " Query = %10lu\n"
  3400. " Disconnect = %10lu\n"
  3401. "\n"
  3402. "SkwanSec Hacks:\n"
  3403. " Verified Old Sig = %10lu\n"
  3404. " Failed Old Sig = %10lu\n"
  3405. " Big TimeSkew Bypass = %10lu\n"
  3406. "\n",
  3407. pstat->RecordFile,
  3408. pstat->RecordFileFree,
  3409. pstat->RecordDs,
  3410. pstat->RecordDsFree,
  3411. pstat->RecordAdmin,
  3412. pstat->RecordAdminFree,
  3413. pstat->RecordDynUp,
  3414. pstat->RecordDynUpFree,
  3415. pstat->RecordAxfr,
  3416. pstat->RecordAxfrFree,
  3417. pstat->RecordIxfr,
  3418. pstat->RecordIxfrFree,
  3419. pstat->RecordCopy,
  3420. pstat->RecordCopyFree,
  3421. pstat->RecordCache,
  3422. pstat->RecordCacheFree,
  3423. #if 0
  3424. pstat->RecordNoExist,
  3425. pstat->RecordNoExistFree,
  3426. pstat->RecordWins,
  3427. pstat->RecordWinsFree,
  3428. pstat->RecordWinsPtr,
  3429. pstat->RecordWinsPtrFree,
  3430. pstat->RecordAuto,
  3431. pstat->RecordAutoFree,
  3432. pstat->RecordUnknown,
  3433. pstat->RecordUnknownFree,
  3434. #endif
  3435. pstat->UdpSocketPnpDelete,
  3436. pstat->UdpRecvFailure,
  3437. pstat->UdpConnResets,
  3438. pstat->UdpConnResetRetryOverflow,
  3439. pstat->UdpGQCSFailure,
  3440. pstat->UdpGQCSFailureWithContext,
  3441. pstat->UdpGQCSConnReset,
  3442. pstat->UdpIndicateRecvFailures,
  3443. pstat->UdpRestartRecvOnSockets,
  3444. pstat->TcpConnectAttempt,
  3445. pstat->TcpConnectFailure,
  3446. pstat->TcpConnect,
  3447. pstat->TcpQuery,
  3448. pstat->TcpDisconnect,
  3449. pstat->SecTsigVerifyOldSig,
  3450. pstat->SecTsigVerifyOldFailed,
  3451. pstat->SecBigTimeSkewBypass
  3452. );
  3453. break;
  3454. }
  3455. default:
  3456. DnsPrint_RpcStatRaw(
  3457. PrintRoutine, pPrintContext,
  3458. NULL,
  3459. pStat,
  3460. DNS_ERROR_INVALID_TYPE );
  3461. break;
  3462. } // end switch
  3463. DnsPrint_Unlock();
  3464. }
  3465. //
  3466. // End of print.c
  3467. //