VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/VBoxTAP/proto.h@ 16684

Last change on this file since 16684 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
Line 
1/*
2 * TAP-Win32 -- A kernel driver to provide virtual tap device functionality
3 * on Windows. Originally derived from the CIPE-Win32
4 * project by Damion K. Wilson, with extensive modifications by
5 * James Yonan.
6 *
7 * All source code which derives from the CIPE-Win32 project is
8 * Copyright (C) Damion K. Wilson, 2003, and is released under the
9 * GPL version 2 (see below).
10 *
11 * All other source code is Copyright (C) 2002-2005 OpenVPN Solutions LLC,
12 * and is released under the GPL version 2 (see below).
13 *
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.
17 *
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.
22 *
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
27 */
28
29//============================================================
30// MAC address, Ethernet header, and ARP
31//============================================================
32
33#pragma pack(1)
34
35#define IP_HEADER_SIZE 20
36
37typedef unsigned char MACADDR [6];
38typedef unsigned long IPADDR;
39
40//-----------------
41// Ethernet address
42//-----------------
43
44typedef struct {
45 MACADDR addr;
46} ETH_ADDR;
47
48typedef struct {
49 ETH_ADDR list[NIC_MAX_MCAST_LIST];
50} MC_LIST;
51
52//----------------
53// Ethernet header
54//----------------
55
56typedef struct
57{
58 MACADDR dest; /* destination eth addr */
59 MACADDR src; /* source ether addr */
60
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;
65
66//----------------
67// ARP packet
68//----------------
69
70typedef struct
71 {
72 MACADDR m_MAC_Destination; // Reverse these two
73 MACADDR m_MAC_Source; // to answer ARP requests
74 USHORT m_Proto; // 0x0806
75
76# define MAC_ADDR_TYPE 0x0001
77 USHORT m_MAC_AddressType; // 0x0001
78
79 USHORT m_PROTO_AddressType; // 0x0800
80 UCHAR m_MAC_AddressSize; // 0x06
81 UCHAR m_PROTO_AddressSize; // 0x04
82
83# define ARP_REQUEST 0x0001
84# define ARP_REPLY 0x0002
85 USHORT m_ARP_Operation; // 0x0001 for ARP request, 0x0002 for ARP reply
86
87 MACADDR m_ARP_MAC_Source;
88 IPADDR m_ARP_IP_Source;
89 MACADDR m_ARP_MAC_Destination;
90 IPADDR m_ARP_IP_Destination;
91 }
92ARP_PACKET, *PARP_PACKET;
93
94//----------
95// IP Header
96//----------
97
98typedef struct {
99# define IPH_GET_VER(v) (((v) >> 4) & 0x0F)
100# define IPH_GET_LEN(v) (((v) & 0x0F) << 2)
101 UCHAR version_len;
102
103 UCHAR tos;
104 USHORT tot_len;
105 USHORT id;
106
107# define IP_OFFMASK 0x1fff
108 USHORT frag_off;
109
110 UCHAR ttl;
111
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;
117
118 USHORT check;
119 ULONG saddr;
120 ULONG daddr;
121 /* The options start here. */
122} IPHDR;
123
124//-----------
125// UDP header
126//-----------
127
128typedef struct {
129 USHORT source;
130 USHORT dest;
131 USHORT len;
132 USHORT check;
133} UDPHDR;
134
135//--------------------------
136// TCP header, per RFC 793.
137//--------------------------
138
139typedef struct {
140 USHORT source; /* source port */
141 USHORT dest; /* destination port */
142 ULONG seq; /* sequence number */
143 ULONG ack_seq; /* acknowledgement number */
144
145# define TCPH_GET_DOFF(d) (((d) & 0xF0) >> 2)
146 UCHAR doff_res;
147
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;
157
158 USHORT window;
159 USHORT check;
160 USHORT urg_ptr;
161} TCPHDR;
162
163#define TCPOPT_EOL 0
164#define TCPOPT_NOP 1
165#define TCPOPT_MAXSEG 2
166#define TCPOLEN_MAXSEG 4
167
168#pragma pack()
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette