Upgrade to OpenVPN 2.1.0
[tomato.git] / release / src / router / openvpn / tap-win32 / prototypes.h
blobff7733aa4da888d7a97d5a1bea151dd76fd8e320
1 /*
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
28 NTSTATUS DriverEntry
30 IN PDRIVER_OBJECT p_DriverObject,
31 IN PUNICODE_STRING p_RegistryPath
34 VOID TapDriverUnload
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,
44 IN UINT p_MediaCount,
45 IN NDIS_HANDLE p_AdapterHandle,
46 IN NDIS_HANDLE p_ConfigurationHandle
49 VOID AdapterHalt
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,
68 IN NDIS_OID p_OID,
69 IN PVOID p_Buffer,
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,
78 IN NDIS_OID p_OID,
79 IN PVOID p_Buffer,
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,
89 IN UINT p_Flags
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,
98 IN UINT p_Offset,
99 IN UINT p_ToTransfer
102 NTSTATUS TapDeviceHook
104 IN PDEVICE_OBJECT p_DeviceObject,
105 IN PIRP p_IRP
108 NDIS_STATUS CreateTapDevice
110 TapExtensionPointer p_Extension,
111 const char *p_Name
114 VOID DestroyTapDevice
116 TapExtensionPointer p_Extension
119 VOID TapDeviceFreeResources
121 TapExtensionPointer p_Extension
124 NTSTATUS CompleteIRP
126 IN PIRP p_IRP,
127 IN TapPacketPointer p_PacketBuffer,
128 IN CCHAR PriorityBoost
131 VOID CancelIRPCallback
133 IN PDEVICE_OBJECT p_DeviceObject,
134 IN PIRP p_IRP
137 VOID CancelIRP
139 TapExtensionPointer p_Extension,
140 IN PIRP p_IRP,
141 BOOLEAN callback
144 VOID FlushQueues
146 TapExtensionPointer p_Extension
149 VOID ResetTapAdapterState
151 TapAdapterPointer p_Adapter
154 BOOLEAN ProcessARP
156 TapAdapterPointer p_Adapter,
157 const PARP_PACKET src,
158 const IPADDR adapter_ip,
159 const IPADDR ip_network,
160 const IPADDR ip_netmask,
161 const MACADDR mac
164 VOID SetMediaStatus
166 TapAdapterPointer p_Adapter,
167 BOOLEAN state
170 VOID InjectPacketDeferred
172 TapAdapterPointer p_Adapter,
173 UCHAR *packet,
174 const unsigned int len
177 VOID InjectPacketNow
179 TapAdapterPointer p_Adapter,
180 UCHAR *packet,
181 const unsigned int len
184 // for KDEFERRED_ROUTINE and Static Driver Verifier
185 //#include <wdm.h>
186 //KDEFERRED_ROUTINE InjectPacketDpc;
188 VOID InjectPacketDpc
190 KDPC *Dpc,
191 PVOID DeferredContext,
192 PVOID SystemArgument1,
193 PVOID SystemArgument2
196 VOID CheckIfDhcpAndTunMode
198 TapAdapterPointer p_Adapter
201 VOID HookDispatchFunctions();
203 #if ENABLE_NONADMIN
205 #if DDKVER_MAJOR < 5600
207 * Better solution for use on Vista DDK, but possibly not compatible with
208 * earlier DDKs:
210 * Eliminate the definition of SECURITY_DESCRIPTOR (and even ZwSetSecurityObject),
211 * and at the top of tapdrv.c change:
213 * #include <ndis.h>
214 * #include <ntstrsafe.h>
215 * #include <ntddk.h>
217 * To
219 * #include <ntifs.h>
220 * #include <ndis.h>
221 * #include <ntstrsafe.h>
223 typedef struct _SECURITY_DESCRIPTOR {
224 unsigned char opaque[64];
225 } SECURITY_DESCRIPTOR;
227 NTSYSAPI
228 NTSTATUS
229 NTAPI
230 ZwSetSecurityObject (
231 IN HANDLE Handle,
232 IN SECURITY_INFORMATION SecurityInformation,
233 IN PSECURITY_DESCRIPTOR SecurityDescriptor);
235 #endif
237 VOID AllowNonAdmin (TapExtensionPointer p_Extension);
239 #endif
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
251 const UCHAR *data,
252 ULONG length,
253 BOOLEAN tun,
254 const char *prefix,
255 LONG *counter
258 #endif
260 #endif