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
27 //===================================================
28 // How many bad DHCPREQUESTs do we receive before we
31 // A bad DHCPREQUEST is defined to be one where the
32 // requestor doesn't know its IP address.
33 //===================================================
35 #define BAD_DHCPREQUEST_NAK_THRESHOLD 3
37 //==============================================
38 // Maximum number of DHCP options bytes supplied
39 //==============================================
41 #define DHCP_USER_SUPPLIED_OPTIONS_BUFFER_SIZE 256
42 #define DHCP_OPTIONS_BUFFER_SIZE 256
44 //===================================
45 // UDP port numbers of DHCP messages.
46 //===================================
48 #define BOOTPS_PORT 67
49 #define BOOTPC_PORT 68
51 //===========================
52 // The DHCP message structure
53 //===========================
56 # define BOOTREQUEST 1
58 UCHAR op
; /* message op */
60 UCHAR htype
; /* hardware address type (e.g. '1' = 10Mb Ethernet) */
61 UCHAR hlen
; /* hardware address length (e.g. '6' for 10Mb Ethernet) */
62 UCHAR hops
; /* client sets to 0, may be used by relay agents */
63 ULONG xid
; /* transaction ID, chosen by client */
64 USHORT secs
; /* seconds since request process began, set by client */
66 ULONG ciaddr
; /* client IP address, client sets if known */
67 ULONG yiaddr
; /* 'your' IP address -- server's response to client */
68 ULONG siaddr
; /* server IP address */
69 ULONG giaddr
; /* relay agent IP address */
70 UCHAR chaddr
[16]; /* client hardware address */
71 UCHAR sname
[64]; /* optional server host name */
72 UCHAR file
[128]; /* boot file name */
73 ULONG magic
; /* must be 0x63825363 (network order) */
85 UCHAR options
[DHCP_OPTIONS_BUFFER_SIZE
];
98 #define DHCPMSG_LEN_BASE(p) (sizeof (DHCPPre))
99 #define DHCPMSG_LEN_OPT(p) ((p)->optlen)
100 #define DHCPMSG_LEN_FULL(p) (DHCPMSG_LEN_BASE(p) + DHCPMSG_LEN_OPT(p))
101 #define DHCPMSG_BUF(p) ((UCHAR*) &(p)->msg)
102 #define DHCPMSG_OVERFLOW(p) ((p)->overflow)
104 //========================================
105 // structs to hold individual DHCP options
106 //========================================
130 #define DHCP_MSG_TYPE 53 /* message type (u8) */
131 #define DHCP_PARM_REQ 55 /* parameter request list: c1 (u8), ... */
132 #define DHCP_CLIENT_ID 61 /* client ID: type (u8), i1 (u8), ... */
133 #define DHCP_IP 50 /* requested IP addr (u32) */
134 #define DHCP_NETMASK 1 /* subnet mask (u32) */
135 #define DHCP_LEASE_TIME 51 /* lease time sec (u32) */
136 #define DHCP_RENEW_TIME 58 /* renewal time sec (u32) */
137 #define DHCP_REBIND_TIME 59 /* rebind time sec (u32) */
138 #define DHCP_SERVER_ID 54 /* server ID: IP addr (u32) */
142 //====================
143 // DHCP Messages types
144 //====================
146 #define DHCPDISCOVER 1
148 #define DHCPREQUEST 3
149 #define DHCPDECLINE 4
152 #define DHCPRELEASE 7
158 DumpDHCP (const ETH_HEADER
*eth
,