Upgrade to OpenVPN 2.1.0
[tomato.git] / release / src / router / openvpn / tap-win32 / tmp / proto.h
blob6c53f401af0917556fd1e11bdbd7e8e83d8569fd
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 //============================================================
30 // MAC address, Ethernet header, and ARP
31 //============================================================
33 #pragma pack(1)
35 #define IP_HEADER_SIZE 20
37 typedef unsigned char MACADDR [6];
38 typedef unsigned long IPADDR;
40 //-----------------
41 // Ethernet address
42 //-----------------
44 typedef struct {
45 MACADDR addr;
46 } ETH_ADDR;
48 typedef struct {
49 ETH_ADDR list[NIC_MAX_MCAST_LIST];
50 } MC_LIST;
52 //----------------
53 // Ethernet header
54 //----------------
56 typedef struct
58 MACADDR dest; /* destination eth addr */
59 MACADDR src; /* source ether addr */
61 # define ETH_P_IP 0x0800 /* IPv4 protocol */
62 # define ETH_P_ARP 0x0806 /* ARP protocol */
63 USHORT proto; /* packet type ID field */
64 } ETH_HEADER, *PETH_HEADER;
66 //----------------
67 // ARP packet
68 //----------------
70 typedef struct
72 MACADDR m_MAC_Destination; // Reverse these two
73 MACADDR m_MAC_Source; // to answer ARP requests
74 USHORT m_Proto; // 0x0806
76 # define MAC_ADDR_TYPE 0x0001
77 USHORT m_MAC_AddressType; // 0x0001
79 USHORT m_PROTO_AddressType; // 0x0800
80 UCHAR m_MAC_AddressSize; // 0x06
81 UCHAR m_PROTO_AddressSize; // 0x04
83 # define ARP_REQUEST 0x0001
84 # define ARP_REPLY 0x0002
85 USHORT m_ARP_Operation; // 0x0001 for ARP request, 0x0002 for ARP reply
87 MACADDR m_ARP_MAC_Source;
88 IPADDR m_ARP_IP_Source;
89 MACADDR m_ARP_MAC_Destination;
90 IPADDR m_ARP_IP_Destination;
92 ARP_PACKET, *PARP_PACKET;
94 //----------
95 // IP Header
96 //----------
98 typedef struct {
99 # define IPH_GET_VER(v) (((v) >> 4) & 0x0F)
100 # define IPH_GET_LEN(v) (((v) & 0x0F) << 2)
101 UCHAR version_len;
103 UCHAR tos;
104 USHORT tot_len;
105 USHORT id;
107 # define IP_OFFMASK 0x1fff
108 USHORT frag_off;
110 UCHAR ttl;
112 # define IPPROTO_UDP 17 /* UDP protocol */
113 # define IPPROTO_TCP 6 /* TCP protocol */
114 # define IPPROTO_ICMP 1 /* ICMP protocol */
115 # define IPPROTO_IGMP 2 /* IGMP protocol */
116 UCHAR protocol;
118 USHORT check;
119 ULONG saddr;
120 ULONG daddr;
121 /* The options start here. */
122 } IPHDR;
124 //-----------
125 // UDP header
126 //-----------
128 typedef struct {
129 USHORT source;
130 USHORT dest;
131 USHORT len;
132 USHORT check;
133 } UDPHDR;
135 //--------------------------
136 // TCP header, per RFC 793.
137 //--------------------------
139 typedef struct {
140 USHORT source; /* source port */
141 USHORT dest; /* destination port */
142 ULONG seq; /* sequence number */
143 ULONG ack_seq; /* acknowledgement number */
145 # define TCPH_GET_DOFF(d) (((d) & 0xF0) >> 2)
146 UCHAR doff_res;
148 # define TCPH_FIN_MASK (1<<0)
149 # define TCPH_SYN_MASK (1<<1)
150 # define TCPH_RST_MASK (1<<2)
151 # define TCPH_PSH_MASK (1<<3)
152 # define TCPH_ACK_MASK (1<<4)
153 # define TCPH_URG_MASK (1<<5)
154 # define TCPH_ECE_MASK (1<<6)
155 # define TCPH_CWR_MASK (1<<7)
156 UCHAR flags;
158 USHORT window;
159 USHORT check;
160 USHORT urg_ptr;
161 } TCPHDR;
163 #define TCPOPT_EOL 0
164 #define TCPOPT_NOP 1
165 #define TCPOPT_MAXSEG 2
166 #define TCPOLEN_MAXSEG 4
168 #pragma pack()