dhcp.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /* dhcp.h
  2. Protocol structures... */
  3. /*
  4. * Copyright (c) 2004-2009 by Internet Systems Consortium, Inc. ("ISC")
  5. * Copyright (c) 1995-2003 by Internet Software Consortium
  6. *
  7. * Permission to use, copy, modify, and distribute this software for any
  8. * purpose with or without fee is hereby granted, provided that the above
  9. * copyright notice and this permission notice appear in all copies.
  10. *
  11. * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
  12. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  13. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
  14. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  15. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  16. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  17. * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  18. *
  19. * Internet Systems Consortium, Inc.
  20. * 950 Charter Street
  21. * Redwood City, CA 94063
  22. * <info@isc.org>
  23. * https://www.isc.org/
  24. *
  25. * This software has been written for Internet Systems Consortium
  26. * by Ted Lemon in cooperation with Vixie Enterprises. To learn more
  27. * about Internet Systems Consortium, see ``https://www.isc.org''.
  28. * To learn more about Vixie Enterprises, see ``http://www.vix.com''.
  29. */
  30. #ifndef DHCP_H
  31. #define DHCP_H
  32. #define DHCP_UDP_OVERHEAD (20 + /* IP header */ \
  33. 8) /* UDP header */
  34. #define DHCP_SNAME_LEN 64
  35. #define DHCP_FILE_LEN 128
  36. #define DHCP_FIXED_NON_UDP 236
  37. #define DHCP_FIXED_LEN (DHCP_FIXED_NON_UDP + DHCP_UDP_OVERHEAD)
  38. /* Everything but options. */
  39. #define BOOTP_MIN_LEN 300
  40. #define DHCP_MTU_MAX 1500
  41. #define DHCP_MTU_MIN 576
  42. #define DHCP_MAX_OPTION_LEN (DHCP_MTU_MAX - DHCP_FIXED_LEN)
  43. #define DHCP_MIN_OPTION_LEN (DHCP_MTU_MIN - DHCP_FIXED_LEN)
  44. struct dhcp_packet {
  45. u_int8_t op; /* 0: Message opcode/type */
  46. u_int8_t htype; /* 1: Hardware addr type (net/if_types.h) */
  47. u_int8_t hlen; /* 2: Hardware addr length */
  48. u_int8_t hops; /* 3: Number of relay agent hops from client */
  49. u_int32_t xid; /* 4: Transaction ID */
  50. u_int16_t secs; /* 8: Seconds since client started looking */
  51. u_int16_t flags; /* 10: Flag bits */
  52. struct in_addr ciaddr; /* 12: Client IP address (if already in use) */
  53. struct in_addr yiaddr; /* 16: Client IP address */
  54. struct in_addr siaddr; /* 18: IP address of next server to talk to */
  55. struct in_addr giaddr; /* 20: DHCP relay agent IP address */
  56. unsigned char chaddr [16]; /* 24: Client hardware address */
  57. char sname [DHCP_SNAME_LEN]; /* 40: Server name */
  58. char file [DHCP_FILE_LEN]; /* 104: Boot filename */
  59. unsigned char options [DHCP_MAX_OPTION_LEN];
  60. /* 212: Optional parameters
  61. (actual length dependent on MTU). */
  62. };
  63. /* BOOTP (rfc951) message types */
  64. #define BOOTREQUEST 1
  65. #define BOOTREPLY 2
  66. /* Possible values for flags field... */
  67. #define BOOTP_BROADCAST 32768L
  68. /* Possible values for hardware type (htype) field... */
  69. #define HTYPE_ETHER 1 /* Ethernet 10Mbps */
  70. #define HTYPE_IEEE802 6 /* IEEE 802.2 Token Ring... */
  71. #define HTYPE_FDDI 8 /* FDDI... */
  72. /* Magic cookie validating dhcp options field (and bootp vendor
  73. extensions field). */
  74. #define DHCP_OPTIONS_COOKIE "\143\202\123\143"
  75. /* DHCP Option codes: */
  76. #define DHO_PAD 0
  77. #define DHO_SUBNET_MASK 1
  78. #define DHO_TIME_OFFSET 2
  79. #define DHO_ROUTERS 3
  80. #define DHO_TIME_SERVERS 4
  81. #define DHO_NAME_SERVERS 5
  82. #define DHO_DOMAIN_NAME_SERVERS 6
  83. #define DHO_LOG_SERVERS 7
  84. #define DHO_COOKIE_SERVERS 8
  85. #define DHO_LPR_SERVERS 9
  86. #define DHO_IMPRESS_SERVERS 10
  87. #define DHO_RESOURCE_LOCATION_SERVERS 11
  88. #define DHO_HOST_NAME 12
  89. #define DHO_BOOT_SIZE 13
  90. #define DHO_MERIT_DUMP 14
  91. #define DHO_DOMAIN_NAME 15
  92. #define DHO_SWAP_SERVER 16
  93. #define DHO_ROOT_PATH 17
  94. #define DHO_EXTENSIONS_PATH 18
  95. #define DHO_IP_FORWARDING 19
  96. #define DHO_NON_LOCAL_SOURCE_ROUTING 20
  97. #define DHO_POLICY_FILTER 21
  98. #define DHO_MAX_DGRAM_REASSEMBLY 22
  99. #define DHO_DEFAULT_IP_TTL 23
  100. #define DHO_PATH_MTU_AGING_TIMEOUT 24
  101. #define DHO_PATH_MTU_PLATEAU_TABLE 25
  102. #define DHO_INTERFACE_MTU 26
  103. #define DHO_ALL_SUBNETS_LOCAL 27
  104. #define DHO_BROADCAST_ADDRESS 28
  105. #define DHO_PERFORM_MASK_DISCOVERY 29
  106. #define DHO_MASK_SUPPLIER 30
  107. #define DHO_ROUTER_DISCOVERY 31
  108. #define DHO_ROUTER_SOLICITATION_ADDRESS 32
  109. #define DHO_STATIC_ROUTES 33
  110. #define DHO_TRAILER_ENCAPSULATION 34
  111. #define DHO_ARP_CACHE_TIMEOUT 35
  112. #define DHO_IEEE802_3_ENCAPSULATION 36
  113. #define DHO_DEFAULT_TCP_TTL 37
  114. #define DHO_TCP_KEEPALIVE_INTERVAL 38
  115. #define DHO_TCP_KEEPALIVE_GARBAGE 39
  116. #define DHO_NIS_DOMAIN 40
  117. #define DHO_NIS_SERVERS 41
  118. #define DHO_NTP_SERVERS 42
  119. #define DHO_VENDOR_ENCAPSULATED_OPTIONS 43
  120. #define DHO_NETBIOS_NAME_SERVERS 44
  121. #define DHO_NETBIOS_DD_SERVER 45
  122. #define DHO_NETBIOS_NODE_TYPE 46
  123. #define DHO_NETBIOS_SCOPE 47
  124. #define DHO_FONT_SERVERS 48
  125. #define DHO_X_DISPLAY_MANAGER 49
  126. #define DHO_DHCP_REQUESTED_ADDRESS 50
  127. #define DHO_DHCP_LEASE_TIME 51
  128. #define DHO_DHCP_OPTION_OVERLOAD 52
  129. #define DHO_DHCP_MESSAGE_TYPE 53
  130. #define DHO_DHCP_SERVER_IDENTIFIER 54
  131. #define DHO_DHCP_PARAMETER_REQUEST_LIST 55
  132. #define DHO_DHCP_MESSAGE 56
  133. #define DHO_DHCP_MAX_MESSAGE_SIZE 57
  134. #define DHO_DHCP_RENEWAL_TIME 58
  135. #define DHO_DHCP_REBINDING_TIME 59
  136. #define DHO_VENDOR_CLASS_IDENTIFIER 60
  137. #define DHO_DHCP_CLIENT_IDENTIFIER 61
  138. #define DHO_NWIP_DOMAIN_NAME 62
  139. #define DHO_NWIP_SUBOPTIONS 63
  140. #define DHO_USER_CLASS 77
  141. #define DHO_FQDN 81
  142. #define DHO_DHCP_AGENT_OPTIONS 82
  143. #define DHO_AUTHENTICATE 90 /* RFC3118, was 210 */
  144. #define DHO_CLIENT_LAST_TRANSACTION_TIME 91
  145. #define DHO_ASSOCIATED_IP 92
  146. #define DHO_SUBNET_SELECTION 118 /* RFC3011! */
  147. #define DHO_DOMAIN_SEARCH 119 /* RFC3397 */
  148. #define DHO_VIVCO_SUBOPTIONS 124
  149. #define DHO_VIVSO_SUBOPTIONS 125
  150. #define DHO_END 255
  151. /* DHCP message types. */
  152. #define DHCPDISCOVER 1
  153. #define DHCPOFFER 2
  154. #define DHCPREQUEST 3
  155. #define DHCPDECLINE 4
  156. #define DHCPACK 5
  157. #define DHCPNAK 6
  158. #define DHCPRELEASE 7
  159. #define DHCPINFORM 8
  160. #define DHCPLEASEQUERY 10
  161. #define DHCPLEASEUNASSIGNED 11
  162. #define DHCPLEASEUNKNOWN 12
  163. #define DHCPLEASEACTIVE 13
  164. /* Relay Agent Information option subtypes: */
  165. #define RAI_CIRCUIT_ID 1
  166. #define RAI_REMOTE_ID 2
  167. #define RAI_AGENT_ID 3
  168. #define RAI_LINK_SELECT 5
  169. /* FQDN suboptions: */
  170. #define FQDN_NO_CLIENT_UPDATE 1
  171. #define FQDN_SERVER_UPDATE 2
  172. #define FQDN_ENCODED 3
  173. #define FQDN_RCODE1 4
  174. #define FQDN_RCODE2 5
  175. #define FQDN_HOSTNAME 6
  176. #define FQDN_DOMAINNAME 7
  177. #define FQDN_FQDN 8
  178. #define FQDN_SUBOPTION_COUNT 8
  179. /* Enterprise Suboptions: */
  180. #define VENDOR_ISC_SUBOPTIONS 2495
  181. #endif /* DHCP_H */