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