iPXE
dhcpv6.h
Go to the documentation of this file.
00001 #ifndef _IPXE_DHCPV6_H
00002 #define _IPXE_DHCPV6_H
00003 
00004 /** @file
00005  *
00006  * Dynamic Host Configuration Protocol for IPv6
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <stdint.h>
00013 #include <ipxe/in.h>
00014 #include <ipxe/uuid.h>
00015 
00016 /** DHCPv6 server port */
00017 #define DHCPV6_SERVER_PORT 547
00018 
00019 /** DHCPv6 client port */
00020 #define DHCPV6_CLIENT_PORT 546
00021 
00022 /**
00023  * A DHCPv6 option
00024  *
00025  */
00026 struct dhcpv6_option {
00027         /** Code */
00028         uint16_t code;
00029         /** Length of the data field */
00030         uint16_t len;
00031         /** Data */
00032         uint8_t data[0];
00033 } __attribute__ (( packed ));
00034 
00035 /** DHCP unique identifier based on UUID (DUID-UUID) */
00036 struct dhcpv6_duid_uuid {
00037         /** Type */
00038         uint16_t type;
00039         /** UUID */
00040         union uuid uuid;
00041 } __attribute__ (( packed ));
00042 
00043 /** DHCP unique identifier based on UUID (DUID-UUID) */
00044 #define DHCPV6_DUID_UUID 4
00045 
00046 /** DHCPv6 client or server identifier option */
00047 struct dhcpv6_duid_option {
00048         /** Option header */
00049         struct dhcpv6_option header;
00050         /** DHCP unique identifier (DUID) */
00051         uint8_t duid[0];
00052 } __attribute__ (( packed ));
00053 
00054 /** DHCPv6 client identifier option */
00055 #define DHCPV6_CLIENT_ID 1
00056 
00057 /** DHCPv6 server identifier option */
00058 #define DHCPV6_SERVER_ID 2
00059 
00060 /** DHCPv6 identity association for non-temporary address (IA_NA) option */
00061 struct dhcpv6_ia_na_option {
00062         /** Option header */
00063         struct dhcpv6_option header;
00064         /** Identity association identifier (IAID) */
00065         uint32_t iaid;
00066         /** Renew time (in seconds) */
00067         uint32_t renew;
00068         /** Rebind time (in seconds) */
00069         uint32_t rebind;
00070         /** IA_NA options */
00071         struct dhcpv6_option options[0];
00072 } __attribute__ (( packed ));
00073 
00074 /** DHCPv6 identity association for non-temporary address (IA_NA) option */
00075 #define DHCPV6_IA_NA 3
00076 
00077 /** DHCPv6 identity association address (IAADDR) option */
00078 struct dhcpv6_iaaddr_option {
00079         /** Option header */
00080         struct dhcpv6_option header;
00081         /** IPv6 address */
00082         struct in6_addr address;
00083         /** Preferred lifetime (in seconds) */
00084         uint32_t preferred;
00085         /** Valid lifetime (in seconds) */
00086         uint32_t valid;
00087         /** IAADDR options */
00088         struct dhcpv6_option options[0];
00089 } __attribute__ (( packed ));
00090 
00091 /** DHCPv6 identity association address (IAADDR) option */
00092 #define DHCPV6_IAADDR 5
00093 
00094 /** DHCPv6 option request option */
00095 struct dhcpv6_option_request_option {
00096         /** Option header */
00097         struct dhcpv6_option header;
00098         /** Requested options */
00099         uint16_t requested[0];
00100 } __attribute__ (( packed ));
00101 
00102 /** DHCPv6 option request option */
00103 #define DHCPV6_OPTION_REQUEST 6
00104 
00105 /** DHCPv6 elapsed time option */
00106 struct dhcpv6_elapsed_time_option {
00107         /** Option header */
00108         struct dhcpv6_option header;
00109         /** Elapsed time, in centiseconds */
00110         uint16_t elapsed;
00111 } __attribute__ (( packed ));
00112 
00113 /** DHCPv6 elapsed time option */
00114 #define DHCPV6_ELAPSED_TIME 8
00115 
00116 /** DHCPv6 status code option */
00117 struct dhcpv6_status_code_option {
00118         /** Option header */
00119         struct dhcpv6_option header;
00120         /** Status code */
00121         uint16_t status;
00122         /** Status message */
00123         char message[0];
00124 } __attribute__ (( packed ));
00125 
00126 /** DHCPv6 status code option */
00127 #define DHCPV6_STATUS_CODE 13
00128 
00129 /** DHCPv6 user class */
00130 struct dhcpv6_user_class {
00131         /** Length */
00132         uint16_t len;
00133         /** User class string */
00134         char string[0];
00135 } __attribute__ (( packed ));
00136 
00137 /** DHCPv6 user class option */
00138 struct dhcpv6_user_class_option {
00139         /** Option header */
00140         struct dhcpv6_option header;
00141         /** User class */
00142         struct dhcpv6_user_class user_class[0];
00143 } __attribute__ (( packed ));
00144 
00145 /** DHCPv6 user class option */
00146 #define DHCPV6_USER_CLASS 15
00147 
00148 /** DHCPv6 vendor class option */
00149 #define DHCPV6_VENDOR_CLASS 16
00150 
00151 /** DHCPv6 PXE vendor class
00152  *
00153  * The DHCPv6 vendor class includes a field for an IANA enterprise
00154  * number.  The EDK2 codebase uses the value 343, with the comment:
00155  *
00156  *     TODO: IANA TBD: temporarily using Intel's
00157  *
00158  * Since this "temporarily" has applied since at least 2010, we assume
00159  * that it has become a de facto standard.
00160  */
00161 #define DHCPV6_VENDOR_CLASS_PXE 343
00162 
00163 /** DHCPv6 DNS recursive name server option */
00164 #define DHCPV6_DNS_SERVERS 23
00165 
00166 /** DHCPv6 domain search list option */
00167 #define DHCPV6_DOMAIN_LIST 24
00168 
00169 /** DHCPv6 bootfile URI option */
00170 #define DHCPV6_BOOTFILE_URL 59
00171 
00172 /** DHCPv6 bootfile parameters option */
00173 #define DHCPV6_BOOTFILE_PARAM 60
00174 
00175 /** DHCPv6 client system architecture option */
00176 #define DHCPV6_CLIENT_ARCHITECTURE 61
00177 
00178 /** DHCPv6 client network interface identifier option */
00179 #define DHCPV6_CLIENT_NDI 62
00180 
00181 /** DHCPv6 syslog server option
00182  *
00183  * This option code has not yet been assigned by IANA.  Please update
00184  * this definition once an option code has been assigned.
00185  */
00186 #define DHCPV6_LOG_SERVERS 0xffffffffUL
00187 
00188 /** Construct a DHCPv6 byte value */
00189 #define DHCPV6_BYTE_VALUE( value ) ( (value) & 0xff )
00190 
00191 /** Construct a DHCPv6 word value */
00192 #define DHCPV6_WORD_VALUE( value ) \
00193         DHCPV6_BYTE_VALUE ( (value) >> 8 ), DHCPV6_BYTE_VALUE ( (value) >> 0 )
00194 
00195 /** Construct a DHCPv6 dword value */
00196 #define DHCPV6_DWORD_VALUE( value ) \
00197         DHCPV6_WORD_VALUE ( (value) >> 16 ), DHCPV6_WORD_VALUE ( (value) >> 0 )
00198 
00199 /** Construct a DHCPv6 option code */
00200 #define DHCPV6_CODE( code ) DHCPV6_WORD_VALUE ( code )
00201 
00202 /** Construct a DHCPv6 option length */
00203 #define DHCPV6_LEN( len ) DHCPV6_WORD_VALUE ( len )
00204 
00205 /** Construct a DHCPv6 option from a list of bytes */
00206 #define DHCPV6_OPTION( ... ) \
00207         DHCPV6_LEN ( VA_ARG_COUNT ( __VA_ARGS__ ) ), __VA_ARGS__
00208 
00209 /** Construct a DHCPv6 option from a list of characters */
00210 #define DHCPV6_STRING( ... ) DHCPV6_OPTION ( __VA_ARGS__ )
00211 
00212 /** Construct a byte-valued DHCPv6 option */
00213 #define DHCPV6_BYTE( value ) DHCPV6_OPTION ( DHCPV6_BYTE_VALUE ( value ) )
00214 
00215 /** Construct a word-valued DHCPv6 option */
00216 #define DHCPV6_WORD( value ) DHCPV6_OPTION ( DHCPV6_WORD_VALUE ( value ) )
00217 
00218 /** Construct a dword-valued DHCPv6 option */
00219 #define DHCPV6_DWORD( value ) DHCPV6_OPTION ( DHCPV6_DWORD_VALUE ( value ) )
00220 
00221 /**
00222  * Any DHCPv6 option
00223  *
00224  */
00225 union dhcpv6_any_option {
00226         struct dhcpv6_option header;
00227         struct dhcpv6_duid_option duid;
00228         struct dhcpv6_ia_na_option ia_na;
00229         struct dhcpv6_iaaddr_option iaaddr;
00230         struct dhcpv6_option_request_option option_request;
00231         struct dhcpv6_elapsed_time_option elapsed_time;
00232         struct dhcpv6_status_code_option status_code;
00233         struct dhcpv6_user_class_option user_class;
00234 };
00235 
00236 /**
00237  * A DHCPv6 header
00238  *
00239  */
00240 struct dhcpv6_header {
00241         /** Message type */
00242         uint8_t type;
00243         /** Transaction ID */
00244         uint8_t xid[3];
00245         /** Options */
00246         struct dhcpv6_option options[0];
00247 } __attribute__ (( packed ));
00248 
00249 /** DHCPv6 solicitation */
00250 #define DHCPV6_SOLICIT 1
00251 
00252 /** DHCPv6 advertisement */
00253 #define DHCPV6_ADVERTISE 2
00254 
00255 /** DHCPv6 request */
00256 #define DHCPV6_REQUEST 3
00257 
00258 /** DHCPv6 reply */
00259 #define DHCPV6_REPLY 7
00260 
00261 /** DHCPv6 information request */
00262 #define DHCPV6_INFORMATION_REQUEST 11
00263 
00264 /** DHCPv6 settings block name */
00265 #define DHCPV6_SETTINGS_NAME "dhcpv6"
00266 
00267 /**
00268  * Construct all-DHCP-relay-agents-and-servers multicast address
00269  *
00270  * @v addr              Zeroed address to construct
00271  */
00272 static inline void ipv6_all_dhcp_relay_and_servers ( struct in6_addr *addr ) {
00273         addr->s6_addr16[0] = htons ( 0xff02 );
00274         addr->s6_addr[13] = 1;
00275         addr->s6_addr[15] = 2;
00276 }
00277 
00278 extern int start_dhcpv6 ( struct interface *job, struct net_device *netdev,
00279                           int stateful );
00280 
00281 #endif /* _IPXE_DHCPV6_H */