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.6 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. rasirdap.h
  5. Abstract:
  6. Author:
  7. mbert 9-97
  8. --*/
  9. #include <ntddk.h>
  10. #include <tdi.h>
  11. #include <tdikrnl.h>
  12. #include <tdiinfo.h>
  13. #include <ipinfo.h>
  14. #include <ntddtcp.h>
  15. #include <ndis.h>
  16. #include <ndiswan.h>
  17. #include <ndistapi.h>
  18. #include <cxport.h>
  19. #include <dbgmsg.h>
  20. #include <refcnt.h>
  21. #include <af_irda.h>
  22. #include <irdatdi.h>
  23. #include <irtdicl.h>
  24. #include <irmem.h>
  25. extern LIST_ENTRY RasIrAdapterList;
  26. extern NDIS_SPIN_LOCK RasIrSpinLock;
  27. #define NDIS_MajorVersion 5
  28. #define NDIS_MinorVersion 0
  29. #define ADAPTER_SIG 0xAA00AA00AA
  30. #define VC_SIG 0xCC00CC00CC
  31. #define ENDP_SIG 0xEE00EE00EE
  32. #define GOODADAPTER(a) ASSERT(a->Sig == (ULONG)ADAPTER_SIG)
  33. #define GOODVC(vc) ASSERT(vc->Sig == (ULONG)VC_SIG)
  34. #define GOODENDP(endp) ASSERT(endp->Sig == (ULONG)ENDP_SIG)
  35. #define RASIR_SERVICE_NAME_DIRECT "IrNetv1"
  36. #define RASIR_SERVICE_NAME_ASYNC "IrNetAsyncv1" // async frameing for Win CE
  37. #define RASIR_SERVICE_NAME_IRMODEM "IrModem"
  38. #define RASIR_MAX_LINE_NAME 64
  39. #define RASIR_INTERNAL_SEND (PVOID) -1
  40. #define RASIR_MAX_RATE 4000000
  41. #define AF_FLAG_CHAR 0x7E
  42. #define AF_ESC_CHAR 0x7D
  43. #define AF_COMP_BIT 0x20
  44. #define TX_BUF_POOL_SIZE 6
  45. #define CALC_FCS(fcs, chr) ((fcs >> 8)^FcsTable[(fcs ^ chr) & 0xFF])
  46. #define STUFF_BYTE(p,b,am) do { \
  47. if (((b < 0x20) && ((1 << b) & am)) || \
  48. b == AF_FLAG_CHAR || b == AF_ESC_CHAR) \
  49. { \
  50. *p++ = AF_ESC_CHAR; \
  51. *p++ = b ^ AF_COMP_BIT; \
  52. } \
  53. else \
  54. { \
  55. *p++ = b;\
  56. } \
  57. } while (0);
  58. #define ASYNC_BUF_SIZE (IRDA_MAX_DATA_SIZE*2) // worst case byte stuffing
  59. typedef struct
  60. {
  61. LIST_ENTRY Linkage;
  62. UCHAR Buf[ASYNC_BUF_SIZE];
  63. int BufLen;
  64. PNDIS_BUFFER pNdisBuf;
  65. } ASYNC_BUFFER, *PASYNC_BUFFER;
  66. typedef struct
  67. {
  68. LIST_ENTRY Linkage;
  69. LIST_ENTRY VcList;
  70. ULONG Sig;
  71. LIST_ENTRY EndpList;
  72. NDIS_HANDLE NdisSapHandle;
  73. NDIS_HANDLE NdisAfHandle;
  74. NDIS_HANDLE MiniportAdapterHandle;
  75. NPAGED_LOOKASIDE_LIST WorkItemsLList;
  76. NPAGED_LOOKASIDE_LIST AsyncBufLList;
  77. NDIS_SPIN_LOCK SpinLock;
  78. NDIS_WAN_CO_INFO Info;
  79. BOOLEAN ModemPort;
  80. WCHAR TapiLineNameBuf[32];
  81. NDIS_STRING TapiLineName;
  82. ULONG Flags;
  83. #define ADF_PENDING_AF_CLOSE 0x00000001
  84. #define ADF_SAP_DEREGISTERED 0x00000002
  85. } RASIR_ADAPTER, *PRASIR_ADAPTER;
  86. typedef struct
  87. {
  88. LIST_ENTRY Linkage;
  89. ULONG Sig;
  90. PRASIR_ADAPTER pAdapter;
  91. PVOID IrdaEndpContext;
  92. ULONG EndpType;
  93. #define EPT_DIRECT 1
  94. #define EPT_ASYNC 2 // using async framing
  95. #if DBG
  96. CHAR ServiceName[IRDA_DEV_SERVICE_LEN];
  97. #endif
  98. } RASIR_IRDA_ENDPOINT, *PRASIR_IRDA_ENDPOINT;
  99. typedef struct
  100. {
  101. LIST_ENTRY Linkage;
  102. ULONG Sig;
  103. PRASIR_ADAPTER pAdapter;
  104. NDIS_HANDLE NdisVcHandle;
  105. PVOID IrdaConnContext;
  106. REF_CNT RefCnt;
  107. PCHAR pInCallParms;
  108. PCO_CALL_PARAMETERS pMakeCall;
  109. PCO_AF_TAPI_MAKE_CALL_PARAMETERS pTmParams;
  110. PCO_AF_TAPI_INCOMING_CALL_PARAMETERS pTiParams;
  111. NDIS_WAN_CO_GET_LINK_INFO LinkInfo;
  112. NDIS_HANDLE RxBufferPool;
  113. NDIS_HANDLE RxPacketPool;
  114. NDIS_HANDLE TxBufferPool;
  115. LONG OutstandingSends;
  116. ULONG Flags;
  117. #define VCF_CREATED_LOCAL 0x00000001
  118. #define VCF_IRDA_OPEN 0x00000002
  119. #define VCF_OPEN 0x00000004
  120. #define VCF_CLOSING 0x00000008
  121. #define VCF_CLOSE_PEND 0x00000010
  122. #define VCF_MAKE_CALL_PEND 0x00000020
  123. ULONG ConnectionSpeed;
  124. BOOLEAN AsyncFraming;
  125. PASYNC_BUFFER pCurrAsyncBuf;
  126. LIST_ENTRY CompletedAsyncBufList;
  127. ULONG AsyncFramingState;
  128. #define RX_READY 0
  129. #define RX_RX 1
  130. #define RX_ESC 2
  131. BOOLEAN IrModemCall;
  132. ULONG ModemState;
  133. #define MS_OFFLINE 0
  134. #define MS_CONNECTING 1
  135. #define MS_ONLINE 2
  136. CHAR OfflineSendBuf[32];
  137. PNDIS_BUFFER pOfflineNdisBuf;
  138. } RASIR_VC, *PRASIR_VC;
  139. typedef struct
  140. {
  141. CO_TAPI_LINE_CAPS caps;
  142. WCHAR LineName[RASIR_MAX_LINE_NAME];
  143. } RASIR_CO_TAPI_LINE_CAPS;
  144. PRASIR_ADAPTER
  145. IrdaEndpointToAdapter(PVOID EndpointContext);
  146. NDIS_STATUS
  147. RasIrInitialize(
  148. OUT PNDIS_STATUS OpenErrorStatus,
  149. OUT PUINT SelectedMediumIndex,
  150. IN PNDIS_MEDIUM MediumArray,
  151. IN UINT MediumArraySize,
  152. IN NDIS_HANDLE MiniportAdapterHandle,
  153. IN NDIS_HANDLE WrapperConfigurationContext);
  154. VOID
  155. RasIrHalt(
  156. IN NDIS_HANDLE MiniportAdapterContext);
  157. NDIS_STATUS
  158. RasIrReset(
  159. OUT PBOOLEAN AddressingReset,
  160. IN NDIS_HANDLE MiniportAdapterContext);
  161. VOID
  162. RasIrReturnPacket(
  163. IN NDIS_HANDLE MiniportAdapterContext,
  164. IN PNDIS_PACKET Packet);
  165. NDIS_STATUS
  166. RasIrCoActivateVc(
  167. IN NDIS_HANDLE MiniportVcContext,
  168. IN OUT PCO_CALL_PARAMETERS CallParameters);
  169. NDIS_STATUS
  170. RasIrCoDeactivateVc(
  171. IN NDIS_HANDLE MiniportVcContext);
  172. VOID
  173. RasIrCoSendPackets(
  174. IN NDIS_HANDLE MiniportVcContext,
  175. IN PPNDIS_PACKET PacketArray,
  176. IN UINT NumberOfPackets);
  177. NDIS_STATUS
  178. RasIrCoRequest(
  179. IN NDIS_HANDLE MiniportAdapterContext,
  180. IN NDIS_HANDLE MiniportVcContext,
  181. IN OUT PNDIS_REQUEST NdisRequest);
  182. VOID
  183. RasIrReturnPacket(
  184. IN NDIS_HANDLE MiniportAdapterContext,
  185. IN PNDIS_PACKET Packet);
  186. // Call Manager handlers
  187. NDIS_STATUS
  188. RasIrCmCreateVc(
  189. IN NDIS_HANDLE ProtocolAfContext,
  190. IN NDIS_HANDLE NdisVcHandle,
  191. OUT PNDIS_HANDLE ProtocolVcContext);
  192. NDIS_STATUS
  193. RasIrCmDeleteVc(
  194. IN NDIS_HANDLE ProtocolVcContext);
  195. NDIS_STATUS
  196. RasIrCmOpenAf(
  197. IN NDIS_HANDLE CallMgrBindingContext,
  198. IN PCO_ADDRESS_FAMILY AddressFamily,
  199. IN NDIS_HANDLE NdisAfHandle,
  200. OUT PNDIS_HANDLE CallMgrAfContext);
  201. NDIS_STATUS
  202. RasIrCmCloseAf(
  203. IN NDIS_HANDLE CallMgrAfContext);
  204. NDIS_STATUS
  205. RasIrCmRegisterSap(
  206. IN NDIS_HANDLE CallMgrAfContext,
  207. IN PCO_SAP Sap,
  208. IN NDIS_HANDLE NdisSapHandle,
  209. OUT PNDIS_HANDLE CallMgrSapContext);
  210. NDIS_STATUS
  211. RasIrCmDeregisterSap(
  212. NDIS_HANDLE CallMgrSapContext);
  213. NDIS_STATUS
  214. RasIrCmMakeCall(
  215. IN NDIS_HANDLE CallMgrVcContext,
  216. IN OUT PCO_CALL_PARAMETERS CallParameters,
  217. IN NDIS_HANDLE NdisPartyHandle,
  218. OUT PNDIS_HANDLE CallMgrPartyContext);
  219. NDIS_STATUS
  220. RasIrCmCloseCall(
  221. IN NDIS_HANDLE CallMgrVcContext,
  222. IN NDIS_HANDLE CallMgrPartyContext,
  223. IN PVOID CloseData,
  224. IN UINT Size);
  225. VOID
  226. RasIrCmIncomingCallComplete(
  227. IN NDIS_STATUS Status,
  228. IN NDIS_HANDLE CallMgrVcContext,
  229. IN PCO_CALL_PARAMETERS CallParameters);
  230. VOID
  231. RasIrCmActivateVcComplete(
  232. IN NDIS_STATUS Status,
  233. IN NDIS_HANDLE CallMgrVcContext,
  234. IN PCO_CALL_PARAMETERS CallParameters);
  235. VOID
  236. RasIrCmDeactivateVcComplete(
  237. IN NDIS_STATUS Status,
  238. IN NDIS_HANDLE CallMgrVcContext);
  239. NDIS_STATUS
  240. RasIrCmModifyCallQoS(
  241. IN NDIS_HANDLE CallMgrVcContext,
  242. IN PCO_CALL_PARAMETERS CallParameters);
  243. NDIS_STATUS
  244. RasIrCmRequest(
  245. IN NDIS_HANDLE CallMgrAfContext,
  246. IN NDIS_HANDLE CallMgrVcContext,
  247. IN NDIS_HANDLE CallMgrPartyContext,
  248. IN OUT PNDIS_REQUEST NdisRequest);
  249. NDIS_STATUS
  250. ScheduleWork(
  251. IN PRASIR_ADAPTER pAdapter,
  252. IN NDIS_PROC pProc,
  253. IN PVOID pContext);
  254. VOID
  255. AllocCallParms(
  256. IN PRASIR_VC pVc);
  257. VOID
  258. DeleteVc(
  259. IN PRASIR_VC pVc);
  260. VOID
  261. CompleteClose(
  262. IN PRASIR_VC pVc);
  263. VOID
  264. ProcessOfflineRxBuf(
  265. IN PRASIR_VC pVc,
  266. IN PIRDA_RECVBUF pRecvBuf);