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.

167 lines
5.1 KiB

  1. //++
  2. //
  3. // Copyright (C) Microsoft Corporation, 1987 - 1999
  4. //
  5. // Module Name:
  6. //
  7. // autonet.c
  8. //
  9. // Abstract:
  10. //
  11. // Queries into network drivers
  12. //
  13. // Author:
  14. //
  15. // Anilth - 4-20-1998
  16. //
  17. // Environment:
  18. //
  19. // User mode only.
  20. // Contains NT-specific code.
  21. //
  22. // Revision History:
  23. //
  24. //--
  25. #include "precomp.h"
  26. #include "dhcptest.h"
  27. //$Review (nsun) Now we just print "Autonet address is in use" if autonet.
  28. // we don't send Dhcp broadcast.
  29. // Maybe later we should send the Dhcp broadcast to see if the Dhcp server works or not
  30. // for all DHCP enabled card
  31. //-------------------------------------------------------------------------//
  32. //###### A u t o n e t T e s t () #######################################//
  33. //-------------------------------------------------------------------------//
  34. HRESULT
  35. AutonetTest(NETDIAG_PARAMS* pParams, NETDIAG_RESULT* pResults)
  36. //++
  37. //
  38. // Routine Description:
  39. //
  40. // Checks if we have autonet addresses on all adapters. If we do than
  41. // the workstation couldn't reach a DHCP server on any adapters.
  42. // Potential HW or NDIS issue.
  43. //
  44. // Arguments:
  45. //
  46. // None.
  47. //
  48. // Return Value:
  49. //
  50. // S_FALSE : Test failed, all adapters are autoconfigure.
  51. // S_OK : Test succeeded, we found at least one non-autoconfigure.
  52. // other : error codes
  53. //
  54. //--
  55. {
  56. PIP_ADAPTER_INFO pIpAdapterInfo;
  57. HRESULT hr = S_FALSE; // Assume that this will fail
  58. int i;
  59. PrintStatusMessage(pParams, 4, IDS_AUTONET_STATUS_MSG);
  60. //
  61. // scan all adapters for a non-autonet address
  62. //
  63. for( i = 0; i < pResults->cNumInterfaces; i++)
  64. {
  65. pIpAdapterInfo = pResults->pArrayInterface[i].IpConfig.pAdapterInfo;
  66. //if this is not an active connection, skip it.
  67. if (!pResults->pArrayInterface[i].IpConfig.fActive ||
  68. NETCARD_DISCONNECTED == pResults->pArrayInterface[i].dwNetCardStatus)
  69. continue;
  70. if ( !pResults->pArrayInterface[i].IpConfig.fAutoconfigActive )
  71. {
  72. //$REVIEW (nsun) maybe we need to DhcpBroadcast(pIpAdapterInfo) here instead
  73. // of for the AutoNet adapters
  74. pResults->pArrayInterface[i].AutoNet.fAutoNet = FALSE;
  75. hr = S_OK;
  76. continue;
  77. }
  78. // Skip WAN Cards
  79. if ( ! strstr(pIpAdapterInfo->AdapterName,"NdisWan") )
  80. pResults->pArrayInterface[i].AutoNet.fAutoNet = TRUE;
  81. }
  82. if ( FHrOK(hr) )
  83. {
  84. PrintStatusMessage(pParams, 0, IDS_GLOBAL_PASS_NL);
  85. pResults->AutoNet.fAllAutoConfig = FALSE;
  86. }
  87. else
  88. {
  89. PrintStatusMessage(pParams, 0, IDS_GLOBAL_FAIL_NL);
  90. pResults->AutoNet.fAllAutoConfig = TRUE;
  91. }
  92. return hr;
  93. } /* END OF AutonetTest() */
  94. void AutonetGlobalPrint(NETDIAG_PARAMS *pParams, NETDIAG_RESULT *pResults)
  95. {
  96. if (pParams->fVerbose || pResults->AutoNet.fAllAutoConfig)
  97. {
  98. PrintNewLine(pParams, 2);
  99. PrintTestTitleResult(pParams,
  100. IDS_AUTONET_LONG,
  101. IDS_AUTONET_SHORT,
  102. TRUE,
  103. pResults->AutoNet.fAllAutoConfig ?
  104. S_FALSE : S_OK, 0);
  105. }
  106. if(pResults->AutoNet.fAllAutoConfig)
  107. {
  108. //IDS_AUTONET_11601 " [FATAL] All adapters are autoconfigured!\n"
  109. PrintMessage(pParams, IDS_AUTONET_11601 );
  110. //IDS_AUTONET_11602 " The DHCP servers are unreachable. Please check cables, hubs, and taps!\n\n"
  111. PrintMessage(pParams, IDS_AUTONET_11602 );
  112. }
  113. else
  114. {
  115. if (pParams->fReallyVerbose)
  116. //IDS_AUTONET_11603 " PASS - you have at least one non-autoconfigured IP address\n"
  117. PrintMessage(pParams, IDS_AUTONET_11603 );
  118. }
  119. }
  120. void AutonetPerInterfacePrint(NETDIAG_PARAMS *pParams,
  121. NETDIAG_RESULT *pResults,
  122. INTERFACE_RESULT *pInterfaceResults)
  123. {
  124. if (!pInterfaceResults->IpConfig.fActive ||
  125. NETCARD_DISCONNECTED == pInterfaceResults->dwNetCardStatus)
  126. return;
  127. if (pParams->fVerbose)
  128. {
  129. //IDS_AUTONET_11604 " Autonet results : "
  130. PrintMessage(pParams, IDS_AUTONET_11604);
  131. if(pInterfaceResults->AutoNet.fAutoNet)
  132. {
  133. PrintMessage(pParams, IDS_GLOBAL_FAIL_NL);
  134. //IDS_AUTONET_11605 " [WARNING] AutoNet is in use. DHCP not available!\n"
  135. PrintMessage(pParams, IDS_AUTONET_11605);
  136. }
  137. else
  138. {
  139. PrintMessage(pParams, IDS_GLOBAL_PASS_NL);
  140. if(pParams->fReallyVerbose)
  141. //IDS_AUTONET_11606 " AutoNet is not in use. \n"
  142. PrintMessage(pParams, IDS_AUTONET_11606);
  143. }
  144. }
  145. }
  146. void AutonetCleanup(IN NETDIAG_PARAMS *pParams, IN OUT NETDIAG_RESULT *pResults)
  147. {
  148. }