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.

226 lines
6.6 KiB

  1. /*****************************************************************************
  2. *
  3. * Copyright (c) 1998-1999 Microsoft Corporation
  4. *
  5. * OSINC.H - includes OS specific headers
  6. *
  7. * Author: Stan Adermann (stana)
  8. *
  9. * Created: 9/2/1998
  10. *
  11. *****************************************************************************/
  12. #ifndef OSINC_H
  13. #define OSINC_H
  14. #define BINARY_COMPATIBLE 0
  15. #include <ntddk.h>
  16. #include <ndis.h>
  17. #include <ndiswan.h>
  18. #include <ndistapi.h>
  19. #include <ntverp.h>
  20. #define PPTP_VENDOR "Microsoft Windows NT"
  21. #define PPTP_FIRMWARE_REVISION VER_PRODUCTBUILD
  22. #define TAPI_LINE_NAME_STRING "RAS VPN Line"
  23. extern ANSI_STRING TapiLineName;
  24. #define TAPI_PROVIDER_STRING "VPN\0RASPPTP"
  25. #define TAPI_DEV_CAPS_SIZE (sizeof(TAPI_PROVIDER_STRING)+ \
  26. TapiLineName.Length + sizeof(UCHAR) * 6 +\
  27. sizeof(NDIS_TAPI_GET_DEV_CAPS))
  28. #define TAPI_LINE_ADDR_STRING "PPTP VPN"
  29. #define OS_SPECIFIC_NDIS_WAN_MEDIUM_TYPE NdisWanMediumPPTP
  30. // OS_CONNECTION_WRAPPER_ID should only be used in one location, TapiLineUp()
  31. #define OS_CONNECTION_WRAPPER_ID ((NDIS_HANDLE) pCall->hTapiCall)
  32. // Other OS's that don't risk blowing the stack or don't have this mechanism
  33. // should just define this TRUE or FALSE.
  34. #define OS_COMPLETE_SEND_NOW(Call) (IoGetRemainingStackSize()>1024)
  35. //
  36. // NDIS version compatibility.
  37. //
  38. #define NDIS_MAJOR_VERSION 4
  39. #define NDIS_MINOR_VERSION 0
  40. #define OS_RANGE_CHECK_ENDPOINTS(ep) \
  41. if ((unsigned)(ep)>(1<<CALL_ID_INDEX_BITS)) \
  42. { \
  43. (ep) = (1<<CALL_ID_INDEX_BITS); \
  44. }
  45. // 4096 because we use 12 bits for the call id.
  46. #define OS_RANGE_CHECK_MAX_TRANSMIT(mt) \
  47. if ((unsigned)(mt)<1) (mt) = 1; \
  48. if ((unsigned)(mt)>1024) (mt) = 1024;
  49. #define OS_DEFAULT_WAN_ENDPOINTS 5
  50. #define OS_LISTENS_PENDING 5
  51. #define LOGHDRS ":::%d:%08x:%08x:%d.%d.%d.%d:"
  52. #define LOGHDR(id, ip) (id), Time.HighPart, Time.LowPart, IPADDR(ip)
  53. typedef VOID (*WORK_PROC)(struct _PPTP_WORK_ITEM *);
  54. typedef struct _PPTP_WORK_ITEM
  55. {
  56. LIST_ENTRY ListEntry;
  57. WORK_PROC Callback;
  58. PVOID Context;
  59. PVOID pBuffer;
  60. ULONG Length;
  61. } PPTP_WORK_ITEM, *PPPTP_WORK_ITEM;
  62. #ifndef PPTP_DPC_USES_NDIS
  63. #define PPTP_DPC_USES_NDIS 0
  64. #endif
  65. #if PPTP_DPC_USES_NDIS
  66. // WARNING: There's a difference in behavior between NdisMSetTimer and
  67. // KeInsertQueueDpc. NdisMSetTimer resets the timer if it's already
  68. // queued, KeInsertQueueDpc does not.
  69. // We purposely wrote the code that uses these macros
  70. // to be agnostic about this behavior. Anyone using these macros should
  71. // study how they are used here to avoid problems with them.
  72. #define PPTP_DPC NDIS_MINIPORT_TIMER
  73. #define PptpInitializeDpc(Dpc, hAdapter, DeferredRoutine, DeferredContext) \
  74. NdisMInitializeTimer((Dpc), (hAdapter), (PNDIS_TIMER_FUNCTION)(DeferredRoutine), (DeferredContext))
  75. #define PptpQueueDpc(Dpc) NdisMSetTimer((Dpc), 1)
  76. #define PptpCancelDpc(Dpc, pCancelled) NdisMCancelTimer((Dpc), (pCancelled))
  77. #else
  78. #define PPTP_DPC KDPC
  79. #define PptpInitializeDpc(Dpc, AdapterHandle, DeferredRoutine, DeferredContext) \
  80. KeInitializeDpc((Dpc), (PKDEFERRED_ROUTINE)(DeferredRoutine), (DeferredContext))
  81. #define PptpQueueDpc(Dpc) \
  82. { \
  83. ASSERT(KeGetCurrentIrql()>=DISPATCH_LEVEL); \
  84. KeInsertQueueDpc((Dpc), NULL, NULL); \
  85. }
  86. #define PptpCancelDpc(Dpc, pCancelled) KeRemoveQueueDpc(Dpc) \
  87. { \
  88. *(PBOOLEAN)(pCancelled) = KeRemoveQueueDpc(Dpc); \
  89. }
  90. #endif
  91. typedef
  92. VOID
  93. (*PPPTP_DPC_FUNCTION) (
  94. IN PVOID SystemSpecific1,
  95. IN PVOID FunctionContext,
  96. IN PVOID SystemSpecific2,
  97. IN PVOID SystemSpecific3
  98. );
  99. #define ASSERT_LOCK_HELD(pNdisLock) ASSERT(KeNumberProcessors==1 || (pNdisLock)->SpinLock!=0)
  100. #ifndef VER_PRODUCTVERSION_W
  101. #error "No VER_PRODUCTVERSION_W"
  102. #endif
  103. #if VER_PRODUCTVERSION_W < 0x0400
  104. #error "VER_PRODUCTVERSION_W < 0x0400"
  105. #endif
  106. #if VER_PRODUCTVERSION_W < 0x0500
  107. // Recreate all the stuff in NT5 that didn't exist in NT4.
  108. typedef ULONG ULONG_PTR, *PULONG_PTR;
  109. //
  110. // Define alignment macros to align structure sizes and pointers up and down.
  111. //
  112. #ifndef ALIGN_DOWN
  113. #define ALIGN_DOWN(length, type) \
  114. ((ULONG)(length) & ~(sizeof(type) - 1))
  115. #endif
  116. #ifndef ALIGN_UP
  117. #define ALIGN_UP(length, type) \
  118. (ALIGN_DOWN(((ULONG)(length) + sizeof(type) - 1), type))
  119. #endif
  120. #ifndef ALIGN_DOWN_POINTER
  121. #define ALIGN_DOWN_POINTER(address, type) \
  122. ((PVOID)((ULONG_PTR)(address) & ~((ULONG_PTR)sizeof(type) - 1)))
  123. #endif
  124. #ifndef ALIGN_UP_POINTER
  125. #define ALIGN_UP_POINTER(address, type) \
  126. (ALIGN_DOWN_POINTER(((ULONG_PTR)(address) + sizeof(type) - 1), type))
  127. #endif
  128. //
  129. // PnP and PM OIDs
  130. //
  131. #ifndef OID_PNP_CAPABILITIES
  132. #define OID_PNP_CAPABILITIES 0xFD010100
  133. #endif
  134. #ifndef OID_PNP_SET_POWER
  135. #define OID_PNP_SET_POWER 0xFD010101
  136. #endif
  137. #ifndef OID_PNP_QUERY_POWER
  138. #define OID_PNP_QUERY_POWER 0xFD010102
  139. #endif
  140. #ifndef OID_PNP_ADD_WAKE_UP_PATTERN
  141. #define OID_PNP_ADD_WAKE_UP_PATTERN 0xFD010103
  142. #endif
  143. #ifndef OID_PNP_REMOVE_WAKE_UP_PATTERN
  144. #define OID_PNP_REMOVE_WAKE_UP_PATTERN 0xFD010104
  145. #endif
  146. #ifndef OID_PNP_WAKE_UP_PATTERN_LIST
  147. #define OID_PNP_WAKE_UP_PATTERN_LIST 0xFD010105
  148. #endif
  149. #ifndef OID_PNP_ENABLE_WAKE_UP
  150. #define OID_PNP_ENABLE_WAKE_UP 0xFD010106
  151. #endif
  152. #ifndef OID_GEN_SUPPORTED_GUIDS
  153. #define OID_GEN_SUPPORTED_GUIDS 0x00010117
  154. #endif
  155. #ifndef NDIS_ATTRIBUTE_NO_HALT_ON_SUSPEND
  156. #define NDIS_ATTRIBUTE_NO_HALT_ON_SUSPEND 0 // So it can't mess up NDIS
  157. #endif
  158. typedef enum _NDIS_DEVICE_POWER_STATE
  159. {
  160. NdisDeviceStateUnspecified = 0,
  161. NdisDeviceStateD0,
  162. NdisDeviceStateD1,
  163. NdisDeviceStateD2,
  164. NdisDeviceStateD3,
  165. NdisDeviceStateMaximum
  166. } NDIS_DEVICE_POWER_STATE, *PNDIS_DEVICE_POWER_STATE;
  167. typedef struct _NDIS_PM_WAKE_UP_CAPABILITIES
  168. {
  169. NDIS_DEVICE_POWER_STATE MinMagicPacketWakeUp;
  170. NDIS_DEVICE_POWER_STATE MinPatternWakeUp;
  171. NDIS_DEVICE_POWER_STATE MinLinkChangeWakeUp;
  172. } NDIS_PM_WAKE_UP_CAPABILITIES, *PNDIS_PM_WAKE_UP_CAPABILITIES;
  173. typedef struct _NDIS_PNP_CAPABILITIES
  174. {
  175. ULONG Flags;
  176. NDIS_PM_WAKE_UP_CAPABILITIES WakeUpCapabilities;
  177. } NDIS_PNP_CAPABILITIES, *PNDIS_PNP_CAPABILITIES;
  178. #define NdisWanMediumPPTP NdisWanMediumSerial
  179. #endif
  180. #endif //OSINC_H