Get rid of "Interrupted service call" messages in syslog
[tomato.git] / release / src / router / openvpn / tap-win32 / types.h
blob4adee6a6f3992b60fd3d46334c1da9fd6b2393e5
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), however due
9 * to the extra costs of supporting Windows Vista, OpenVPN Solutions
10 * LLC reserves the right to change the terms of the TAP-Win32/TAP-Win64
11 * license for versions 9.1 and higher prior to the official release of
12 * OpenVPN 2.1.
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License version 2
16 * as published by the Free Software Foundation.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program (see the file COPYING included with this
25 * distribution); if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #ifndef TAP_TYPES_DEFINED
30 #define TAP_TYPES_DEFINED
32 typedef struct _Queue
34 ULONG base;
35 ULONG size;
36 ULONG capacity;
37 ULONG max_size;
38 PVOID data[];
39 } Queue;
41 typedef struct _TapAdapter;
42 typedef struct _TapPacket;
44 typedef union _TapAdapterQuery
46 NDIS_HARDWARE_STATUS m_HardwareStatus;
47 NDIS_MEDIUM m_Medium;
48 NDIS_PHYSICAL_MEDIUM m_PhysicalMedium;
49 UCHAR m_MacAddress [6];
50 UCHAR m_Buffer [256];
51 ULONG m_Long;
52 USHORT m_Short;
53 UCHAR m_Byte;
55 TapAdapterQuery, *TapAdapterQueryPointer;
57 typedef struct _TapExtension
59 // TAP device object and packet queues
60 Queue *m_PacketQueue, *m_IrpQueue;
61 PDEVICE_OBJECT m_TapDevice;
62 NDIS_HANDLE m_TapDeviceHandle;
63 ULONG m_TapOpens;
65 // Used to lock packet queues
66 NDIS_SPIN_LOCK m_QueueLock;
67 BOOLEAN m_AllocatedSpinlocks;
69 // Used to bracket open/close
70 // state changes.
71 MUTEX m_OpenCloseMutex;
73 // True if device has been permanently halted
74 BOOLEAN m_Halt;
76 // TAP device name
77 unsigned char *m_TapName;
78 UNICODE_STRING m_UnicodeLinkName;
79 BOOLEAN m_CreatedUnicodeLinkName;
81 // Used for device status ioctl only
82 const char *m_LastErrorFilename;
83 int m_LastErrorLineNumber;
84 LONG m_NumTapOpens;
86 // Flags
87 BOOLEAN m_TapIsRunning;
88 BOOLEAN m_CalledTapDeviceFreeResources;
90 // DPC queue for deferred packet injection
91 BOOLEAN m_InjectDpcInitialized;
92 KDPC m_InjectDpc;
93 NDIS_SPIN_LOCK m_InjectLock;
94 Queue *m_InjectQueue;
96 TapExtension, *TapExtensionPointer;
98 typedef struct _TapPacket
100 # define TAP_PACKET_SIZE(data_size) (sizeof (TapPacket) + (data_size))
101 # define TP_TUN 0x80000000
102 # define TP_SIZE_MASK (~TP_TUN)
103 ULONG m_SizeFlags;
104 UCHAR m_Data []; // m_Data must be the last struct member
106 TapPacket, *TapPacketPointer;
108 typedef struct _InjectPacket
110 # define INJECT_PACKET_SIZE(data_size) (sizeof (InjectPacket) + (data_size))
111 # define INJECT_PACKET_FREE(ib) NdisFreeMemory ((ib), INJECT_PACKET_SIZE ((ib)->m_Size), 0)
112 ULONG m_Size;
113 UCHAR m_Data []; // m_Data must be the last struct member
115 InjectPacket, *InjectPacketPointer;
117 typedef struct _TapAdapter
119 # define NAME(a) ((a)->m_NameAnsi.Buffer)
120 ANSI_STRING m_NameAnsi;
121 MACADDR m_MAC;
122 BOOLEAN m_InterfaceIsRunning;
123 NDIS_HANDLE m_MiniportAdapterHandle;
124 LONG m_Rx, m_Tx, m_RxErr, m_TxErr;
125 #if PACKET_TRUNCATION_CHECK
126 LONG m_RxTrunc, m_TxTrunc;
127 #endif
128 NDIS_MEDIUM m_Medium;
129 ULONG m_Lookahead;
130 ULONG m_MTU;
132 // TRUE if adapter should always be
133 // "connected" even when device node
134 // is not open by a userspace process.
135 BOOLEAN m_MediaStateAlwaysConnected;
137 // TRUE if device is "connected"
138 BOOLEAN m_MediaState;
140 // Adapter power state
141 char m_DeviceState;
143 // Info for point-to-point mode
144 BOOLEAN m_tun;
145 IPADDR m_localIP;
146 IPADDR m_remoteNetwork;
147 IPADDR m_remoteNetmask;
148 ETH_HEADER m_TapToUser;
149 ETH_HEADER m_UserToTap;
150 MACADDR m_MAC_Broadcast;
152 // Used for DHCP server masquerade
153 BOOLEAN m_dhcp_enabled;
154 IPADDR m_dhcp_addr;
155 ULONG m_dhcp_netmask;
156 IPADDR m_dhcp_server_ip;
157 BOOLEAN m_dhcp_server_arp;
158 MACADDR m_dhcp_server_mac;
159 ULONG m_dhcp_lease_time;
160 UCHAR m_dhcp_user_supplied_options_buffer[DHCP_USER_SUPPLIED_OPTIONS_BUFFER_SIZE];
161 ULONG m_dhcp_user_supplied_options_buffer_len;
162 BOOLEAN m_dhcp_received_discover;
163 ULONG m_dhcp_bad_requests;
165 // Help to tear down the adapter by keeping
166 // some state information on allocated
167 // resources.
168 BOOLEAN m_CalledAdapterFreeResources;
169 BOOLEAN m_RegisteredAdapterShutdownHandler;
171 // Multicast list info
172 NDIS_SPIN_LOCK m_MCLock;
173 BOOLEAN m_MCLockAllocated;
174 ULONG m_MCListSize;
175 MC_LIST m_MCList;
177 // Information on the TAP device
178 TapExtension m_Extension;
179 } TapAdapter, *TapAdapterPointer;
181 #endif