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.

370 lines
13 KiB

  1. //++
  2. //
  3. // Copyright (C) Microsoft Corporation, 1987 - 1999
  4. //
  5. // Module Name:
  6. //
  7. // wantest.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. #undef IsEqualGUID
  27. #include <ras.h>
  28. #include <tapi.h>
  29. #include <unimodem.h>
  30. //$REVIEW (nsun) is this reasonable
  31. #define MAX_RASCONN 100
  32. BOOL
  33. WANTest(NETDIAG_PARAMS* pParams, NETDIAG_RESULT* pResults)
  34. // Description:
  35. // This routine tests the WAN/TAPI configurations
  36. //
  37. //
  38. // Author:
  39. // NSun
  40. //
  41. {
  42. HRESULT hr = S_OK;
  43. DWORD dwReturn;
  44. DWORD dwByteCount;
  45. RASCONN pRasConn[MAX_RASCONN];
  46. RASENTRY RasEntry;
  47. DWORD dwEntryInfoSize;
  48. RAS_STATS RasStats;
  49. DWORD dwNumConnections;
  50. DWORD i;
  51. PrintStatusMessage( pParams, 4, IDS_WAN_STATUS_MSG );
  52. InitializeListHead( &pResults->Wan.lmsgOutput );
  53. dwByteCount = sizeof(RASCONN) * MAX_RASCONN;
  54. //
  55. // dwSize identifies the version of the structure being passed
  56. //
  57. pRasConn[0].dwSize = sizeof(RASCONN);
  58. dwReturn = RasEnumConnections(pRasConn,
  59. &dwByteCount,
  60. &dwNumConnections);
  61. if (dwReturn != 0) {
  62. //IDS_WAN_15001 "RasEnumConnections failed\n"
  63. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Quiet, IDS_WAN_15001);
  64. hr = S_FALSE;
  65. goto LERROR;
  66. }
  67. if (dwNumConnections == 0) {
  68. //IDS_WAN_15002 "No active remote access connections.\n"
  69. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15002);
  70. goto LERROR;
  71. }
  72. pResults->Wan.fPerformed = TRUE;
  73. for ( i = 0; i < dwNumConnections; i++)
  74. {
  75. //IDS_WAN_15003 "Entry Name: "
  76. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15003);
  77. if (pRasConn[i].szEntryName[0] == '.')
  78. {
  79. //IDS_WAN_15004 "N/A, phone number %s\n"
  80. AddMessageToList( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15004, pRasConn[i].szEntryName+1); // skip the dot
  81. //IDS_WAN_15005 "The following is default entry properties.\n"
  82. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15005);
  83. pRasConn[i].szEntryName[0] = 0;
  84. }
  85. else
  86. //IDS_WAN_15006 "%s\n"
  87. AddMessageToList( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15006, pRasConn[i].szEntryName);
  88. RasEntry.dwSize = sizeof(RasEntry);
  89. dwEntryInfoSize = sizeof(RasEntry);
  90. dwReturn = RasGetEntryProperties(NULL,
  91. pRasConn[i].szEntryName,
  92. &RasEntry,
  93. &dwEntryInfoSize,
  94. NULL,
  95. NULL);
  96. if (dwReturn != 0) {
  97. //IDS_WAN_15056 "RasGetEntryProperties for %s failed. [%s]\n"
  98. AddMessageToList( &pResults->Wan.lmsgOutput, Nd_Quiet, IDS_WAN_15056,
  99. pRasConn[i].szEntryName, NetStatusToString(dwReturn));
  100. hr = S_FALSE;
  101. continue;
  102. }
  103. //
  104. // dump the connection properties
  105. //
  106. // print the device type
  107. //IDS_WAN_15008 "Device Type: "
  108. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15008);
  109. //$ REVIEW
  110. // Why are there '\n''s at the end of the names?
  111. if (!_tcscmp(RasEntry.szDeviceType,_T("RASDT_Modem\n")))
  112. {
  113. // IDS_WAN_15009 "Modem\n"
  114. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose,
  115. IDS_WAN_15009);
  116. }
  117. else if (!_tcscmp(RasEntry.szDeviceType,_T("RASDT_Isdn\n")))
  118. {
  119. // IDS_WAN_15010 "ISDN card\n"
  120. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose,
  121. IDS_WAN_15010);
  122. }
  123. else if (!_tcscmp(RasEntry.szDeviceType,_T("RASDT_X25\n")))
  124. {
  125. //IDS_WAN_15011 "X25 card\n"
  126. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose,
  127. IDS_WAN_15011);
  128. }
  129. else if (!_tcscmp(RasEntry.szDeviceType,_T("RASDT_Vpn\n")))
  130. {
  131. //IDS_WAN_15012 "Virtual Private Network\n"
  132. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose,
  133. IDS_WAN_15012);
  134. }
  135. else if (!_tcscmp(RasEntry.szDeviceType,_T("RASDT_PAD")))
  136. {
  137. //IDS_WAN_15013 "Packet Assembler / Dissasembler\n"
  138. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose,
  139. IDS_WAN_15013);
  140. }
  141. //
  142. // Framing protocol in use
  143. //
  144. //IDS_WAN_15014 "Framing protocol : "
  145. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15014);
  146. if (RasEntry.dwFramingProtocol & RASFP_Ppp)
  147. //IDS_WAN_15015 " PPP\n"
  148. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15015);
  149. else
  150. if (RasEntry.dwFramingProtocol & RASFP_Slip)
  151. //IDS_WAN_15016 " Slip\n"
  152. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15016);
  153. else
  154. if (RasEntry.dwFramingProtocol & RASFP_Ras)
  155. //IDS_WAN_15017 " MS Proprietary protocol\n"
  156. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15017);
  157. //
  158. // PPP and LCP Settings
  159. //
  160. if (RasEntry.dwFramingProtocol & RASFP_Ppp) {
  161. //IDS_WAN_15018 "LCP Extensions : "
  162. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15018);
  163. if (RasEntry.dwfOptions & RASEO_DisableLcpExtensions)
  164. //IDS_WAN_DISABLED " Disabled\n"
  165. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_DISABLED);
  166. else
  167. //IDS_WAN_ENABLED " Enabled\n"
  168. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_ENABLED);
  169. //IDS_WAN_15021 "Software Compression : "
  170. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15021);
  171. if (RasEntry.dwfOptions & RASEO_SwCompression)
  172. //IDS_WAN_ENABLED " Enabled\n"
  173. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_ENABLED);
  174. else
  175. //IDS_WAN_DISABLED " Disabled\n"
  176. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_DISABLED);
  177. }
  178. //
  179. // Network protocols in use and options
  180. //
  181. //IDS_WAN_15024 "Network protocols :\n "
  182. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15024);
  183. if (RasEntry.dwfNetProtocols & RASNP_NetBEUI)
  184. //IDS_WAN_15025 " NetBEUI\n"
  185. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15025);
  186. if (RasEntry.dwfNetProtocols & RASNP_Ipx)
  187. //IDS_WAN_15026 " IPX\n"
  188. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15026);
  189. if (RasEntry.dwfNetProtocols & RASNP_Ip)
  190. //IDS_WAN_15027 " TCP/IP\n"
  191. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15027);
  192. //
  193. // TCP/IP options
  194. //
  195. if (RasEntry.dwfNetProtocols & RASNP_Ip) {
  196. //IDS_WAN_15028 "IP Address : "
  197. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15028);
  198. if (RasEntry.dwfOptions & RASEO_SpecificIpAddr)
  199. //IDS_WAN_15029 "Specified\n"
  200. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15029);
  201. else
  202. //IDS_WAN_15030 "Server Assigned\n"
  203. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15030);
  204. //IDS_WAN_15031 "Name Server: "
  205. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15031);
  206. if (RasEntry.dwfOptions & RASEO_SpecificNameServers)
  207. //IDS_WAN_15032 "Specified\n"
  208. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15032);
  209. else
  210. //IDS_WAN_15033 "Server Assigned\n"
  211. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15033);
  212. // IP hdr compression makes sense only if we use PPP
  213. if (RasEntry.dwFramingProtocol & RASFP_Ppp) {
  214. //IDS_WAN_15034 "IP Header compression : "
  215. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15034);
  216. if (RasEntry.dwfOptions & RASEO_IpHeaderCompression)
  217. //IDS_WAN_15035 " Enabled\n"
  218. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15035);
  219. else
  220. //IDS_WAN_15036 " Disabled\n"
  221. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15036);
  222. }
  223. //IDS_WAN_15037 "Use default gateway on remote network : "
  224. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15037);
  225. if (RasEntry.dwfOptions & RASEO_RemoteDefaultGateway)
  226. //IDS_WAN_15038 "Enabled\n"
  227. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15038);
  228. else
  229. //IDS_WAN_15039 "Disabled\n"
  230. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15039);
  231. }
  232. //
  233. // Collect statistics regarding this connection
  234. //
  235. RasStats.dwSize = sizeof(RAS_STATS); // pass version information
  236. dwReturn = RasGetConnectionStatistics(
  237. pRasConn[i].hrasconn,
  238. &RasStats);
  239. if (dwReturn != 0) {
  240. //IDS_WAN_15040 " RasGetConnectionStatistics for %s failed. [%s]\n"
  241. AddMessageToList( &pResults->Wan.lmsgOutput, Nd_Quiet, IDS_WAN_15040,
  242. pRasConn[i].szEntryName, NetStatusToString(dwReturn) );
  243. hr = S_FALSE;
  244. continue;
  245. }
  246. //IDS_WAN_15041 "\n\tConnection Statistics:\n"
  247. AddMessageToListId( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15041);
  248. //IDS_WAN_15042 "\tBytes Transmitted : %d\n"
  249. AddMessageToList( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15042, RasStats.dwBytesXmited);
  250. //IDS_WAN_15043 "\tBytes Received : %d\n"
  251. AddMessageToList( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15043,RasStats.dwBytesRcved);
  252. //IDS_WAN_15044 "\tFrames Transmitted : %d\n"
  253. AddMessageToList( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15044,RasStats.dwFramesXmited);
  254. //IDS_WAN_15045 "\tFrames Received : %d\n"
  255. AddMessageToList( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15045,RasStats.dwFramesRcved);
  256. //IDS_WAN_15046 "\tCRC Errors : %d\n"
  257. AddMessageToList( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15046,RasStats.dwFramesRcved);
  258. //IDS_WAN_15047 "\tTimeout Errors : %d\n"
  259. AddMessageToList( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15047,RasStats.dwTimeoutErr);
  260. //IDS_WAN_15048 "\tAlignment Errors : %d\n"
  261. AddMessageToList( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15048,RasStats.dwAlignmentErr);
  262. //IDS_WAN_15049 "\tH/W Overrun Errors : %d\n"
  263. AddMessageToList( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15049,RasStats.dwHardwareOverrunErr);
  264. //IDS_WAN_15050 "\tFraming Errors : %d\n"
  265. AddMessageToList( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15050,RasStats.dwFramingErr);
  266. //IDS_WAN_15051 "\tBuffer Overrun Errors : %d\n"
  267. AddMessageToList( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15051,RasStats.dwBufferOverrunErr);
  268. //IDS_WAN_15052 "\tCompression Ratio In : %d\n"
  269. AddMessageToList( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15052,RasStats.dwCompressionRatioIn);
  270. //IDS_WAN_15053 "\tCompression Ratio Out : %d\n"
  271. AddMessageToList( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15053,RasStats.dwCompressionRatioOut);
  272. //IDS_WAN_15054 "\tBaud Rate ( Bps ) : %d\n"
  273. AddMessageToList( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15054,RasStats.dwBps);
  274. //IDS_WAN_15055 "\tConnection Duration : %d\n"
  275. AddMessageToList( &pResults->Wan.lmsgOutput, Nd_Verbose, IDS_WAN_15055,RasStats.dwConnectDuration);
  276. } // end of for loop
  277. LERROR:
  278. pResults->Wan.hr = hr;
  279. return hr;
  280. }
  281. void WANGlobalPrint(NETDIAG_PARAMS *pParams, NETDIAG_RESULT *pResults)
  282. {
  283. if (pParams->fVerbose)
  284. {
  285. PrintNewLine(pParams, 2);
  286. PrintTestTitleResult(pParams,
  287. IDS_WAN_LONG,
  288. IDS_WAN_SHORT,
  289. pResults->Wan.fPerformed,
  290. pResults->Wan.hr,
  291. 0);
  292. }
  293. PrintMessageList(pParams, &pResults->Wan.lmsgOutput);
  294. }
  295. void WANPerInterfacePrint(NETDIAG_PARAMS *pParams, NETDIAG_RESULT *pResults, INTERFACE_RESULT *pInterfaceResults)
  296. {
  297. //Not a PerInterface test
  298. }
  299. void WANCleanup(IN NETDIAG_PARAMS *pParams, IN OUT NETDIAG_RESULT *pResults)
  300. {
  301. MessageListCleanUp(&pResults->Wan.lmsgOutput);
  302. }