BadVPN – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /**
2 * @file dhcp_proto.h
3 * @author Ambroz Bizjak <ambrop7@gmail.com>
4 *
5 * @section LICENSE
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of the author nor the
15 * names of its contributors may be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * @section DESCRIPTION
30 *
31 * Definitions for the DHCP protocol.
32 */
33  
34 #ifndef BADVPN_MISC_DHCP_PROTO_H
35 #define BADVPN_MISC_DHCP_PROTO_H
36  
37 #include <stdint.h>
38  
39 #include <misc/packed.h>
40  
41 #define DHCP_OP_BOOTREQUEST 1
42 #define DHCP_OP_BOOTREPLY 2
43  
44 #define DHCP_HARDWARE_ADDRESS_TYPE_ETHERNET 1
45  
46 #define DHCP_MAGIC 0x63825363
47  
48 #define DHCP_OPTION_PAD 0
49 #define DHCP_OPTION_END 255
50  
51 #define DHCP_OPTION_SUBNET_MASK 1
52 #define DHCP_OPTION_ROUTER 3
53 #define DHCP_OPTION_DOMAIN_NAME_SERVER 6
54 #define DHCP_OPTION_HOST_NAME 12
55 #define DHCP_OPTION_REQUESTED_IP_ADDRESS 50
56 #define DHCP_OPTION_IP_ADDRESS_LEASE_TIME 51
57 #define DHCP_OPTION_DHCP_MESSAGE_TYPE 53
58 #define DHCP_OPTION_DHCP_SERVER_IDENTIFIER 54
59 #define DHCP_OPTION_PARAMETER_REQUEST_LIST 55
60 #define DHCP_OPTION_MAXIMUM_MESSAGE_SIZE 57
61 #define DHCP_OPTION_RENEWAL_TIME_VALUE 58
62 #define DHCP_OPTION_REBINDING_TIME_VALUE 59
63 #define DHCP_OPTION_VENDOR_CLASS_IDENTIFIER 60
64 #define DHCP_OPTION_CLIENT_IDENTIFIER 61
65  
66 #define DHCP_MESSAGE_TYPE_DISCOVER 1
67 #define DHCP_MESSAGE_TYPE_OFFER 2
68 #define DHCP_MESSAGE_TYPE_REQUEST 3
69 #define DHCP_MESSAGE_TYPE_DECLINE 4
70 #define DHCP_MESSAGE_TYPE_ACK 5
71 #define DHCP_MESSAGE_TYPE_NAK 6
72 #define DHCP_MESSAGE_TYPE_RELEASE 7
73  
74 B_START_PACKED
75 struct dhcp_header {
76 uint8_t op;
77 uint8_t htype;
78 uint8_t hlen;
79 uint8_t hops;
80 uint32_t xid;
81 uint16_t secs;
82 uint16_t flags;
83 uint32_t ciaddr;
84 uint32_t yiaddr;
85 uint32_t siaddr;
86 uint32_t giaddr;
87 uint8_t chaddr[16];
88 uint8_t sname[64];
89 uint8_t file[128];
90 uint32_t magic;
91 } B_PACKED;
92 B_END_PACKED
93  
94 B_START_PACKED
95 struct dhcp_option_header {
96 uint8_t type;
97 uint8_t len;
98 } B_PACKED;
99 B_END_PACKED
100  
101 B_START_PACKED
102 struct dhcp_option_dhcp_message_type {
103 uint8_t type;
104 } B_PACKED;
105 B_END_PACKED
106  
107 B_START_PACKED
108 struct dhcp_option_maximum_message_size {
109 uint16_t size;
110 } B_PACKED;
111 B_END_PACKED
112  
113 B_START_PACKED
114 struct dhcp_option_dhcp_server_identifier {
115 uint32_t id;
116 } B_PACKED;
117 B_END_PACKED
118  
119 B_START_PACKED
120 struct dhcp_option_time {
121 uint32_t time;
122 } B_PACKED;
123 B_END_PACKED
124  
125 B_START_PACKED
126 struct dhcp_option_addr {
127 uint32_t addr;
128 } B_PACKED;
129 B_END_PACKED
130  
131 #endif