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.

681 lines
19 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: results.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef HEADER_RESULTS
  11. #define HEADER_RESULTS
  12. #ifdef _DEBUG
  13. #define DebugMessage(str) printf(str)
  14. #define DebugMessage2(format, arg) printf(format, arg)
  15. #define DebugMessage3(format, arg1, arg2) printf(format, arg1, arg2)
  16. #else
  17. #define DebugMessage(str)
  18. #define DebugMessage2(format, arg)
  19. #define DebugMessage3(format, arg1, arg2)
  20. #endif
  21. #ifdef _SHOW_GURU
  22. #define PrintGuru(status, guru) _PrintGuru(status, guru)
  23. #define PrintGuruMessage printf
  24. #define PrintGuruMessage2 printf
  25. #define PrintGuruMessage3 printf
  26. #else
  27. #define PrintGuru(status, guru)
  28. #define PrintGuruMessage( str )
  29. #define PrintGuruMessage2( format, arg )
  30. #define PrintGuruMessage3(format, arg1, arg2)
  31. #endif
  32. #define NETCARD_CONNECTED 0
  33. #define NETCARD_DISCONNECTED 1
  34. #define NETCARD_STATUS_UNKNOWN 2
  35. /*---------------------------------------------------------------------------
  36. Struct: HotFixInfo
  37. This structure holds the information about a single Hotfix.
  38. ---------------------------------------------------------------------------*/
  39. typedef struct
  40. {
  41. BOOL fInstalled;
  42. LPTSTR pszName; // use Free() to free
  43. } HotFixInfo;
  44. /*---------------------------------------------------------------------------
  45. NdMessage
  46. This provides for an easier way to pass messages along.
  47. ---------------------------------------------------------------------------*/
  48. typedef enum {
  49. Nd_Quiet = 0, // i.e. always print
  50. Nd_Verbose = 1,
  51. Nd_ReallyVerbose = 2,
  52. Nd_DebugVerbose = 3,
  53. } NdVerbose;
  54. typedef struct
  55. {
  56. NdVerbose ndVerbose;
  57. // possible combinations
  58. // uMessageId == 0, pszMessage == NULL -- assume not set
  59. // uMessageId != 0, pszMessage == NULL -- use string id
  60. // uMessageId == 0, pszMessage != NULL -- use string
  61. // uMessageId != 0, pszMessage != NULL -- use string id
  62. //
  63. // Note: the maximum size for a string loaded through this is 4096!
  64. UINT uMessageId;
  65. LPTSTR pszMessage;
  66. } NdMessage;
  67. typedef struct ND_MESSAGE_LIST
  68. {
  69. LIST_ENTRY listEntry;
  70. NdMessage msg;
  71. }NdMessageList;
  72. void SetMessageId(NdMessage *pNdMsg, NdVerbose ndv, UINT uMessageId);
  73. void SetMessage(NdMessage *pNdMsg, NdVerbose ndv, UINT uMessageId, ...);
  74. void SetMessageSz(NdMessage *pNdMsg, NdVerbose ndv, LPCTSTR pszMessage);
  75. void ClearMessage(NdMessage *pNdMsg);
  76. void PrintNdMessage(NETDIAG_PARAMS *pParams, NdMessage *pNdMsg);
  77. void AddIMessageToList(PLIST_ENTRY plistHead, NdVerbose ndv, int nIndent, UINT uMessageId, ...);
  78. void AddIMessageToListSz(PLIST_ENTRY plistHead, NdVerbose ndv, int nIndent, LPCTSTR pszMsg);
  79. void AddMessageToList(PLIST_ENTRY plistHead, NdVerbose ndv, UINT uMessageId, ...);
  80. void AddMessageToListSz(PLIST_ENTRY plistHead, NdVerbose ndv, LPCTSTR pszMsg);
  81. void AddMessageToListId(PLIST_ENTRY plistHead, NdVerbose ndv, UINT uMessageId);
  82. void PrintMessageList(NETDIAG_PARAMS *pParams, PLIST_ENTRY plistHead);
  83. void MessageListCleanUp(PLIST_ENTRY plistHead);
  84. // These functions are for status messages (the messages that appear at the
  85. // top).
  86. void PrintStatusMessage(NETDIAG_PARAMS *pParams, int iIndent, UINT uMessageId, ...);
  87. void PrintStatusMessageSz(NETDIAG_PARAMS *pParams, int iIndent, LPCTSTR pszMessage);
  88. // Use this for printing debug messages (messages that require fDebugVerbose)
  89. void PrintDebug(NETDIAG_PARAMS *pParams, int nIndent, UINT uMessageId, ...);
  90. void PrintDebugSz(NETDIAG_PARAMS *pParams, int nIndent, LPCTSTR pszMessage, ...);
  91. /*---------------------------------------------------------------------------
  92. Struct: GLOBAL_RESULT
  93. ---------------------------------------------------------------------------*/
  94. typedef struct {
  95. WCHAR swzNetBiosName[MAX_COMPUTERNAME_LENGTH+1];
  96. TCHAR szDnsHostName[DNS_MAX_NAME_LENGTH+1];
  97. LPTSTR pszDnsDomainName; // this points to a string in szDnsHostName
  98. WSADATA wsaData;
  99. // NetBT parameters
  100. DWORD dwLMHostsEnabled; // TRUE, FALSE, or HRESULT on error to read
  101. DWORD dwDnsForWINS; // TRUE, FALSE, or HRESULT on error to read
  102. // Server/OS information (such as version, build no, etc...)
  103. LPTSTR pszCurrentVersion;
  104. LPTSTR pszCurrentBuildNumber;
  105. LPTSTR pszCurrentType;
  106. LPTSTR pszProcessorInfo;
  107. LPTSTR pszServerType;
  108. int cHotFixes;
  109. HotFixInfo * pHotFixes;
  110. // List of domains to be tested
  111. LIST_ENTRY listTestedDomains;
  112. // Domain member information
  113. // the primary domain info got by using DsRoleGetPrimaryDomainInformation()
  114. PDSROLE_PRIMARY_DOMAIN_INFO_BASIC pPrimaryDomainInfo;
  115. PTESTED_DOMAIN pMemberDomain; //the primary domain info in the TESTED_DOMAIN struct
  116. BOOL fNetlogonIsRunning;
  117. HRESULT hrMemberTestResult; // result of the test
  118. // Logon information (who we're logged on as)
  119. PUNICODE_STRING pLogonUser;
  120. PUNICODE_STRING pLogonDomainName;
  121. PTESTED_DOMAIN pLogonDomain;
  122. BOOL fLogonWithCachedCredentials;
  123. LPWSTR pswzLogonServer;
  124. BOOL fKerberosIsWorking;
  125. BOOL fSysVolNotReady;
  126. // Is there any interfaces that are NetBT enabled
  127. BOOL fHasNbtEnabledInterface;
  128. } GLOBAL_RESULT;
  129. /*---------------------------------------------------------------------------
  130. Struct: GLOBAL_IPCONFIG
  131. ---------------------------------------------------------------------------*/
  132. typedef struct {
  133. // set to TRUE if InitIpconfig has been run
  134. BOOL fInitIpconfigCalled;
  135. // Is IPX actually up and running?
  136. BOOL fEnabled;
  137. //
  138. // IP-related info (non-DHCP related)
  139. //
  140. FIXED_INFO * pFixedInfo;
  141. //
  142. // This is a pointer to the beginning of the adapter list
  143. // (Use this to free up the list of interfaces)
  144. //
  145. IP_ADAPTER_INFO * pAdapterInfoList;
  146. // Is DHCP enabled? (on any adapter)
  147. BOOL fDhcpEnabled;
  148. } GLOBAL_IPCONFIG;
  149. /*---------------------------------------------------------------------------
  150. Struct: IPCONFIG_TST
  151. ---------------------------------------------------------------------------*/
  152. typedef struct {
  153. // IP is active on this interface
  154. BOOL fActive;
  155. //
  156. // Pointer to the IP adapter info for this interface
  157. // Do NOT free this up! (free up the entire list by freeing
  158. // up GLOBAL_IPCONFIG::pAdapterInfoList
  159. //
  160. IP_ADAPTER_INFO * pAdapterInfo;
  161. TCHAR szDhcpClassID[MAX_DOMAIN_NAME_LEN];
  162. // Is autoconfiguration possible?
  163. DWORD fAutoconfigEnabled;
  164. // is the adapter currently autoconfigured?
  165. DWORD fAutoconfigActive;
  166. // WINS node type?
  167. UINT uNodeType;
  168. TCHAR szDomainName[MAX_DOMAIN_NAME_LEN+1];
  169. IP_ADDR_STRING DnsServerList;
  170. // Can we ping the DHCP server?
  171. HRESULT hrPingDhcpServer;
  172. NdMessage msgPingDhcpServer;
  173. // Can we ping the WINS servers?
  174. HRESULT hrPingPrimaryWinsServer;
  175. NdMessage msgPingPrimaryWinsServer;
  176. HRESULT hrPingSecondaryWinsServer;
  177. NdMessage msgPingSecondaryWinsServer;
  178. // hrOK if the default gateway is on the same subnet as the ip address
  179. HRESULT hrDefGwSubnetCheck;
  180. // Test result
  181. HRESULT hr;
  182. } IPCONFIG_TST;
  183. /*---------------------------------------------------------------------------
  184. Struct: GLOBAL_LOOPBACK
  185. ---------------------------------------------------------------------------*/
  186. typedef struct
  187. {
  188. NdMessage msgLoopBack;
  189. HRESULT hr;
  190. } GLOBAL_LOOPBACK;
  191. /*---------------------------------------------------------------------------
  192. Struct: GLOBAL_IPX
  193. ---------------------------------------------------------------------------*/
  194. typedef struct
  195. {
  196. // TRUE if IPX is installed, FALSE otherwise
  197. BOOL fInstalled;
  198. // Is IPX actually up and running?
  199. BOOL fEnabled;
  200. // Handle to IPX
  201. HANDLE hIsnIpxFd;
  202. HRESULT hr;
  203. } GLOBAL_IPX;
  204. /*---------------------------------------------------------------------------
  205. Struct: GLOBAL_NETBT_TRANSPORTS
  206. ---------------------------------------------------------------------------*/
  207. typedef struct
  208. {
  209. LONG cTransportCount;
  210. LIST_ENTRY Transports;
  211. HRESULT hr;
  212. BOOL fPerformed; //FALSE: there are no inerfaces that are NetBT enabled. Test skipped.
  213. NdMessage msgTestResult;
  214. } GLOBAL_NETBT_TRANSPORTS;
  215. /*---------------------------------------------------------------------------
  216. Struct: GLOBAL_DEFGW
  217. ---------------------------------------------------------------------------*/
  218. typedef struct
  219. {
  220. // S_FALSE if no default gateways were reachable
  221. // S_OK if at least one default gateway was reached
  222. HRESULT hrReachable;
  223. } GLOBAL_DEFGW;
  224. /*---------------------------------------------------------------------------
  225. Struct: GLOBAL_AUTONET
  226. ---------------------------------------------------------------------------*/
  227. typedef struct
  228. {
  229. BOOL fAllAutoConfig;
  230. } GLOBAL_AUTONET;
  231. /*---------------------------------------------------------------------------
  232. Struct: GLOBAL_NETBTNM
  233. ---------------------------------------------------------------------------*/
  234. typedef struct
  235. {
  236. LIST_ENTRY lmsgGlobalOutput;
  237. HRESULT hrTestResult;
  238. } GLOBAL_NBTNM;
  239. /*---------------------------------------------------------------------------
  240. Struct: GLOBAL_BROWSER
  241. ---------------------------------------------------------------------------*/
  242. typedef struct
  243. {
  244. LIST_ENTRY lmsgOutput;
  245. HRESULT hrTestResult;
  246. BOOL fPerformed; //test will be skipped if no interfaces have NetBT enabled
  247. } GLOBAL_BROWSER;
  248. /*---------------------------------------------------------------------------
  249. Struct: GLOBAL_BINDINGS
  250. ---------------------------------------------------------------------------*/
  251. typedef struct
  252. {
  253. LIST_ENTRY lmsgOutput;
  254. HRESULT hrTestResult;
  255. } GLOBAL_BINDINGS;
  256. /*---------------------------------------------------------------------------
  257. Struct: GLOBAL_WAN
  258. ---------------------------------------------------------------------------*/
  259. typedef struct
  260. {
  261. LIST_ENTRY lmsgOutput;
  262. HRESULT hr;
  263. BOOL fPerformed; //FALSE: there are no active RAS connections. Test skipped.
  264. } GLOBAL_WAN;
  265. /*---------------------------------------------------------------------------
  266. Struct: GLOBAL_WINSOCK
  267. ---------------------------------------------------------------------------*/
  268. typedef struct
  269. {
  270. UINT idsContext;// str ID of context, which has %s to take the cause of failure
  271. HRESULT hr; // 0: success, otherwise failed
  272. DWORD dwMaxUDP; // max size of UDP packets, 0
  273. DWORD dwProts; // number of protocols providers
  274. LPWSAPROTOCOL_INFO pProtInfo; // information on the providers
  275. } GLOBAL_WINSOCK;
  276. typedef struct
  277. {
  278. DWORD dwNumRoutes;
  279. LIST_ENTRY lmsgRoute;
  280. DWORD dwNumPersistentRoutes;
  281. LIST_ENTRY lmsgPersistentRoute;
  282. HRESULT hrTestResult;
  283. } GLOBAL_ROUTE;
  284. typedef struct
  285. {
  286. LIST_ENTRY lmsgOutput;
  287. HRESULT hrTestResult;
  288. } GLOBAL_NDIS;
  289. typedef struct
  290. {
  291. LIST_ENTRY lmsgGlobalOutput;
  292. LIST_ENTRY lmsgInterfaceOutput; //Interface statistics
  293. LIST_ENTRY lmsgConnectionGlobalOutput;
  294. LIST_ENTRY lmsgTcpConnectionOutput;
  295. LIST_ENTRY lmsgUdpConnectionOutput;
  296. LIST_ENTRY lmsgIpOutput; // IP statistics
  297. LIST_ENTRY lmsgTcpOutput; // TCP statistics
  298. LIST_ENTRY lmsgUdpOutput; // UDP statistics
  299. LIST_ENTRY lmsgIcmpOutput; // ICMP statistics
  300. HRESULT hrTestResult;
  301. } GLOBAL_NETSTAT;
  302. /*---------------------------------------------------------------------------
  303. Struct: GLOBAL_IPSEC
  304. ---------------------------------------------------------------------------*/
  305. typedef struct
  306. {
  307. LIST_ENTRY lmsgGlobalOutput;
  308. LIST_ENTRY lmsgAdditOutput;
  309. } GLOBAL_IPSEC;
  310. /*---------------------------------------------------------------------------
  311. Struct: GLOBAL_DNS
  312. ---------------------------------------------------------------------------*/
  313. typedef struct {
  314. HRESULT hr;
  315. BOOL fOutput;
  316. LIST_ENTRY lmsgOutput;
  317. } GLOBAL_DNS;
  318. /*---------------------------------------------------------------------------
  319. Struct: GLOBAL_NETWARE
  320. ---------------------------------------------------------------------------*/
  321. typedef struct {
  322. LPTSTR pszUser;
  323. LPTSTR pszServer;
  324. LPTSTR pszTree;
  325. LPTSTR pszContext;
  326. BOOL fConnStatus;
  327. BOOL fNds;
  328. DWORD dwConnType;
  329. LIST_ENTRY lmsgOutput;
  330. HRESULT hr;
  331. } GLOBAL_NETWARE;
  332. /*---------------------------------------------------------------------------
  333. Struct: MODEM_DEVICE
  334. ---------------------------------------------------------------------------*/
  335. typedef struct
  336. {
  337. DWORD dwNegotiatedSpeed;
  338. DWORD dwModemOptions;
  339. DWORD dwDeviceID;
  340. LPTSTR pszPort;
  341. LPTSTR pszName;
  342. } MODEM_DEVICE;
  343. /*---------------------------------------------------------------------------
  344. Struct: GLOBAL_MODEM
  345. ---------------------------------------------------------------------------*/
  346. typedef struct {
  347. NdMessage ndOutput;
  348. int cModems;
  349. MODEM_DEVICE * pModemDevice;
  350. HRESULT hr;
  351. BOOL fPerformed; //FALSE: the machine has no line device, test skipped
  352. } GLOBAL_MODEM;
  353. /*---------------------------------------------------------------------------
  354. Struct: GLOBAL_DCLIST
  355. ---------------------------------------------------------------------------*/
  356. typedef struct
  357. {
  358. LIST_ENTRY lmsgOutput;
  359. BOOL fPerformed; //FALSE: the machine is not a member machine, nor a DC, test skipped
  360. NdMessage msgErr;
  361. HRESULT hr;
  362. } GLOBAL_DCLIST;
  363. /*---------------------------------------------------------------------------
  364. Struct: GLOBAL_TRUST
  365. ---------------------------------------------------------------------------*/
  366. typedef struct
  367. {
  368. LPTSTR pszContext; // context of failure
  369. HRESULT hr; // 0: success, otherwise failed
  370. BOOL fPerformed; //FALSE: the machine is not a member machine, nor a DC, test skipped
  371. LIST_ENTRY lmsgOutput;
  372. } GLOBAL_TRUST;
  373. /*---------------------------------------------------------------------------
  374. Struct: GLOBAL_KERBEROS
  375. ---------------------------------------------------------------------------*/
  376. typedef struct
  377. {
  378. UINT idsContext;// str ID of context, which has %s to take the cause of failure
  379. HRESULT hr; // 0: success, otherwise failed
  380. BOOL fPerformed; //FALSE: the machine is not a member machine, nor a DC, test skipped
  381. LIST_ENTRY lmsgOutput;
  382. } GLOBAL_KERBEROS;
  383. /*---------------------------------------------------------------------------
  384. Struct: GLOBAL_LDAP
  385. ---------------------------------------------------------------------------*/
  386. typedef struct
  387. {
  388. UINT idsContext;// str ID of context, which has %s to take the cause of failure
  389. HRESULT hr; // 0: success, otherwise failed
  390. BOOL fPerformed; //FALSE: the machine is not a member machine, nor a DC, test skipped
  391. LIST_ENTRY lmsgOutput;
  392. } GLOBAL_LDAP;
  393. typedef struct
  394. {
  395. HRESULT hr;
  396. BOOL fPerformed; //FALSE: the machine is not a member machine, nor a DC, test skipped
  397. LIST_ENTRY lmsgOutput;
  398. } GLOBAL_DSGETDC;
  399. /*---------------------------------------------------------------------------
  400. Struct: AUTONET_TST
  401. ---------------------------------------------------------------------------*/
  402. typedef struct {
  403. BOOL fAutoNet;
  404. } AUTONET_TST;
  405. /*---------------------------------------------------------------------------
  406. Struct: DEF_GW_TST
  407. ---------------------------------------------------------------------------*/
  408. typedef struct {
  409. BOOL dwNumReachable;
  410. LIST_ENTRY lmsgOutput;
  411. } DEF_GW_TST;
  412. /*---------------------------------------------------------------------------
  413. Struct: NBT_NM_TST
  414. ---------------------------------------------------------------------------*/
  415. typedef struct {
  416. LIST_ENTRY lmsgOutput;
  417. BOOL fActive; //used for additional Nbt interfaces whose pResults->fActive == FALSE
  418. BOOL fQuietOutput;
  419. } NBT_NM_TST;
  420. /*---------------------------------------------------------------------------
  421. Struct: WINS_TST
  422. ---------------------------------------------------------------------------*/
  423. typedef struct {
  424. LIST_ENTRY lmsgPrimary;
  425. LIST_ENTRY lmsgSecondary;
  426. // Test result
  427. HRESULT hr;
  428. BOOL fPerformed; //if FALSE: there is no WINS servier configured for this interface, test skipped
  429. }WINS_TST;
  430. /*---------------------------------------------------------------------------
  431. Struct: DNS_TST
  432. ---------------------------------------------------------------------------*/
  433. typedef struct {
  434. // Set to TRUE if there is non-verbose output (i.e. errors)
  435. BOOL fOutput;
  436. LIST_ENTRY lmsgOutput;
  437. } DNS_TST;
  438. typedef struct {
  439. int garbage;
  440. } NDIS_TST;
  441. typedef struct ___IPX_TEST_FRAME__ {
  442. // returns 0-3
  443. ULONG uFrameType;
  444. // returns virtual net if NicId = 0
  445. ULONG uNetworkNumber;
  446. // adapter's MAC address
  447. UCHAR Node[6];
  448. LIST_ENTRY list_entry;
  449. } IPX_TEST_FRAME;
  450. /*---------------------------------------------------------------------------
  451. Struct: IPX_TST
  452. ---------------------------------------------------------------------------*/
  453. typedef struct {
  454. // Is this interface enabled for IPX?
  455. BOOL fActive;
  456. // passed into various functions
  457. USHORT uNicId;
  458. // Returns TRUE if set
  459. BOOL fBindingSet;
  460. // 1 = lan, 2 = up wan, 3 = down wan
  461. UCHAR uType;
  462. // to support more than one FRAME type
  463. LIST_ENTRY list_entry_Frames; // it's ZeroMemoryed during init
  464. } IPX_TST;
  465. /*---------------------------------------------------------------------------
  466. Struct: INTERFACE_RESULT
  467. ---------------------------------------------------------------------------*/
  468. typedef struct {
  469. // If this is set to TRUE, show the data for this interface
  470. BOOL fActive;
  471. // The media-sense status of this card
  472. DWORD dwNetCardStatus;
  473. // Name (or ID) of this adapter (typically a GUID)
  474. LPTSTR pszName;
  475. // Friendly name for this adapter
  476. LPTSTR pszFriendlyName;
  477. //if NetBT is enabled
  478. BOOL fNbtEnabled;
  479. IPCONFIG_TST IpConfig;
  480. AUTONET_TST AutoNet;
  481. DEF_GW_TST DefGw;
  482. NBT_NM_TST NbtNm;
  483. WINS_TST Wins;
  484. DNS_TST Dns;
  485. NDIS_TST Ndis;
  486. IPX_TST Ipx;
  487. } INTERFACE_RESULT;
  488. /*---------------------------------------------------------------------------
  489. Struct: NETDIAG_RESULT
  490. ---------------------------------------------------------------------------*/
  491. typedef struct {
  492. GLOBAL_RESULT Global;
  493. GLOBAL_IPCONFIG IpConfig;
  494. GLOBAL_LOOPBACK LoopBack;
  495. GLOBAL_NETBT_TRANSPORTS NetBt;
  496. GLOBAL_DEFGW DefGw;
  497. GLOBAL_AUTONET AutoNet;
  498. GLOBAL_NBTNM NbtNm;
  499. GLOBAL_BROWSER Browser;
  500. GLOBAL_BINDINGS Bindings;
  501. GLOBAL_WINSOCK Winsock;
  502. GLOBAL_WAN Wan;
  503. GLOBAL_IPX Ipx;
  504. GLOBAL_DNS Dns;
  505. GLOBAL_ROUTE Route;
  506. GLOBAL_NDIS Ndis;
  507. GLOBAL_NETSTAT Netstat;
  508. GLOBAL_NETWARE Netware;
  509. GLOBAL_TRUST Trust;
  510. GLOBAL_MODEM Modem;
  511. GLOBAL_KERBEROS Kerberos;
  512. GLOBAL_DCLIST DcList;
  513. GLOBAL_LDAP LDAP;
  514. GLOBAL_DSGETDC DsGetDc;
  515. GLOBAL_IPSEC IPSec;
  516. LONG cNumInterfaces;
  517. LONG cNumInterfacesAllocated;
  518. INTERFACE_RESULT* pArrayInterface;
  519. } NETDIAG_RESULT;
  520. void ResultsInit(NETDIAG_RESULT* pResults);
  521. void PrintGlobalResults(NETDIAG_PARAMS *pParams, NETDIAG_RESULT *pResults);
  522. void PrintPerInterfaceResults(NETDIAG_PARAMS *pParams,
  523. NETDIAG_RESULT *pResults,
  524. INTERFACE_RESULT *pIfRes);
  525. void FindInterface(NETDIAG_RESULT *pResult, INTERFACE_RESULT **ppIf);
  526. void ResultsCleanup(NETDIAG_PARAMS *pParams, NETDIAG_RESULT* pResults);
  527. void PrintWaitDots(NETDIAG_PARAMS *pParams);
  528. #endif