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
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).
11 * All other source code is Copyright (C) 2002-2005 OpenVPN Solutions LLC,
12 * and is released under the GPL version 2 (see below).
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
31 //===================================================
32 // How many bad DHCPREQUESTs do we receive before we
35 // A bad DHCPREQUEST is defined to be one where the
36 // requestor doesn't know its IP address.
37 //===================================================
39 #define BAD_DHCPREQUEST_NAK_THRESHOLD 3
41 //==============================================
42 // Maximum number of DHCP options bytes supplied
43 //==============================================
45 #define DHCP_USER_SUPPLIED_OPTIONS_BUFFER_SIZE 256
46 #define DHCP_OPTIONS_BUFFER_SIZE 256
48 //===================================
49 // UDP port numbers of DHCP messages.
50 //===================================
52 #define BOOTPS_PORT 67
53 #define BOOTPC_PORT 68
55 //===========================
56 // The DHCP message structure
57 //===========================
60 # define BOOTREQUEST 1
62 UCHAR op
; /* message op */
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 */
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) */
89 UCHAR options
[DHCP_OPTIONS_BUFFER_SIZE
];
100 //===================
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)
108 //========================================
109 // structs to hold individual DHCP options
110 //========================================
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) */
146 //====================
147 // DHCP Messages types
148 //====================
150 #define DHCPDISCOVER 1
152 #define DHCPREQUEST 3
153 #define DHCPDECLINE 4
156 #define DHCPRELEASE 7
162 DumpDHCP (const ETH_HEADER
*eth
,