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.

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