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.

461 lines
13 KiB

  1. // headers\et30type.h is assumed to be included
  2. // ET30ACTION, ET30EVENT
  3. // headers\timeouts.h ... TO
  4. // headers\fr.h ... IFR
  5. #define MODEM_CLASS1 1
  6. #define MODEM_CLASS2 2
  7. #define MODEM_CLASS2_0 3
  8. typedef ET30ACTION ( __cdecl FAR* LPWHATNEXTPROC)(LPVOID, ET30EVENT, ...);
  9. #define MAXRECVFRAMES 20
  10. typedef struct {
  11. LPFR rglpfr[MAXRECVFRAMES];
  12. BYTE b[];
  13. } FRAMESPACE, far* LPFRAMESPACE;
  14. typedef struct {
  15. LPFRAMESPACE lpfs; // ptr to storage for recvd frames
  16. UWORD Nframes; // Number of recvd frames
  17. IFR ifrCommand,
  18. ifrResp,
  19. ifrSend;
  20. USHORT uTrainCount;
  21. USHORT uRecvTCFMod; // for fastexit stuff
  22. // set this from the DCS and jump straight into RecvTCF
  23. // Used to decide whether to insert a 1 bit or not (T30 sec 5.3.6.1)
  24. BOOL fReceivedDIS;
  25. BOOL fReceivedDTC;
  26. BOOL fReceivedEOM;
  27. // Used to determine whether to call PutRecvBuf(END_PAGE/END_DOC)
  28. // Set when we finish receiving page, reset after calling PutRecvBuf(...)
  29. BOOL fAtEndOfRecvPage;
  30. // Used when sending MCF/RTN to determine whether we succeeded to receive last page
  31. // Set when we finish receiving page, reset when we start to (try to) receive next page
  32. BOOL fReceivedPage;
  33. LONG sRecvBufSize;
  34. TO toT1; // This is used in MainBody.
  35. // Some modems can't train at higher speeds (timeout or return
  36. // ERRROR on AT+FRM=xxx) with other specific devices, but are OK at lower
  37. // speeds. So we keep track of the number of times we try to get the TCF,
  38. // and after the 2nd failed attempt, send an FTT instead of going to
  39. // node F.
  40. # define CLEAR_MISSED_TCFS() (pTG->T30.uMissedTCFs=0)
  41. # define MAX_MISSED_TCFS_BEFORE_FTT 2
  42. USHORT uMissedTCFs;
  43. } ET30T30;
  44. typedef enum { modeNONE=0, modeNONECM, modeECM, modeECMRETX } PHASECMODE;
  45. typedef struct {
  46. IFR ifrLastSent;
  47. PHASECMODE modePrevRecv;
  48. BOOL fGotWrongMode;
  49. } ET30ECHOPROTECT;
  50. //
  51. // headers\awnsfint.h is assumed to be included
  52. // force include to class1\*.c
  53. #pragma pack(1) // ensure packed structure
  54. typedef struct {
  55. BYTE G1stuff :3;
  56. BYTE G2stuff :5;
  57. BYTE G3Tx :1; // In DIS indicates poll doc avail. Must be 0 in DCS.
  58. BYTE G3Rx :1; // Must set to 1 in BOTH DCS/DTC
  59. BYTE Baud :4;
  60. BYTE ResFine_200 :1;
  61. BYTE MR_2D :1;
  62. BYTE PageWidth :2;
  63. BYTE PageLength :2;
  64. BYTE MinScanCode :3;
  65. BYTE Extend24 :1;
  66. BYTE Hand2400 :1;
  67. BYTE Uncompressed :1;
  68. BYTE ECM :1;
  69. BYTE SmallFrame :1;
  70. BYTE ELM :1;
  71. BYTE Reserved1 :1;
  72. BYTE MMR :1;
  73. BYTE Extend32 :1;
  74. BYTE WidthInvalid :1;
  75. BYTE Width2 :4;
  76. // 1 == WidthA5_1216
  77. // 2 == WidthA6_864
  78. // 4 == WidthA5_1728
  79. // 8 == WidthA6_1728
  80. BYTE Reserved2 :2;
  81. BYTE Extend40 :1;
  82. BYTE Res8x15 :1;
  83. BYTE Res_300 :1;
  84. BYTE Res16x15_400 :1;
  85. BYTE ResInchBased :1;
  86. BYTE ResMetricBased :1;
  87. BYTE MinScanSuperHalf:1;
  88. BYTE SEPcap :1;
  89. BYTE Extend48 :1;
  90. BYTE SUBcap :1;
  91. BYTE PWDcap :1;
  92. BYTE CanEmitDataFile :1;
  93. BYTE Reserved3 :1;
  94. BYTE BFTcap :1;
  95. BYTE DTMcap :1;
  96. BYTE EDIcap :1;
  97. BYTE Extend56 :1;
  98. BYTE BTMcap :1;
  99. BYTE Reserved4 :1;
  100. BYTE CanEmitCharFile :1;
  101. BYTE CharMode :1;
  102. BYTE Reserved5 :3;
  103. BYTE Extend64 :1;
  104. } DIS, far* LPDIS, near* NPDIS;
  105. #pragma pack()
  106. #define MAXFRAMES 10
  107. #define MAXSPACE 512
  108. typedef struct
  109. {
  110. USHORT uNumFrames;
  111. USHORT uFreeSpaceOff;
  112. LPFR rglpfr[MAXFRAMES];
  113. BYTE b[MAXSPACE];
  114. }
  115. RFS, near* NPRFS;
  116. #define IDFIFSIZE 20 // from protocol\protocol.h
  117. typedef struct {
  118. ////////////////////////// Client BC parameters
  119. BC RecvCaps; // ==> NSF/DIS recved
  120. BC RecvParams; // ==> NSS/DCS recvd
  121. BC SendCaps; // ==> NSF/DIS sent
  122. BC SendParams; // ==> NSS/DCS sent
  123. BOOL fRecvCapsGot;
  124. BOOL fSendCapsInited;
  125. BOOL fSendParamsInited;
  126. BOOL fRecvParamsGot;
  127. ////////////////////////// Hardware parameters
  128. LLPARAMS llRecvCaps; // DIS recvd
  129. LLPARAMS llSendCaps; // DIS sent---use uRecvSpeeds
  130. LLPARAMS llSendParams; // used to negotiate DCS--use uSendSpeeds
  131. LLPARAMS llNegot; // DCS sent
  132. LLPARAMS llRecvParams; // recvd DCS
  133. BOOL fllRecvCapsGot;
  134. BOOL fllSendCapsInited;
  135. BOOL fllSendParamsInited;
  136. BOOL fllNegotiated;
  137. BOOL fllRecvParamsGot;
  138. USHORT HighestSendSpeed;
  139. USHORT LowestSendSpeed;
  140. ////////////////////////// Flags to make decisions with
  141. BOOL fAbort;
  142. ///////////////////////// CSI/TSI/CIG Received Frames
  143. BYTE bRemoteID[IDFIFSIZE+1];
  144. ///////////////////////// DIS Received Frames
  145. DIS RemoteDIS;
  146. USHORT uRemoteDISlen;
  147. BOOL fRecvdDIS;
  148. ///////////////////////// DIS Send Frames (We need so we can check the DIS we send as receiver against DCS)
  149. DIS LocalDIS;
  150. USHORT uLocalDISlen;
  151. BOOL fLocalDIS;
  152. ///////////////////////// DCS Received Frames
  153. DIS RemoteDCS;
  154. USHORT uRemoteDCSlen;
  155. BOOL fRecvdDCS;
  156. }
  157. PROT, near* NPPROT;
  158. #define COMMANDBUFSIZE 40
  159. typedef struct {
  160. TO toRecv;
  161. BYTE bCmdBuf[COMMANDBUFSIZE];
  162. USHORT uCmdLen;
  163. BOOL fHDLC;
  164. USHORT CurMod;
  165. enum {SEND, RECV, IDLE } DriverMode;
  166. enum {COMMAND, FRH, FTH, FTM, FRM} ModemMode;
  167. } CLASS1_MODEM;
  168. #define OVBUFSIZE 4096
  169. typedef struct
  170. {
  171. enum {eDEINIT, eFREE, eALLOC, eIO_PENDING} eState;
  172. OVERLAPPED ov;
  173. char rgby[OVBUFSIZE]; // Buffer associated with this overlapped struct.
  174. DWORD dwcb; // Current count of data in this buffer.
  175. } OVREC;
  176. typedef struct {
  177. UWORD cbInSize;
  178. UWORD cbOutSize;
  179. DCB dcb;
  180. DCB dcbOrig;
  181. BOOL fStateChanged;
  182. COMSTAT comstat;
  183. BOOL fCommOpen;
  184. # define NUM_OVS 2 // Need atleast 2 to get true overlaped I/O
  185. // We maintain a queue of overlapped structures, having upto
  186. // NUM_OVS overlapped writes pending. If NUM_OVS writes are pending,
  187. // we do a GetOverlappedResult(fWait=TRUE) on the earliest write, and
  188. // then reuse that structure...
  189. OVERLAPPED ovAux; // For ReadFile and WriteFile(MyWriteComm only).
  190. OVREC rgovr[NUM_OVS]; // For WriteFile
  191. UINT uovFirst;
  192. UINT uovLast;
  193. UINT covAlloced;
  194. BOOL fDoOverlapped;
  195. BOOL fovInited;
  196. OVREC *lpovrCur;
  197. BYTE fEnableHandoff:1; // True if we are to enable adaptive answer
  198. BYTE fDataCall:1; // True if a data call is active.
  199. } FCOM_COMM;
  200. //
  201. // NCUPARAMS is defined in headers\ncuparm.h, included by .\modemddi.h
  202. // we will force define modemddi.h
  203. //
  204. #define REPLYBUFSIZE 400
  205. #define MAXKEYSIZE 128
  206. typedef struct {
  207. BYTE fModemInit :1; // Reset & synced up with modem
  208. BYTE fOffHook :1; // Online (either dialled or answered)
  209. BOOL fInDial, fInAnswer, fInDialog;
  210. } FCOM_STATUS;
  211. typedef struct {
  212. BYTE bLastReply[REPLYBUFSIZE+1];
  213. BYTE bEntireReply[REPLYBUFSIZE+1]; // Used only for storing
  214. TO toDialog, toZero;
  215. CMDTAB CurrCmdTab;
  216. MODEMCAPS CurrMdmCaps;
  217. // Following point to the location of the profile information.
  218. # define MAXKEYSIZE 128
  219. DWORD dwProfileID;
  220. char rgchKey[MAXKEYSIZE];
  221. } FCOM_MODEM;
  222. // Inst from fxrn\efaxrun.h
  223. typedef enum { IDLE1, BEFORE_ANSWER, BEFORE_RECVCAPS, SENDDATA_PHASE,
  224. SENDDATA_BETWEENPAGES, /** BEFORE_HANGUP, BEFORE_ACCEPT, **/
  225. BEFORE_RECVPARAMS, RECVDATA_PHASE, RECVDATA_BETWEENPAGES,
  226. SEND_PENDING } STATE;
  227. typedef struct
  228. {
  229. USHORT Encoding;
  230. DWORD AwRes;
  231. USHORT PageWidth;
  232. USHORT PageLength;
  233. USHORT fLastPage;
  234. }
  235. AWFILEINFO, FAR* LPAWFI;
  236. typedef struct {
  237. STATE state;
  238. AWFILEINFO awfi;
  239. HANDLE hfile;
  240. BC SendCaps;
  241. BC RemoteRecvCaps;
  242. BC SendParams;
  243. BC RecvParams;
  244. PROTPARAMS ProtParams;
  245. }
  246. INSTDATA, *PINSTDATA;
  247. //memory management
  248. #define STATICBUFSIZE (MY_BIGBUF_ACTUALSIZE * 2)
  249. #define STATICBUFCOUNT 2
  250. typedef struct {
  251. HANDLE hComm;
  252. CHAR szDeviceName[1];
  253. } DEVICEID, FAR * LPDEVICEID;
  254. // Note: DEVCFG and DEVCFGHDR are received from Unimodem through lineGetDevConfig
  255. // Therefore, they must match Unimodem internal declarations
  256. typedef struct tagDEVCFGHDR {
  257. DWORD dwSize;
  258. DWORD dwVersion;
  259. DWORD fdwSettings;
  260. } DEVCFGHDR;
  261. typedef struct tagDEVCFG {
  262. DEVCFGHDR dfgHdr;
  263. COMMCONFIG commconfig;
  264. } DEVCFG, *PDEVCFG, FAR* LPDEVCFG;
  265. #define IDVARSTRINGSIZE (sizeof(VARSTRING)+128)
  266. #define ASYNC_TIMEOUT 120000L
  267. #define ASYNC_SHORT_TIMEOUT 20000L
  268. #define BAD_HANDLE(h) (!(h) || (h)==INVALID_HANDLE_VALUE)
  269. // ASCII stuff
  270. typedef struct _FAX_RECEIVE_A {
  271. DWORD SizeOfStruct;
  272. LPSTR FileName;
  273. LPSTR ReceiverName;
  274. LPSTR ReceiverNumber;
  275. DWORD Reserved[4];
  276. } FAX_RECEIVE_A, *PFAX_RECEIVE_A;
  277. typedef struct _FAX_SEND_A {
  278. DWORD SizeOfStruct;
  279. LPSTR FileName;
  280. LPSTR CallerName;
  281. LPSTR CallerNumber;
  282. LPSTR ReceiverName;
  283. LPSTR ReceiverNumber;
  284. DWORD Reserved[4];
  285. } FAX_SEND_A, *PFAX_SEND_A;
  286. typedef struct _COMM_CACHE {
  287. DWORD dwMaxSize;
  288. DWORD dwCurrentSize;
  289. DWORD dwOffset;
  290. DWORD fReuse;
  291. char lpBuffer[4096];
  292. } COMM_CACHE;
  293. typedef struct {
  294. UWORD cbLineMin;
  295. // Output filtering (DLE stuffing and ZERO stuffing only)
  296. // All inited in FComOutFilterInit()
  297. LPB lpbFilterBuf;
  298. UWORD cbLineCount; // Has to be 16 bits
  299. BYTE bLastOutByte; // Stuff: last byte of previous input buffer
  300. // Input filtering (DLE stripping) only.
  301. // All inited in FComInFilterInit()
  302. BYTE fGotDLEETX :1;
  303. BYTE bPrevIn; // Strip::last byte of prev buffer was DLE
  304. UWORD cbPost;
  305. #define POSTBUFSIZE 20
  306. BYTE rgbPost[POSTBUFSIZE+1];
  307. } FCOM_FILTER;
  308. #define MAXDUMPFRAMES 100
  309. #define MAXDUMPSPACE 400
  310. typedef struct
  311. {
  312. USHORT uNumFrames;
  313. USHORT uFreeSpaceOff;
  314. USHORT uFrameOff[MAXDUMPFRAMES]; // arrays of offsets to frames
  315. BYTE b[MAXDUMPSPACE];
  316. } PROTDUMP, FAR* LPPROTDUMP;
  317. typedef struct {
  318. DWORD fAvail;
  319. DWORD ThreadId;
  320. HANDLE FaxHandle;
  321. LPVOID pTG;
  322. HLINE LineHandle;
  323. HCALL CallHandle;
  324. DWORD DeviceId;
  325. HANDLE CompletionPortHandle;
  326. ULONG_PTR CompletionKey;
  327. DWORD TiffThreadId;
  328. DWORD TimeStart;
  329. DWORD TimeUpdated;
  330. DWORD CkSum;
  331. } T30_RECOVERY_GLOB;
  332. typedef struct {
  333. DWORD dwContents; // Set to 1 (indicates containing key)
  334. DWORD dwKeyOffset; // Offset to key from start of this struct.
  335. // (not from start of LINEDEVCAPS ).
  336. // 8 in our case.
  337. BYTE rgby[1]; // place containing null-terminated
  338. // registry key.
  339. } MDM_DEVSPEC, FAR * LPMDM_DEVSPEC;