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.

160 lines
7.9 KiB

  1. /*++
  2. Copyright (c) 1990-1995 Microsoft Corporation
  3. Module Name:
  4. requestm.h
  5. Abstract:
  6. Author:
  7. Kyle Brandon (KyleB)
  8. Environment:
  9. Kernel mode
  10. Revision History:
  11. --*/
  12. #ifndef __REQUESTM_H
  13. #define __REQUESTM_H
  14. typedef struct _NDIS_REQUEST_RESERVED
  15. {
  16. PNDIS_REQUEST Next;
  17. PNDIS_OPEN_BLOCK Open;
  18. PVOID Context;
  19. ULONG Flags;
  20. } NDIS_REQUEST_RESERVED, *PNDIS_REQUEST_RESERVED;
  21. #define PNDIS_RESERVED_FROM_PNDIS_REQUEST(_request) ((PNDIS_REQUEST_RESERVED)((_request)->MacReserved))
  22. //
  23. // Used by the NdisCoRequest api to keep context information in the Request->NdisReserved
  24. //
  25. typedef struct _NDIS_COREQ_RESERVED
  26. {
  27. union
  28. {
  29. struct
  30. {
  31. CO_REQUEST_COMPLETE_HANDLER CoRequestCompleteHandler;
  32. NDIS_HANDLE VcContext;
  33. NDIS_HANDLE AfContext;
  34. NDIS_HANDLE PartyContext;
  35. };
  36. struct
  37. {
  38. NDIS_STATUS Status;
  39. KEVENT Event;
  40. };
  41. };
  42. } NDIS_COREQ_RESERVED, *PNDIS_COREQ_RESERVED;
  43. #define REQST_DOWNLEVEL 0x00000001
  44. #define REQST_FREE_REQUEST 0x00000002
  45. #define REQST_SIGNAL_EVENT 0x00000004
  46. #define REQST_SAVE_BUF 0x00000008
  47. #define REQST_LAST_RESTORE 0x00000010
  48. #define REQST_MANDATORY 0x00000020
  49. #define REQST_COMPLETED 0x80000000
  50. #define PNDIS_COREQ_RESERVED_FROM_REQUEST(_request) ((PNDIS_COREQ_RESERVED)((_request)->NdisReserved))
  51. //
  52. // The following structure keeps track of wakeup patterns for open blocks.
  53. //
  54. typedef struct _NDIS_PACKET_PATTERN_ENTRY
  55. {
  56. SINGLE_LIST_ENTRY Link;
  57. PNDIS_OPEN_BLOCK Open;
  58. NDIS_PM_PACKET_PATTERN Pattern;
  59. } NDIS_PACKET_PATTERN_ENTRY, *PNDIS_PACKET_PATTERN_ENTRY;
  60. #define MINIPORT_QUERY_INFO(_M_, _R_, _S_) *(_S_) = ndisMDispatchRequest(_M_, _R_, TRUE)
  61. #define MINIPORT_SET_INFO(_M_, _R_, _S_) *(_S_) = ndisMDispatchRequest(_M_, _R_, FALSE)
  62. #define SAVE_REQUEST_BUF(_M_, _R_, _B_, _L_) \
  63. { \
  64. PNDIS_RESERVED_FROM_PNDIS_REQUEST(_R_)->Flags |= REQST_SAVE_BUF; \
  65. (_M_)->SetInfoBuf = (_R_)->DATA.SET_INFORMATION.InformationBuffer; \
  66. (_M_)->SetInfoBufLen = (USHORT)((_R_)->DATA.SET_INFORMATION.InformationBufferLength); \
  67. (_R_)->DATA.SET_INFORMATION.InformationBuffer = _B_; \
  68. (_R_)->DATA.SET_INFORMATION.InformationBufferLength = _L_; \
  69. }
  70. #define RESTORE_REQUEST_BUF(_M_, _R_) \
  71. { \
  72. if (PNDIS_RESERVED_FROM_PNDIS_REQUEST(_R_)->Flags & REQST_SAVE_BUF) \
  73. { \
  74. PNDIS_RESERVED_FROM_PNDIS_REQUEST(_R_)->Flags &= ~REQST_SAVE_BUF; \
  75. (_R_)->DATA.SET_INFORMATION.InformationBuffer = (_M_)->SetInfoBuf; \
  76. (_R_)->DATA.SET_INFORMATION.InformationBufferLength = (_M_)->SetInfoBufLen; \
  77. (_M_)->SetInfoBuf = NULL; \
  78. (_M_)->SetInfoBufLen = 0; \
  79. } \
  80. }
  81. //
  82. // This macro verifies the query information buffer length.
  83. //
  84. #define VERIFY_QUERY_PARAMETERS(_Request, _SizeNeeded, _Status) \
  85. { \
  86. _Status = NDIS_STATUS_SUCCESS; \
  87. if ((_Request)->DATA.QUERY_INFORMATION.InformationBufferLength < (_SizeNeeded)) \
  88. { \
  89. (_Request)->DATA.QUERY_INFORMATION.BytesNeeded = (_SizeNeeded); \
  90. _Status = NDIS_STATUS_INVALID_LENGTH; \
  91. } \
  92. }
  93. //
  94. // This macro verifies the set information buffer length.
  95. //
  96. #define VERIFY_SET_PARAMETERS(_Request, _SizeNeeded, _Status) \
  97. { \
  98. _Status = NDIS_STATUS_SUCCESS; \
  99. if ((_Request)->DATA.SET_INFORMATION.InformationBufferLength < (_SizeNeeded)) \
  100. { \
  101. (_Request)->DATA.SET_INFORMATION.BytesNeeded = (_SizeNeeded); \
  102. _Status = NDIS_STATUS_INVALID_LENGTH; \
  103. } \
  104. }
  105. #define SET_INTERNAL_REQUEST(_Request, _Open, _Flags) \
  106. { \
  107. PNDIS_RESERVED_FROM_PNDIS_REQUEST(_Request)->Open = (_Open); \
  108. PNDIS_RESERVED_FROM_PNDIS_REQUEST(_Request)->Flags = _Flags; \
  109. \
  110. if (NULL != (_Open)) \
  111. { \
  112. M_OPEN_INCREMENT_REF_INTERLOCKED(_Open); \
  113. \
  114. DBGPRINT(DBG_COMP_OPENREF, DBG_LEVEL_INFO, \
  115. ("+ Open 0x%x Reference 0x%x\n", _Open, (_Open)->References)); \
  116. } \
  117. }
  118. #define SET_INTERNAL_REQUEST_NULL_OPEN(_Request, _Flags) \
  119. { \
  120. PNDIS_RESERVED_FROM_PNDIS_REQUEST(_Request)->Open = NULL; \
  121. PNDIS_RESERVED_FROM_PNDIS_REQUEST(_Request)->Flags = _Flags; \
  122. }
  123. #define INIT_INTERNAL_REQUEST(_Request, _Oid, _Type, _Buf, _Len) \
  124. { \
  125. NdisZeroMemory(_Request, sizeof(NDIS_REQUEST)); \
  126. PNDIS_RESERVED_FROM_PNDIS_REQUEST(_Request)->Flags = REQST_SIGNAL_EVENT; \
  127. (_Request)->DATA.QUERY_INFORMATION.Oid = _Oid; \
  128. (_Request)->RequestType = _Type; \
  129. (_Request)->DATA.QUERY_INFORMATION.InformationBuffer = _Buf; \
  130. (_Request)->DATA.QUERY_INFORMATION.InformationBufferLength = _Len; \
  131. }
  132. #endif // __REQUESTM_H