Source code of Windows XP (NT5)
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.

737 lines
13 KiB

  1. /*++
  2. Copyright (c) 1995-1998 Microsoft Corporation
  3. Module Name:
  4. RCANdis.h
  5. Abstract:
  6. The module defines the constants, structures and function templates for
  7. the NDIS side of RCA
  8. Author:
  9. Shyam Pather (SPATHER)
  10. Revision History:
  11. Who When What
  12. -------- -------- ----------------------------------------------
  13. SPATHER 04-20-99 Created / adapted from original RCA code by RMachin/JameelH
  14. --*/
  15. #ifndef _RCANDIS__H
  16. #define _RCANDIS__H
  17. #define RCA_CL_NAME L"RCA"
  18. #define RCA_SAP_STRING L"WAN/RCA"
  19. #define MAX_HASH_SIZE 64
  20. #define NDIS_MAJOR_VERSION 0x05
  21. #define NDIS_MINOR_VERSION 0x00
  22. typedef VOID (*PFN_RCARECEIVE_CALLBACK) (
  23. IN PVOID RcaVcContext,
  24. IN PVOID ClientReceiveContext,
  25. IN PNDIS_PACKET pPacket
  26. );
  27. //
  28. // Will be called with lock held.
  29. //
  30. typedef VOID (*PFN_RCASENDCOMPLETE_CALLBACK) (
  31. IN PVOID RcaVcContext,
  32. IN PVOID ClientSendContext,
  33. IN PVOID PacketContext,
  34. IN PMDL pSentMdl,
  35. IN NDIS_STATUS Status
  36. );
  37. //
  38. // will be called at DISPATCH_LEVEL
  39. // must not use vc context after this
  40. //
  41. typedef VOID (*PFN_VCCLOSE_CALLBACK) (
  42. IN PVOID RcaVcContext,
  43. IN PVOID ClientReceiveContext,
  44. IN PVOID ClientSendContext
  45. );
  46. typedef struct _RCA_CO_NDIS_HANDLERS {
  47. PFN_RCARECEIVE_CALLBACK ReceiveCallback;
  48. PFN_RCASENDCOMPLETE_CALLBACK SendCompleteCallback;
  49. PFN_VCCLOSE_CALLBACK VcCloseCallback;
  50. } RCA_CO_NDIS_HANDLERS, *PRCA_CO_NDIS_HANDLERS;
  51. //
  52. // Structure to hold info about how many bindings/SAP registrations we've made.
  53. //
  54. typedef struct _RCA_BINDING_INFO {
  55. ULONG AdapterCnt;
  56. ULONG SAPCnt;
  57. BOOL BindingsComplete;
  58. RCABlockStruc Block;
  59. } RCA_BINDING_INFO, *PRCA_BINDING_INFO;
  60. //
  61. // Forward references
  62. //
  63. typedef struct _RCA_VC RCA_VC, *PRCA_VC;
  64. typedef struct _RCA_ADAPTER RCA_ADAPTER, *PRCA_ADAPTER;
  65. typedef struct _RCA_PROTOCOL_CONTEXT {
  66. #if DBG
  67. ULONG rca_sig;
  68. #endif
  69. PRCA_ADAPTER AdapterList;
  70. PRCA_VC VcHashTable[MAX_HASH_SIZE];
  71. NDIS_SPIN_LOCK SpinLock;
  72. NDIS_HANDLE RCAClProtocolHandle;
  73. RCA_BINDING_INFO BindingInfo;
  74. RCA_CO_NDIS_HANDLERS Handlers;
  75. } RCA_PROTOCOL_CONTEXT, *PRCA_PROTOCOL_CONTEXT;
  76. extern RCA_PROTOCOL_CONTEXT GlobalContext;
  77. typedef struct _RCA_VC {
  78. #if DBG
  79. ULONG rca_sig;
  80. #endif
  81. struct _RCA_VC *NextVcOnAdapter;
  82. struct _RCA_VC **PrevVcOnAdapter;
  83. struct _RCA_VC *NextVcOnHash;
  84. struct _RCA_VC **PrevVcOnHash;
  85. struct _RCA_ADAPTER *pAdapter;
  86. ULONG Flags;
  87. ULONG RefCount;
  88. NDIS_SPIN_LOCK SpinLock;
  89. ULONGLONG uqBytesRead;
  90. NDIS_HANDLE NdisVcHandle;
  91. CO_CALL_PARAMETERS CallParameters;
  92. RCABlockStruc CloseBlock;
  93. ULONG ClosingState;
  94. PVOID ClientReceiveContext;
  95. PVOID ClientSendContext;
  96. LONG PendingSends;
  97. } RCA_VC, *PRCA_VC;
  98. #define VC_ACTIVE 0x0001
  99. #define VC_CLOSING 0x8000
  100. #define CLOSING_INCOMING_CLOSE 0x01
  101. #define CLOSING_CLOSE_COMPLETE 0x02
  102. #define CLOSING_DELETE_VC 0x04
  103. #define HASH_VC(_VcContext) (PtrToUlong((PVOID)(((ULONG_PTR)_VcContext >> 4) % MAX_HASH_SIZE)))
  104. //
  105. // We allocate one RCA_ADAPTER structure for each adapter that
  106. // the RCA opens. A pointer to this structure is passed to NdisOpenAdapter
  107. // as the BindingContext.
  108. //
  109. typedef struct _RCA_ADAPTER
  110. {
  111. #if DBG
  112. ULONG rca_sig;
  113. #endif
  114. ULONG AdapterFlags;
  115. #define RCA_ADAPTERFLAGS_DEACTIVATE_IN_PROGRESS 0x0001
  116. #define RCA_ADAPTERFLAGS_DEACTIVATE_COMPLETE 0x0002
  117. #define RCA_ADAPTERFLAGS_DEREG_SAP 0x0004
  118. #define RCA_ADAPTERFLAGS_DEREG_SAP_COMPLETE 0x0008
  119. #define RCA_ADAPTERFLAGS_CLOSE_AF 0x0010
  120. #define RCA_ADAPTERFLAGS_CLOSE_AF_COMPLETE 0x0020
  121. #define RCA_ADAPTERFLAGS_UNBIND_IN_PROGRESS 0x0040
  122. #define RCA_ADAPTERFLAGS_UNBIND_COMPLETE 0x0080
  123. ULONG AfRegisteringCount;
  124. RCABlockStruc AfRegisterBlock;
  125. ULONG AfOpenCount;
  126. ULONG OldAdapterFlags;
  127. struct _RCA_ADAPTER *NextAdapter;
  128. struct _RCA_ADAPTER **PrevAdapter;
  129. struct _RCA_VC *VcList;
  130. NDIS_HANDLE NdisBindingHandle; // set by NdisOpenAdapter
  131. NDIS_HANDLE NdisAfHandle; // set by NDIS on NdisOpenAddressFamily
  132. NDIS_HANDLE NdisSapHandle; // For calls to NDIS re this SAP
  133. RCABlockStruc Block; // used to block current thread
  134. NDIS_SPIN_LOCK SpinLock;
  135. NDIS_WORK_ITEM DeactivateWorkItem;
  136. RCABlockStruc DeactivateBlock;
  137. NDIS_HANDLE SendBufferPool;
  138. NDIS_HANDLE RecvBufferPool;
  139. NDIS_HANDLE SendPacketPool;
  140. NDIS_HANDLE RecvPacketPool;
  141. RCABlockStruc CloseBlock;
  142. BOOL BlockedOnClose;
  143. } RCA_ADAPTER, *PRCA_ADAPTER;
  144. #define RCA_SET_ADAPTER_FLAG_LOCKED(_pAdapter, _FlagValue) \
  145. ACQUIRE_SPIN_LOCK(&_pAdapter->SpinLock); \
  146. _pAdapter->AdapterFlags |= _FlagValue; \
  147. RELEASE_SPIN_LOCK(&_pAdapter->SpinLock);
  148. #define RCA_CLEAR_ADAPTER_FLAG_LOCKED(_pAdapter, _FlagValue) \
  149. ACQUIRE_SPIN_LOCK(&_pAdapter->SpinLock); \
  150. _pAdapter->AdapterFlags &= ~_FlagValue; \
  151. RELEASE_SPIN_LOCK(&_pAdapter->SpinLock);
  152. extern
  153. NDIS_STATUS
  154. RCACoNdisInitialize(
  155. IN PRCA_CO_NDIS_HANDLERS pHandlers,
  156. IN ULONG ulInitTimeout
  157. );
  158. extern
  159. VOID
  160. RCACoNdisUninitialize(
  161. );
  162. extern
  163. NDIS_STATUS
  164. RCACoNdisGetVcContextForReceive(
  165. IN UNICODE_STRING VcHandle,
  166. IN PVOID ClientReceiveContext,
  167. OUT PVOID *VcContext
  168. );
  169. extern
  170. NDIS_STATUS
  171. RCACoNdisGetVcContextForSend(
  172. IN UNICODE_STRING VcHandle,
  173. IN PVOID ClientSendContext,
  174. OUT PVOID *VcContext
  175. );
  176. extern
  177. NDIS_STATUS
  178. RCACoNdisReleaseSendVcContext(
  179. IN PVOID VcContext
  180. );
  181. extern
  182. NDIS_STATUS
  183. RCACoNdisReleaseReceiveVcContext(
  184. IN PVOID VcContext
  185. );
  186. extern
  187. NDIS_STATUS
  188. RCACoNdisCloseCallOnVc(
  189. IN PVOID VcContext
  190. );
  191. extern
  192. NDIS_STATUS
  193. RCACoNdisCloseCallOnVcNoWait(
  194. IN PVOID VcContext
  195. );
  196. extern
  197. NDIS_STATUS
  198. RCACoNdisSendFrame(
  199. IN PVOID VcContext,
  200. IN PMDL pMdl,
  201. IN PVOID PacketContext
  202. );
  203. extern
  204. NDIS_STATUS
  205. RCACoNdisGetMdlFromPacket(
  206. IN PNDIS_PACKET pPacket,
  207. OUT PMDL *ppMdl
  208. );
  209. extern
  210. VOID
  211. RCACoNdisReturnPacket(
  212. IN PNDIS_PACKET pPacket
  213. );
  214. extern
  215. NDIS_STATUS
  216. RCACoNdisGetMaxSduSizes(
  217. IN PVOID VcContext,
  218. OUT ULONG *RxMaxSduSize,
  219. OUT ULONG *TxMaxSduSize
  220. );
  221. extern
  222. NDIS_STATUS
  223. RCAPnPSetPower(
  224. IN PRCA_ADAPTER pAdapter,
  225. IN PNET_PNP_EVENT NetPnPEvent
  226. );
  227. extern
  228. NDIS_STATUS
  229. RCAPnPQueryPower(
  230. IN PRCA_ADAPTER pAdapter,
  231. IN PNET_PNP_EVENT NetPnPEvent
  232. );
  233. extern
  234. NDIS_STATUS
  235. RCAPnPQueryRemoveDevice(
  236. IN PRCA_ADAPTER pAdapter,
  237. IN PNET_PNP_EVENT NetPnPEvent
  238. );
  239. extern
  240. NDIS_STATUS
  241. RCAPnPCancelRemoveDevice(
  242. IN PRCA_ADAPTER pAdapter,
  243. IN PNET_PNP_EVENT NetPnPEvent
  244. );
  245. extern
  246. NDIS_STATUS
  247. RCAPnPEventBindsComplete(
  248. IN PRCA_ADAPTER pAdapter,
  249. IN PNET_PNP_EVENT NetPnPEvent
  250. );
  251. extern
  252. NDIS_STATUS
  253. RCAPnPEventHandler(
  254. IN NDIS_HANDLE ProtocolBindingContext,
  255. IN PNET_PNP_EVENT NetPnPEvent
  256. );
  257. extern
  258. VOID
  259. RCABindAdapter(
  260. OUT PNDIS_STATUS pStatus,
  261. IN NDIS_HANDLE BindContext,
  262. IN PNDIS_STRING DeviceName,
  263. IN PVOID SystemSpecific1,
  264. IN PVOID SystemSpecific2
  265. );
  266. extern
  267. VOID
  268. RCAOpenAdaperComplete(
  269. IN NDIS_HANDLE BindingContext,
  270. IN NDIS_STATUS Status,
  271. IN NDIS_STATUS OpenErrorStatus
  272. );
  273. extern
  274. VOID
  275. RCADeactivateAdapterWorker(
  276. IN PNDIS_WORK_ITEM pWorkItem,
  277. IN PVOID Context
  278. );
  279. extern
  280. VOID
  281. RCADeactivateAdapter(
  282. IN PRCA_ADAPTER pAdapter
  283. );
  284. extern
  285. VOID
  286. RCAUnbindAdapter(
  287. OUT PNDIS_STATUS pStatus,
  288. IN NDIS_HANDLE ProtocolBindContext,
  289. IN PNDIS_HANDLE UnbindContext
  290. );
  291. extern
  292. VOID
  293. RCAOpenAdapterComplete(
  294. IN NDIS_HANDLE BindingContext,
  295. IN NDIS_STATUS Status,
  296. IN NDIS_STATUS OpenErrorStatus
  297. );
  298. extern
  299. VOID
  300. RCACloseAdapterComplete(
  301. IN NDIS_HANDLE BindingContext,
  302. IN NDIS_STATUS Status
  303. );
  304. extern
  305. VOID
  306. RCANotifyAfRegistration(
  307. IN NDIS_HANDLE BindingContext,
  308. IN PCO_ADDRESS_FAMILY pFamily
  309. );
  310. extern
  311. VOID
  312. RCAOpenAfComplete(
  313. IN NDIS_STATUS Status,
  314. IN NDIS_HANDLE ProtocolAfContext,
  315. IN NDIS_HANDLE NdisAfHandle
  316. );
  317. extern
  318. VOID
  319. RCACloseAfComplete(
  320. IN NDIS_STATUS Status,
  321. IN NDIS_HANDLE ProtocolAfContext
  322. );
  323. extern
  324. VOID
  325. RCARegisterSapComplete(
  326. IN NDIS_STATUS Status,
  327. IN NDIS_HANDLE ProtocolSapContext,
  328. IN PCO_SAP pSap,
  329. IN NDIS_HANDLE NdisSapHandle
  330. );
  331. extern
  332. VOID
  333. RCADeregisterSapComplete(
  334. IN NDIS_STATUS Status,
  335. IN NDIS_HANDLE ProtocolSapContext
  336. );
  337. //
  338. // Dummy NDIS functions
  339. //
  340. extern
  341. VOID
  342. RCATransferDataComplete(
  343. IN NDIS_HANDLE ProtocolBindingContext,
  344. IN PNDIS_PACKET Packet,
  345. IN NDIS_STATUS Status,
  346. IN UINT BytesTransferred);
  347. extern
  348. VOID
  349. RCAResetComplete(
  350. IN NDIS_HANDLE ProtocolBindingContext,
  351. IN NDIS_STATUS Status
  352. );
  353. extern
  354. VOID
  355. RCARequestComplete(
  356. IN NDIS_HANDLE ProtocolBindingContext,
  357. IN PNDIS_REQUEST NdisRequest,
  358. IN NDIS_STATUS Status
  359. );
  360. extern
  361. NDIS_STATUS
  362. RCAReceive(
  363. IN NDIS_HANDLE ProtocolBindingContext,
  364. IN NDIS_HANDLE MacReceiveContext,
  365. IN PVOID HeaderBuffer,
  366. IN UINT HeaderBufferSize,
  367. IN PVOID LookAheadBuffer,
  368. IN UINT LookAheadBufferSize,
  369. IN UINT PacketSize
  370. );
  371. extern
  372. INT
  373. RCAReceivePacket(
  374. IN NDIS_HANDLE ProtocolBindingContext,
  375. IN PNDIS_PACKET Packet
  376. );
  377. extern
  378. VOID
  379. RCAStatus(
  380. IN NDIS_HANDLE ProtocolBindingContext,
  381. IN NDIS_STATUS GeneralStatus,
  382. IN PVOID StatusBuffer,
  383. IN UINT StatusBufferSize
  384. );
  385. extern
  386. VOID
  387. RCAStatusComplete(
  388. IN NDIS_HANDLE ProtocolBindingContext
  389. );
  390. extern
  391. VOID
  392. RCACoStatus(
  393. IN NDIS_HANDLE ProtocolBindingContext,
  394. IN NDIS_HANDLE ProtocolVcContext OPTIONAL,
  395. IN NDIS_STATUS GeneralStatus,
  396. IN PVOID StatusBuffer,
  397. IN UINT StatusBufferSize
  398. );
  399. extern
  400. VOID
  401. RCASendComplete(
  402. IN NDIS_HANDLE ProtocolBindingContext,
  403. IN PNDIS_PACKET Packet,
  404. IN NDIS_STATUS Status
  405. );
  406. extern
  407. VOID
  408. RCAModifyCallQosComplete(
  409. IN NDIS_STATUS status,
  410. IN NDIS_HANDLE ProtocolVcContext,
  411. IN PCO_CALL_PARAMETERS CallParameters
  412. );
  413. extern
  414. VOID
  415. RCAAddPartyComplete(
  416. IN NDIS_STATUS status,
  417. IN NDIS_HANDLE ProtocolPartyContext,
  418. IN NDIS_HANDLE NdisPartyHandle,
  419. IN PCO_CALL_PARAMETERS CallParameters
  420. );
  421. extern
  422. VOID
  423. RCADropPartyComplete(
  424. IN NDIS_STATUS status,
  425. IN NDIS_HANDLE ProtocolPartyContext
  426. );
  427. extern
  428. VOID
  429. RCAIncomingCallQosChange(
  430. IN NDIS_HANDLE ProtocolVcContext,
  431. IN PCO_CALL_PARAMETERS CallParameters
  432. );
  433. extern
  434. VOID
  435. RCAIncomingDropParty(
  436. IN NDIS_STATUS DropStatus,
  437. IN NDIS_HANDLE ProtocolPartyContext,
  438. IN PVOID CloseData OPTIONAL,
  439. IN UINT Size OPTIONAL
  440. );
  441. extern
  442. VOID
  443. RCACoRequestComplete(
  444. IN NDIS_STATUS NdisStatus,
  445. IN NDIS_HANDLE ProtocolAfContext,
  446. IN NDIS_HANDLE ProtocolVcContext OPTIONAL,
  447. IN NDIS_HANDLE ProtocolPartyContext OPTIONAL,
  448. IN OUT PNDIS_REQUEST NdisRequest
  449. );
  450. //
  451. // Co-NDIS client stuff.
  452. //
  453. extern
  454. BOOLEAN
  455. RCAReferenceVc(
  456. IN PRCA_VC pRcaVc
  457. );
  458. extern
  459. VOID
  460. RCADereferenceVc(
  461. IN PRCA_VC pRcaVc
  462. );
  463. extern
  464. VOID
  465. RCACoSendComplete(
  466. IN NDIS_STATUS Status,
  467. IN NDIS_HANDLE ProtocolVcContext,
  468. IN PNDIS_PACKET pNdisPacket
  469. );
  470. extern
  471. UINT
  472. RCACoReceivePacket(
  473. IN NDIS_HANDLE ProtocolBindingContext,
  474. IN NDIS_HANDLE ProtocolVcContext,
  475. IN PNDIS_PACKET pNdisPacket
  476. );
  477. extern
  478. VOID
  479. RCAReceiveComplete(
  480. IN NDIS_HANDLE ProtocolBindingContext
  481. );
  482. extern
  483. NDIS_STATUS
  484. RCACreateVc(
  485. IN NDIS_HANDLE ProtocolAfContext,
  486. IN NDIS_HANDLE NdisVcHandle,
  487. OUT PNDIS_HANDLE pProtocolVcContext
  488. );
  489. extern
  490. NDIS_STATUS
  491. RCADeleteVc(
  492. IN NDIS_HANDLE ProtocolVcContext
  493. );
  494. extern
  495. NDIS_STATUS
  496. RCAIncomingCall(
  497. IN NDIS_HANDLE ProtocolSapContext,
  498. IN NDIS_HANDLE ProtocolVcContext,
  499. IN OUT PCO_CALL_PARAMETERS pCallParams
  500. );
  501. extern
  502. VOID
  503. RCAIncomingCloseCall(
  504. IN NDIS_STATUS closeStatus,
  505. IN NDIS_HANDLE ProtocolVcContext,
  506. IN PVOID CloseData OPTIONAL,
  507. IN UINT Size OPTIONAL
  508. );
  509. extern
  510. VOID
  511. RCACloseCallComplete(
  512. IN NDIS_STATUS Status,
  513. IN NDIS_HANDLE ProtocolVcContext,
  514. IN NDIS_HANDLE ProtocolPartyContext OPTIONAL
  515. );
  516. extern
  517. VOID
  518. RCACallConnected(
  519. IN NDIS_HANDLE ProtocolVcContext
  520. );
  521. extern
  522. NDIS_STATUS
  523. RCARequest(
  524. IN NDIS_HANDLE ProtocolAfContext,
  525. IN NDIS_HANDLE ProtocolVcContext OPTIONAL,
  526. IN NDIS_HANDLE ProtocolPartyContext OPTIONAL,
  527. IN OUT PNDIS_REQUEST NdisRequest
  528. );
  529. /*++
  530. VOID
  531. RCAFreeCopyPacket(
  532. IN PNDIS_PACKET pNdisPacket
  533. )
  534. Routine Description:
  535. Free a local receive packet into our pool.
  536. Arguments:
  537. pAdapter - Pointer to our adapter structure
  538. pNdisPacket - Packet to be freed.
  539. Return Value:
  540. None
  541. --*/
  542. #define RCAFreeCopyPacket(_pPacket) \
  543. { \
  544. PNDIS_BUFFER pNdisBuffer; \
  545. PUCHAR pBuffer; \
  546. ULONG BufferLength; \
  547. \
  548. NdisQueryPacket((_pPacket), \
  549. NULL, \
  550. NULL, \
  551. &pNdisBuffer, \
  552. NULL); \
  553. \
  554. NdisQueryBuffer(pNdisBuffer, \
  555. &pBuffer, \
  556. &BufferLength); \
  557. \
  558. if (NULL != pNdisBuffer) \
  559. NdisFreeBuffer(pNdisBuffer); \
  560. \
  561. if (NULL != (_pPacket)) \
  562. NdisFreePacket((_pPacket)); \
  563. \
  564. if (NULL != pBuffer) \
  565. RCAFreeMem(pBuffer); \
  566. }
  567. #endif // _RCANDIS__H