Get rid of "Interrupted service call" messages in syslog
[tomato.git] / release / src / router / openvpn / tap-win32 / dhcp.h
blob8f40f540048e5bffac0a36b09e329ab63b923735
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 #pragma pack(1)
31 //===================================================
32 // How many bad DHCPREQUESTs do we receive before we
33 // return a NAK?
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 //===========================
59 typedef struct {
60 # define BOOTREQUEST 1
61 # define BOOTREPLY 2
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 */
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;
80 typedef struct {
81 ETH_HEADER eth;
82 IPHDR ip;
83 UDPHDR udp;
84 DHCP dhcp;
85 } DHCPPre;
87 typedef struct {
88 DHCPPre pre;
89 UCHAR options[DHCP_OPTIONS_BUFFER_SIZE];
90 } DHCPFull;
92 typedef struct {
93 unsigned int optlen;
94 BOOLEAN overflow;
95 DHCPFull msg;
96 } DHCPMsg;
98 //===================
99 // Macros for DHCPMSG
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 //========================================
112 typedef struct {
113 UCHAR type;
114 } DHCPOPT0;
116 typedef struct {
117 UCHAR type;
118 UCHAR len;
119 UCHAR data;
120 } DHCPOPT8;
122 typedef struct {
123 UCHAR type;
124 UCHAR len;
125 ULONG data;
126 } DHCPOPT32;
128 #pragma pack()
130 //==================
131 // DHCP Option types
132 //==================
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
146 //====================
147 // DHCP Messages types
148 //====================
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
159 #if DBG
161 VOID
162 DumpDHCP (const ETH_HEADER *eth,
163 const IPHDR *ip,
164 const UDPHDR *udp,
165 const DHCP *dhcp,
166 const int optlen);
168 #endif