dhcp4.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /*
  2. * Copyright (c) 2004-2011 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. namespace isc {
  36. namespace dhcp {
  37. /* IPv4 Broadcast address */
  38. #define DHCP_IPV4_BROADCAST_ADDRESS "255.255.255.255"
  39. /* BOOTP (rfc951) message types */
  40. enum BOOTPTypes {
  41. BOOTREQUEST = 1,
  42. BOOTREPLY = 2
  43. };
  44. /* Possible values for flags field... */
  45. static const uint16_t BOOTP_BROADCAST = 32768L;
  46. /* Possible values for hardware type (htype) field... */
  47. enum HType {
  48. HTYPE_ETHER = 1, /* Ethernet 10Mbps */
  49. HTYPE_IEEE802 = 6, /* IEEE 802.2 Token Ring */
  50. HTYPE_FDDI = 8 /* FDDI */
  51. /// TODO Add infiniband here
  52. };
  53. /* DHCP Option codes: */
  54. enum DHCPOptionType {
  55. DHO_PAD = 0,
  56. DHO_SUBNET_MASK = 1,
  57. DHO_TIME_OFFSET = 2,
  58. DHO_ROUTERS = 3,
  59. DHO_TIME_SERVERS = 4,
  60. DHO_NAME_SERVERS = 5,
  61. DHO_DOMAIN_NAME_SERVERS = 6,
  62. DHO_LOG_SERVERS = 7,
  63. DHO_COOKIE_SERVERS = 8,
  64. DHO_LPR_SERVERS = 9,
  65. DHO_IMPRESS_SERVERS = 10,
  66. DHO_RESOURCE_LOCATION_SERVERS = 11,
  67. DHO_HOST_NAME = 12,
  68. DHO_BOOT_SIZE = 13,
  69. DHO_MERIT_DUMP = 14,
  70. DHO_DOMAIN_NAME = 15,
  71. DHO_SWAP_SERVER = 16,
  72. DHO_ROOT_PATH = 17,
  73. DHO_EXTENSIONS_PATH = 18,
  74. DHO_IP_FORWARDING = 19,
  75. DHO_NON_LOCAL_SOURCE_ROUTING = 20,
  76. DHO_POLICY_FILTER = 21,
  77. DHO_MAX_DGRAM_REASSEMBLY = 22,
  78. DHO_DEFAULT_IP_TTL = 23,
  79. DHO_PATH_MTU_AGING_TIMEOUT = 24,
  80. DHO_PATH_MTU_PLATEAU_TABLE = 25,
  81. DHO_INTERFACE_MTU = 26,
  82. DHO_ALL_SUBNETS_LOCAL = 27,
  83. DHO_BROADCAST_ADDRESS = 28,
  84. DHO_PERFORM_MASK_DISCOVERY = 29,
  85. DHO_MASK_SUPPLIER = 30,
  86. DHO_ROUTER_DISCOVERY = 31,
  87. DHO_ROUTER_SOLICITATION_ADDRESS = 32,
  88. DHO_STATIC_ROUTES = 33,
  89. DHO_TRAILER_ENCAPSULATION = 34,
  90. DHO_ARP_CACHE_TIMEOUT = 35,
  91. DHO_IEEE802_3_ENCAPSULATION = 36,
  92. DHO_DEFAULT_TCP_TTL = 37,
  93. DHO_TCP_KEEPALIVE_INTERVAL = 38,
  94. DHO_TCP_KEEPALIVE_GARBAGE = 39,
  95. DHO_NIS_DOMAIN = 40,
  96. DHO_NIS_SERVERS = 41,
  97. DHO_NTP_SERVERS = 42,
  98. DHO_VENDOR_ENCAPSULATED_OPTIONS = 43,
  99. DHO_NETBIOS_NAME_SERVERS = 44,
  100. DHO_NETBIOS_DD_SERVER = 45,
  101. DHO_NETBIOS_NODE_TYPE = 46,
  102. DHO_NETBIOS_SCOPE = 47,
  103. DHO_FONT_SERVERS = 48,
  104. DHO_X_DISPLAY_MANAGER = 49,
  105. DHO_DHCP_REQUESTED_ADDRESS = 50,
  106. DHO_DHCP_LEASE_TIME = 51,
  107. DHO_DHCP_OPTION_OVERLOAD = 52,
  108. DHO_DHCP_MESSAGE_TYPE = 53,
  109. DHO_DHCP_SERVER_IDENTIFIER = 54,
  110. DHO_DHCP_PARAMETER_REQUEST_LIST = 55,
  111. DHO_DHCP_MESSAGE = 56,
  112. DHO_DHCP_MAX_MESSAGE_SIZE = 57,
  113. DHO_DHCP_RENEWAL_TIME = 58,
  114. DHO_DHCP_REBINDING_TIME = 59,
  115. DHO_VENDOR_CLASS_IDENTIFIER = 60,
  116. DHO_DHCP_CLIENT_IDENTIFIER = 61,
  117. DHO_NWIP_DOMAIN_NAME = 62,
  118. DHO_NWIP_SUBOPTIONS = 63,
  119. DHO_USER_CLASS = 77,
  120. DHO_FQDN = 81,
  121. DHO_DHCP_AGENT_OPTIONS = 82,
  122. DHO_AUTHENTICATE = 90, /* RFC3118, was 210 */
  123. DHO_CLIENT_LAST_TRANSACTION_TIME = 91,
  124. DHO_ASSOCIATED_IP = 92,
  125. DHO_SUBNET_SELECTION = 118, /* RFC3011! */
  126. DHO_DOMAIN_SEARCH = 119, /* RFC3397 */
  127. DHO_VIVCO_SUBOPTIONS = 124,
  128. DHO_VIVSO_SUBOPTIONS = 125,
  129. DHO_END = 255
  130. };
  131. /* DHCP message types. */
  132. enum DHCPMessageType {
  133. DHCPDISCOVER = 1,
  134. DHCPOFFER = 2,
  135. DHCPREQUEST = 3,
  136. DHCPDECLINE = 4,
  137. DHCPACK = 5,
  138. DHCPNAK = 6,
  139. DHCPRELEASE = 7,
  140. DHCPINFORM = 8,
  141. DHCPLEASEQUERY = 10,
  142. DHCPLEASEUNASSIGNED = 11,
  143. DHCPLEASEUNKNOWN = 12,
  144. DHCPLEASEACTIVE = 13
  145. };
  146. static const uint16_t DHCP4_CLIENT_PORT = 68;
  147. static const uint16_t DHCP4_SERVER_PORT = 67;
  148. /// Magic cookie validating dhcp options field (and bootp vendor
  149. /// extensions field).
  150. static const uint32_t DHCP_OPTIONS_COOKIE = 0x63825363;
  151. // TODO: Following are leftovers from dhcp.h import from ISC DHCP
  152. // They will be converted to C++-style defines once they will start
  153. // to be used.
  154. #if 0
  155. /* Relay Agent Information option subtypes: */
  156. #define RAI_CIRCUIT_ID 1
  157. #define RAI_REMOTE_ID 2
  158. #define RAI_AGENT_ID 3
  159. #define RAI_LINK_SELECT 5
  160. /* FQDN suboptions: */
  161. #define FQDN_NO_CLIENT_UPDATE 1
  162. #define FQDN_SERVER_UPDATE 2
  163. #define FQDN_ENCODED 3
  164. #define FQDN_RCODE1 4
  165. #define FQDN_RCODE2 5
  166. #define FQDN_HOSTNAME 6
  167. #define FQDN_DOMAINNAME 7
  168. #define FQDN_FQDN 8
  169. #define FQDN_SUBOPTION_COUNT 8
  170. /* Enterprise Suboptions: */
  171. #define VENDOR_ISC_SUBOPTIONS 2495
  172. #endif
  173. } // end of isc::dhcp namespace
  174. } // end of isc namespace
  175. #endif /* DHCP_H */