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.

468 lines
19 KiB

  1. /////////////////////////////////////////////////////////////////////
  2. //
  3. // CopyRight ( c ) 1999 Microsoft Corporation
  4. //
  5. // Module Name: util.cpp
  6. //
  7. // Description:
  8. // const definition
  9. //
  10. // Author:
  11. // Henry Wang ( henrywa ) March 8, 2000
  12. //
  13. //
  14. //////////////////////////////////////////////////////////////////////
  15. #include "DnsWmi.h"
  16. //
  17. // These macros allow us to widen DNS RPC string constants.
  18. //
  19. #define MYTXT2(str) L##str
  20. #define MYTXT(str) MYTXT2(str)
  21. const WCHAR* const PVD_CLASS_SERVER = L"MicrosoftDNS_Server";
  22. const WCHAR* const PVD_CLASS_DOMAIN = L"MicrosoftDNS_Domain";
  23. const WCHAR* const PVD_CLASS_ZONE = L"MicrosoftDNS_Zone";
  24. const WCHAR* const PVD_CLASS_CACHE = L"MicrosoftDNS_Cache";
  25. const WCHAR* const PVD_CLASS_ROOTHINTS = L"MicrosoftDNS_RootHints";
  26. const WCHAR* const PVD_CLASS_RESOURCERECORD = L"MicrosoftDNS_ResourceRecord";
  27. const WCHAR* const PVD_CLASS_RR_A = L"MicrosoftDNS_AType";
  28. const WCHAR* const PVD_CLASS_RR_SOA = L"MicrosoftDNS_SOAType";
  29. const WCHAR* const PVD_CLASS_RR_PTR = L"MicrosoftDNS_PTRType";
  30. const WCHAR* const PVD_CLASS_RR_NS = L"MicrosoftDNS_NSType";
  31. const WCHAR* const PVD_CLASS_RR_CNAME = L"MicrosoftDNS_CNAMEType";
  32. const WCHAR* const PVD_CLASS_RR_MB = L"MicrosoftDNS_MBType";
  33. const WCHAR* const PVD_CLASS_RR_MD = L"MicrosoftDNS_MDType";
  34. const WCHAR* const PVD_CLASS_RR_MF = L"MicrosoftDNS_MFType";
  35. const WCHAR* const PVD_CLASS_RR_MG = L"MicrosoftDNS_MGType";
  36. const WCHAR* const PVD_CLASS_RR_MR = L"MicrosoftDNS_MRType";
  37. const WCHAR* const PVD_CLASS_RR_MINFO = L"MicrosoftDNS_MINFOType";
  38. const WCHAR* const PVD_CLASS_RR_RP = L"MicrosoftDNS_RPType";
  39. const WCHAR* const PVD_CLASS_RR_MX = L"MicrosoftDNS_MXType";
  40. const WCHAR* const PVD_CLASS_RR_AFSDB = L"MicrosoftDNS_AFSDBType";
  41. const WCHAR* const PVD_CLASS_RR_RT = L"MicrosoftDNS_RTType";
  42. const WCHAR* const PVD_CLASS_RR_HINFO = L"MicrosoftDNS_HINFOType";
  43. const WCHAR* const PVD_CLASS_RR_ISDN = L"MicrosoftDNS_ISDNType";
  44. const WCHAR* const PVD_CLASS_RR_TXT = L"MicrosoftDNS_TXTType";
  45. const WCHAR* const PVD_CLASS_RR_X25 = L"MicrosoftDNS_X25Type";
  46. const WCHAR* const PVD_CLASS_RR_NULL = L"MicrosoftDNS_NULLType";
  47. const WCHAR* const PVD_CLASS_RR_WKS = L"MicrosoftDNS_WKSType";
  48. const WCHAR* const PVD_CLASS_RR_AAAA = L"MicrosoftDNS_AAAAType";
  49. const WCHAR* const PVD_CLASS_RR_SRV = L"MicrosoftDNS_SRVType";
  50. const WCHAR* const PVD_CLASS_RR_ATMA = L"MicrosoftDNS_ATMAType";
  51. const WCHAR* const PVD_CLASS_RR_WINS = L"MicrosoftDNS_WINSType";
  52. const WCHAR* const PVD_CLASS_RR_WINSR = L"MicrosoftDNS_WINSRType";
  53. const WCHAR* const PVD_CLASS_RR_KEY = L"MicrosoftDNS_KEYType";
  54. const WCHAR* const PVD_CLASS_RR_SIG = L"MicrosoftDNS_SIGType";
  55. const WCHAR* const PVD_CLASS_RR_NXT = L"MicrosoftDNS_NXTType";
  56. const WCHAR* const PVD_CLASS_SERVERDOMAIN = L"MicrosoftDNS_ServerDomainContainment";
  57. const WCHAR* const PVD_CLASS_DOMAINDOMAIN = L"MicrosoftDNS_DomainDomainContainment";
  58. const WCHAR* const PVD_CLASS_DOMAINRESOURCERECORD = L"MicrosoftDNS_DomainResourceRecordContainment";
  59. const WCHAR* const PVD_CLASS_STATISTIC= L"MicrosoftDNS_Statistic";
  60. // server
  61. const WCHAR* const PVD_SRV_ADDRESS_ANSWER_LIMIT = L"AddressAnswerLimit";
  62. const WCHAR* const PVD_SRV_BOOT_METHOD = L"BootMethod";
  63. const WCHAR* const PVD_SRV_DS_POLLING_INTERVAL = L"DsPollingInterval";
  64. const WCHAR* const PVD_SRV_EVENT_LOG_LEVEL = L"EventLogLevel";
  65. const WCHAR* const PVD_SRV_ALLOW_UPDATE = L"AllowUpdate";
  66. const WCHAR* const PVD_SRV_AUTO_CACHE_UPDATE = L"AutoCacheUpdate";
  67. const WCHAR* const PVD_SRV_AUTO_REVERSE_ZONES = L"DisableAutoReverseZones";
  68. const WCHAR* const PVD_SRV_BIND_SECONDARIES = L"SlowZoneTransfer";
  69. const WCHAR* const PVD_SRV_DISJOINT_NETS = L"DisjointNets";
  70. const WCHAR* const PVD_SRV_DS_AVAILABLE = L"DsAvailable";
  71. const WCHAR* const PVD_SRV_FORWARD_DELEGATION = L"ForwardDelegations";
  72. const WCHAR* const PVD_SRV_LOCAL_NETPRIORITY = L"LocalNetPriority";
  73. const WCHAR* const PVD_SRV_LOOSE_WILDCARDING = L"LooseWildcarding";
  74. const WCHAR* const PVD_SRV_NO_RECURSION = L"NoRecursion";
  75. const WCHAR* const PVD_SRV_ROUND_ROBIN = L"RoundRobin";
  76. const WCHAR* const PVD_SRV_SECURE_RESPONSES = L"SecureResponses";
  77. const WCHAR* const PVD_SRV_SLAVE = L"Slave";
  78. const WCHAR* const PVD_SRV_STRICT_FILE_PARSING = L"StrictFileParsing";
  79. const WCHAR* const PVD_SRV_AUTO_CONFIG_FILE_ZONES = L"AutoConfigFileZones";
  80. const WCHAR* const PVD_SRV_DEFAULT_AGING_STATE = L"DefaultAgingState";
  81. const WCHAR* const PVD_SRV_DEFAULT_REFRESH_INTERVAL = L"DefaultRefreshInterval";
  82. const WCHAR* const PVD_SRV_DEFAULT_NOREFRESH_INTERVAL = L"DefaultNoRefreshInterval";
  83. const WCHAR* const PVD_SRV_ENABLE_EDNS = L"EnableEDnsProbes";
  84. const WCHAR* const PVD_SRV_EDNS_CACHE_TIMEOUT = L"EDnsCacheTimeout";
  85. const WCHAR* const PVD_SRV_MAX_UDP_PACKET_SIZE = L"MaximumUdpPacketSize";
  86. const WCHAR* const PVD_SRV_ENABLE_DNSSEC = L"EnableDnsSec";
  87. const WCHAR* const PVD_SRV_ENABLE_DP = L"EnableDirectoryPartitionSupport";
  88. const WCHAR* const PVD_SRV_UPDATE_OPTIONS = MYTXT( DNS_REGKEY_UPDATE_OPTIONS );
  89. // dww - 6/24/99
  90. // WriteAuthoritySoa removed from the schema.
  91. // const WCHAR* const PVD_SRV_WRITE_AUTHIORITY_SOA = L"WriteAuthoritySoa";
  92. const WCHAR* const PVD_SRV_WRITE_AUTHORITY_NS = L"WriteAuthorityNS";
  93. const WCHAR* const PVD_SRV_LISTEN_IP_ADDRESSES_ARRAY = L"ListenIPAddresses";
  94. const WCHAR* const PVD_SRV_LOG_LEVEL = L"LogLevel";
  95. const WCHAR* const PVD_SRV_MAX_CACHE_TTL = L"MaxCacheTTL";
  96. const WCHAR* const PVD_SRV_NAME_CHECK_FLAG = L"NameCheckFlag";
  97. const WCHAR* const PVD_SRV_RECURSION_RETRY = L"RecursionRetry";
  98. const WCHAR* const PVD_SRV_RECURSION_TIMEOUT = L"RecursionTimeout";
  99. const WCHAR* const PVD_SRV_RPC_PROTOCOL = L"RpcProtocol";
  100. const WCHAR* const PVD_SRV_SEND_ON_NON_DNS_PORT = L"SendOnNonDnsPort";
  101. const WCHAR* const PVD_SRV_SERVER_IP_ADDRESSES_ARRAY = L"ServerAddresses";
  102. const WCHAR* const PVD_SRV_SERVER_NAME = L"Name";
  103. const WCHAR* const PVD_SRV_VERSION = L"Version";
  104. const WCHAR* const PVD_SRV_STARTED = L"Started";
  105. const WCHAR* const PVD_SRV_STARTMODE = L"StartMode";
  106. // resource record
  107. const WCHAR* const PVD_REC_CONTAINER_NAME = L"ContainerName";
  108. const WCHAR* const PVD_REC_SERVER_NAME = L"DnsServerName";
  109. const WCHAR* const PVD_REC_DOMAIN_NAME = L"DomainName";
  110. const WCHAR* const PVD_REC_OWNER_NAME = L"OwnerName";
  111. const WCHAR* const PVD_REC_CLASS = L"RecordClass";
  112. const WCHAR* const PVD_REC_RDATA = L"RecordData";
  113. const WCHAR* const PVD_REC_TXT_REP = L"TextRepresentation";
  114. const WCHAR* const PVD_REC_TTL = L"TTL";
  115. const WCHAR* const PVD_REC_TYPE = L"RecordType";
  116. const WCHAR* const PVD_REC_AAAA_IP = L"IPv6Address";
  117. const WCHAR* const PVD_REC_AFSBD_SERVER_NAME = L"ServerName";
  118. const WCHAR* const PVD_REC_AFSBD_SUB_TYPE = L"SubType";
  119. const WCHAR* const PVD_REC_ATMA_FORMAT = L"Format";
  120. const WCHAR* const PVD_REC_ATMA_ATM_ADDRESS = L"ATMAddress";
  121. const WCHAR* const PVD_REC_A_IP = L"IPAddress";
  122. const WCHAR* const PVD_REC_CNAME_PRIMARY_NAME = L"PrimaryName";
  123. const WCHAR* const PVD_REC_HINFO_CPU = L"CPU";
  124. const WCHAR* const PVD_REC_HINFO_OS = L"OS";
  125. const WCHAR* const PVD_REC_ISDN_ISDN_NUM = L"ISDNNumber";
  126. const WCHAR* const PVD_REC_ISDN_SUB_ADDRESS = L"SubAddress";
  127. const WCHAR* const PVD_REC_MB_MBHOST = L"MBHost";
  128. const WCHAR* const PVD_REC_MD_MDHOST = L"MDHost";
  129. const WCHAR* const PVD_REC_MF_MFHOST = L"MFHost";
  130. const WCHAR* const PVD_REC_MG_MGMAILBOX = L"MGMailBox";
  131. const WCHAR* const PVD_REC_MINFO_ERROR_MAILBOX = L"ErrorMailBox";
  132. const WCHAR* const PVD_REC_MINFO_RESP_MAILBOX = L"ResponsibleMailBox";
  133. const WCHAR* const PVD_REC_MR_MRMAILBOX = L"MRMailBox";
  134. const WCHAR* const PVD_REC_MX_MAIL_EXCHANGE = L"MailExchange";
  135. const WCHAR* const PVD_REC_MX_PREFERENCE = L"Preference";
  136. const WCHAR* const PVD_REC_NS_NSHOST = L"NSHost";
  137. const WCHAR* const PVD_REC_NULL_NULLDATA = L"NULLDATA";
  138. const WCHAR* const PVD_REC_PTR_PTRDOMAIN_NAME = L"PTRDomainName";
  139. const WCHAR* const PVD_REC_RP_RPMAILBOX = L"RPMailBox";
  140. const WCHAR* const PVD_REC_RP_TXT_DOMAIN_NAME = L"TxtDomainName";
  141. const WCHAR* const PVD_REC_RT_HOST = L"IntermediateHost";
  142. const WCHAR* const PVD_REC_RT_PREFERENCE = L"Preference";
  143. const WCHAR* const PVD_REC_SOA_EXPIRE_LIMIT = L"ExpireLimit";
  144. const WCHAR* const PVD_REC_SOA_TTL = L"MinimumTTL";
  145. const WCHAR* const PVD_REC_SOA_PRIMARY_SERVER = L"PrimaryServer";
  146. const WCHAR* const PVD_REC_SOA_REFRESH = L"RefreshInterval";
  147. const WCHAR* const PVD_REC_SOA_RESPONSIBLE = L"ResponsibleParty";
  148. const WCHAR* const PVD_REC_SOA_RETRY_DELAY = L"RetryDelay";
  149. const WCHAR* const PVD_REC_SOA_SERIAL_NUMBER = L"SerialNumber";
  150. const WCHAR* const PVD_REC_SRV_PORT = L"Port";
  151. const WCHAR* const PVD_REC_SRV_PRIORITY = L"Priority";
  152. const WCHAR* const PVD_REC_SRV_WEIGHT = L"Weight";
  153. const WCHAR* const PVD_REC_SRV_DOMAINNAME = L"DomainName";
  154. const WCHAR* const PVD_REC_TXT_TEXT = L"DescriptiveText";
  155. const WCHAR* const PVD_REC_WINSR_TIMEOUT = L"LookupTimeOut";
  156. const WCHAR* const PVD_REC_WINSR_MAPPING_FLAG = L"MappingFlag";
  157. const WCHAR* const PVD_REC_WINSR_RESULT_DOMAIN = L"ResultDomain";
  158. const WCHAR* const PVD_REC_WINSR_CACHE_TIMEOUT = L"CacheTimeOut";
  159. const WCHAR* const PVD_REC_WINS_TIMEOUT = L"LookupTimeOut";
  160. const WCHAR* const PVD_REC_WINS_MAPPING_FLAG = L"MappingFlag";
  161. const WCHAR* const PVD_REC_WINS_WINS_SERVER = L"WinsServers";
  162. const WCHAR* const PVD_REC_WINS_CACHE_TIMEOUT = L"CacheTimeOut";
  163. const WCHAR* const PVD_REC_WKS_INTERNET_ADDRESS = L"InternetAddress";
  164. const WCHAR* const PVD_REC_WKS_IP_PROTOCOL = L"IPProtocol";
  165. const WCHAR* const PVD_REC_WKS_BIT_MASK = L"Services";
  166. const WCHAR* const PVD_REC_X25_PSDNADDRESS = L"PSDNAddress";
  167. // domain
  168. const WCHAR* const PVD_DOMAIN_CONTAINER_NAME = L"ContainerName";
  169. const WCHAR* const PVD_DOMAIN_FQDN = L"Name";
  170. const WCHAR* const PVD_DOMAIN_SERVER_NAME = L"DnsServerName";
  171. //zone
  172. const WCHAR* const PVD_ZONE_ALLOW_UPDATE = L"AllowUpdate";
  173. const WCHAR* const PVD_ZONE_AUTO_CREATED = L"AutoCreated";
  174. const WCHAR* const PVD_ZONE_DISABLE_WIN_SRECORD_REPLICATION = L"DisableWINSRecordReplication";
  175. //const WCHAR* const PVD_DS_INTEGRATED L"DsIntegrated"
  176. const WCHAR* const PVD_ZONE_NOTIFY = L"Notify";
  177. const WCHAR* const PVD_ZONE_PAUSED = L"Paused";
  178. const WCHAR* const PVD_ZONE_REVERSE = L"Reverse";
  179. const WCHAR* const PVD_ZONE_AGING = L"Aging";
  180. const WCHAR* const PVD_ZONE_SECURE_SECONDARIES = L"SecureSecondaries";
  181. const WCHAR* const PVD_ZONE_SHUTDOWN = L"Shutdown";
  182. const WCHAR* const PVD_ZONE_USE_WINS = L"UseWins";
  183. const WCHAR* const PVD_ZONE_MASTERS_IP_ADDRESSES_ARRAY = L"MasterServers";
  184. const WCHAR* const PVD_ZONE_LOCAL_MASTERS_IP_ADDRESSES_ARRAY = L"LocalMasterServers";
  185. const WCHAR* const PVD_ZONE_DATA_FILE = L"DataFile";
  186. const WCHAR* const PVD_ZONE_SECONDARIES_IP_ADDRESSES_ARRAY = L"SecondaryServers";
  187. const WCHAR* const PVD_ZONE_NOTIFY_IPADDRESSES_ARRAY = L"NotifyServers";
  188. const WCHAR* const PVD_ZONE_ZONE_TYPE = L"ZoneType";
  189. const WCHAR* const PVD_ZONE_DS_INTEGRATED = L"DsIntegrated";
  190. const WCHAR* const PVD_ZONE_AVAIL_FOR_SCAVENGE_TIME = L"AvailForScavengeTime";
  191. const WCHAR* const PVD_ZONE_REFRESH_INTERVAL = L"RefreshInterval";
  192. const WCHAR* const PVD_ZONE_NOREFRESH_INTERVAL = L"NoRefreshInterval";
  193. const WCHAR* const PVD_ZONE_SCAVENGE_SERVERS = L"ScavengeServers";
  194. const WCHAR* const PVD_ZONE_FORWARDER_SLAVE = L"ForwarderSlave";
  195. const WCHAR* const PVD_ZONE_FORWARDER_TIMEOUT = L"ForwarderTimeout";
  196. const WCHAR* const PVD_ZONE_LAST_SOA_CHECK = L"LastSuccessfulSoaCheck";
  197. const WCHAR* const PVD_ZONE_LAST_GOOD_XFR = L"LastSuccessfulXfr";
  198. //domaindomain
  199. //domain resource record containment
  200. // server domain containment
  201. const WCHAR* const PVD_ASSOC_CHILD = L"PartComponent";
  202. const WCHAR* const PVD_ASSOC_PARENT = L"GroupComponent";
  203. // method
  204. const WCHAR* const PVD_MTH_SRV_RESTART = L"RestartDNSServer";
  205. const WCHAR* const PVD_MTH_SRV_START_SERVICE = L"StartService";
  206. const WCHAR* const PVD_MTH_SRV_STOP_SERVICE = L"StopService";
  207. const WCHAR* const PVD_MTH_ZONE_RESUMEZONE = L"ResumeZone";
  208. const WCHAR* const PVD_MTH_ZONE_PAUSEZONE = L"PauseZone";
  209. const WCHAR* const PVD_MTH_ZONE_RELOADZONE = L"ReloadZone";
  210. const WCHAR* const PVD_MTH_ZONE_FORCEREFRESH = L"ForceRefresh";
  211. const WCHAR* const PVD_MTH_ZONE_UPDATEFROMDS = L"UpdateFromDS";
  212. const WCHAR* const PVD_MTH_ZONE_WRITEBACKZONETOFILE = L"WriteBackZoneToFile";
  213. const WCHAR* const PVD_MTH_ZONE_CHANGEZONETYPE = L"ChangeZoneType";
  214. const WCHAR* const PVD_MTH_ZONE_CREATEZONE = L"CreateZone";
  215. const WCHAR* const PVD_MTH_ZONE_RESETNOTIFYIPARRAY = L"ResetNotifyIpArray";
  216. const WCHAR* const PVD_MTH_ZONE_RESETSECONDARYIPARRAY = L"ResetSecondaries";
  217. const WCHAR* const PVD_MTH_ZONE_GETDISTINGUISHEDNAME = L"GetDistinguishedName";
  218. const WCHAR* const PVD_MTH_ZONE_ARG_ZONENAME = L"ZoneName";
  219. const WCHAR* const PVD_MTH_ZONE_ARG_ZONETYPE = L"ZoneType";
  220. const WCHAR* const PVD_MTH_ZONE_ARG_DATAFILENAME = L"DataFileName";
  221. const WCHAR* const PVD_MTH_ZONE_ARG_IPADDRARRAY = L"IpAddr";
  222. const WCHAR* const PVD_MTH_ZONE_ARG_ADMINEMAILNAME = L"AdminEmailName";
  223. const WCHAR* const PVD_MTH_ZONE_ARG_SECURITY = L"SecureSecondaries";
  224. const WCHAR* const PVD_MTH_ZONE_ARG_NOTIFY = L"Notify";
  225. const WCHAR* const PVD_MTH_ZONE_ARG_SECONDARYIPARRAY = L"SecondaryServers";
  226. const WCHAR* const PVD_MTH_ZONE_ARG_NOTIFYIPARRAY = L"NotifyServers";
  227. //
  228. // Methods and stuff
  229. //
  230. const WCHAR* const PVD_MTH_REC_CREATEINSTANCEFROMTEXTREPRESENTATION = L"CreateInstanceFromTextRepresentation";
  231. const WCHAR* const PVD_MTH_REC_MODIFY = L"Modify";
  232. const WCHAR* const PVD_MTH_REC_CREATEINSTANCEFROMPROPERTYDATA = L"CreateInstanceFromPropertyData";
  233. const WCHAR* const PVD_MTH_REC_GETOBJECTBYTEXT = L"GetObjectByTextRepresentation";
  234. const WCHAR* const PVD_MTH_REC_ARG_DNSSERVER_NAME = L"DnsServerName";
  235. const WCHAR* const PVD_MTH_REC_ARG_CONTAINER_NAME = L"ContainerName";
  236. const WCHAR* const PVD_MTH_REC_ARG_TEXTREP = L"TextRepresentation";
  237. const WCHAR* const PVD_MTH_REC_ARG_RR = L"RR";
  238. const WCHAR* const PVD_MTH_RH_WRITEBACKROOTHINTDATAFILE = L"WriteBackRootHintDatafile";
  239. const WCHAR* const PVD_MTH_CACHE_CLEARDNSSERVERCACHE = L"ClearCache";
  240. //general
  241. const WCHAR* const PVD_DNS_CACHE = L"..Cache";
  242. const WCHAR* const PVD_DNS_ROOTHINTS = L"..RootHints";
  243. const WCHAR* const PVD_DNS_LOCAL_SERVER = L".";
  244. const WCHAR* const PVD_DNS_RETURN_VALUE = L"ReturnValue";
  245. class CClassData
  246. {
  247. public:
  248. const WCHAR* wszClassName;
  249. FPNEW pfConstruct;
  250. const char* szType;
  251. };
  252. CClassData g_ClassDataArray[]=
  253. {
  254. {PVD_CLASS_SERVER, CDnsServer::CreateThis, ""},
  255. {PVD_CLASS_DOMAIN, CDnsDomain::CreateThis, ""},
  256. {PVD_CLASS_ZONE, CDnsZone::CreateThis, ""},
  257. {PVD_CLASS_CACHE, CDnsCache::CreateThis, ""},
  258. {PVD_CLASS_ROOTHINTS, CDnsRootHints::CreateThis, ""},
  259. {PVD_CLASS_RESOURCERECORD, CDnsResourceRecord::CreateThis, ""},
  260. {PVD_CLASS_RR_A, CDnsResourceRecord::CreateThis, "A"},
  261. {PVD_CLASS_RR_SOA, CDnsResourceRecord::CreateThis, "SOA"},
  262. {PVD_CLASS_RR_NS, CDnsResourceRecord::CreateThis, "NS"},
  263. {PVD_CLASS_RR_CNAME,CDnsResourceRecord::CreateThis, "CNAME"},
  264. {PVD_CLASS_RR_PTR, CDnsResourceRecord::CreateThis, "PTR"},
  265. {PVD_CLASS_RR_MB, CDnsResourceRecord::CreateThis, "MB"},
  266. {PVD_CLASS_RR_MD, CDnsResourceRecord::CreateThis, "MD"},
  267. {PVD_CLASS_RR_MF, CDnsResourceRecord::CreateThis, "MF"},
  268. {PVD_CLASS_RR_MG, CDnsResourceRecord::CreateThis, "MG"},
  269. {PVD_CLASS_RR_MR, CDnsResourceRecord::CreateThis, "MR"},
  270. {PVD_CLASS_RR_MINFO, CDnsResourceRecord::CreateThis, "MINFO"},
  271. {PVD_CLASS_RR_RP, CDnsResourceRecord::CreateThis, "RP"},
  272. {PVD_CLASS_RR_MX, CDnsResourceRecord::CreateThis, "MX"},
  273. {PVD_CLASS_RR_AFSDB, CDnsResourceRecord::CreateThis, "AFSDB"},
  274. {PVD_CLASS_RR_RT, CDnsResourceRecord::CreateThis, "RT"},
  275. {PVD_CLASS_RR_HINFO, CDnsResourceRecord::CreateThis, "HINFO"},
  276. {PVD_CLASS_RR_ISDN, CDnsResourceRecord::CreateThis, "ISDN"},
  277. {PVD_CLASS_RR_TXT, CDnsResourceRecord::CreateThis, "TXT"},
  278. {PVD_CLASS_RR_X25, CDnsResourceRecord::CreateThis, "X25"},
  279. {PVD_CLASS_RR_NULL, CDnsResourceRecord::CreateThis, "NULL"},
  280. {PVD_CLASS_RR_WKS, CDnsResourceRecord::CreateThis, "WKS"},
  281. {PVD_CLASS_RR_AAAA, CDnsResourceRecord::CreateThis, "AAAA"},
  282. {PVD_CLASS_RR_SRV, CDnsResourceRecord::CreateThis, "SRV"},
  283. {PVD_CLASS_RR_ATMA, CDnsResourceRecord::CreateThis, "ATMA"},
  284. {PVD_CLASS_RR_WINS, CDnsResourceRecord::CreateThis, "WINS"},
  285. {PVD_CLASS_RR_WINSR, CDnsResourceRecord::CreateThis, "WINSR"},
  286. {PVD_CLASS_RR_SIG, CDnsResourceRecord::CreateThis, "SIG"},
  287. {PVD_CLASS_RR_KEY, CDnsResourceRecord::CreateThis, "KEY"},
  288. {PVD_CLASS_RR_NXT, CDnsResourceRecord::CreateThis, "NXT"},
  289. {PVD_CLASS_SERVERDOMAIN, CDnsServerDomainContainment::CreateThis, ""},
  290. {PVD_CLASS_DOMAINDOMAIN, CDnsDomainDomainContainment::CreateThis,""},
  291. {PVD_CLASS_STATISTIC, CDnsStatistic::CreateThis,""},
  292. {PVD_CLASS_DOMAINRESOURCERECORD,
  293. CDnsDomainResourceRecordContainment::CreateThis,""}
  294. };
  295. int g_cClassDataEntries = sizeof(g_ClassDataArray) / sizeof(CClassData);
  296. SCODE CreateClass(
  297. const WCHAR* strClassName,
  298. CWbemServices* pNamespace,
  299. void** ppNewClass)
  300. {
  301. for(int i =0; i< g_cClassDataEntries; i++)
  302. {
  303. if(_wcsicmp(
  304. strClassName,
  305. g_ClassDataArray[i].wszClassName) == 0)
  306. {
  307. *ppNewClass = (void*) g_ClassDataArray[i].pfConstruct(
  308. strClassName,
  309. pNamespace,
  310. g_ClassDataArray[i].szType);
  311. return WBEM_S_NO_ERROR;
  312. }
  313. }
  314. throw WBEM_E_INVALID_PARAMETER;
  315. return S_OK;
  316. }
  317. BSTR AllocBstr(const WCHAR* pwsz)
  318. {
  319. BSTR bstr = SysAllocString(pwsz);
  320. if (bstr == NULL)
  321. throw WBEM_E_OUT_OF_MEMORY;
  322. return bstr;
  323. }
  324. wstring
  325. CharToWstring(
  326. LPCSTR lpFromStr,
  327. DWORD wLength)
  328. {
  329. wstring wStr;
  330. if (wLength == 0)
  331. return wStr; //L"";
  332. WCHAR * pwchar = new WCHAR[ sizeof( WCHAR ) * ( wLength + 1 ) ];
  333. if ( !pwchar )
  334. {
  335. throw WBEM_E_OUT_OF_MEMORY;
  336. }
  337. int rt = MultiByteToWideChar(
  338. CP_ACP,
  339. 0,
  340. lpFromStr,
  341. wLength,
  342. pwchar,
  343. wLength);
  344. if(rt != 0)
  345. {
  346. *(pwchar+wLength)=L'\0';
  347. wStr = pwchar;
  348. }
  349. delete [] pwchar;
  350. return wStr;
  351. }
  352. int
  353. CharToWchar(
  354. LPCSTR lpMultiByteStr,
  355. LPWSTR* lppWideCharStr)
  356. {
  357. int cchMultiByte;
  358. cchMultiByte = strlen(lpMultiByteStr);
  359. *lppWideCharStr = (WCHAR*) malloc ((cchMultiByte+1)*sizeof(WCHAR));
  360. if ( *lppWideCharStr == NULL )
  361. {
  362. return 0;
  363. }
  364. return MultiByteToWideChar(
  365. CP_ACP, // code page
  366. 0 ,
  367. lpMultiByteStr, // address of string to map
  368. -1, // number of bytes in string
  369. *lppWideCharStr, // address of wide-character buffer
  370. (cchMultiByte+1)*sizeof(WCHAR) // size of buffer
  371. );
  372. }
  373. int
  374. WcharToString(
  375. LPCWSTR lpWideCharStr,
  376. string& str)
  377. {
  378. char * temp = NULL;
  379. int rt = WcharToChar(lpWideCharStr, &temp);
  380. if ( rt != 0)
  381. {
  382. str = temp;
  383. }
  384. delete [] temp;
  385. return rt;
  386. }
  387. int
  388. WcharToChar(
  389. LPCWSTR lpWideCharStr,
  390. LPSTR* lppMultiByteStr)
  391. {
  392. int cWchar;
  393. if ( !lpWideCharStr )
  394. return 0;
  395. cWchar= wcslen(lpWideCharStr)+1;
  396. *lppMultiByteStr = ( CHAR * ) new char[ cWchar * sizeof ( CHAR ) ];
  397. if ( !*lppMultiByteStr )
  398. {
  399. throw WBEM_E_OUT_OF_MEMORY;
  400. }
  401. return WideCharToMultiByte(
  402. CP_ACP, // code page
  403. 0, // character-type options
  404. lpWideCharStr, // address of string to map
  405. -1, // number of bytes in string
  406. *lppMultiByteStr, // address of wide-character buffer
  407. cWchar*sizeof(CHAR) ,// size of buffer
  408. NULL,
  409. NULL
  410. );
  411. }
  412. wstring
  413. IpAddressToString(DWORD ip)
  414. {
  415. char temp[30];
  416. sprintf(temp, "%d.%d.%d.%d",
  417. * ( (PUCHAR) &ip + 0 ),
  418. * ( (PUCHAR) &ip + 1 ),
  419. * ( (PUCHAR) &ip + 2 ),
  420. * ( (PUCHAR) &ip + 3 ) );
  421. return CharToWstring(temp, strlen(temp));
  422. }