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.

301 lines
8.0 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: netdiag.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef HEADER_NETDIAG
  11. #define HEADER_NETDIAG
  12. //////////////////////////////////////////////////////////////////////////////
  13. //
  14. // Constants particular to the current NT development environment
  15. //
  16. //////////////////////////////////////////////////////////////////////////////
  17. //
  18. // Developers responsible for tested portions of NT
  19. //
  20. #define NET_GURU "[Contact NSun]"
  21. #define DHCP_GURU "[Contact ThiruB/RameshV]"
  22. #define TCPIP_GURU "[Contact PradeepB]"
  23. #define NETBT_GURU "[Contact MAlam]"
  24. #define WINSOCK_GURU "[Contact KarolyS]"
  25. #define REDIR_GURU "[Contact SethuR]"
  26. #define BOWSER_GURU "[Contact CliffV]"
  27. #define DNS_GURU "[Contact DnsDev]"
  28. #define SAM_GURU "[Contact MurliS]"
  29. #define LSA_GURU "[Contact MacM]"
  30. #define DSGETDC_GURU "[Contact CliffV]"
  31. #define NETLOGON_GURU "[Contact CliffV]"
  32. #define KERBEROS_GURU "[Contact ChandanS]"
  33. #define NTLM_GURU "[Contact ChandanS]"
  34. #define LDAP_GURU "[Contact AnoopA]"
  35. //////////////////////////////////////////////////////////////////////////////
  36. //
  37. // Constants particular to the current version of NT.
  38. //
  39. //////////////////////////////////////////////////////////////////////////////
  40. #define NETBT_DEVICE_PREFIX L"\\device\\Netbt_tcpip_{"
  41. //
  42. // Complain about pre-IDW builds
  43. //
  44. #define NTBUILD_IDW 1716
  45. #define NTBUILD_DYNAMIC_DNS 1716
  46. #define NTBUILD_BOWSER 1716
  47. #define NTBUILD_DNSSERVERLIST 1728
  48. //
  49. // New functions for displaying routing table - Rajkumar
  50. //
  51. #define WILD_CARD (ULONG)(-1)
  52. #define ROUTE_DATA_STRING_SIZE 300
  53. #define NTOA(STR,ADDR) \
  54. strncpy( STR, \
  55. inet_ntoa(*(struct in_addr*)(&(ADDR))), \
  56. sizeof(STR)-1 )
  57. #ifdef _UNICODE
  58. #define INET_ADDR(_sz) inet_addrW(_sz)
  59. #else
  60. #define INET_ADDR(_sz) inet_addrA(_swz)
  61. #endif
  62. ULONG inet_addrW(LPCWSTR pswz);
  63. #define inet_addrA(_psz) inet_addr(_psz)
  64. #define MAX_METRIC 9999
  65. #define ROUTE_SEPARATOR ','
  66. #define MAX_CONTACT_STRING 256
  67. // Some winsock defines
  68. //////////////////////////////////////////////////////////////////////////////
  69. //
  70. // Globals
  71. //
  72. //////////////////////////////////////////////////////////////////////////////
  73. //extern BOOL IpConfigCalled;
  74. //extern BOOL ProblemBased;
  75. extern int ProblemNumber;
  76. //
  77. // This has been made global so that we dump the information in WinsockTest - Rajkumar
  78. //
  79. //extern WSADATA wsaData;
  80. //extern PFIXED_INFO GlobalIpconfigFixedInfo;
  81. //extern PADAPTER_INFO GlobalIpconfigAdapterInfo;
  82. //extern PIP_ADAPTER_INFO IpGlobalIpconfigAdapterInfo;
  83. //extern BOOLEAN GlobalDhcpEnabled;
  84. //
  85. // Structure describing a single Netbt Transport
  86. //
  87. //extern LIST_ENTRY GlobalNetbtTransports;
  88. //extern LIST_ENTRY GlobalTestedDomains;
  89. //
  90. // Globals defining the command line arguments.
  91. //
  92. //extern BOOL Verbose;
  93. extern BOOL ReallyVerbose;
  94. //extern BOOL DebugVerbose;
  95. //extern BOOL GlobalFixProblems;
  96. //extern BOOL GlobalDcAccountEnum;
  97. extern PTESTED_DOMAIN GlobalQueriedDomain;
  98. //
  99. // Describe the domain this machine is a member of
  100. //
  101. //extern int GlobalNtBuildNumber;
  102. //extern PDSROLE_PRIMARY_DOMAIN_INFO_BASIC GlobalDomainInfo;
  103. //extern PTESTED_DOMAIN GlobalMemberDomain;
  104. //
  105. // Who we're currently logged on as
  106. //
  107. //extern PUNICODE_STRING GlobalLogonUser;
  108. //extern PUNICODE_STRING GlobalLogonDomainName;
  109. //extern PTESTED_DOMAIN GlobalLogonDomain;
  110. //extern BOOLEAN GlobalLogonWithCachedCredentials;
  111. //
  112. // A Zero GUID for comparison
  113. //
  114. extern GUID NlDcZeroGuid;
  115. //
  116. // State determined by previous tests
  117. //
  118. //extern BOOL GlobalNetlogonIsRunning; // Netlogon is running on this machine
  119. //extern BOOL GlobalKerberosIsWorking; // Kerberos is working
  120. //
  121. // Netbios name of this machine
  122. //
  123. //extern WCHAR GlobalNetbiosComputerName[MAX_COMPUTERNAME_LENGTH+1];
  124. //extern CHAR GlobalDnsHostName[DNS_MAX_NAME_LENGTH+1];
  125. //extern LPSTR GlobalDnsDomainName;
  126. // Commented out to port to Source Depot - smanda
  127. #ifdef SLM_TREE
  128. extern DSGETDCNAMEW NettestDsGetDcNameW;
  129. #else
  130. extern DSGETDCNAMEW DsGetDcNameW;
  131. #endif
  132. void PrintMessage(NETDIAG_PARAMS *pParams, UINT uMessageID, ...);
  133. void PrintMessageSz(NETDIAG_PARAMS *pParams, LPCTSTR pszMessage);
  134. int match( const char * p, const char * s );
  135. //only used in Kerberos test so far
  136. VOID sPrintTime(LPSTR str, LARGE_INTEGER ConvertTime);
  137. DWORD LoadContact(LPCTSTR pszTestName, LPTSTR pszContactInfo, DWORD cChSize);
  138. NET_API_STATUS IsServiceStarted(IN LPTSTR pszServiceName);
  139. VOID PrintSid(IN NETDIAG_PARAMS *pParams, IN PSID Sid OPTIONAL);
  140. LPSTR MapTime(DWORD_PTR TimeVal);
  141. #ifdef _UNICODE
  142. #define IsIcmpResponse(_psz) IsIcmpResponseW(_psz)
  143. #else
  144. #define IsIcmpResponse(_psz) IsIcmpResponseA(_psz)
  145. #endif
  146. BOOL IsIcmpResponseW(LPCWSTR pswzIpAddrStr);
  147. BOOL IsIcmpResponseA(LPCSTR pszIpAddrStr);
  148. PTESTED_DOMAIN
  149. AddTestedDomain(
  150. IN NETDIAG_PARAMS *pParams,
  151. IN NETDIAG_RESULT *pResults,
  152. IN LPWSTR pswzNetbiosDomainName,
  153. IN LPWSTR pswzDnsDomainName,
  154. IN BOOL bPrimaryDomain
  155. );
  156. //used in DCListTest and TrustTest
  157. NTSTATUS NettestSamConnect(
  158. IN NETDIAG_PARAMS *pParams,
  159. IN LPWSTR DcName,
  160. OUT PSAM_HANDLE SamServerHandle
  161. );
  162. /*---------------------------------------------------------------------------
  163. Misc. utilities
  164. ---------------------------------------------------------------------------*/
  165. HRESULT GetComputerNameInfo(NETDIAG_PARAMS *pParams, NETDIAG_RESULT *pResults);
  166. HRESULT GetDNSInfo(NETDIAG_PARAMS *pParams, NETDIAG_RESULT *pResults);
  167. HRESULT GetNetBTParameters(IN NETDIAG_PARAMS *pParams,
  168. IN OUT NETDIAG_RESULT *pResults);
  169. LPTSTR NetStatusToString( NET_API_STATUS NetStatus );
  170. LPTSTR Win32ErrorToString(DWORD Id);
  171. #define DimensionOf(rg) (sizeof(rg) / sizeof(*rg))
  172. /*---------------------------------------------------------------------------
  173. Error handling utilities
  174. ---------------------------------------------------------------------------*/
  175. #define CheckHr(x) \
  176. if ((hr = (x)) & (0x80000000)) \
  177. goto Error;
  178. #define CheckErr(x) \
  179. if ((hr = HResultFromWin32(x)) & (0x80000000)) \
  180. goto Error;
  181. HRESULT HResultFromWin32(DWORD dwErr);
  182. #define FHrSucceeded(hr) SUCCEEDED(hr)
  183. #define FHrOK(hr) ((hr) == S_OK)
  184. #define FHrFailed(hr) FAILED(hr)
  185. #define hrOK S_OK
  186. // if hr failed, assign hr and ids contect to the structure, and goto L_ERR
  187. #define CHK_HR_CONTEXT(w, h, IDS){ \
  188. if (FAILED(h)) {\
  189. (w).hr = (h), (w).idsContext = (IDS); goto L_ERR;}}
  190. /*!--------------------------------------------------------------------------
  191. FormatError
  192. This function will lookup the error message associated with
  193. the HRESULT.
  194. Author: KennT
  195. ---------------------------------------------------------------------------*/
  196. void FormatError(HRESULT hr, TCHAR *pszBuffer, UINT cchBuffer);
  197. void FormatWin32Error(DWORD dwErr, TCHAR *pszBuffer, UINT cchBuffer);
  198. /*---------------------------------------------------------------------------
  199. Tracing utilites
  200. ---------------------------------------------------------------------------*/
  201. void TraceBegin();
  202. void TraceEnd();
  203. void TraceError(LPCSTR pszString, HRESULT hr);
  204. void TraceResult(LPCSTR pszString, HRESULT hr);
  205. void TraceSz(LPCSTR pszString);
  206. /*---------------------------------------------------------------------------
  207. Character utilities
  208. ---------------------------------------------------------------------------*/
  209. LPTSTR MapGuidToAdapterName(LPCTSTR AdapterGuid);
  210. LPTSTR MapGuidToServiceName(LPCTSTR AdapterGuid);
  211. LPWSTR MapGuidToServiceNameW(LPCWSTR AdapterGuid);
  212. /*---------------------------------------------------------------------------
  213. Memory allocation utilities
  214. ---------------------------------------------------------------------------*/
  215. #define Malloc(_cb) malloc(_cb)
  216. #define Realloc(_pv, _cb) realloc(_pv, _cb)
  217. #define Free(_pv) free(_pv)
  218. #endif