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.

385 lines
13 KiB

  1. //****************************************************************************
  2. //
  3. // Microsoft NT Remote Access Service
  4. //
  5. // Copyright (C) 1994-95 Microsft Corporation. All rights reserved.
  6. //
  7. // Filename: rastapi.h
  8. //
  9. // Revision History
  10. //
  11. // Mar 28 1992 Gurdeep Singh Pall Created
  12. //
  13. //
  14. // Description: This file contains all structs for TAPI.DLL
  15. //
  16. //****************************************************************************
  17. #include <wanpub.h> // for NDIS_WAN_MEDIUM_SUBTYPE
  18. #define DEVICETYPE_ISDN "ISDN"
  19. #define DEVICETYPE_X25 "X25"
  20. #define DEVICETYPE_UNIMODEM "MODEM"
  21. #define DEVICETYPE_PPTP "VPN"
  22. #define DEVICETYPE_ATM "ATM"
  23. #define REMOTEACCESS_APP "RemoteAccess"
  24. #define CONTROLBLOCKSIGNATURE 0x06051932
  25. #define CLIENT_USAGE "Client"
  26. #define SERVER_USAGE "Server"
  27. #define ROUTER_USAGE "Router"
  28. #define REGISTRY_RASMAN_TAPI_KEY "Software\\Microsoft\\RAS\\Tapi Devices"
  29. #define REGISTRY_ADDRESS "Address"
  30. #define REGISTRY_FRIENDLYNAME "Friendly Name"
  31. #define REGISTRY_MEDIATYPE "Media Type"
  32. #define REGISTRY_USAGE "Usage"
  33. #define LOW_MAJOR_VERSION 0x0001
  34. #define LOW_MINOR_VERSION 0x0003
  35. #define HIGH_MAJOR_VERSION 0x0002
  36. #define HIGH_MINOR_VERSION 0x0000
  37. #define LOW_VERSION ((LOW_MAJOR_VERSION << 16) | LOW_MINOR_VERSION)
  38. #define HIGH_VERSION ((HIGH_MAJOR_VERSION << 16) | HIGH_MINOR_VERSION)
  39. #define LOW_EXT_MAJOR_VERSION 0x0000
  40. #define LOW_EXT_MINOR_VERSION 0x0000
  41. #define HIGH_EXT_MAJOR_VERSION 0x0000
  42. #define HIGH_EXT_MINOR_VERSION 0x0000
  43. #define LOW_EXT_VERSION ((LOW_EXT_MAJOR_VERSION << 16) | LOW_EXT_MINOR_VERSION)
  44. #define HIGH_EXT_VERSION ((HIGH_EXT_MAJOR_VERSION << 16) | HIGH_EXT_MINOR_VERSION)
  45. // Generic indexes
  46. #define ADDRESS_INDEX 0
  47. #define CONNECTBPS_INDEX 1
  48. // ISDN param indexes
  49. #define ISDN_ADDRESS_INDEX ADDRESS_INDEX
  50. #define ISDN_CONNECTBPS_INDEX CONNECTBPS_INDEX
  51. #define ISDN_LINETYPE_INDEX 2
  52. #define ISDN_FALLBACK_INDEX 3
  53. #define ISDN_COMPRESSION_INDEX 4
  54. #define ISDN_CHANNEL_AGG_INDEX 5
  55. // X25 indexes
  56. #define X25_ADDRESS_INDEX ADDRESS_INDEX
  57. #define X25_CONNECTBPS_INDEX CONNECTBPS_INDEX
  58. #define X25_DIAGNOSTICS_INDEX 2
  59. #define X25_USERDATA_INDEX 3
  60. #define X25_FACILITIES_INDEX 4
  61. enum PORT_STATE {
  62. PS_CLOSED,
  63. PS_OPEN,
  64. PS_LISTENING,
  65. PS_CONNECTED,
  66. PS_CONNECTING,
  67. PS_DISCONNECTING,
  68. PS_UNINITIALIZED,
  69. PS_UNAVAILABLE,
  70. } ;
  71. typedef enum PORT_STATE PORT_STATE ;
  72. typedef enum PORT_STATE LINE_STATE ;
  73. enum LISTEN_SUBSTATE {
  74. LS_WAIT,
  75. LS_RINGING,
  76. LS_ACCEPT,
  77. LS_ANSWER,
  78. LS_COMPLETE,
  79. LS_ERROR,
  80. } ;
  81. typedef enum LISTEN_SUBSTATE LISTEN_SUBSTATE ;
  82. #define TLI_FLAG_OPENED_FOR_DIALOUT 0x00000001
  83. #define TLI_FLAG_OPEN_FOR_LISTEN 0x00000002
  84. struct TapiLineInfo {
  85. struct TapiLineInfo *TLI_Next;
  86. DWORD TLI_LineId ; // Returned by LineInitialize
  87. HLINE TLI_LineHandle ; // Returned by LineOpen
  88. // struct TapiPortControlBlock *pTPCB; // TAPI port associated with this line
  89. LINE_STATE TLI_LineState ; // open?, closed?, listen posted?.
  90. DWORD TLI_OpenCount ;
  91. DWORD NegotiatedApiVersion;
  92. DWORD NegotiatedExtVersion;
  93. BOOL CharModeSupported;
  94. BOOL TLI_MultiEndpoint;
  95. DeviceInfo *TLI_pDeviceInfo; // pointer to the deviceinfo block
  96. DWORD TLI_dwfFlags;
  97. DWORD TLI_DialoutCount;
  98. DWORD TLI_MediaMode ; // Media mode to use for lineopens.
  99. #define MAX_PROVIDER_NAME 48
  100. CHAR TLI_ProviderName[MAX_PROVIDER_NAME] ;
  101. } ;
  102. typedef struct TapiLineInfo TapiLineInfo ;
  103. typedef enum RASTAPI_DEV_CMD
  104. {
  105. RASTAPI_DEV_SEND, // Send a buffer to the miniport
  106. RASTAPI_DEV_RECV, // Read a buffer from the miniport
  107. RASTAPI_DEV_PPP_MODE // Put the miniport into PPP framing mode
  108. } RASTAPI_DEV_CMD;
  109. typedef struct RASTAPI_DEV_SPECIFIC
  110. {
  111. RASTAPI_DEV_CMD Command; // RASTAPI_DEV_SEND, RASTAPI_DEV_RECV, RASTAPI_DEV_PPP_MODE
  112. DWORD Reserved;
  113. DWORD DataSize;
  114. UCHAR Data[1];
  115. } RASTAPI_DEV_SPECIFIC, *PRASTAPI_DEV_SPECIFIC;
  116. //
  117. // Magic Cookie used in DEV_DATA_MODES command
  118. //
  119. #define MINIPORT_COOKIE 0x494E494D
  120. //
  121. // DEV_SPECIFIC Flags
  122. //
  123. #define CHAR_MODE 0x00000001 // Miniport supports character mode
  124. typedef struct RASTAPI_DEV_DATA_MODES
  125. {
  126. DWORD MagicCookie;
  127. DWORD DataModes;
  128. } RASTAPI_DEV_DATA_MODES, *PRASTAPI_DEV_DATA_MODES;
  129. typedef struct _RECV_FIFO
  130. {
  131. DWORD Count; // # of elements in fifo
  132. DWORD In; // indexs into circular buffer
  133. DWORD Out; //
  134. DWORD Size; // Size of Buffer
  135. BYTE Buffer[1]; // storage
  136. } RECV_FIFO, *PRECV_FIFO;
  137. #define RASTAPI_FLAG_UNAVAILABLE 0x00000001
  138. #define RASTAPI_FLAG_DIALEDIN 0x00000002
  139. #define RASTAPI_FLAG_LINE_DROP_PENDING 0x00000004
  140. #define RASTAPI_FLAG_LISTEN_PENDING 0x00000008
  141. #define RASTAPI_FLAG_OPENED_FOR_DIALOUT 0x00000010
  142. struct TapiPortControlBlock {
  143. DWORD TPCB_Signature ; // Unique signature for verifying block ptr.
  144. struct TapiPortControlBlock *TPCB_next; // next TAPI port in the list
  145. HANDLE TPCB_Handle ; // Handle used to identify this port
  146. CHAR TPCB_Name[MAX_PORT_NAME] ; // Friendly Name of the port
  147. CHAR TPCB_Address[MAX_PORT_NAME] ; // Address - please note for legacy tapi dev. this is
  148. // a GUID - so has to be at least 16 bytes.
  149. PORT_STATE TPCB_State ; // State of the port
  150. LISTEN_SUBSTATE TPCB_ListenState ; // state of the listen
  151. CHAR TPCB_DeviceType[MAX_DEVICETYPE_NAME] ; // ISDN, etc.
  152. CHAR TPCB_DeviceName [MAX_DEVICE_NAME] ; // Digiboard etc.
  153. RASMAN_USAGE TPCB_Usage ; // CALLIN, CALLOUT or BOTH
  154. TapiLineInfo *TPCB_Line ; // Handle to the "line" this port belongs to
  155. DWORD TPCB_AddressId ; // Address ID for this "port"
  156. DWORD TPCB_CallId; // CallI ID for this "port"
  157. HCALL TPCB_CallHandle ; // When connected the call id
  158. HANDLE TPCB_IoCompletionPort; // passed in on open
  159. DWORD TPCB_CompletionKey; // passed in on open
  160. DWORD TPCB_RequestId ; // id for async requests.
  161. DWORD TPCB_AsyncErrorCode ; // used to store asycn returned code.
  162. CHAR TPCB_Info[6][100] ; // port info associated with this connection
  163. HANDLE TPCB_Endpoint ; // used to store asyncmac context for unimodem ports
  164. HANDLE TPCB_CommHandle ; // used to store comm port handle used in unimodem ports
  165. RAS_OVERLAPPED TPCB_ReadOverlapped ; // used in read async ops.
  166. RAS_OVERLAPPED TPCB_WriteOverlapped ; // used in write async ops.
  167. RAS_OVERLAPPED TPCB_DiscOverlapped; // used in signaling disconnection
  168. PBYTE TPCB_DevConfig ; // Opaque blob of data used for configuring tapi
  169. // devices - this is passed in to
  170. // us using DeviceSetDevConfig() ;
  171. DWORD TPCB_SizeOfDevConfig ; // Size of the above blob.
  172. PBYTE TPCB_DefaultDevConfig ; // The current config for the device that is saved
  173. // away before we write any changes
  174. // to the device. This allows RAS to be a good
  175. // citizen by not overwriting defauls.
  176. DWORD TPCB_DefaultDevConfigSize ;
  177. DWORD TPCB_DisconnectReason ; // Reason for disconnection.
  178. DWORD TPCB_NumberOfRings ; // Number of rings received so far.
  179. DWORD IdleReceived;
  180. BOOL TPCB_dwFlags; // is this client dialed in
  181. RASTAPI_CONNECT_INFO *TPCB_pConnectInfo;
  182. //
  183. // Char Mode Support ( for USR )
  184. //
  185. DWORD TPCB_SendRequestId; // Request Id stored to id the event in callback
  186. // that send completed for a char mode port
  187. PVOID TPCB_SendDesc; // Send Desc passed to lineDevSpecific call for send request
  188. DWORD TPCB_RecvRequestId; // Request Id stored to id the event in callback that recv completed
  189. // for a char mode port
  190. PVOID TPCB_RecvDesc; // Recv Desc passed to lineDevSpecific call
  191. PBYTE TPCB_RasmanRecvBuffer;
  192. DWORD TPCB_RasmanRecvBufferSize;
  193. PRECV_FIFO TPCB_RecvFifo;
  194. DWORD TPCB_ModeRequestId; // Request id stored to id the event that mode was set for a char mode
  195. PVOID TPCB_ModeRequestDesc; // desc.
  196. BOOL TPCB_CharMode; // CharMode ?
  197. } ;
  198. typedef struct TapiPortControlBlock TapiPortControlBlock ;
  199. struct _ZOMBIE_CALL {
  200. LIST_ENTRY Linkage;
  201. DWORD RequestID;
  202. HCALL hCall;
  203. } ;
  204. typedef struct _ZOMBIE_CALL ZOMBIE_CALL;
  205. VOID FAR PASCAL RasTapiCallback ( HANDLE,
  206. DWORD,
  207. ULONG_PTR,
  208. ULONG_PTR,
  209. ULONG_PTR,
  210. ULONG_PTR) ;
  211. VOID SetIsdnParams ( TapiPortControlBlock *,
  212. LINECALLPARAMS *) ;
  213. VOID GetMutex (HANDLE, DWORD) ;
  214. VOID FreeMutex (HANDLE) ;
  215. DWORD EnumerateTapiPorts (HANDLE) ;
  216. VOID PostDisconnectCompletion( TapiPortControlBlock * );
  217. VOID PostNotificationCompletion( TapiPortControlBlock * );
  218. VOID PostNotificationNewPort ( PortMediaInfo *);
  219. VOID PostNotificationRemoveLine ( DWORD );
  220. DWORD dwAddPorts( PBYTE, LPVOID );
  221. DWORD dwRemovePort ( TapiPortControlBlock * );
  222. DWORD CopyDataToFifo(PRECV_FIFO, PBYTE, DWORD);
  223. DWORD CopyDataFromFifo(PRECV_FIFO, PBYTE, DWORD);
  224. // rtnetcfg.cpp
  225. DWORD dwGetNumberOfRings ( PDWORD pdwRings );
  226. DWORD dwGetPortUsage(DWORD *pdwUsage);
  227. LONG lrIsModemRasEnabled(HKEY hkey,
  228. BOOL *pfRasEnabled,
  229. BOOL *pfRouterEnabled );
  230. DeviceInfo * GetDeviceInfo(PBYTE pbAddress, BOOL fModem);
  231. DWORD GetEndPointInfo(DeviceInfo **ppDeviceInfo,
  232. PBYTE pbAddress,
  233. BOOL fForceRead,
  234. NDIS_WAN_MEDIUM_SUBTYPE eDeviceType);
  235. // init.c
  236. DWORD GetDeviceTypeFromDeviceGuid( GUID *pDeviceGuid );
  237. VOID RasTapiTrace( CHAR * Format, ... ) ;
  238. VOID TraceEndPointInfo(DeviceInfo *pInfo);
  239. DWORD DwRasErrorFromDisconnectMode(DWORD dm);
  240. //diag.c
  241. DWORD
  242. DwGetConnectInfo(
  243. TapiPortControlBlock *port,
  244. HCALL hCall,
  245. LINECALLINFO *pLineCallInfo
  246. );