dhcp4.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. /*
  2. * Copyright (C) 2004-2017 Internet Systems Consortium, Inc. ("ISC")
  3. * Copyright (c) 1995-2003 by Internet Software Consortium
  4. *
  5. * This Source Code Form is subject to the terms of the Mozilla Public
  6. * License, v. 2.0. If a copy of the MPL was not distributed with this
  7. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  8. *
  9. * Internet Systems Consortium, Inc.
  10. * 950 Charter Street
  11. * Redwood City, CA 94063
  12. * <info@isc.org>
  13. * https://www.isc.org/
  14. *
  15. * This software has been written for Internet Systems Consortium
  16. * by Ted Lemon in cooperation with Vixie Enterprises. To learn more
  17. * about Internet Systems Consortium, see ``https://www.isc.org''.
  18. * To learn more about Vixie Enterprises, see ``http://www.vix.com''.
  19. */
  20. /*
  21. * NOTE: This files is imported from ISC DHCP. It uses C notation.
  22. * Format kept for easier merge.
  23. */
  24. #ifndef DHCP_H
  25. #define DHCP_H
  26. #include <stdint.h>
  27. /// @note Code points in comments are those assigned by IANA
  28. /// but not yet implemented in Kea.
  29. /// To implement a standard option, remove the comment characters,
  30. /// add an entry in std_option_defs.h, add a stdOptionDefs4 unit test
  31. /// in tests/libdhcp++_unittest.cc and update dhcp4-std-options-list-part2
  32. /// in the dhcp4-srv.xml source file of the user guide.
  33. namespace isc {
  34. namespace dhcp {
  35. /* IPv4 Broadcast address */
  36. #define DHCP_IPV4_BROADCAST_ADDRESS "255.255.255.255"
  37. /* BOOTP (rfc951) message types */
  38. enum BOOTPTypes {
  39. BOOTREQUEST = 1,
  40. BOOTREPLY = 2
  41. };
  42. /* Possible values for flags field... */
  43. static const uint16_t BOOTP_BROADCAST = 32768L;
  44. /// @brief Possible values for hardware type (htype) field.
  45. enum HType {
  46. HTYPE_UNDEFINED = 0, ///< not specified or undefined
  47. HTYPE_ETHER = 1, ///< Ethernet 10Mbps
  48. HTYPE_DOCSIS = 1, ///< The traffic captures we have from cable modems as
  49. /// well as this list by IANA:
  50. /// http://www.iana.org/assignments/
  51. /// arp-parameters/arp-parameters.xhtml suggest that
  52. /// Ethernet (1) should be used in DOCSIS environment.
  53. HTYPE_IEEE802 = 6, ///< IEEE 802.2 Token Ring
  54. HTYPE_FDDI = 8 ///< FDDI
  55. /// TODO Add infiniband here
  56. };
  57. /* DHCP Option codes: */
  58. enum DHCPOptionType {
  59. DHO_PAD = 0,
  60. DHO_SUBNET_MASK = 1,
  61. DHO_TIME_OFFSET = 2,
  62. DHO_ROUTERS = 3,
  63. DHO_TIME_SERVERS = 4,
  64. DHO_NAME_SERVERS = 5,
  65. DHO_DOMAIN_NAME_SERVERS = 6,
  66. DHO_LOG_SERVERS = 7,
  67. DHO_COOKIE_SERVERS = 8,
  68. DHO_LPR_SERVERS = 9,
  69. DHO_IMPRESS_SERVERS = 10,
  70. DHO_RESOURCE_LOCATION_SERVERS = 11,
  71. DHO_HOST_NAME = 12,
  72. DHO_BOOT_SIZE = 13,
  73. DHO_MERIT_DUMP = 14,
  74. DHO_DOMAIN_NAME = 15,
  75. DHO_SWAP_SERVER = 16,
  76. DHO_ROOT_PATH = 17,
  77. DHO_EXTENSIONS_PATH = 18,
  78. DHO_IP_FORWARDING = 19,
  79. DHO_NON_LOCAL_SOURCE_ROUTING = 20,
  80. DHO_POLICY_FILTER = 21,
  81. DHO_MAX_DGRAM_REASSEMBLY = 22,
  82. DHO_DEFAULT_IP_TTL = 23,
  83. DHO_PATH_MTU_AGING_TIMEOUT = 24,
  84. DHO_PATH_MTU_PLATEAU_TABLE = 25,
  85. DHO_INTERFACE_MTU = 26,
  86. DHO_ALL_SUBNETS_LOCAL = 27,
  87. DHO_BROADCAST_ADDRESS = 28,
  88. DHO_PERFORM_MASK_DISCOVERY = 29,
  89. DHO_MASK_SUPPLIER = 30,
  90. DHO_ROUTER_DISCOVERY = 31,
  91. DHO_ROUTER_SOLICITATION_ADDRESS = 32,
  92. DHO_STATIC_ROUTES = 33,
  93. DHO_TRAILER_ENCAPSULATION = 34,
  94. DHO_ARP_CACHE_TIMEOUT = 35,
  95. DHO_IEEE802_3_ENCAPSULATION = 36,
  96. DHO_DEFAULT_TCP_TTL = 37,
  97. DHO_TCP_KEEPALIVE_INTERVAL = 38,
  98. DHO_TCP_KEEPALIVE_GARBAGE = 39,
  99. DHO_NIS_DOMAIN = 40,
  100. DHO_NIS_SERVERS = 41,
  101. DHO_NTP_SERVERS = 42,
  102. DHO_VENDOR_ENCAPSULATED_OPTIONS = 43,
  103. DHO_NETBIOS_NAME_SERVERS = 44,
  104. DHO_NETBIOS_DD_SERVER = 45,
  105. DHO_NETBIOS_NODE_TYPE = 46,
  106. DHO_NETBIOS_SCOPE = 47,
  107. DHO_FONT_SERVERS = 48,
  108. DHO_X_DISPLAY_MANAGER = 49,
  109. DHO_DHCP_REQUESTED_ADDRESS = 50,
  110. DHO_DHCP_LEASE_TIME = 51,
  111. DHO_DHCP_OPTION_OVERLOAD = 52,
  112. DHO_DHCP_MESSAGE_TYPE = 53,
  113. DHO_DHCP_SERVER_IDENTIFIER = 54,
  114. DHO_DHCP_PARAMETER_REQUEST_LIST = 55,
  115. DHO_DHCP_MESSAGE = 56,
  116. DHO_DHCP_MAX_MESSAGE_SIZE = 57,
  117. DHO_DHCP_RENEWAL_TIME = 58,
  118. DHO_DHCP_REBINDING_TIME = 59,
  119. DHO_VENDOR_CLASS_IDENTIFIER = 60,
  120. DHO_DHCP_CLIENT_IDENTIFIER = 61,
  121. DHO_NWIP_DOMAIN_NAME = 62,
  122. DHO_NWIP_SUBOPTIONS = 63,
  123. DHO_NISP_DOMAIN_NAME = 64,
  124. DHO_NISP_SERVER_ADDR = 65,
  125. DHO_TFTP_SERVER_NAME = 66,
  126. DHO_BOOT_FILE_NAME = 67,
  127. DHO_HOME_AGENT_ADDRS = 68,
  128. DHO_SMTP_SERVER = 69,
  129. DHO_POP3_SERVER = 70,
  130. DHO_NNTP_SERVER = 71,
  131. DHO_WWW_SERVER = 72,
  132. DHO_FINGER_SERVER = 73,
  133. DHO_IRC_SERVER = 74,
  134. DHO_STREETTALK_SERVER = 75,
  135. DHO_STDASERVER = 76,
  136. DHO_USER_CLASS = 77,
  137. DHO_DIRECTORY_AGENT = 78,
  138. DHO_SERVICE_SCOPE = 79,
  139. // DHO_RAPID_COMMIT = 80,
  140. DHO_FQDN = 81,
  141. DHO_DHCP_AGENT_OPTIONS = 82,
  142. // DHO_ISNS = 83,
  143. // 84 is removed/unassigned
  144. DHO_NDS_SERVERS = 85,
  145. DHO_NDS_TREE_NAME = 86,
  146. DHO_NDS_CONTEXT = 87,
  147. DHO_BCMCS_DOMAIN_NAME_LIST = 88,
  148. DHO_BCMCS_IPV4_ADDR = 89,
  149. DHO_AUTHENTICATE = 90, /* RFC3118, was 210 */
  150. DHO_CLIENT_LAST_TRANSACTION_TIME = 91,
  151. DHO_ASSOCIATED_IP = 92,
  152. DHO_SYSTEM = 93, /* RFC4578 */
  153. DHO_NDI = 94, /* RFC4578 */
  154. // DHO_LDAP = 95,
  155. // 96 is removed/unassigned
  156. DHO_UUID_GUID = 97, /* RFC4578 */
  157. DHO_USER_AUTH = 98,
  158. DHO_GEOCONF_CIVIC = 99,
  159. DHO_PCODE = 100,
  160. DHO_TCODE = 101,
  161. // 102-111 are removed/unassigned
  162. DHO_NETINFO_ADDR = 112,
  163. DHO_NETINFO_TAG = 113,
  164. DHO_URL = 114,
  165. // 115 is removed/unassigned
  166. DHO_AUTO_CONFIG = 116,
  167. DHO_NAME_SERVICE_SEARCH = 117,
  168. DHO_SUBNET_SELECTION = 118, /* RFC3011 */
  169. DHO_DOMAIN_SEARCH = 119, /* RFC3397 */
  170. // DHO_SIP_SERVERS = 120,
  171. // DHO_CLASSLESS_STATIC_ROUTE = 121,
  172. // DHO_CCC = 122,
  173. // DHO_GEOCONF = 123,
  174. DHO_VIVCO_SUBOPTIONS = 124,
  175. DHO_VIVSO_SUBOPTIONS = 125,
  176. // 126-127 are removed/unassigned
  177. // 128-135 have multiple definitions including PXE
  178. DHO_PANA_AGENT = 136,
  179. DHO_V4_LOST = 137,
  180. DHO_CAPWAP_AC_V4 = 138,
  181. // DHO_IPV4_ADDR_MOS = 139,
  182. // DHO_IPV4_FQDN_MOS = 140,
  183. DHO_SIP_UA_CONF_SERVICE_DOMAINS = 141,
  184. // DHO_IPV4_ADDR_ANDSF = 142,
  185. // 143 is removed/unassigned
  186. // DHO_GEOLOC = 144,
  187. // DHO_FORCERENEW_NONCE_CAPABLE = 145,
  188. DHO_RDNSS_SELECT = 146,
  189. // 147-149 are removed/unassigned
  190. // 150 have multiple definitions
  191. // DHO_STATUS_CODE = 151,
  192. // DHO_BASE_TIME = 152,
  193. // DHO_START_TIME_OF_STATE = 153,
  194. // DHO_QUERY_START_TIME = 154,
  195. // DHO_QUERY_END_TIME = 155,
  196. // DHO_DHCP_STATE = 156,
  197. // DHO_DATA_SOURCE = 157,
  198. // DHO_V4_PCP_SERVER = 158,
  199. DHO_V4_PORTPARAMS = 159,
  200. DHO_V4_CAPTIVE_PORTAL = 160,
  201. // 161-209 are removed/unassigned
  202. // DHO_PATH_PREFIX = 210,
  203. // DHO_REBOOT_TIME = 211,
  204. DHO_6RD = 212,
  205. DHO_V4_ACCESS_DOMAIN = 213,
  206. // 214-219 are removed/unassigned
  207. // DHO_SUBNET_ALLOC = 220,
  208. // DHO_VSS = 221,
  209. // 222-223 are removed/unassigned
  210. // 224-254 are reserved for private use
  211. DHO_END = 255
  212. };
  213. /* DHCP message types. */
  214. enum DHCPMessageType {
  215. DHCP_NOTYPE = 0, ///< Message Type option missing
  216. DHCPDISCOVER = 1,
  217. DHCPOFFER = 2,
  218. DHCPREQUEST = 3,
  219. DHCPDECLINE = 4,
  220. DHCPACK = 5,
  221. DHCPNAK = 6,
  222. DHCPRELEASE = 7,
  223. DHCPINFORM = 8,
  224. // DHCPFORCERENEW = 9,
  225. DHCPLEASEQUERY = 10,
  226. DHCPLEASEUNASSIGNED = 11,
  227. DHCPLEASEUNKNOWN = 12,
  228. DHCPLEASEACTIVE = 13,
  229. DHCPBULKLEASEQUERY = 14,
  230. DHCPLEASEQUERYDONE = 15
  231. // DHCPACTIVELEASEQUERY = 16,
  232. // DHCPLEASEQUERYSTATUS = 17,
  233. // DHCPTLS = 18
  234. };
  235. static const uint16_t DHCP4_CLIENT_PORT = 68;
  236. static const uint16_t DHCP4_SERVER_PORT = 67;
  237. /// Magic cookie validating dhcp options field (and bootp vendor
  238. /// extensions field).
  239. static const uint32_t DHCP_OPTIONS_COOKIE = 0x63825363;
  240. /* Relay Agent Information option subtypes: */
  241. static const uint16_t RAI_OPTION_AGENT_CIRCUIT_ID = 1; // RFC3046
  242. static const uint16_t RAI_OPTION_REMOTE_ID = 2; // RFC3046
  243. /* option 3 is reserved and will never be assigned */
  244. static const uint16_t RAI_OPTION_DOCSIS_DEVICE_CLASS = 4; // RFC3256
  245. static const uint16_t RAI_OPTION_LINK_SELECTION = 5; // RFC3527
  246. static const uint16_t RAI_OPTION_SUBSCRIBER_ID = 6; //RFC3993
  247. static const uint16_t RAI_OPTION_RADIUS = 7; //RFC4014
  248. static const uint16_t RAI_OPTION_AUTH = 8; //RFC4030
  249. static const uint16_t RAI_OPTION_VSI = 9; // RFC4243
  250. static const uint16_t RAI_OPTION_RELAY_FLAGS = 10; // RFC5010
  251. static const uint16_t RAI_OPTION_SERVER_ID_OVERRIDE = 11; // RFC5107
  252. static const uint16_t RAI_OPTION_RELAY_ID = 12; //RFC6925
  253. static const uint16_t RAI_OPTION_ACCESS_TECHNO_TYPE = 13; // RFC7839
  254. static const uint16_t RAI_OPTION_ACCESS_NETWORK_NAME = 14; // RFC7839
  255. static const uint16_t RAI_OPTION_ACCESS_POINT_NAME = 15; // RFC7839
  256. static const uint16_t RAI_OPTION_ACCESS_POINT_BSSID = 16; // RFC7839
  257. static const uint16_t RAI_OPTION_OPERATOR_ID = 17; // RFC7839
  258. static const uint16_t RAI_OPTION_OPERATOR_REALM = 18; // RFC7839
  259. static const uint16_t RAI_OPTION_VIRTUAL_SUBNET_SELECT = 151; //RFC6607
  260. static const uint16_t RAI_OPTION_VIRTUAL_SUBNET_SELECT_CTRL = 152; //RFC6607
  261. // TODO: Following are leftovers from dhcp.h import from ISC DHCP
  262. // They will be converted to C++-style defines once they will start
  263. // to be used.
  264. #if 0
  265. /* FQDN suboptions: */
  266. #define FQDN_NO_CLIENT_UPDATE 1
  267. #define FQDN_SERVER_UPDATE 2
  268. #define FQDN_ENCODED 3
  269. #define FQDN_RCODE1 4
  270. #define FQDN_RCODE2 5
  271. #define FQDN_HOSTNAME 6
  272. #define FQDN_DOMAINNAME 7
  273. #define FQDN_FQDN 8
  274. #define FQDN_SUBOPTION_COUNT 8
  275. /* Enterprise Suboptions: */
  276. #define VENDOR_ISC_SUBOPTIONS 2495
  277. #endif
  278. /* Client identifier types */
  279. static const uint8_t CLIENT_ID_OPTION_TYPE_DUID = 255;
  280. } // end of isc::dhcp namespace
  281. } // end of isc namespace
  282. #endif /* DHCP_H */