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.

332 lines
9.0 KiB

  1. /*-----------------------------------------------------------------------------
  2. icwerr.cpp
  3. Maps RAS and downloading errors to string resource indices
  4. Copyright (C) 1996 Microsoft Corporation
  5. All rights reserved.
  6. Authors:
  7. ChrisK ChrisKauffman
  8. History:
  9. 7/22/96 ChrisK Cleaned and formatted
  10. -----------------------------------------------------------------------------*/
  11. #include "pch.hpp"
  12. #include "globals.h"
  13. //#include <raserror.h>
  14. #include "..\inc\icwerr.h"
  15. #define RAS_BOGUS_AUTHFAILCODE_1 84
  16. #define RAS_BOGUS_AUTHFAILCODE_2 74389484
  17. // ############################################################################
  18. WORD RasErrorToIDS(DWORD dwErr)
  19. {
  20. if(dwErr==RAS_BOGUS_AUTHFAILCODE_1 || dwErr==RAS_BOGUS_AUTHFAILCODE_2)
  21. {
  22. return IDS_PPPRANDOMFAILURE;
  23. }
  24. if((dwErr>=653 && dwErr<=663) || (dwErr==667) || (dwErr>=669 && dwErr<=675))
  25. {
  26. #ifdef DEBUG
  27. OutputDebugString("Got random RAS MEDIA error!\r\n");
  28. #endif
  29. return IDS_MEDIAINIERROR;
  30. }
  31. switch(dwErr)
  32. {
  33. default:
  34. return IDS_PPPRANDOMFAILURE;
  35. case SUCCESS:
  36. return IDS_PPPRANDOMFAILURE;
  37. case ERROR_DOWNLOADDIDNT:
  38. return IDS_CANTDOWNLOAD;
  39. case ERROR_LINE_BUSY:
  40. return IDS_PHONEBUSY;
  41. case ERROR_NO_ANSWER:
  42. return IDS_NOANSWER;
  43. case ERROR_VOICE_ANSWER:
  44. case ERROR_NO_CARRIER:
  45. return IDS_RASNOCARRIER;
  46. case ERROR_NO_DIALTONE:
  47. return IDS_NODIALTONE;
  48. case ERROR_HARDWARE_FAILURE: // modem turned off
  49. case ERROR_PORT_ALREADY_OPEN: // procomm/hypertrm/RAS has COM port
  50. case ERROR_PORT_OR_DEVICE:
  51. return IDS_NODEVICE;
  52. case ERROR_USER_DISCONNECTION:
  53. return IDS_USERCANCELEDDIAL;
  54. case ERROR_BUFFER_INVALID: // bad/empty rasdilap struct
  55. case ERROR_BUFFER_TOO_SMALL: // ditto?
  56. case ERROR_CANNOT_FIND_PHONEBOOK_ENTRY: // if connectoid name in registry is wrong
  57. return IDS_TCPINSTALLERROR;
  58. case ERROR_AUTHENTICATION_FAILURE: // get this on actual CHAP reject
  59. return IDS_PPPRANDOMFAILURE;
  60. case ERROR_PPP_TIMEOUT: // get this on CHAP timeout
  61. return IDS_PPPRANDOMFAILURE;
  62. case ERROR_REMOTE_DISCONNECTION: // Ascend drops connection on auth-fail
  63. return IDS_PPPRANDOMFAILURE;
  64. case ERROR_AUTH_INTERNAL: // got this on random POP failure
  65. case ERROR_PROTOCOL_NOT_CONFIGURED: // get this if LCP fails
  66. case ERROR_PPP_NO_PROTOCOLS_CONFIGURED: // get this if IPCP addr download gives garbage
  67. return IDS_PPPRANDOMFAILURE;
  68. case ERROR_USERCANCEL:
  69. return IDS_USERCANCELEDDIAL;
  70. /******
  71. case ERROR_CHANGING_PASSWORD:
  72. case ERROR_PASSWD_EXPIRED:
  73. ev = EVENT_INVALIDPASSWORD; break;
  74. case ERROR_ACCT_DISABLED:
  75. case ERROR_ACCT_EXPIRED:
  76. ev = EVENT_LOCKEDACCOUNT; break;
  77. case ERROR_NO_DIALIN_PERMISSION:
  78. case ERROR_RESTRICTED_LOGON_HOURS:
  79. case ERROR_AUTHENTICATION_FAILURE:
  80. ev = EVENT_RAS_AUTH_FAILED; break;
  81. case ERROR_ALREADY_DISCONNECTING:
  82. case ERROR_DISCONNECTION:
  83. ev = EVENT_CONNECTION_DROPPED; break;
  84. case PENDING:
  85. case ERROR_INVALID_PORT_HANDLE:
  86. case ERROR_CANNOT_SET_PORT_INFO:
  87. case ERROR_PORT_NOT_CONNECTED:
  88. case ERROR_DEVICE_DOES_NOT_EXIST:
  89. case ERROR_DEVICETYPE_DOES_NOT_EXIST:
  90. case ERROR_PORT_NOT_FOUND:
  91. case ERROR_DEVICENAME_TOO_LONG:
  92. case ERROR_DEVICENAME_NOT_FOUND:
  93. ev=EVENT_BAD_MODEM_CONFIG; break;
  94. case ERROR_TAPI_CONFIGURATION:
  95. ev=EVENT_BAD_TAPI_CONFIG; break;
  96. ev=EVENT_MODEM_BUSY; break;
  97. case ERROR_BUFFER_TOO_SMALL:
  98. case ERROR_WRONG_INFO_SPECIFIED:
  99. case ERROR_EVENT_INVALID:
  100. case ERROR_BUFFER_INVALID:
  101. case ERROR_ASYNC_REQUEST_PENDING:
  102. case ERROR_CANNOT_OPEN_PHONEBOOK:
  103. case ERROR_CANNOT_LOAD_PHONEBOOK:
  104. case ERROR_CANNOT_WRITE_PHONEBOOK:
  105. case ERROR_CORRUPT_PHONEBOOK:
  106. case ERROR_CANNOT_LOAD_STRING:
  107. case ERROR_OUT_OF_BUFFERS:
  108. case ERROR_MACRO_NOT_FOUND:
  109. case ERROR_MACRO_NOT_DEFINED:
  110. case ERROR_MESSAGE_MACRO_NOT_FOUND:
  111. case ERROR_DEFAULTOFF_MACRO_NOT_FOUND:
  112. case ERROR_FILE_COULD_NOT_BE_OPENED:
  113. case ERROR_PORT_NOT_OPEN:
  114. case ERROR_PORT_DISCONNECTED:
  115. case ERROR_NO_ENDPOINTS:
  116. case ERROR_KEY_NOT_FOUND:
  117. case ERROR_INVALID_SIZE:
  118. case ERROR_PORT_NOT_AVAILABLE:
  119. case ERROR_UNKNOWN:
  120. case ERROR_WRONG_DEVICE_ATTACHED:
  121. case ERROR_BAD_STRING:
  122. case ERROR_BAD_USAGE_IN_INI_FILE:
  123. case ERROR_READING_SECTIONNAME:
  124. case ERROR_READING_DEVICETYPE:
  125. case ERROR_READING_DEVICENAME:
  126. case ERROR_READING_USAGE:
  127. case ERROR_READING_MAXCONNECTBPS:
  128. case ERROR_READING_MAXCARRIERBPS:
  129. case ERROR_IN_COMMAND:
  130. case ERROR_WRITING_SECTIONNAME:
  131. case ERROR_WRITING_DEVICETYPE:
  132. case ERROR_WRITING_DEVICENAME:
  133. case ERROR_WRITING_MAXCONNECTBPS:
  134. case ERROR_WRITING_MAXCARRIERBPS:
  135. case ERROR_WRITING_USAGE:
  136. case ERROR_WRITING_DEFAULTOFF:
  137. case ERROR_READING_DEFAULTOFF:
  138. case ERROR_EMPTY_INI_FILE:
  139. case ERROR_FROM_DEVICE:
  140. case ERROR_UNRECOGNIZED_RESPONSE:
  141. case ERROR_NO_RESPONSES:
  142. case ERROR_NO_COMMAND_FOUND:
  143. case ERROR_WRONG_KEY_SPECIFIED:
  144. case ERROR_UNKNOWN_DEVICE_TYPE:
  145. case ERROR_ALLOCATING_MEMORY:
  146. case ERROR_PORT_NOT_CONFIGURED:
  147. case ERROR_DEVICE_NOT_READY:
  148. case ERROR_READING_INI_FILE:
  149. case ERROR_NO_CONNECTION:
  150. case ERROR_PORT_OR_DEVICE:
  151. case ERROR_NOT_BINARY_MACRO:
  152. case ERROR_DCB_NOT_FOUND:
  153. case ERROR_STATE_MACHINES_NOT_STARTED:
  154. case ERROR_STATE_MACHINES_ALREADY_STARTED:
  155. case ERROR_PARTIAL_RESPONSE_LOOPING:
  156. case ERROR_UNKNOWN_RESPONSE_KEY:
  157. case ERROR_RECV_BUF_FULL:
  158. case ERROR_CMD_TOO_LONG:
  159. case ERROR_UNSUPPORTED_BPS:
  160. case ERROR_UNEXPECTED_RESPONSE:
  161. case ERROR_INTERACTIVE_MODE:
  162. case ERROR_BAD_CALLBACK_NUMBER:
  163. case ERROR_INVALID_AUTH_STATE:
  164. case ERROR_WRITING_INITBPS:
  165. case ERROR_X25_DIAGNOSTIC:
  166. case ERROR_OVERRUN:
  167. case ERROR_RASMAN_CANNOT_INITIALIZE:
  168. case ERROR_BIPLEX_PORT_NOT_AVAILABLE:
  169. case ERROR_NO_ACTIVE_ISDN_LINES:
  170. case ERROR_NO_ISDN_CHANNELS_AVAILABLE:
  171. case ERROR_TOO_MANY_LINE_ERRORS:
  172. ev=EVENT_INTERNAL_ERROR; break;
  173. case ERROR_ROUTE_NOT_AVAILABLE:
  174. case ERROR_ROUTE_NOT_ALLOCATED:
  175. case ERROR_INVALID_COMPRESSION_SPECIFIED:
  176. case ERROR_CANNOT_PROJECT_CLIENT:
  177. case ERROR_CANNOT_GET_LANA:
  178. case ERROR_NETBIOS_ERROR:
  179. case ERROR_NAME_EXISTS_ON_NET:
  180. ev=EVENT_BAD_NET_CONFIG; break;
  181. case ERROR_REQUEST_TIMEOUT:
  182. case ERROR_SERVER_OUT_OF_RESOURCES:
  183. case ERROR_SERVER_GENERAL_NET_FAILURE:
  184. case WARNING_MSG_ALIAS_NOT_ADDED:
  185. case ERROR_SERVER_NOT_RESPONDING:
  186. ev=EVENT_GENERAL_NET_ERROR; break;
  187. case ERROR_IP_CONFIGURATION:
  188. case ERROR_NO_IP_ADDRESSES:
  189. case ERROR_PPP_REMOTE_TERMINATED:
  190. case ERROR_PPP_NO_RESPONSE:
  191. case ERROR_PPP_INVALID_PACKET:
  192. case ERROR_PHONE_NUMBER_TOO_LONG:
  193. case ERROR_IPXCP_NO_DIALOUT_CONFIGURED:
  194. case ERROR_IPXCP_NO_DIALIN_CONFIGURED:
  195. case ERROR_IPXCP_DIALOUT_ALREADY_ACTIVE:
  196. case ERROR_ACCESSING_TCPCFGDLL:
  197. case ERROR_NO_IP_RAS_ADAPTER:
  198. case ERROR_SLIP_REQUIRES_IP:
  199. case ERROR_PROJECTION_NOT_COMPLETE:
  200. case ERROR_PPP_NOT_CONVERGING:
  201. case ERROR_PPP_CP_REJECTED:
  202. case ERROR_PPP_LCP_TERMINATED:
  203. case ERROR_PPP_REQUIRED_ADDRESS_REJECTED:
  204. case ERROR_PPP_NCP_TERMINATED:
  205. case ERROR_PPP_LOOPBACK_DETECTED:
  206. case ERROR_PPP_NO_ADDRESS_ASSIGNED:
  207. case ERROR_CANNOT_USE_LOGON_CREDENTIALS:
  208. case ERROR_NO_LOCAL_ENCRYPTION:
  209. case ERROR_NO_REMOTE_ENCRYPTION:
  210. case ERROR_REMOTE_REQUIRES_ENCRYPTION:
  211. case ERROR_IPXCP_NET_NUMBER_CONFLICT:
  212. ev = EVENT_PPP_FAILURE; break;
  213. ***********/
  214. }
  215. return (0xFFFF);
  216. }
  217. // ############################################################################
  218. HRESULT LoadDialErrorString(HRESULT hrIN, LPTSTR lpszBuff, DWORD dwBufferSize)
  219. {
  220. if (lpszBuff && dwBufferSize)
  221. {
  222. WORD wSID = 0;
  223. wSID = RasErrorToIDS(hrIN);
  224. if (0xFFFF != wSID)
  225. {
  226. if (0 != LoadString(GetModuleHandle(NULL),wSID,lpszBuff,(int)dwBufferSize))
  227. return ERROR_SUCCESS;
  228. }
  229. }
  230. return ERROR_INVALID_PARAMETER;
  231. }
  232. HRESULT WINAPI StatusMessageCallback(DWORD dwStatus, LPTSTR pszBuffer, DWORD dwBufferSize)
  233. {
  234. WORD iIDS = 0;
  235. switch(dwStatus)
  236. {
  237. case RASCS_OpenPort:
  238. iIDS = IDS_RAS_OPENPORT;
  239. break;
  240. case RASCS_PortOpened:
  241. iIDS = IDS_RAS_PORTOPENED;
  242. break;
  243. case RASCS_ConnectDevice:
  244. iIDS = IDS_RAS_DIALING;
  245. break;
  246. case RASCS_DeviceConnected:
  247. iIDS = IDS_RAS_CONNECTED;
  248. break;
  249. #if (WINVER >= 0x400)
  250. case RASCS_StartAuthentication:
  251. case RASCS_LogonNetwork:
  252. iIDS = IDS_RAS_LOCATING;
  253. break;
  254. // case RASCS_CallbackComplete:
  255. // iIDS = IDS_RAS_CONNECTED;
  256. // break;
  257. #endif
  258. /* ETC...
  259. RASCS_AllDevicesConnected,
  260. RASCS_Authenticate,
  261. RASCS_AuthNotify,
  262. RASCS_AuthRetry,
  263. RASCS_AuthCallback,
  264. RASCS_AuthChangePassword,
  265. RASCS_AuthProject,
  266. RASCS_AuthLinkSpeed,
  267. RASCS_AuthAck,
  268. RASCS_ReAuthenticate,
  269. RASCS_Authenticated,
  270. RASCS_PrepareForCallback,
  271. RASCS_WaitForModemReset,
  272. RASCS_WaitForCallback,
  273. RASCS_Projected,
  274. RASCS_Interactive = RASCS_PAUSED,
  275. RASCS_RetryAuthentication,
  276. RASCS_CallbackSetByCaller,
  277. RASCS_PasswordExpired,
  278. */
  279. case RASCS_Connected:
  280. break;
  281. case RASCS_Disconnected:
  282. break;
  283. }
  284. if (iIDS && 0 != LoadString(GetModuleHandle(NULL),iIDS,pszBuffer,(int)dwBufferSize))
  285. return ERROR_SUCCESS;
  286. else
  287. return ERROR_INVALID_PARAMETER;
  288. }