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.

675 lines
20 KiB

  1. /*++
  2. Copyright (c) 1995-1996 Microsoft Corporation
  3. Module Name:
  4. pxdefs.h
  5. Abstract:
  6. Defines for ndproxy.sys
  7. Author:
  8. Tony Bell
  9. Revision History:
  10. Who When What
  11. -------- -------- ----------------------------------------------
  12. TonyBe 03/04/99 Created
  13. --*/
  14. #ifndef _PXDEFS__H
  15. #define _PXDEFS__H
  16. ///////////////////////////////////////////////////////////////////////////
  17. // Constants
  18. ///////////////////////////////////////////////////////////////////////////
  19. #define MODULE_INIT 0x00010000
  20. #define MODULE_NTINIT 0x00020000
  21. #define MODULE_CO 0x00030000
  22. #define MODULE_CL 0x00040000
  23. #define MODULE_DEBUG 0x00050000
  24. #define MODULE_CM 0x00060000
  25. #define MODULE_UTIL 0x00070000
  26. #define MODULE_CFG 0x00080000
  27. #define MODULE_TAPI 0x00100000
  28. //
  29. // Proxy's memory tags
  30. //
  31. #define PX_EVENT_TAG '1XP'
  32. #define PX_VCTABLE_TAG '2XP'
  33. #define PX_ADAPTER_TAG '3XP'
  34. #define PX_CLSAP_TAG '4XP'
  35. #define PX_CMSAP_TAG '5XP'
  36. #define PX_PARTY_TAG '6XP'
  37. #define PX_COCALLPARAMS_TAG '7XP'
  38. #define PX_REQUEST_TAG '8XP'
  39. #define PX_PROVIDER_TAG '9XP'
  40. #define PX_ENUMLINE_TAG 'aXP'
  41. #define PX_TAPILINE_TAG 'bXP'
  42. #define PX_ENUMADDR_TAG 'cXP'
  43. #define PX_TAPIADDR_TAG 'dXP'
  44. #define PX_TAPICALL_TAG 'eXP'
  45. #define PX_LINECALLINFO_TAG 'fXP'
  46. #define PX_CMAF_TAG 'gXP'
  47. #define PX_CLAF_TAG 'hXP'
  48. #define PX_VC_TAG 'iXP'
  49. #define PX_TRANSLATE_CALL 'jXP'
  50. #define PX_TRANSLATE_SAP 'kXP'
  51. #define PX_LINETABLE_TAG 'lXP'
  52. #define NDIS_MAJOR_VERSION 0x05
  53. #define NDIS_MINOR_VERSION 0x00
  54. #define PX_MAJOR_VERSION 0x01
  55. #define PX_MINOR_VERSION 0x00
  56. #define DD_PROXY_DEVICE_NAME L"\\Device\\NDProxy"
  57. #define PX_NAME L"NDProxy"
  58. #define MAX_ADSL_MEDIATYPE_STRING 48
  59. #define MAX_STATUS_COUNT 8
  60. #define MAX_LINE_DEVS 255
  61. #define MAX_NUM_CONCURRENT_CALLS 1000
  62. #define MAX_DEVCLASS_STRINGSIZE 16
  63. #define LINE_TABLE_SIZE 500
  64. #define VC_TABLE_SIZE 500
  65. #define MAX_STRING_PARAM_SIZE 40
  66. #define MAX_OUT_CALL_STATES 4
  67. #define LINE_CALL_INFO_VAR_DATA_SIZE (17*MAX_STRING_PARAM_SIZE)
  68. //
  69. // ADSL flags to indicate overriding registry values
  70. // in device extension
  71. //
  72. #define ADSL_TX_RATE_FROM_REG ((USHORT)0x0001)
  73. #define ADSL_RX_RATE_FROM_REG ((USHORT)0x0002)
  74. #define ADSL_FLAGS_MASK ((USHORT)0x0004)
  75. //
  76. // Status of tapi with ndproxy
  77. //
  78. typedef enum _NDISTAPI_STATUS {
  79. NDISTAPI_STATUS_CONNECTED,
  80. NDISTAPI_STATUS_DISCONNECTED,
  81. NDISTAPI_STATUS_CONNECTING,
  82. NDISTAPI_STATUS_DISCONNECTING
  83. } NDISTAPI_STATUS, *PNDISTAPI_STATUS;
  84. //
  85. // Status of providers with ndproxy
  86. //
  87. typedef enum _PROVIDER_STATUS {
  88. PROVIDER_STATUS_ONLINE,
  89. PROVIDER_STATUS_OFFLINE
  90. } PROVIDER_STATUS, *PPROVIDER_STATUS;
  91. //
  92. // States for PX_ADAPTER
  93. //
  94. typedef enum PX_ADAPTER_STATE {
  95. PX_ADAPTER_CLOSED,
  96. PX_ADAPTER_CLOSING,
  97. PX_ADAPTER_OPENING,
  98. PX_ADAPTER_OPEN
  99. } PX_ADAPTER_STATE;
  100. //
  101. // States for PX_CL_AF, PX_CM_AF
  102. //
  103. typedef enum PX_AF_STATE{
  104. PX_AF_CLOSED,
  105. PX_AF_CLOSING,
  106. PX_AF_OPENING,
  107. PX_AF_OPENED
  108. } PX_AF_STATE;
  109. //
  110. // States for PX_CL_SAP, PX_CM_SAP
  111. //
  112. typedef enum PX_SAP_STATE {
  113. PX_SAP_CLOSED,
  114. PX_SAP_CLOSING,
  115. PX_SAP_OPENING,
  116. PX_SAP_OPENED
  117. } PX_SAP_STATE;
  118. //
  119. // States for PX_VC between ndproxy
  120. // and the underlying call manager
  121. //
  122. typedef enum PX_VC_STATE {
  123. PX_VC_IDLE, // created
  124. PX_VC_PROCEEDING, // outgoing
  125. PX_VC_OFFERING, // incoming
  126. PX_VC_DISCONNECTING,
  127. PX_VC_CONNECTED
  128. } PX_VC_STATE;
  129. //
  130. // States for PX_VC between ndproxy
  131. // and the client
  132. //
  133. typedef enum PX_VC_HANDOFF_STATE {
  134. PX_VC_HANDOFF_IDLE, // created
  135. PX_VC_HANDOFF_OFFERING, // incoming (always)
  136. PX_VC_HANDOFF_DISCONNECTING,
  137. PX_VC_HANDOFF_CONNECTED
  138. } PX_VC_HANDOFF_STATE;
  139. ///////////////////////////////////////////////////////////////////////////
  140. // Macros
  141. ///////////////////////////////////////////////////////////////////////////
  142. #ifdef ROUND_UP
  143. #undef ROUND_UP
  144. #endif
  145. #define ROUND_UP(_Val) (((_Val) + 3) & ~3)
  146. #ifndef MAX
  147. /*++
  148. OPAQUE
  149. MAX(
  150. IN OPAQUE Fred,
  151. IN OPAQUE Shred
  152. )
  153. --*/
  154. #define MAX(Fred, Shred) (((Fred) > (Shred)) ? (Fred) : (Shred))
  155. #endif // MAX
  156. #ifndef MIN
  157. /*++
  158. OPAQUE
  159. MIN(
  160. IN OPAQUE Fred,
  161. IN OPAQUE Shred
  162. )
  163. --*/
  164. #define MIN(Fred, Shred) (((Fred) < (Shred)) ? (Fred) : (Shred))
  165. #endif // MIN
  166. /*++
  167. PVOID
  168. PxAllocMem(
  169. IN ULONG Size
  170. )
  171. --*/
  172. #if DBG
  173. #define PxAllocMem(_p, _s, _t) \
  174. _p = PxAuditAllocMem((PVOID)(&(_p)), _s, _t, _FILENUMBER, __LINE__);
  175. #else // DBG
  176. #define PxAllocMem(_p, _s, _t) \
  177. _p = ExAllocatePoolWithTag(NonPagedPool, (ULONG)_s, (ULONG)_t)
  178. #endif // DBG
  179. /*++
  180. VOID
  181. PxFreeMem(
  182. IN PVOID Pointer
  183. )
  184. --*/
  185. #if DBG
  186. #define PxFreeMem(Pointer) PxAuditFreeMem((PVOID)Pointer)
  187. #else
  188. #define PxFreeMem(Pointer) ExFreePool((PVOID)(Pointer))
  189. #endif // DBG
  190. /*++
  191. VOID
  192. PxInitBlockStruc(
  193. PxBlockStruc *pBlock
  194. )
  195. --*/
  196. #define PxInitBlockStruc(pBlock) NdisInitializeEvent(&((pBlock)->Event))
  197. /*++
  198. NDIS_STATUS
  199. PxBlock(
  200. PxBlockStruc *pBlock
  201. )
  202. --*/
  203. #define PxBlock(pBlock) \
  204. (NdisWaitEvent(&((pBlock)->Event), 0), (pBlock)->Status)
  205. /*++
  206. VOID
  207. PxSignal(
  208. IN PxBlockStruc *pBlock,
  209. IN UINT Status
  210. )
  211. --*/
  212. #define PxSignal(_pbl, _s) \
  213. { (_pbl)->Status = _s; NdisSetEvent(&((_pbl)->Event)); }
  214. /*++
  215. VOID
  216. REF_ADAPTER(
  217. IN PPX_ADAPTER _pa
  218. )
  219. --*/
  220. #define REF_ADAPTER(_pa) \
  221. (_pa)->RefCount++
  222. /*++
  223. VOID
  224. DEREF_ADAPTER(
  225. IN PPX_ADAPTER _pa
  226. )
  227. --*/
  228. #define DEREF_ADAPTER(_pa) \
  229. { \
  230. NdisAcquireSpinLock(&(_pa)->Lock); \
  231. if (--(_pa)->RefCount == 0) { \
  232. NdisReleaseSpinLock(&(_pa)->Lock); \
  233. PxFreeAdapter(_pa); \
  234. } else { \
  235. NdisReleaseSpinLock(&(_pa)->Lock); \
  236. } \
  237. }
  238. /*++
  239. VOID
  240. DEREF_ADAPTER_LOCKED(
  241. IN PPX_ADAPTER _pa
  242. )
  243. --*/
  244. #define DEREF_ADAPTER_LOCKED(_pa) \
  245. { \
  246. if (--(_pa)->RefCount == 0) { \
  247. NdisReleaseSpinLock(&(_pa)->Lock); \
  248. PxFreeAdapter(_pa); \
  249. } else { \
  250. NdisReleaseSpinLock(&(_pa)->Lock); \
  251. } \
  252. }
  253. /*++
  254. REF_CM_AF(
  255. IN PPX_CM_AF _paf
  256. )
  257. --*/
  258. #define REF_CM_AF(_paf) \
  259. { \
  260. ASSERT((LONG)(_paf)->RefCount != 0); \
  261. (_paf)->RefCount++; \
  262. }
  263. /*++
  264. VOID
  265. DEREF_CM_AF(
  266. IN PPX_CM_AF _paf
  267. )
  268. --*/
  269. #define DEREF_CM_AF(_paf) \
  270. { \
  271. NdisAcquireSpinLock(&(_paf)->Lock); \
  272. ASSERT((LONG)(_paf)->RefCount > 0); \
  273. if (--(_paf)->RefCount == 0) { \
  274. DoDerefCmAfWork(_paf); \
  275. } else { \
  276. NdisReleaseSpinLock(&(_paf)->Lock); \
  277. } \
  278. }
  279. /*++
  280. VOID
  281. DEREF_CM_AF_LOCKED(
  282. IN PPX_CM_AF _paf
  283. )
  284. --*/
  285. #define DEREF_CM_AF_LOCKED(_paf) \
  286. { \
  287. ASSERT((LONG)(_paf)->RefCount > 0); \
  288. if (--(_paf)->RefCount == 0) { \
  289. DoDerefCmAfWork(_paf); \
  290. } else { \
  291. NdisReleaseSpinLock(&(_paf)->Lock); \
  292. } \
  293. }
  294. /*++
  295. REF_CL_AF(
  296. IN PPX_CL_AF _paf
  297. )
  298. --*/
  299. #define REF_CL_AF(_paf) \
  300. { \
  301. ASSERT((LONG)(_paf)->RefCount != 0); \
  302. (_paf)->RefCount++; \
  303. }
  304. /*++
  305. VOID
  306. DEREF_CL_AF(
  307. IN PPX_CL_AF _paf
  308. )
  309. --*/
  310. #define DEREF_CL_AF(_paf) \
  311. { \
  312. if ((_paf) != NULL) { \
  313. NdisAcquireSpinLock(&(_paf)->Lock); \
  314. ASSERT((LONG)(_paf)->RefCount > 0); \
  315. if (--(_paf)->RefCount == 0) { \
  316. DoDerefClAfWork(_paf); \
  317. } else { \
  318. NdisReleaseSpinLock(&(_paf)->Lock); \
  319. } \
  320. } \
  321. }
  322. /*++
  323. VOID
  324. DEREF_CL_AF_LOCKED(
  325. IN PPX_CL_AF _paf
  326. )
  327. --*/
  328. #define DEREF_CL_AF_LOCKED(_paf) \
  329. { \
  330. if ((_paf) != NULL) { \
  331. ASSERT((LONG)(_paf)->RefCount > 0); \
  332. if (--(_paf)->RefCount == 0) { \
  333. DoDerefClAfWork(_paf); \
  334. } else { \
  335. NdisReleaseSpinLock(&(_paf)->Lock); \
  336. } \
  337. } \
  338. }
  339. /*++
  340. REF_VC(
  341. IN PPX_VC _pvc
  342. )
  343. --*/
  344. #define REF_VC(_pvc) \
  345. (_pvc)->RefCount++
  346. #ifdef CODELETEVC_FIXED
  347. /*++
  348. VOID
  349. DEREF_VC(
  350. IN PPX_VC _pvc
  351. )
  352. --*/
  353. #define DEREF_VC(_pvc) \
  354. { \
  355. if (_pvc != NULL) { \
  356. NdisAcquireSpinLock(&(_pvc)->Lock); \
  357. if (--(_pvc)->RefCount == 0) { \
  358. DoDerefVcWork(_pvc); \
  359. } else { \
  360. NdisReleaseSpinLock(&(_pvc)->Lock); \
  361. } \
  362. } \
  363. }
  364. /*++
  365. VOID
  366. DEREF_VC_LOCKED(
  367. IN PPX_VC _pvc
  368. )
  369. --*/
  370. #define DEREF_VC_LOCKED(_pvc) \
  371. { \
  372. if (_pvc != NULL) { \
  373. if (--(_pvc)->RefCount == 0) { \
  374. DoDrefVcWork(_pvc); \
  375. } else { \
  376. NdisReleaseSpinLock(&(_pvc)->Lock); \
  377. } \
  378. } \
  379. }
  380. #else
  381. /*++
  382. VOID
  383. DEREF_VC(
  384. IN PPX_VC _pvc
  385. )
  386. --*/
  387. #define DEREF_VC(_pvc) \
  388. { \
  389. if (_pvc != NULL) { \
  390. NdisAcquireSpinLock(&(_pvc)->Lock); \
  391. if (--(_pvc)->RefCount == 0) { \
  392. DoDerefVcWork(_pvc); \
  393. } else { \
  394. NdisReleaseSpinLock(&(_pvc)->Lock); \
  395. } \
  396. } \
  397. }
  398. /*++
  399. VOID
  400. DEREF_VC_LOCKED(
  401. IN PPX_VC _pvc
  402. )
  403. --*/
  404. #define DEREF_VC_LOCKED(_pvc) \
  405. { \
  406. if (_pvc != NULL) { \
  407. if (--(_pvc)->RefCount == 0) { \
  408. DoDerefVcWork(_pvc); \
  409. } else { \
  410. NdisReleaseSpinLock(&(_pvc)->Lock); \
  411. } \
  412. } \
  413. }
  414. #endif
  415. /*++
  416. REF_TAPILINE
  417. IN PPX_TAPI_LINE _ptl
  418. )
  419. --*/
  420. #define REF_TAPILINE(_ptl) \
  421. (_ptl)->RefCount++
  422. /*++
  423. VOID
  424. DEREF_TAPILINE(
  425. IN PPX_TAPI_LINE _ptl
  426. )
  427. --*/
  428. #define DEREF_TAPILINE(_ptl) \
  429. { \
  430. if (_ptl != NULL) { \
  431. NdisAcquireSpinLock(&(_ptl)->Lock); \
  432. if (--(_ptl)->RefCount == 0) { \
  433. NdisReleaseSpinLock(&(_ptl)->Lock); \
  434. FreeTapiLine(_ptl); \
  435. } else { \
  436. NdisReleaseSpinLock(&(_ptl)->Lock); \
  437. } \
  438. } \
  439. }
  440. /*++
  441. VOID
  442. DEREF_TAPILINE_LOCKED(
  443. IN PPX_TAPI_LINE _ptl
  444. )
  445. --*/
  446. #define DEREF_TAPILINE_LOCKED(_ptl) \
  447. { \
  448. if (_ptl != NULL) { \
  449. if (--(_ptl)->RefCount == 0) { \
  450. NdisReleaseSpinLock(&(_ptl)->Lock); \
  451. FreeTapiLine(_ptl); \
  452. } else { \
  453. NdisReleaseSpinLock(&(_ptl)->Lock); \
  454. } \
  455. } \
  456. }
  457. /*++
  458. VOID
  459. AdapterFromBindContext(
  460. IN NDIS_HANDLE _ctx,
  461. IN PPX_ADAPTER _pa,
  462. IN BOOLENA _bcl
  463. )
  464. --*/
  465. #define AdapterFromBindContext(_ctx, _pa, _bcl) \
  466. { \
  467. if (*(PULONG)(_ctx) == PX_ADAPTER_SIG) { \
  468. (_pa) = CONTAINING_RECORD((_ctx), PX_ADAPTER, Sig); \
  469. (_bcl) = FALSE; \
  470. } else { \
  471. (_pa) = (PPX_ADAPTER)(_ctx); \
  472. (_bcl) = TRUE; \
  473. } \
  474. }
  475. /*++
  476. VOID
  477. AdapterFromClBindContext(
  478. IN NDIS_HANDLE _ctx,
  479. IN PPX_ADAPTER _pa
  480. )
  481. --*/
  482. #define AdapterFromClBindContext(_ctx, _pa) \
  483. (_pa) = (PPX_ADAPTER)(_ctx)
  484. /*++
  485. VOID
  486. AdapterFromCmBindContext(
  487. IN NDIS_HANDLE _ctx,
  488. IN PPX_ADAPTER _pa
  489. )
  490. --*/
  491. #define AdapterFromCmBindContext(_ctx, _pa) \
  492. { \
  493. ASSERT(*(PULONG)(_ctx) == PX_ADAPTER_SIG); \
  494. (_pa) = CONTAINING_RECORD((_ctx), PX_ADAPTER, Sig); \
  495. }
  496. /*
  497. VOID
  498. SendTapiCallState(
  499. IN PPX_VC _pvc,
  500. IN ULONG_PTR _p1,
  501. IN ULONG_PTR _p2,
  502. IN ULONG_PTR _p3
  503. )
  504. */
  505. #define SendTapiCallState(_pvc, _p1, _p2, _p3) \
  506. { \
  507. NDIS_TAPI_EVENT _le; \
  508. PPX_TAPI_LINE _tl; \
  509. PXDEBUGP (PXD_LOUD, PXM_TAPI, \
  510. ("SendTapiCallState: Vc %p, CallState: %x, p2: %x, p3 %x\n",\
  511. _pvc, _p1, _p2, _p3)); \
  512. _tl = (_pvc)->TapiLine; \
  513. _le.htLine = _tl->htLine; \
  514. _le.htCall = _pvc->htCall; \
  515. _le.ulMsg = LINE_CALLSTATE; \
  516. _le.ulParam1 = _p1; \
  517. _le.ulParam2 = _p2; \
  518. _le.ulParam3 = _p3; \
  519. ASSERT((_p1) != (_pvc)->ulCallState); \
  520. (_pvc)->ulCallState = (_p1); \
  521. (_pvc)->ulCallStateMode = (_p2); \
  522. NdisReleaseSpinLock(&(_pvc)->Lock); \
  523. PxIndicateStatus(&(_le), sizeof(NDIS_TAPI_EVENT)); \
  524. NdisAcquireSpinLock(&(_pvc)->Lock); \
  525. }
  526. // if ((_p1) == LINECALLSTATE_DISCONNECTED) { \
  527. // InterlockedDecrement((PLONG)&(_tl)->DevStatus->ulNumActiveCalls);\
  528. // } else if ((_p1) == LINECALLSTATE_OFFERING || (_p1) == LINECALLSTATE_PROCEEDING) {\
  529. // InterlockedIncrement((PLONG)&(_tl)->DevStatus->ulNumActiveCalls);\
  530. // } \
  531. /*
  532. VOID
  533. SendTapiNewCall(
  534. IN PPX_VC _pvc,
  535. IN ULONG_PTR _p1,
  536. IN ULONG_PTR _p2,
  537. IN ULONG_PTR _p3
  538. )
  539. */
  540. #define SendTapiNewCall(_pvc, _p1, _p2, _p3) \
  541. { \
  542. NDIS_TAPI_EVENT _le; \
  543. _le.htLine = _pvc->TapiLine->htLine; \
  544. _le.htCall = _pvc->htCall; \
  545. _le.ulMsg = LINE_NEWCALL; \
  546. _le.ulParam1 = _p1; \
  547. _le.ulParam2 = _p2; \
  548. _le.ulParam3 = _p3; \
  549. PXDEBUGP (PXD_LOUD, PXM_TAPI, \
  550. ("SendTapiNewCall: Vc %p, p1: %x, p2: %x, p3 %x\n",\
  551. _pvc, _p1, _p2, _p3)); \
  552. NdisReleaseSpinLock(&(_pvc)->Lock); \
  553. PxIndicateStatus(&(_le), sizeof(NDIS_TAPI_EVENT)); \
  554. NdisAcquireSpinLock(&(_pvc)->Lock); \
  555. }
  556. /*
  557. VOID
  558. SendTapiLineClose(
  559. IN PPX_TAPI_LINE _ptl
  560. )
  561. */
  562. #define SendTapiLineClose(_ptl) \
  563. { \
  564. NDIS_TAPI_EVENT _le; \
  565. _le.htLine = (_ptl)->htLine; \
  566. _le.htCall = 0; \
  567. _le.ulMsg = LINE_CLOSE; \
  568. _le.ulParam1 = 0; \
  569. _le.ulParam2 = 0; \
  570. _le.ulParam3 = 0; \
  571. PXDEBUGP (PXD_LOUD, PXM_TAPI, \
  572. ("SendTapiLineClose: TapiLine %p\n",_ptl)); \
  573. PxIndicateStatus(&(_le), sizeof(NDIS_TAPI_EVENT)); \
  574. }
  575. /*
  576. VOID
  577. SendTapiLineCreate(
  578. IN PPX_TAPI_LINE _ptl
  579. )
  580. */
  581. #define SendTapiLineCreate(_ptl) \
  582. { \
  583. NDIS_TAPI_EVENT _le; \
  584. _le.htLine = (_ptl)->htLine; \
  585. _le.htCall = 0; \
  586. _le.ulMsg = LINE_CREATE; \
  587. _le.ulParam1 = 0; \
  588. _le.ulParam2 = (_ptl)->hdLine; \
  589. _le.ulParam3 = 0; \
  590. PXDEBUGP (PXD_LOUD, PXM_TAPI, \
  591. ("SendTapiLineCreate: TapiLine %p\n",_ptl)); \
  592. PxIndicateStatus(&(_le), sizeof(NDIS_TAPI_EVENT)); \
  593. }
  594. #endif