Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

dhcpv6.h 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. #ifndef _IPXE_DHCPV6_H
  2. #define _IPXE_DHCPV6_H
  3. /** @file
  4. *
  5. * Dynamic Host Configuration Protocol for IPv6
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. #include <stdint.h>
  10. #include <ipxe/in.h>
  11. #include <ipxe/uuid.h>
  12. /** DHCPv6 server port */
  13. #define DHCPV6_SERVER_PORT 547
  14. /** DHCPv6 client port */
  15. #define DHCPV6_CLIENT_PORT 546
  16. /**
  17. * A DHCPv6 option
  18. *
  19. */
  20. struct dhcpv6_option {
  21. /** Code */
  22. uint16_t code;
  23. /** Length of the data field */
  24. uint16_t len;
  25. /** Data */
  26. uint8_t data[0];
  27. } __attribute__ (( packed ));
  28. /** DHCP unique identifier based on UUID (DUID-UUID) */
  29. struct dhcpv6_duid_uuid {
  30. /** Type */
  31. uint16_t type;
  32. /** UUID */
  33. union uuid uuid;
  34. } __attribute__ (( packed ));
  35. /** DHCP unique identifier based on UUID (DUID-UUID) */
  36. #define DHCPV6_DUID_UUID 4
  37. /** DHCPv6 client or server identifier option */
  38. struct dhcpv6_duid_option {
  39. /** Option header */
  40. struct dhcpv6_option header;
  41. /** DHCP unique identifier (DUID) */
  42. uint8_t duid[0];
  43. } __attribute__ (( packed ));
  44. /** DHCPv6 client identifier option */
  45. #define DHCPV6_CLIENT_ID 1
  46. /** DHCPv6 server identifier option */
  47. #define DHCPV6_SERVER_ID 2
  48. /** DHCPv6 identity association for non-temporary address (IA_NA) option */
  49. struct dhcpv6_ia_na_option {
  50. /** Option header */
  51. struct dhcpv6_option header;
  52. /** Identity association identifier (IAID) */
  53. uint32_t iaid;
  54. /** Renew time (in seconds) */
  55. uint32_t renew;
  56. /** Rebind time (in seconds) */
  57. uint32_t rebind;
  58. /** IA_NA options */
  59. struct dhcpv6_option options[0];
  60. } __attribute__ (( packed ));
  61. /** DHCPv6 identity association for non-temporary address (IA_NA) option */
  62. #define DHCPV6_IA_NA 3
  63. /** DHCPv6 identity association address (IAADDR) option */
  64. struct dhcpv6_iaaddr_option {
  65. /** Option header */
  66. struct dhcpv6_option header;
  67. /** IPv6 address */
  68. struct in6_addr address;
  69. /** Preferred lifetime (in seconds) */
  70. uint32_t preferred;
  71. /** Valid lifetime (in seconds) */
  72. uint32_t valid;
  73. /** IAADDR options */
  74. struct dhcpv6_option options[0];
  75. } __attribute__ (( packed ));
  76. /** DHCPv6 identity association address (IAADDR) option */
  77. #define DHCPV6_IAADDR 5
  78. /** DHCPv6 option request option */
  79. struct dhcpv6_option_request_option {
  80. /** Option header */
  81. struct dhcpv6_option header;
  82. /** Requested options */
  83. uint16_t requested[0];
  84. } __attribute__ (( packed ));
  85. /** DHCPv6 option request option */
  86. #define DHCPV6_OPTION_REQUEST 6
  87. /** DHCPv6 elapsed time option */
  88. struct dhcpv6_elapsed_time_option {
  89. /** Option header */
  90. struct dhcpv6_option header;
  91. /** Elapsed time, in centiseconds */
  92. uint16_t elapsed;
  93. } __attribute__ (( packed ));
  94. /** DHCPv6 elapsed time option */
  95. #define DHCPV6_ELAPSED_TIME 8
  96. /** DHCPv6 status code option */
  97. struct dhcpv6_status_code_option {
  98. /** Option header */
  99. struct dhcpv6_option header;
  100. /** Status code */
  101. uint16_t status;
  102. /** Status message */
  103. char message[0];
  104. } __attribute__ (( packed ));
  105. /** DHCPv6 status code option */
  106. #define DHCPV6_STATUS_CODE 13
  107. /** DHCPv6 user class */
  108. struct dhcpv6_user_class {
  109. /** Length */
  110. uint16_t len;
  111. /** User class string */
  112. char string[0];
  113. } __attribute__ (( packed ));
  114. /** DHCPv6 user class option */
  115. struct dhcpv6_user_class_option {
  116. /** Option header */
  117. struct dhcpv6_option header;
  118. /** User class */
  119. struct dhcpv6_user_class user_class[0];
  120. } __attribute__ (( packed ));
  121. /** DHCPv6 user class option */
  122. #define DHCPV6_USER_CLASS 15
  123. /** DHCPv6 DNS recursive name server option */
  124. #define DHCPV6_DNS_SERVERS 23
  125. /** DHCPv6 domain search list option */
  126. #define DHCPV6_DOMAIN_LIST 24
  127. /** DHCPv6 bootfile URI option */
  128. #define DHCPV6_BOOTFILE_URL 59
  129. /** DHCPv6 bootfile parameters option */
  130. #define DHCPV6_BOOTFILE_PARAM 60
  131. /** DHCPv6 syslog server option
  132. *
  133. * This option code has not yet been assigned by IANA. Please update
  134. * this definition once an option code has been assigned.
  135. */
  136. #define DHCPV6_LOG_SERVERS 0xffffffffUL
  137. /**
  138. * Any DHCPv6 option
  139. *
  140. */
  141. union dhcpv6_any_option {
  142. struct dhcpv6_option header;
  143. struct dhcpv6_duid_option duid;
  144. struct dhcpv6_ia_na_option ia_na;
  145. struct dhcpv6_iaaddr_option iaaddr;
  146. struct dhcpv6_option_request_option option_request;
  147. struct dhcpv6_elapsed_time_option elapsed_time;
  148. struct dhcpv6_status_code_option status_code;
  149. struct dhcpv6_user_class_option user_class;
  150. };
  151. /**
  152. * A DHCPv6 header
  153. *
  154. */
  155. struct dhcpv6_header {
  156. /** Message type */
  157. uint8_t type;
  158. /** Transaction ID */
  159. uint8_t xid[3];
  160. /** Options */
  161. struct dhcpv6_option options[0];
  162. } __attribute__ (( packed ));
  163. /** DHCPv6 solicitation */
  164. #define DHCPV6_SOLICIT 1
  165. /** DHCPv6 advertisement */
  166. #define DHCPV6_ADVERTISE 2
  167. /** DHCPv6 request */
  168. #define DHCPV6_REQUEST 3
  169. /** DHCPv6 reply */
  170. #define DHCPV6_REPLY 7
  171. /** DHCPv6 information request */
  172. #define DHCPV6_INFORMATION_REQUEST 11
  173. /** DHCPv6 settings block name */
  174. #define DHCPV6_SETTINGS_NAME "dhcpv6"
  175. /**
  176. * Construct all-DHCP-relay-agents-and-servers multicast address
  177. *
  178. * @v addr Zeroed address to construct
  179. */
  180. static inline void ipv6_all_dhcp_relay_and_servers ( struct in6_addr *addr ) {
  181. addr->s6_addr16[0] = htons ( 0xff02 );
  182. addr->s6_addr[13] = 1;
  183. addr->s6_addr[15] = 2;
  184. }
  185. extern int start_dhcpv6 ( struct interface *job, struct net_device *netdev,
  186. int stateful );
  187. #endif /* _IPXE_DHCPV6_H */