xref: /freebsd/contrib/wpa/src/common/dhcp.h (revision ce6a89e27cd190313be39bb479880aeda4778436)
1 /*
2  * DHCP definitions
3  * Copyright (c) 2014-2017, Qualcomm Atheros, Inc.
4  *
5  * This software may be distributed under the terms of the BSD license.
6  * See README for more details.
7  */
8 
9 #ifndef DHCP_H
10 #define DHCP_H
11 
12 /*
13  * Translate Linux to FreeBSD
14  */
15 #define iphdr		ip
16 #define ihl		ip_hl
17 #define verson		ip_v
18 #define tos		ip_tos
19 #define tot_len		ip_len
20 #define id		ip_id
21 #define frag_off	ip_off
22 #define ttl		ip_ttl
23 #define protocol	ip_p
24 #define check		ip_sum
25 #define saddr		ip_src
26 #define daddr		ip_dst
27 
28 #include <netinet/ip.h>
29 #if __FAVOR_BSD
30 #include <netinet/udp.h>
31 #else
32 #define __FAVOR_BSD 1
33 #include <netinet/udp.h>
34 #undef __FAVOR_BSD
35 #endif
36 
37 #define DHCP_SERVER_PORT 67
38 #define DHCP_CLIENT_PORT 68
39 
40 struct dhcp_data {
41 	u8 op;
42 	u8 htype;
43 	u8 hlen;
44 	u8 hops;
45 	be32 xid;
46 	be16 secs;
47 	be16 flags;
48 	be32 client_ip;
49 	be32 your_ip;
50 	be32 server_ip;
51 	be32 relay_ip;
52 	u8 hw_addr[16];
53 	u8 serv_name[64];
54 	u8 boot_file[128];
55 } STRUCT_PACKED;
56 
57 struct bootp_pkt {
58 	struct iphdr iph;
59 	struct udphdr udph;
60 	u8 op;
61 	u8 htype;
62 	u8 hlen;
63 	u8 hops;
64 	be32 xid;
65 	be16 secs;
66 	be16 flags;
67 	be32 client_ip;
68 	be32 your_ip;
69 	be32 server_ip;
70 	be32 relay_ip;
71 	u8 hw_addr[16];
72 	u8 serv_name[64];
73 	u8 boot_file[128];
74 	u8 exten[312];
75 } STRUCT_PACKED;
76 
77 #define DHCP_MAGIC 0x63825363
78 
79 /*
80  * IANA DHCP/BOOTP registry
81  * http://www.iana.org/assignments/bootp-dhcp-parameters/bootp-dhcp-parameters.xhtml
82 */
83 enum dhcp_options {
84 	DHCP_OPT_PAD = 0,
85 	DHCP_OPT_SUBNET_MASK = 1,
86 	DHCP_OPT_TIME_OFFSET = 2,
87 	DHCP_OPT_ROUTER = 3,
88 	DHCP_OPT_TIME_SERVER = 4,
89 	DHCP_OPT_NAME_SERVER = 5,
90 	DHCP_OPT_DOMAIN_NAME_SERVER = 6,
91 	DHCP_OPT_LOG_SERVER = 7,
92 	DHCP_OPT_QUOTES_SERVER = 8,
93 	DHCP_OPT_LPR_SERVER = 9,
94 	DHCP_OPT_IMPRESS_SERVER = 10,
95 	DHCP_OPT_RLP_SERVER = 11,
96 	DHCP_OPT_HOSTNAME = 12,
97 	DHCP_OPT_BOOT_FILE_SIZE = 13,
98 	DHCP_OPT_MERIT_DUMP_FILE = 14,
99 	DHCP_OPT_DOMAIN_NAME = 15,
100 	DHCP_OPT_SWAP_SERVER = 16,
101 	DHCP_OPT_ROOT_PATH = 17,
102 	DHCP_OPT_EXTENSION_PATH = 18,
103 	DHCP_OPT_FORWARD = 19,
104 	DHCP_OPT_SRC_RTE = 20,
105 	DHCP_OPT_POLICY_FILTER = 21,
106 	DHCP_OPT_MAX_DG_ASSEMBLY = 22,
107 	DHCP_OPT_DEFAULT_IP_TTL = 23,
108 	DHCP_OPT_MTU_TIMEOUT = 24,
109 	DHCP_OPT_MTU_PLATEAU = 25,
110 	DHCP_OPT_MTU_INTERFACE = 26,
111 	DHCP_OPT_ALL_SUBNETS_LOCAL = 27,
112 	DHCP_OPT_BROADCAST_ADDRESS = 28,
113 	DHCP_OPT_MASK_DISCOVERY = 29,
114 	DHCP_OPT_MASK_SUPPLIER = 30,
115 	DHCP_OPT_ROUTER_DISCOVERY = 31,
116 	DHCP_OPT_ROUTER_SOLICITATION_ADDRESS = 32,
117 	DHCP_OPT_STATIC_ROUTE = 33,
118 	DHCP_OPT_TRAILERS = 34,
119 	DHCP_OPT_ARP_TIMEOUT = 35,
120 	DHCP_OPT_ETHERNET = 36,
121 	DHCP_OPT_TCP_DEFAULT_TTL = 37,
122 	DHCP_OPT_TCP_KEEPALIVE_INTERVAL = 38,
123 	DHCP_OPT_TCP_KEEPALIVE_GARBAGE = 39,
124 	DHCP_OPT_NIS_DOMAIN = 40,
125 	DHCP_OPT_NIS_SERVERS = 41,
126 	DHCP_OPT_NTP_SERVERS = 42,
127 	DHCP_OPT_VENDOR_SPECIFIC = 43,
128 	DHCP_OPT_NETBIOS_NAME_SERVER = 44,
129 	DHCP_OPT_NETBIOS_DISTRIBUTION_SERVER = 45,
130 	DHCP_OPT_NETBIOS_NODE_TYPE = 46,
131 	DHCP_OPT_NETBIOS_SCOPE = 47,
132 	DHCP_OPT_FONT_SERVER = 48,
133 	DHCP_OPT_DISPLAY_MANAGER = 49,
134 	DHCP_OPT_REQUESTED_IP_ADDRESS = 50,
135 	DHCP_OPT_IP_ADDRESS_LEASE_TIME = 51,
136 	DHCP_OPT_OVERLOAD = 52,
137 	DHCP_OPT_MSG_TYPE = 53,
138 	DHCP_OPT_SERVER_ID = 54,
139 	DHCP_OPT_PARAMETER_REQ_LIST = 55,
140 	DHCP_OPT_MESSAGE = 56,
141 	DHCP_OPT_MAX_MESSAGE_SIZE = 57,
142 	DHCP_OPT_RENEWAL_TIME = 58,
143 	DHCP_OPT_REBINDING_TIME = 59,
144 	DHCP_OPT_VENDOR_CLASS_ID = 60,
145 	DHCP_OPT_CLIENT_ID = 61,
146 	DHCP_OPT_NETWARE_IP_DOMAIN = 62,
147 	DHCP_OPT_NETWARE_IP_OPTION = 63,
148 	DHCP_OPT_NIS_V3_DOMAIN = 64,
149 	DHCP_OPT_NIS_V3_SERVERS = 65,
150 	DHCP_OPT_TFTP_SERVER_NAME = 66,
151 	DHCP_OPT_BOOT_FILE_NAME = 67,
152 	DHCP_OPT_HOME_AGENT_ADDRESSES = 68,
153 	DHCP_OPT_SMTP_SERVER = 69,
154 	DHCP_OPT_POP3_SERVER = 70,
155 	DHCP_OPT_NNTP_SERVER = 71,
156 	DHCP_OPT_WWW_SERVER = 72,
157 	DHCP_OPT_FINGER_SERVER = 73,
158 	DHCP_OPT_IRC_SERVER = 74,
159 	DHCP_OPT_STREETTALK_SERVER = 75,
160 	DHCP_OPT_STDA_SERVER = 76,
161 	DHCP_OPT_USER_CLASS = 77,
162 	DHCP_OPT_DIRECTORY_AGENT = 78,
163 	DHCP_OPT_SERVICE_SCOPE = 79,
164 	DHCP_OPT_RAPID_COMMIT = 80,
165 	DHCP_OPT_CLIENT_FQDN = 81,
166 	DHCP_OPT_RELAY_AGENT_INFO = 82,
167 	DHCP_OPT_ISNS = 83,
168 	DHCP_OPT_NDS_SERVERS = 85,
169 	DHCP_OPT_NDS_TREE_NAME = 86,
170 	DHCP_OPT_NDS_CONTEXT = 87,
171 	DHCP_OPT_BCMCS_CONTROLLER_DOMAIN_NAME_LIST = 88,
172 	DHCP_OPT_BCMCS_CONTROLLER_IPV4_ADDRESS = 89,
173 	DHCP_OPT_AUTHENTICATION = 90,
174 	DHCP_OPT_CLIENT_LAST_TRANSACTION_TIME = 91,
175 	DHCP_OPT_ASSOCIATED_IP = 92,
176 	DHCP_OPT_CLIENT_SYSYEM = 93,
177 	DHCP_OPT_CLIENT_NDI = 94,
178 	DHCP_OPT_LDAP = 95,
179 	DHCP_OPT_UUID_GUID = 97,
180 	DHCP_OPT_USER_AUTH = 98,
181 	DHCP_OPT_GEOCONF_CIVIC = 99,
182 	DHCP_OPT_PCODE = 100,
183 	DHCP_OPT_TCODE = 101,
184 	DHCP_OPT_NETINFO_ADDRESS = 112,
185 	DHCP_OPT_NETINFO_TAG = 113,
186 	DHCP_OPT_URL = 114,
187 	DHCP_OPT_AUTO_CONFIG = 116,
188 	DHCP_OPT_NAME_SERVICE_SEARCH = 117,
189 	DHCP_OPT_SUBNET_SELECTION = 118,
190 	DHCP_OPT_DOMAIN_SEARCH = 119,
191 	DHCP_OPT_SIP_SERVERS_DCP = 120,
192 	DHCP_OPT_CLASSLESS_STATIC_ROUTE = 121,
193 	DHCP_OPT_CCC = 122,
194 	DHCP_OPT_GEOCONF = 123,
195 	DHCP_OPT_V_I_VENDOR_CLASS = 124,
196 	DHCP_OPT_V_I_VENDOR_SPECIFIC_INFO = 125,
197 	DHCP_OPT_PANA_AGENT = 136,
198 	DHCP_OPT_V4_LOST = 137,
199 	DHCP_OPT_CAPWAP_AC_V4 = 138,
200 	DHCP_OPT_IPV4_ADDRESS_MOS = 139,
201 	DHCP_OPT_IPV4_FQDN_MOS = 140,
202 	DHCP_OPT_SIP_UA_CONF = 141,
203 	DHCP_OPT_IPV4_ADDRESS_ANDSF = 142,
204 	DHCP_OPT_GEOLOC = 144,
205 	DHCP_OPT_FORCERENEW_NONCE_CAPABLE = 145,
206 	DHCP_OPT_RDNSS_SELECTION = 146,
207 	DHCP_OPT_TFTP_SERVER_ADDRESS = 150,
208 	DHCP_OPT_STATUS_CODE = 151,
209 	DHCP_OPT_BASE_TIME = 152,
210 	DHCP_OPT_START_TIME_OF_STATE = 153,
211 	DHCP_OPT_QUERY_START_TIME = 154,
212 	DHCP_OPT_QUERY_END_TIME = 155,
213 	DHCP_OPT_STATE = 156,
214 	DHCP_OPT_DATA_SOURCE = 157,
215 	DHCP_OPT_V4_PCP_SERVER = 158,
216 	DHCP_OPT_V4_PORTPARAMS = 159,
217 	DHCP_OPT_CAPTIVE_PORTAL = 160,
218 	DHCP_OPT_CONF_FILE = 209,
219 	DHCP_OPT_PATH_PREFIX = 210,
220 	DHCP_OPT_REBOOT_TIME = 211,
221 	DHCP_OPT_6RD = 212,
222 	DHCP_OPT_V4_ACCESS_DOMAIN = 213,
223 	DHCP_OPT_SUBNET_ALLOCATION = 220,
224 	DHCP_OPT_VSS = 221,
225 	DHCP_OPT_END = 255
226 };
227 
228 enum dhcp_message_types {
229 	DHCPDISCOVER = 1,
230 	DHCPOFFER = 2,
231 	DHCPREQUEST = 3,
232 	DHCPDECLINE = 4,
233 	DHCPACK = 5,
234 	DHCPNAK = 6,
235 	DHCPRELEASE = 7,
236 	DHCPINFORM = 8,
237 	DHCPFORCERENEW = 9,
238 	DHCPLEASEQUERY = 10,
239 	DHCPLEASEUNASSIGNED = 11,
240 	DHCPLEASEUNKNOWN = 12,
241 	DHCPLEASEACTIVE = 13,
242 	DHCPBULKLEASEQUERY = 14,
243 	DHCPLEASEQUERYDONE = 15,
244 	DHCPACTIVELEASEQUERY = 16,
245 	DHCPLEASEQUERYSTATUS = 17,
246 	DHCPTLS = 18,
247 };
248 
249 enum dhcp_relay_agent_suboptions {
250 	DHCP_RELAY_OPT_AGENT_CIRCUIT_ID = 1,
251 	DHCP_RELAY_OPT_AGENT_REMOTE_ID = 2,
252 	DHCP_RELAY_OPT_DOCSIS_DEVICE_CLASS = 4,
253 	DHCP_RELAY_OPT_LINK_SELECTION = 5,
254 	DHCP_RELAY_OPT_SUBSCRIBE_ID = 6,
255 	DHCP_RELAY_OPT_RADIUS_ATTRIBUTES = 7,
256 	DHCP_RELAY_OPT_AUTHENTICATION = 8,
257 	DHCP_RELAY_OPT_VEDOR_SPECIFIC = 9,
258 	DHCP_RELAY_OPT_RELAY_AGENT_FLAGS = 10,
259 	DHCP_RELAY_OPT_SERVER_ID_OVERRIDE = 11,
260 	DHCP_RELAY_OPT_RELAY_AGENT_ID = 12,
261 	DHCP_RELAY_OPT_ACCESS_TECHNOLOGY_TYPE = 13,
262 	DHCP_RELAY_OPT_ACCESS_NETWORK_NAME = 14,
263 	DHCP_RELAY_OPT_ACCESS_POINT_NAME = 15,
264 	DHCP_RELAY_OPT_ACCESS_POINT_BSSID = 16,
265 	DHCP_RELAY_OPT_OPERATOR_ID = 17,
266 	DHCP_RELAY_OPT_OPERATOR_REALM = 18,
267 	DHCP_RELAY_OPT_DHCPV4_VIRTUAL_SUBNET_SELECTION = 151,
268 	DHCP_RELAY_OPT_DHCPV4_VIRTUAL_SUBNET_SELECTION_CONTROL = 152,
269 };
270 
271 enum access_technology_types {
272 	ACCESS_TECHNOLOGY_VIRTUAL = 1,
273 	ACCESS_TECHNOLOGY_PPP = 2,
274 	ACCESS_TECHNOLOGY_ETHERNET = 3,
275 	ACCESS_TECHNOLOGY_WLAN = 4,
276 	ACCESS_TECHNOLOGY_WIMAX = 5,
277 };
278 
279 #endif /* DHCP_H */
280