dhcp4.h 11 KB

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