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.0KB

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