2 * TAP-Win32/TAP-Win64 -- A kernel driver to provide virtual tap
3 * device functionality on Windows.
5 * This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
7 * This source code is Copyright (C) 2002-2009 OpenVPN Technologies, Inc.,
8 * and is released under the GPL version 2 (see below).
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.
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.
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
25 #ifndef TAP_PROTOTYPES_DEFINED
26 #define TAP_PROTOTYPES_DEFINED
30 IN PDRIVER_OBJECT p_DriverObject
,
31 IN PUNICODE_STRING p_RegistryPath
36 IN PDRIVER_OBJECT p_DriverObject
39 NDIS_STATUS AdapterCreate
41 OUT PNDIS_STATUS p_ErrorStatus
,
42 OUT PUINT p_MediaIndex
,
43 IN PNDIS_MEDIUM p_Media
,
45 IN NDIS_HANDLE p_AdapterHandle
,
46 IN NDIS_HANDLE p_ConfigurationHandle
51 IN NDIS_HANDLE p_AdapterContext
54 VOID AdapterFreeResources
56 TapAdapterPointer p_Adapter
59 NDIS_STATUS AdapterReset
61 OUT PBOOLEAN p_AddressingReset
,
62 IN NDIS_HANDLE p_AdapterContext
65 NDIS_STATUS AdapterQuery
67 IN NDIS_HANDLE p_AdapterContext
,
70 IN ULONG p_BufferLength
,
71 OUT PULONG p_BytesWritten
,
72 OUT PULONG p_BytesNeeded
75 NDIS_STATUS AdapterModify
77 IN NDIS_HANDLE p_AdapterContext
,
80 IN ULONG p_BufferLength
,
81 OUT PULONG p_BytesRead
,
82 OUT PULONG p_BytesNeeded
85 NDIS_STATUS AdapterTransmit
87 IN NDIS_HANDLE p_AdapterContext
,
88 IN PNDIS_PACKET p_Packet
,
92 NDIS_STATUS AdapterReceive
94 OUT PNDIS_PACKET p_Packet
,
95 OUT PUINT p_Transferred
,
96 IN NDIS_HANDLE p_AdapterContext
,
97 IN NDIS_HANDLE p_ReceiveContext
,
102 NTSTATUS TapDeviceHook
104 IN PDEVICE_OBJECT p_DeviceObject
,
108 NDIS_STATUS CreateTapDevice
110 TapExtensionPointer p_Extension
,
114 VOID DestroyTapDevice
116 TapExtensionPointer p_Extension
119 VOID TapDeviceFreeResources
121 TapExtensionPointer p_Extension
127 IN TapPacketPointer p_PacketBuffer
,
128 IN CCHAR PriorityBoost
131 VOID CancelIRPCallback
133 IN PDEVICE_OBJECT p_DeviceObject
,
139 TapExtensionPointer p_Extension
,
146 TapExtensionPointer p_Extension
149 VOID ResetTapAdapterState
151 TapAdapterPointer p_Adapter
156 TapAdapterPointer p_Adapter
,
157 const PARP_PACKET src
,
158 const IPADDR adapter_ip
,
159 const IPADDR ip_network
,
160 const IPADDR ip_netmask
,
166 TapAdapterPointer p_Adapter
,
170 VOID InjectPacketDeferred
172 TapAdapterPointer p_Adapter
,
174 const unsigned int len
179 TapAdapterPointer p_Adapter
,
181 const unsigned int len
184 // for KDEFERRED_ROUTINE and Static Driver Verifier
186 //KDEFERRED_ROUTINE InjectPacketDpc;
191 PVOID DeferredContext
,
192 PVOID SystemArgument1
,
193 PVOID SystemArgument2
196 VOID CheckIfDhcpAndTunMode
198 TapAdapterPointer p_Adapter
201 VOID
HookDispatchFunctions();
205 #if DDKVER_MAJOR < 5600
207 * Better solution for use on Vista DDK, but possibly not compatible with
210 * Eliminate the definition of SECURITY_DESCRIPTOR (and even ZwSetSecurityObject),
211 * and at the top of tapdrv.c change:
214 * #include <ntstrsafe.h>
221 * #include <ntstrsafe.h>
223 typedef struct _SECURITY_DESCRIPTOR
{
224 unsigned char opaque
[64];
225 } SECURITY_DESCRIPTOR
;
230 ZwSetSecurityObject (
232 IN SECURITY_INFORMATION SecurityInformation
,
233 IN PSECURITY_DESCRIPTOR SecurityDescriptor
);
237 VOID
AllowNonAdmin (TapExtensionPointer p_Extension
);
241 struct WIN2K_NDIS_MINIPORT_BLOCK
243 unsigned char opaque
[16];
244 UNICODE_STRING MiniportName
; // how mini-port refers to us
247 #if PACKET_TRUNCATION_CHECK
249 VOID IPv4PacketSizeVerify