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.

158 lines
3.7 KiB

  1. // Copyright (c) 1997-1999 Microsoft Corporation
  2. //
  3. // DNS API wrappers
  4. //
  5. // 12-16-97 sburns
  6. #ifndef DNS_HPP_INCLUDED
  7. #define DNS_HPP_INCLUDED
  8. // A collection of DNS related names.
  9. namespace Dns
  10. {
  11. // the number of bytes in a full DNS name to reserve for stuff
  12. // netlogon pre-/appends to DNS names when registering them
  13. const size_t SRV_RECORD_RESERVE = 100;
  14. // the max lengths, in bytes, of strings when represented in the UTF-8
  15. // character set. These are the limits we expose to the user
  16. const size_t MAX_NAME_LENGTH = DNS_MAX_NAME_LENGTH - SRV_RECORD_RESERVE;
  17. const size_t MAX_LABEL_LENGTH = DNS_MAX_LABEL_LENGTH;
  18. // Compares DNS names with DnsNameCompareEx (see private\inc\dnsapi.h),
  19. // returning the result.
  20. DNS_NAME_COMPARE_STATUS
  21. CompareNames(const String& dnsNameLeft, const String& dnsNameRight);
  22. // Returns the name of the parent DNS domain. E.g. if "foo.bar.com" is
  23. // passed, then "bar.com" is the result. If "com" is passed, then "."
  24. // (the root zone) is the result.
  25. //
  26. // domainName - the name of the domain
  27. String
  28. GetParentDomainName(const String& domainName);
  29. // Returns corresponding NetBIOS name, or empty string if mapping failed.
  30. // Not for domain names -- just computer names!
  31. //
  32. // hostname - the name to be mapped to a NetBIOS name. This name must be a
  33. // valid DNS name.
  34. //
  35. // err - ptr to a variable that will accept the win error code returned if
  36. // the conversion fails. If the conversion fails, the return value is
  37. // the empty string.
  38. String
  39. HostnameToNetbiosName(const String& hostname, HRESULT* err=0);
  40. // returns true if the DNS client is configured, false if not.
  41. bool
  42. IsClientConfigured();
  43. // returns true if the Microsoft DNS server is installed on this computer,
  44. // false if not.
  45. bool
  46. IsServiceInstalled();
  47. // returns true if the Microsoft DNS server is currently running on this
  48. // computer, false if not.
  49. bool
  50. IsServiceRunning();
  51. enum ValidateResult
  52. {
  53. VALID,
  54. INVALID,
  55. NON_RFC,
  56. TOO_LONG,
  57. NUMERIC,
  58. BAD_CHARS
  59. };
  60. // Validates a single DNS label for proper length (in the UTF-8
  61. // character set) and syntax.
  62. //
  63. // candidateDNSLabel - the label to be validated
  64. ValidateResult
  65. ValidateDnsLabelSyntax(const String& candidateDNSLabel);
  66. // Validates the format, not the existence, of a DNS name. Checks for
  67. // proper length in the UTF-8 character set, and proper syntax.
  68. //
  69. // candidateDNSName - in, the DNS name to verify.
  70. //
  71. // maxUnicodeCharacters - in, maximum number of uncode characters to
  72. // allow in the name. If the name contains more characters than this,
  73. // TOO_LONG is returned.
  74. //
  75. // maxUTF8Bytes - in, maximum number of bytes allowed to represent the name
  76. // in the UTF-8 character set. Since a unicode character requires at
  77. // least one byte in UTF-8, this value must be >= maxUnicodeCharacters.
  78. ValidateResult
  79. ValidateDnsNameSyntax(
  80. const String& candidateDNSName,
  81. size_t maxUnicodeCharacters = Dns::MAX_NAME_LENGTH,
  82. size_t maxUTF8Bytes = Dns::MAX_NAME_LENGTH);
  83. }
  84. DNS_STATUS
  85. MyDnsValidateName(const String& name, DNS_NAME_FORMAT format);
  86. String
  87. MyDnsStatusString(DNS_STATUS status);
  88. // caller must free the result with MyDnsRecordListFree
  89. DNS_STATUS
  90. MyDnsQuery(
  91. const String& name,
  92. WORD type,
  93. DWORD options,
  94. DNS_RECORD*& result);
  95. void
  96. MyDnsRecordListFree(DNS_RECORD* rl);
  97. #endif // DNS_HPP_INCLUDED