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