|
@@ -40,6 +40,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
40
|
40
|
#include <ipxe/crc32.h>
|
41
|
41
|
#include <ipxe/errortab.h>
|
42
|
42
|
#include <ipxe/ipv6.h>
|
|
43
|
+#include <ipxe/dhcp_arch.h>
|
43
|
44
|
#include <ipxe/dhcpv6.h>
|
44
|
45
|
|
45
|
46
|
/** @file
|
|
@@ -364,10 +365,17 @@ static int dhcpv6_register ( struct dhcpv6_option_list *options,
|
364
|
365
|
*
|
365
|
366
|
*/
|
366
|
367
|
|
367
|
|
-/** Options to be requested */
|
368
|
|
-static uint16_t dhcpv6_requested_options[] = {
|
369
|
|
- htons ( DHCPV6_DNS_SERVERS ), htons ( DHCPV6_DOMAIN_LIST ),
|
370
|
|
- htons ( DHCPV6_BOOTFILE_URL ), htons ( DHCPV6_BOOTFILE_PARAM ),
|
|
368
|
+/** Raw option data for options common to all DHCPv6 requests */
|
|
369
|
+static uint8_t dhcpv6_request_options_data[] = {
|
|
370
|
+ DHCPV6_CODE ( DHCPV6_OPTION_REQUEST ),
|
|
371
|
+ DHCPV6_OPTION ( DHCPV6_CODE ( DHCPV6_DNS_SERVERS ),
|
|
372
|
+ DHCPV6_CODE ( DHCPV6_DOMAIN_LIST ),
|
|
373
|
+ DHCPV6_CODE ( DHCPV6_BOOTFILE_URL ),
|
|
374
|
+ DHCPV6_CODE ( DHCPV6_BOOTFILE_PARAM ) ),
|
|
375
|
+ DHCPV6_CODE ( DHCPV6_CLIENT_ARCHITECTURE ),
|
|
376
|
+ DHCPV6_WORD ( DHCP_ARCH_CLIENT_ARCHITECTURE ),
|
|
377
|
+ DHCPV6_CODE ( DHCPV6_CLIENT_NDI ),
|
|
378
|
+ DHCPV6_OPTION ( DHCP_ARCH_CLIENT_NDI )
|
371
|
379
|
};
|
372
|
380
|
|
373
|
381
|
/**
|
|
@@ -565,15 +573,14 @@ static int dhcpv6_tx ( struct dhcpv6_session *dhcpv6 ) {
|
565
|
573
|
struct dhcpv6_duid_option *server_id;
|
566
|
574
|
struct dhcpv6_ia_na_option *ia_na;
|
567
|
575
|
struct dhcpv6_iaaddr_option *iaaddr;
|
568
|
|
- struct dhcpv6_option_request_option *option_request;
|
569
|
576
|
struct dhcpv6_user_class_option *user_class;
|
570
|
577
|
struct dhcpv6_elapsed_time_option *elapsed;
|
571
|
578
|
struct dhcpv6_header *dhcphdr;
|
572
|
579
|
struct io_buffer *iobuf;
|
|
580
|
+ void *options;
|
573
|
581
|
size_t client_id_len;
|
574
|
582
|
size_t server_id_len;
|
575
|
583
|
size_t ia_na_len;
|
576
|
|
- size_t option_request_len;
|
577
|
584
|
size_t user_class_string_len;
|
578
|
585
|
size_t user_class_len;
|
579
|
586
|
size_t elapsed_len;
|
|
@@ -592,16 +599,14 @@ static int dhcpv6_tx ( struct dhcpv6_session *dhcpv6 ) {
|
592
|
599
|
} else {
|
593
|
600
|
ia_na_len = 0;
|
594
|
601
|
}
|
595
|
|
- option_request_len = ( sizeof ( *option_request ) +
|
596
|
|
- sizeof ( dhcpv6_requested_options ) );
|
597
|
602
|
user_class_string_len = dhcpv6_user_class ( NULL, 0 );
|
598
|
603
|
user_class_len = ( sizeof ( *user_class ) +
|
599
|
604
|
sizeof ( user_class->user_class[0] ) +
|
600
|
605
|
user_class_string_len );
|
601
|
606
|
elapsed_len = sizeof ( *elapsed );
|
602
|
607
|
total_len = ( sizeof ( *dhcphdr ) + client_id_len + server_id_len +
|
603
|
|
- ia_na_len + option_request_len + user_class_len +
|
604
|
|
- elapsed_len );
|
|
608
|
+ ia_na_len + sizeof ( dhcpv6_request_options_data ) +
|
|
609
|
+ user_class_len + elapsed_len );
|
605
|
610
|
|
606
|
611
|
/* Allocate packet */
|
607
|
612
|
iobuf = xfer_alloc_iob ( &dhcpv6->xfer, total_len );
|
|
@@ -652,13 +657,10 @@ static int dhcpv6_tx ( struct dhcpv6_session *dhcpv6 ) {
|
652
|
657
|
}
|
653
|
658
|
}
|
654
|
659
|
|
655
|
|
- /* Construct option request */
|
656
|
|
- option_request = iob_put ( iobuf, option_request_len );
|
657
|
|
- option_request->header.code = htons ( DHCPV6_OPTION_REQUEST );
|
658
|
|
- option_request->header.len = htons ( option_request_len -
|
659
|
|
- sizeof ( option_request->header ));
|
660
|
|
- memcpy ( option_request->requested, dhcpv6_requested_options,
|
661
|
|
- sizeof ( dhcpv6_requested_options ) );
|
|
660
|
+ /* Construct fixed request options */
|
|
661
|
+ options = iob_put ( iobuf, sizeof ( dhcpv6_request_options_data ) );
|
|
662
|
+ memcpy ( options, dhcpv6_request_options_data,
|
|
663
|
+ sizeof ( dhcpv6_request_options_data ) );
|
662
|
664
|
|
663
|
665
|
/* Construct user class */
|
664
|
666
|
user_class = iob_put ( iobuf, user_class_len );
|