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.

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