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.

233 lines
7.0 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"
  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 MAX_CALL_ID_RANGE ((ULONG)0x10000)
  41. #define OS_RANGE_CHECK_ENDPOINTS(ep, baseid) \
  42. if ((unsigned)(ep)>(1<<CALL_ID_INDEX_BITS)) \
  43. { \
  44. (ep) = (1<<CALL_ID_INDEX_BITS); \
  45. } \
  46. if (((ep) + (baseid)) > MAX_CALL_ID_RANGE) \
  47. { \
  48. baseid = MAX_CALL_ID_RANGE - (ep); \
  49. } \
  50. if(baseid != 0 || (ep) != OS_CLIENT_WAN_ENDPOINTS) \
  51. PptpClientSide = FALSE;
  52. #define OS_RANGE_CHECK_MAX_TRANSMIT(mt) \
  53. if ((unsigned)(mt)<1) (mt) = 1; \
  54. if ((unsigned)(mt)>1024) (mt) = 1024;
  55. #define OS_DEFAULT_WAN_ENDPOINTS 5
  56. #define OS_CLIENT_WAN_ENDPOINTS 32
  57. #define OS_LISTENS_PENDING 5
  58. #define LOGHDRS ":::%d:%08x:%08x:%d.%d.%d.%d:"
  59. #define LOGHDR(id, ip) (id), Time.HighPart, Time.LowPart, IPADDR(ip)
  60. typedef VOID (*WORK_PROC)(struct _PPTP_WORK_ITEM *);
  61. typedef struct _PPTP_WORK_ITEM
  62. {
  63. LIST_ENTRY ListEntry;
  64. WORK_PROC Callback;
  65. PVOID Context;
  66. PVOID pBuffer;
  67. ULONG Length;
  68. } PPTP_WORK_ITEM, *PPPTP_WORK_ITEM;
  69. #ifndef PPTP_DPC_USES_NDIS
  70. #define PPTP_DPC_USES_NDIS 0
  71. #endif
  72. #if PPTP_DPC_USES_NDIS
  73. // WARNING: There's a difference in behavior between NdisMSetTimer and
  74. // KeInsertQueueDpc. NdisMSetTimer resets the timer if it's already
  75. // queued, KeInsertQueueDpc does not.
  76. // We purposely wrote the code that uses these macros
  77. // to be agnostic about this behavior. Anyone using these macros should
  78. // study how they are used here to avoid problems with them.
  79. #define PPTP_DPC NDIS_MINIPORT_TIMER
  80. #define PptpInitializeDpc(Dpc, hAdapter, DeferredRoutine, DeferredContext) \
  81. NdisMInitializeTimer((Dpc), (hAdapter), (PNDIS_TIMER_FUNCTION)(DeferredRoutine), (DeferredContext))
  82. #define PptpQueueDpc(Dpc) NdisMSetTimer((Dpc), 1)
  83. #define PptpCancelDpc(Dpc, pCancelled) NdisMCancelTimer((Dpc), (pCancelled))
  84. #else
  85. #define PPTP_DPC KDPC
  86. #define PptpInitializeDpc(Dpc, AdapterHandle, DeferredRoutine, DeferredContext) \
  87. KeInitializeDpc((Dpc), (PKDEFERRED_ROUTINE)(DeferredRoutine), (DeferredContext))
  88. #define PptpQueueDpc(Dpc) \
  89. { \
  90. ASSERT(KeGetCurrentIrql()>=DISPATCH_LEVEL); \
  91. KeInsertQueueDpc((Dpc), NULL, NULL); \
  92. }
  93. #define PptpCancelDpc(Dpc, pCancelled) KeRemoveQueueDpc(Dpc) \
  94. { \
  95. *(PBOOLEAN)(pCancelled) = KeRemoveQueueDpc(Dpc); \
  96. }
  97. #endif
  98. typedef
  99. VOID
  100. (*PPPTP_DPC_FUNCTION) (
  101. IN PVOID SystemSpecific1,
  102. IN PVOID FunctionContext,
  103. IN PVOID SystemSpecific2,
  104. IN PVOID SystemSpecific3
  105. );
  106. #define ASSERT_LOCK_HELD(pNdisLock) ASSERT(KeNumberProcessors==1 || (pNdisLock)->SpinLock!=0)
  107. #ifndef VER_PRODUCTVERSION_W
  108. #error "No VER_PRODUCTVERSION_W"
  109. #endif
  110. #if VER_PRODUCTVERSION_W < 0x0400
  111. #error "VER_PRODUCTVERSION_W < 0x0400"
  112. #endif
  113. #if VER_PRODUCTVERSION_W < 0x0500
  114. // Recreate all the stuff in NT5 that didn't exist in NT4.
  115. typedef ULONG ULONG_PTR, *PULONG_PTR;
  116. //
  117. // Define alignment macros to align structure sizes and pointers up and down.
  118. //
  119. #ifndef ALIGN_DOWN
  120. #define ALIGN_DOWN(length, type) \
  121. ((ULONG)(length) & ~(sizeof(type) - 1))
  122. #endif
  123. #ifndef ALIGN_UP
  124. #define ALIGN_UP(length, type) \
  125. (ALIGN_DOWN(((ULONG)(length) + sizeof(type) - 1), type))
  126. #endif
  127. #ifndef ALIGN_DOWN_POINTER
  128. #define ALIGN_DOWN_POINTER(address, type) \
  129. ((PVOID)((ULONG_PTR)(address) & ~((ULONG_PTR)sizeof(type) - 1)))
  130. #endif
  131. #ifndef ALIGN_UP_POINTER
  132. #define ALIGN_UP_POINTER(address, type) \
  133. (ALIGN_DOWN_POINTER(((ULONG_PTR)(address) + sizeof(type) - 1), type))
  134. #endif
  135. //
  136. // PnP and PM OIDs
  137. //
  138. #ifndef OID_PNP_CAPABILITIES
  139. #define OID_PNP_CAPABILITIES 0xFD010100
  140. #endif
  141. #ifndef OID_PNP_SET_POWER
  142. #define OID_PNP_SET_POWER 0xFD010101
  143. #endif
  144. #ifndef OID_PNP_QUERY_POWER
  145. #define OID_PNP_QUERY_POWER 0xFD010102
  146. #endif
  147. #ifndef OID_PNP_ADD_WAKE_UP_PATTERN
  148. #define OID_PNP_ADD_WAKE_UP_PATTERN 0xFD010103
  149. #endif
  150. #ifndef OID_PNP_REMOVE_WAKE_UP_PATTERN
  151. #define OID_PNP_REMOVE_WAKE_UP_PATTERN 0xFD010104
  152. #endif
  153. #ifndef OID_PNP_WAKE_UP_PATTERN_LIST
  154. #define OID_PNP_WAKE_UP_PATTERN_LIST 0xFD010105
  155. #endif
  156. #ifndef OID_PNP_ENABLE_WAKE_UP
  157. #define OID_PNP_ENABLE_WAKE_UP 0xFD010106
  158. #endif
  159. #ifndef OID_GEN_SUPPORTED_GUIDS
  160. #define OID_GEN_SUPPORTED_GUIDS 0x00010117
  161. #endif
  162. #ifndef NDIS_ATTRIBUTE_NO_HALT_ON_SUSPEND
  163. #define NDIS_ATTRIBUTE_NO_HALT_ON_SUSPEND 0 // So it can't mess up NDIS
  164. #endif
  165. typedef enum _NDIS_DEVICE_POWER_STATE
  166. {
  167. NdisDeviceStateUnspecified = 0,
  168. NdisDeviceStateD0,
  169. NdisDeviceStateD1,
  170. NdisDeviceStateD2,
  171. NdisDeviceStateD3,
  172. NdisDeviceStateMaximum
  173. } NDIS_DEVICE_POWER_STATE, *PNDIS_DEVICE_POWER_STATE;
  174. typedef struct _NDIS_PM_WAKE_UP_CAPABILITIES
  175. {
  176. NDIS_DEVICE_POWER_STATE MinMagicPacketWakeUp;
  177. NDIS_DEVICE_POWER_STATE MinPatternWakeUp;
  178. NDIS_DEVICE_POWER_STATE MinLinkChangeWakeUp;
  179. } NDIS_PM_WAKE_UP_CAPABILITIES, *PNDIS_PM_WAKE_UP_CAPABILITIES;
  180. typedef struct _NDIS_PNP_CAPABILITIES
  181. {
  182. ULONG Flags;
  183. NDIS_PM_WAKE_UP_CAPABILITIES WakeUpCapabilities;
  184. } NDIS_PNP_CAPABILITIES, *PNDIS_PNP_CAPABILITIES;
  185. #define NdisWanMediumPPTP NdisWanMediumSerial
  186. #endif
  187. #endif //OSINC_H