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.

368 lines
10 KiB

  1. //****************************************************************************
  2. //
  3. // Microsoft NT Remote Access Service
  4. //
  5. // Copyright (C) 1992-93 Microsft Corporation. All rights reserved.
  6. //
  7. // Filename: mxspriv.h
  8. //
  9. // Revision History
  10. //
  11. // Jun 5, 1992 J. Perry Hannah Created
  12. //
  13. //
  14. // Description: This file contains structure and constant definitions
  15. // and API prototypes for RASMXS.DLL. This file is used
  16. // used only by RASMXS.DLL source files, and is not public
  17. // in any way.
  18. //
  19. //****************************************************************************
  20. #ifndef _MXSPRIV_
  21. #define _MXSPRIV_
  22. //* Defines ****************************************************************
  23. //
  24. #define INITIAL_PARAMS 13 //Inital buffer size in params
  25. #define MAX_LEN_STR_FROM_NUMBER 10
  26. #define MIN_LINK_SPEED 2400
  27. #define LOOP_TXT "LOOP"
  28. #define SERIAL_DLL_FILENAME "RASSER.DLL"
  29. #define RAS_PATH "\\RAS\\"
  30. #define PAD_INF_FILENAME "PAD.INF"
  31. #define MODEM_INF_FILENAME "MODEM.INF"
  32. #define SWITCH_INF_FILENAME "SWITCH.INF"
  33. #define LOG_FILENAME "DEVICE.LOG"
  34. #define ALL_MACROS 0 //Used by MacroCount()
  35. #define BINARY_MACROS 1 //Used by MacroCount()
  36. #define ON_SUFFIX 1
  37. #define OFF_SUFFIX 2
  38. #define NOT_BINARY_MACRO FALSE
  39. #define WAITFORCOMPLETION TRUE
  40. #define INVALID_INDEX 0xffffffff
  41. #define MODEM_RETRIES 3
  42. #define NO_RESPONSE_DELAY 2000 //Time to wait in mS
  43. //ReadFile time outs in mS
  44. #define TO_WRITE 2000 //Write timeout
  45. #define TO_ECHO 2000 //WaitForEcho
  46. #define TO_FIRSTCHARAFTERECHO 120000 //WaitForFirstChar following echo
  47. #define TO_FIRSTCHARNOECHO 10000 //WaitForFirstChar when no echo
  48. #define TO_PARTIALRESPONSE 25000 //WaitForFirstChar of 2nd part
  49. #define TO_RCV_INTERVAL 500 //ReceiveString
  50. #define TO_RCV_CONSTANT 3000 //ReceiveString
  51. #define MXS_COMPRESSION_OFF_KEY MXS_COMPRESSION_KEY##""##MXS_OFF_SUFX
  52. #define MXS_COMPRESSION_ON_KEY MXS_COMPRESSION_KEY##""##MXS_ON_SUFX
  53. #define MXS_HDWFLOWCONTROL_OFF_KEY MXS_HDWFLOWCONTROL_KEY##""##MXS_OFF_SUFX
  54. #define MXS_HDWFLOWCONTROL_ON_KEY MXS_HDWFLOWCONTROL_KEY##""##MXS_ON_SUFX
  55. #define MXS_PROTOCOL_OFF_KEY MXS_PROTOCOL_KEY##""##MXS_OFF_SUFX
  56. #define MXS_PROTOCOL_ON_KEY MXS_PROTOCOL_KEY##""##MXS_ON_SUFX
  57. #define MXS_SPEAKER_OFF_KEY MXS_SPEAKER_KEY##""##MXS_OFF_SUFX
  58. #define MXS_SPEAKER_ON_KEY MXS_SPEAKER_KEY##""##MXS_ON_SUFX
  59. #define MXS_AUTODIAL_OFF_KEY MXS_AUTODIAL_KEY##""##MXS_OFF_SUFX
  60. #define MXS_AUTODIAL_ON_KEY MXS_AUTODIAL_KEY##""##MXS_ON_SUFX
  61. #define RASMAN_REGISTRY_PATH "System\\CurrentControlSet\\Services\\Rasman\\Parameters"
  62. #define RASMAN_LOGGING_VALUE "Logging"
  63. //* Macros *****************************************************************
  64. //
  65. #define ATTRIBCPY(DEST,SRC) (((ATTRIB_ENABLED)&(SRC))?\
  66. ((DEST)|=(ATTRIB_ENABLED)):\
  67. ((DEST)&=(~ATTRIB_ENABLED)))
  68. #define XOR(A,B) (((A)||(B))&&!((A)&&(B)))
  69. // Note: The following macro assumes that CreateAttributes() has already
  70. // been called to set attribute bits.
  71. #define ISUNARYMACRO(P) (!((ATTRIB_VARIABLE|ATTRIB_BINARYMACRO)&(P)))
  72. #define STRICMP _stricmp
  73. #ifdef DEBUG
  74. #define DebugPrintf(_args_) DbgPrntf _args_
  75. #define DebugString(_args_) DbgStr _args_
  76. #else
  77. #define DebugPrintf(_args_)
  78. #define DebugString(_args_)
  79. #endif
  80. #ifdef DBGCON
  81. #define ConsolePrintf(_args_) ConPrintf _args_
  82. #else
  83. #define ConsolePrintf(_args_)
  84. #endif
  85. //* Data Structures ********************************************************
  86. //
  87. typedef struct DEVICE_CB DEVICE_CB;
  88. struct DEVICE_CB // Device Control Block
  89. {
  90. DEVICE_CB *pNextDeviceCB;
  91. HANDLE hPort;
  92. TCHAR szDeviceName[MAX_DEVICE_NAME+1];
  93. TCHAR szDeviceType[MAX_DEVICETYPE_NAME];
  94. DEVICETYPE eDeviceType;
  95. RASMAN_DEVICEINFO *pInfoTable;
  96. MACROXLATIONTABLE *pMacros;
  97. HRASFILE hInfFile;
  98. TCHAR *pszResponseStart; // Start of response following echo
  99. DWORD cbRead; // Bytes read per FileRead
  100. DWORD cbTotal; // Cumulative bytes read & kept
  101. HANDLE hNotifier; // Event signaled when async I/O finished
  102. DWORD dCmdLen; // Indicates length of echo string
  103. BOOL bResponseExpected; // Some commands have no responses
  104. BOOL fPartialResponse;
  105. BOOL bErrorControlOn;
  106. DWORD dwRetries; // Num retries on modem hardware errors
  107. NEXTACTION eDevNextAction; // DeviceStateMachine() State
  108. CMDTYPE eCmdType; // Used by DeviceStateMachine()
  109. CMDTYPE eNextCmdType; // Used by DeviceStateMachine()
  110. BOOL fEndOfSection; // Used by DeviceStateMachine()
  111. RCVSTATE eRcvState; // ReceiveStateMachine() State
  112. RAS_OVERLAPPED Overlapped; // Struct used by Win32 async file I/O
  113. TCHAR szPortBps[MAX_LEN_STR_FROM_NUMBER];
  114. TCHAR szCommand[MAX_CMD_BUF_LEN];
  115. TCHAR szResponse[MAX_RCV_BUF_LEN];
  116. TCHAR szPortName[MAX_PORT_NAME + 1];
  117. };
  118. typedef struct ERROR_ELEM ERROR_ELEM;
  119. struct ERROR_ELEM
  120. {
  121. TCHAR szKey[MAX_PARAM_KEY_SIZE];
  122. DWORD dwErrorCode;
  123. };
  124. typedef struct RESPSECTION RESPSECTION ;
  125. struct RESPSECTION
  126. {
  127. HRASFILE Handle ;
  128. WORD UseCount ;
  129. HANDLE Mutex ;
  130. } ;
  131. struct SavedSections {
  132. struct SavedSections* Next ;
  133. TCHAR FileName[MAX_PATH] ;
  134. TCHAR SectionName[MAX_DEVICE_NAME+1] ;
  135. HRASFILE hFile ;
  136. BOOL InUse ;
  137. } ;
  138. typedef struct SavedSections SavedSections ;
  139. //* Internal Prototypes ****************************************************
  140. //
  141. //* From mxsutils.c --------------------------------------------------------
  142. //
  143. #ifdef DEBUG
  144. void DbgPrntf(const char * format, ...);
  145. void DbgStr(char Str[], DWORD StrLen);
  146. #endif
  147. #ifdef DBGCON
  148. VOID ConPrintf ( char *Format, ... );
  149. #endif
  150. DWORD AddDeviceToList(DEVICE_CB **ppDeviceList,
  151. HANDLE hIOPort,
  152. LPTSTR lpDeviceType,
  153. LPTSTR lpDeviceName,
  154. DEVICE_CB **ppDevice);
  155. DWORD AddInternalMacros(DEVICE_CB *pDev, RASMAN_DEVICEINFO *pDI);
  156. WORD BinarySuffix(TCHAR *pch);
  157. DWORD BuildOutputTable(DEVICE_CB *pDevice, BYTE *pbInfo, DWORD *pdwSize);
  158. BOOL DeviceAttachedToPort(RASMAN_PORTINFO *pPortInfo,
  159. char *pszDeviceType,
  160. char *pszDeviceName);
  161. DWORD ReceiveStateMachine(DEVICE_CB *pDevice, HANDLE hIOPort);
  162. BOOL CheckForOverruns(HANDLE hIOPort);
  163. char* CmdTypeToStr(char *pszStr, CMDTYPE eCmdType);
  164. DWORD ConnectListen(HANDLE hIOPort,
  165. char *pszDeviceType,
  166. char *pszDeviceName,
  167. CMDTYPE eCmd);
  168. BOOL CoreMacroNameMatch(LPTSTR lpszShortName, LPTSTR lpszFullName);
  169. DWORD CreateAttributes(DEVICE_CB *pDevice);
  170. void CreateDefaultOffString(DEVICE_CB *pDev, char *pszDefaultOff);
  171. DWORD CreateInfoTable(DEVICE_CB *pDevice);
  172. DEVICETYPE DeviceTypeStrToEnum(LPTSTR lpszDeviceType);
  173. DEVICE_CB* FindDeviceInList(DEVICE_CB *pDev,
  174. HANDLE hIOPort,
  175. TCHAR *pszDeviceType,
  176. TCHAR *pszDeviceName);
  177. DEVICE_CB* FindPortInList(DEVICE_CB *pDeviceList,
  178. HANDLE hIOPort,
  179. DEVICE_CB **pPrevDev);
  180. DWORD GetCoreMacroName(LPTSTR lpszFullName, LPTSTR lpszCoreName);
  181. DWORD GetDeviceCB(HANDLE hIOPort,
  182. char *pszDeviceType,
  183. char *pszDeviceName,
  184. DEVICE_CB **ppDev);
  185. void GetInfFileName(LPTSTR pszDeviceType,
  186. LPTSTR pszFileName,
  187. DWORD dwFileNameLen);
  188. void GetMem(DWORD dSize, BYTE **ppMem);
  189. void GetNextParameter(TCHAR **ppch, TCHAR *pchEnd);
  190. BOOL GetPortDefaultOff(RASMAN_PORTINFO *pPortInfo, TCHAR **lpszValue);
  191. void GetPcbString(RASMAN_PORTINFO *pPortInfo, char *pszPcbKey, char *pszDest);
  192. void InitLog(void);
  193. void InitParameterStr(TCHAR *pch, TCHAR **ppchEnd);
  194. BOOL IsBinaryMacro(TCHAR *pch);
  195. BOOL IsLoggingOn(void);
  196. BOOL IsUnaryMacro(RAS_PARAMS Param);
  197. BOOL IsVariable(RAS_PARAMS Param);
  198. DWORD LoadRasserDll(PortGetInfo_t *pPortGetInfo, PortSetInfo_t *pPortSetInfo);
  199. void LogString(DEVICE_CB *pDev,
  200. TCHAR *pszLabel,
  201. TCHAR *psString,
  202. DWORD dwStringLen);
  203. WORD MacroCount(RASMAN_DEVICEINFO *pInfo, WORD wType);
  204. DWORD UpdateInfoTable(DEVICE_CB *pDevice, RASMAN_DEVICEINFO *pNewInfo);
  205. DWORD OpenResponseSection (PCHAR) ;
  206. // VOID CloseResponseSection () ;
  207. BOOL FindOpenDevSection (PTCH, PTCH, HRASFILE *) ;
  208. VOID AddOpenDevSection (PTCH, PTCH, HRASFILE) ;
  209. VOID CloseOpenDevSection (HRASFILE) ;
  210. //* From mxsstate.c --------------------------------------------------------
  211. //
  212. DWORD BuildMacroXlationTable(DEVICE_CB *pDevice);
  213. DWORD CheckBpsMacros(DEVICE_CB *pDev);
  214. DWORD CheckResponse(DEVICE_CB *pDev, LPTSTR szKey);
  215. DWORD CommWait(DEVICE_CB *pDevice, HANDLE hIOPort, DWORD dwPause);
  216. DWORD DeviceStateMachine(DEVICE_CB *pDevice, HANDLE hIOPort);
  217. UINT FindTableEntry(RASMAN_DEVICEINFO *pTable, TCHAR *pszKey);
  218. DWORD MapKeyToErrorCode(TCHAR *pszKey);
  219. DWORD PortSetStringInfo(HANDLE hIOPort,
  220. char *pszKey,
  221. char *psStr,
  222. DWORD sStrLen);
  223. DWORD PutInMessage(DEVICE_CB *pDevice, LPTSTR lpszStr, DWORD dwStrLen);
  224. BOOL ReceiveString(DEVICE_CB *pDevice, HANDLE hIOPort);
  225. DWORD ResetBPS(DEVICE_CB *pDev);
  226. DWORD ModemResponseLen(DEVICE_CB *pDev);
  227. BOOL WaitForFirstChar(DEVICE_CB *pDevice, HANDLE hIOPort);
  228. BOOL WaitForEcho(DEVICE_CB *pDevice, HANDLE hIOPort, DWORD cbEcho);
  229. #endif // _MXSPRIV_