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