VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/VBoxTAP/dhcp.h@ 1608

Last change on this file since 1608 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.9 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#pragma pack(1)
30
31//===================================================
32// How many bad DHCPREQUESTs do we receive before we
33// return a NAK?
34//
35// A bad DHCPREQUEST is defined to be one where the
36// requestor doesn't know its IP address.
37//===================================================
38
39#define BAD_DHCPREQUEST_NAK_THRESHOLD 3
40
41//==============================================
42// Maximum number of DHCP options bytes supplied
43//==============================================
44
45#define DHCP_USER_SUPPLIED_OPTIONS_BUFFER_SIZE 256
46#define DHCP_OPTIONS_BUFFER_SIZE 256
47
48//===================================
49// UDP port numbers of DHCP messages.
50//===================================
51
52#define BOOTPS_PORT 67
53#define BOOTPC_PORT 68
54
55//===========================
56// The DHCP message structure
57//===========================
58
59typedef struct {
60# define BOOTREQUEST 1
61# define BOOTREPLY 2
62 UCHAR op; /* message op */
63
64 UCHAR htype; /* hardware address type (e.g. '1' = 10Mb Ethernet) */
65 UCHAR hlen; /* hardware address length (e.g. '6' for 10Mb Ethernet) */
66 UCHAR hops; /* client sets to 0, may be used by relay agents */
67 ULONG xid; /* transaction ID, chosen by client */
68 USHORT secs; /* seconds since request process began, set by client */
69 USHORT flags;
70 ULONG ciaddr; /* client IP address, client sets if known */
71 ULONG yiaddr; /* 'your' IP address -- server's response to client */
72 ULONG siaddr; /* server IP address */
73 ULONG giaddr; /* relay agent IP address */
74 UCHAR chaddr[16]; /* client hardware address */
75 UCHAR sname[64]; /* optional server host name */
76 UCHAR file[128]; /* boot file name */
77 ULONG magic; /* must be 0x63825363 (network order) */
78} DHCP;
79
80typedef struct {
81 ETH_HEADER eth;
82 IPHDR ip;
83 UDPHDR udp;
84 DHCP dhcp;
85} DHCPPre;
86
87typedef struct {
88 DHCPPre pre;
89 UCHAR options[DHCP_OPTIONS_BUFFER_SIZE];
90} DHCPFull;
91
92typedef struct {
93 unsigned int optlen;
94 BOOLEAN overflow;
95 DHCPFull msg;
96} DHCPMsg;
97
98//===================
99// Macros for DHCPMSG
100//===================
101
102#define DHCPMSG_LEN_BASE(p) (sizeof (DHCPPre))
103#define DHCPMSG_LEN_OPT(p) ((p)->optlen)
104#define DHCPMSG_LEN_FULL(p) (DHCPMSG_LEN_BASE(p) + DHCPMSG_LEN_OPT(p))
105#define DHCPMSG_BUF(p) ((UCHAR*) &(p)->msg)
106#define DHCPMSG_OVERFLOW(p) ((p)->overflow)
107
108//========================================
109// structs to hold individual DHCP options
110//========================================
111
112typedef struct {
113 UCHAR type;
114} DHCPOPT0;
115
116typedef struct {
117 UCHAR type;
118 UCHAR len;
119 UCHAR data;
120} DHCPOPT8;
121
122typedef struct {
123 UCHAR type;
124 UCHAR len;
125 ULONG data;
126} DHCPOPT32;
127
128#pragma pack()
129
130//==================
131// DHCP Option types
132//==================
133
134#define DHCP_MSG_TYPE 53 /* message type (u8) */
135#define DHCP_PARM_REQ 55 /* parameter request list: c1 (u8), ... */
136#define DHCP_CLIENT_ID 61 /* client ID: type (u8), i1 (u8), ... */
137#define DHCP_IP 50 /* requested IP addr (u32) */
138#define DHCP_NETMASK 1 /* subnet mask (u32) */
139#define DHCP_LEASE_TIME 51 /* lease time sec (u32) */
140#define DHCP_RENEW_TIME 58 /* renewal time sec (u32) */
141#define DHCP_REBIND_TIME 59 /* rebind time sec (u32) */
142#define DHCP_SERVER_ID 54 /* server ID: IP addr (u32) */
143#define DHCP_PAD 0
144#define DHCP_END 255
145
146//====================
147// DHCP Messages types
148//====================
149
150#define DHCPDISCOVER 1
151#define DHCPOFFER 2
152#define DHCPREQUEST 3
153#define DHCPDECLINE 4
154#define DHCPACK 5
155#define DHCPNAK 6
156#define DHCPRELEASE 7
157#define DHCPINFORM 8
158
159#if DEBUG
160
161VOID
162DumpDHCP (const ETH_HEADER *eth,
163 const IPHDR *ip,
164 const UDPHDR *udp,
165 const DHCP *dhcp,
166 const int optlen);
167
168#endif
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