Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
4.0 KiB

  1. //================================================================================
  2. // Copyright (C) 1997 Microsoft Corporation
  3. // Author: Rameshv
  4. // Description: this program tests the dhcpread.c module.
  5. //================================================================================
  6. //================================================================================
  7. // headers
  8. //================================================================================
  9. #include <hdrmacro.h>
  10. #include <store.h>
  11. #include <dhcpmsg.h>
  12. #include <wchar.h>
  13. #include <dhcpbas.h>
  14. #include <mm\opt.h> // need all the MM stuff...
  15. #include <mm\optl.h>
  16. #include <mm\optdefl.h>
  17. #include <mm\optclass.h>
  18. #include <mm\classdefl.h>
  19. #include <mm\bitmask.h>
  20. #include <mm\reserve.h>
  21. #include <mm\range.h>
  22. #include <mm\subnet.h>
  23. #include <mm\sscope.h>
  24. #include <mm\oclassdl.h>
  25. #include <mm\server.h>
  26. #include <mm\address.h>
  27. #include <mm\server2.h>
  28. #include <mm\memfree.h>
  29. #include <mmreg\regutil.h> // need all the registry stuff
  30. #include <mmreg\regread.h>
  31. #include <mmreg\regsave.h>
  32. #include <dhcpread.h>
  33. #include <dhcpapi.h>
  34. #include <dhcpds.h>
  35. #include <mm\mmdump.h>
  36. void _cdecl main(int argc, char *argv[]) {
  37. ARRAY TestArray;
  38. ARRAY_LOCATION Loc;
  39. PM_SERVER ThisServer;
  40. DWORD Result;
  41. LPWSTR ServerName;
  42. WCHAR Buf[1000];
  43. if( 1 == argc ) { // no arguments? then dump full ds
  44. printf("================================================================================\n");
  45. printf(" Dump of all DHCP servers in DS\n");
  46. printf("================================================================================\n");
  47. printf("*** Use: %s <server-name> to dump for required dhcp server alone ***\n", argv[0]);
  48. printf("================================================================================\n");
  49. ServerName = NULL;
  50. } else if( 2 == argc ) {
  51. int i = 0;
  52. while(Buf[i] = (WCHAR)argv[1][i]) i ++;
  53. ServerName = Buf;
  54. printf("================================================================================\n");
  55. printf(" Dump DHCP server <%ws>\n", ServerName);
  56. printf("================================================================================\n");
  57. printf("*** Use: %s <server-name> to dump for required dhcp server alone ***\n", argv[0]);
  58. printf("================================================================================\n");
  59. } else {
  60. printf("Usage: %s [dns-name-of-dhcp-server-to-dump]\n", argv[0]);
  61. return;
  62. }
  63. Result = DhcpDsInitDS(0, NULL);
  64. if( ERROR_SUCCESS != Result ) {
  65. printf("DhcpDsInitDS failed: 0x%lx (%ld)\n", Result, Result);
  66. return;
  67. }
  68. MemArrayInit(&TestArray);
  69. Result = DhcpDsGetEnterpriseServers(
  70. /* Reserved */ DDS_RESERVED_DWORD,
  71. /* ServerName */ ServerName,
  72. /* Servers */ &TestArray
  73. );
  74. printf("DhcpDsGetEnterpriseServers(): 0x%lx (%ld)\n", Result, Result);
  75. printf("TestArray'Size = %ld\n", MemArraySize(&TestArray));
  76. for( Result = MemArrayInitLoc(&TestArray, &Loc)
  77. ; ERROR_SUCCESS == Result ;
  78. Result = MemArrayNextLoc(&TestArray, &Loc)
  79. ) {
  80. Result = MemArrayGetElement(&TestArray, &Loc, &ThisServer);
  81. MmDumpServer(0, ThisServer);
  82. MemServerFree(ThisServer);
  83. }
  84. printf("================================================================================\n");
  85. }
  86. //================================================================================
  87. // end of file
  88. //================================================================================