prototypes.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. /*
  2. * TAP-Windows -- A kernel driver to provide virtual tap
  3. * device functionality on Windows.
  4. *
  5. * This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
  6. *
  7. * This source code is Copyright (C) 2002-2010 OpenVPN Technologies, Inc.,
  8. * and is released under the GPL version 2 (see below).
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program (see the file COPYING included with this
  21. * distribution); if not, write to the Free Software Foundation, Inc.,
  22. * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  23. */
  24. #ifndef TAP_PROTOTYPES_DEFINED
  25. #define TAP_PROTOTYPES_DEFINED
  26. NTSTATUS DriverEntry
  27. (
  28. IN PDRIVER_OBJECT p_DriverObject,
  29. IN PUNICODE_STRING p_RegistryPath
  30. );
  31. VOID TapDriverUnload
  32. (
  33. IN PDRIVER_OBJECT p_DriverObject
  34. );
  35. NDIS_STATUS AdapterCreate
  36. (
  37. OUT PNDIS_STATUS p_ErrorStatus,
  38. OUT PUINT p_MediaIndex,
  39. IN PNDIS_MEDIUM p_Media,
  40. IN UINT p_MediaCount,
  41. IN NDIS_HANDLE p_AdapterHandle,
  42. IN NDIS_HANDLE p_ConfigurationHandle
  43. );
  44. VOID AdapterHalt
  45. (
  46. IN NDIS_HANDLE p_AdapterContext
  47. );
  48. VOID AdapterFreeResources
  49. (
  50. TapAdapterPointer p_Adapter
  51. );
  52. NDIS_STATUS AdapterReset
  53. (
  54. OUT PBOOLEAN p_AddressingReset,
  55. IN NDIS_HANDLE p_AdapterContext
  56. );
  57. NDIS_STATUS AdapterQuery
  58. (
  59. IN NDIS_HANDLE p_AdapterContext,
  60. IN NDIS_OID p_OID,
  61. IN PVOID p_Buffer,
  62. IN ULONG p_BufferLength,
  63. OUT PULONG p_BytesWritten,
  64. OUT PULONG p_BytesNeeded
  65. );
  66. NDIS_STATUS AdapterModify
  67. (
  68. IN NDIS_HANDLE p_AdapterContext,
  69. IN NDIS_OID p_OID,
  70. IN PVOID p_Buffer,
  71. IN ULONG p_BufferLength,
  72. OUT PULONG p_BytesRead,
  73. OUT PULONG p_BytesNeeded
  74. );
  75. NDIS_STATUS AdapterTransmit
  76. (
  77. IN NDIS_HANDLE p_AdapterContext,
  78. IN PNDIS_PACKET p_Packet,
  79. IN UINT p_Flags
  80. );
  81. NDIS_STATUS AdapterReceive
  82. (
  83. OUT PNDIS_PACKET p_Packet,
  84. OUT PUINT p_Transferred,
  85. IN NDIS_HANDLE p_AdapterContext,
  86. IN NDIS_HANDLE p_ReceiveContext,
  87. IN UINT p_Offset,
  88. IN UINT p_ToTransfer
  89. );
  90. NTSTATUS TapDeviceHook
  91. (
  92. IN PDEVICE_OBJECT p_DeviceObject,
  93. IN PIRP p_IRP
  94. );
  95. NDIS_STATUS CreateTapDevice
  96. (
  97. TapExtensionPointer p_Extension,
  98. const char *p_Name
  99. );
  100. VOID DestroyTapDevice
  101. (
  102. TapExtensionPointer p_Extension
  103. );
  104. VOID TapDeviceFreeResources
  105. (
  106. TapExtensionPointer p_Extension
  107. );
  108. NTSTATUS CompleteIRP
  109. (
  110. IN PIRP p_IRP,
  111. IN TapPacketPointer p_PacketBuffer,
  112. IN CCHAR PriorityBoost
  113. );
  114. VOID CancelIRPCallback
  115. (
  116. IN PDEVICE_OBJECT p_DeviceObject,
  117. IN PIRP p_IRP
  118. );
  119. VOID CancelIRP
  120. (
  121. TapExtensionPointer p_Extension,
  122. IN PIRP p_IRP,
  123. BOOLEAN callback
  124. );
  125. VOID FlushQueues
  126. (
  127. TapExtensionPointer p_Extension
  128. );
  129. VOID ResetTapAdapterState
  130. (
  131. TapAdapterPointer p_Adapter
  132. );
  133. BOOLEAN ProcessARP
  134. (
  135. TapAdapterPointer p_Adapter,
  136. const PARP_PACKET src,
  137. const IPADDR adapter_ip,
  138. const IPADDR ip_network,
  139. const IPADDR ip_netmask,
  140. const MACADDR mac
  141. );
  142. VOID SetMediaStatus
  143. (
  144. TapAdapterPointer p_Adapter,
  145. BOOLEAN state
  146. );
  147. VOID InjectPacketDeferred
  148. (
  149. TapAdapterPointer p_Adapter,
  150. UCHAR *packet,
  151. const unsigned int len
  152. );
  153. VOID InjectPacketNow
  154. (
  155. TapAdapterPointer p_Adapter,
  156. UCHAR *packet,
  157. const unsigned int len
  158. );
  159. // for KDEFERRED_ROUTINE and Static Driver Verifier
  160. //#include <wdm.h>
  161. //KDEFERRED_ROUTINE InjectPacketDpc;
  162. VOID InjectPacketDpc
  163. (
  164. KDPC *Dpc,
  165. PVOID DeferredContext,
  166. PVOID SystemArgument1,
  167. PVOID SystemArgument2
  168. );
  169. VOID CheckIfDhcpAndTunMode
  170. (
  171. TapAdapterPointer p_Adapter
  172. );
  173. VOID HookDispatchFunctions();
  174. #if ENABLE_NONADMIN
  175. #if defined(DDKVER_MAJOR) && DDKVER_MAJOR < 5600
  176. /*
  177. * Better solution for use on Vista DDK, but possibly not compatible with
  178. * earlier DDKs:
  179. *
  180. * Eliminate the definition of SECURITY_DESCRIPTOR (and even ZwSetSecurityObject),
  181. * and at the top of tapdrv.c change:
  182. *
  183. * #include <ndis.h>
  184. * #include <ntstrsafe.h>
  185. * #include <ntddk.h>
  186. *
  187. * To
  188. *
  189. * #include <ntifs.h>
  190. * #include <ndis.h>
  191. * #include <ntstrsafe.h>
  192. */
  193. typedef struct _SECURITY_DESCRIPTOR {
  194. unsigned char opaque[64];
  195. } SECURITY_DESCRIPTOR;
  196. NTSYSAPI
  197. NTSTATUS
  198. NTAPI
  199. ZwSetSecurityObject (
  200. IN HANDLE Handle,
  201. IN SECURITY_INFORMATION SecurityInformation,
  202. IN PSECURITY_DESCRIPTOR SecurityDescriptor);
  203. #endif
  204. VOID AllowNonAdmin (TapExtensionPointer p_Extension);
  205. #endif
  206. struct WIN2K_NDIS_MINIPORT_BLOCK
  207. {
  208. unsigned char opaque[16];
  209. UNICODE_STRING MiniportName; // how mini-port refers to us
  210. };
  211. #if PACKET_TRUNCATION_CHECK
  212. VOID IPv4PacketSizeVerify
  213. (
  214. const UCHAR *data,
  215. ULONG length,
  216. BOOLEAN tun,
  217. const char *prefix,
  218. LONG *counter
  219. );
  220. #endif
  221. #endif