7
7
#include < config.h>
8
8
#include < asiolink/io_address.h>
9
9
#include < cc/data.h>
10
+ #include < dhcp/option_int.h>
10
11
#include < dhcp/option6_addrlst.h>
11
12
#include < dhcp/testutils/iface_mgr_test_config.h>
12
13
#include < dhcp6/json_config_parser.h>
@@ -370,7 +371,7 @@ TEST_F(AddrRegTest, noSubnet) {
370
371
}
371
372
372
373
// Test that an IA_NA option is fordidden.
373
- TEST_F (AddrRegTest, iA_NA ) {
374
+ TEST_F (AddrRegTest, unexpectedIA_NA ) {
374
375
IfaceMgrTestConfig test_config (true );
375
376
376
377
ASSERT_NO_THROW (configure (config_));
@@ -403,7 +404,7 @@ TEST_F(AddrRegTest, iA_NA) {
403
404
}
404
405
405
406
// Test that an IA_TA option is fordidden.
406
- TEST_F (AddrRegTest, iA_TA ) {
407
+ TEST_F (AddrRegTest, unexpectedIA_TA ) {
407
408
IfaceMgrTestConfig test_config (true );
408
409
409
410
ASSERT_NO_THROW (configure (config_));
@@ -414,7 +415,7 @@ TEST_F(AddrRegTest, iA_TA) {
414
415
addr_reg_inf->setIndex (ETH0_INDEX);
415
416
OptionPtr clientid = generateClientId ();
416
417
addr_reg_inf->addOption (clientid);
417
- Option6IAPtr ia (new Option6IA ( D6O_IA_TA, 234 ));
418
+ OptionPtr ia (new OptionInt< uint32_t >(Option::V6, D6O_IA_TA, 234 ));
418
419
addr_reg_inf->addOption (ia);
419
420
420
421
// Pass it to the server.
@@ -437,7 +438,7 @@ TEST_F(AddrRegTest, iA_TA) {
437
438
}
438
439
439
440
// Test that an IA_PD option is fordidden.
440
- TEST_F (AddrRegTest, iA_PD ) {
441
+ TEST_F (AddrRegTest, unexpectedIA_PD ) {
441
442
IfaceMgrTestConfig test_config (true );
442
443
443
444
ASSERT_NO_THROW (configure (config_));
@@ -497,7 +498,7 @@ TEST_F(AddrRegTest, noIAADDR) {
497
498
498
499
string expected = " DHCP6_ADDR_REG_INFORM_FAIL " ;
499
500
expected += " error on ADDR-REG-INFORM from client fe80::abcd: " ;
500
- expected += " Exactly 1 IAADDRE option expected, but 0 received" ;
501
+ expected += " Exactly 1 IAADDR option expected, but 0 received" ;
501
502
EXPECT_EQ (1 , countFile (expected));
502
503
}
503
504
@@ -535,6 +536,44 @@ TEST_F(AddrRegTest, twoIAADDR) {
535
536
EXPECT_EQ (1 , countFile (expected));
536
537
}
537
538
539
+ // Test that a well formed IAADDR option is required.
540
+ TEST_F (AddrRegTest, badIAADDR) {
541
+ IfaceMgrTestConfig test_config (true );
542
+
543
+ ASSERT_NO_THROW (configure (config_));
544
+
545
+ Pkt6Ptr addr_reg_inf = Pkt6Ptr (new Pkt6 (DHCPV6_ADDR_REG_INFORM, 1234 ));
546
+ addr_reg_inf->setRemoteAddr (IOAddress (" fe80::abcd" ));
547
+ addr_reg_inf->setIface (" eth0" );
548
+ addr_reg_inf->setIndex (ETH0_INDEX);
549
+ OptionPtr clientid = generateClientId ();
550
+ addr_reg_inf->addOption (clientid);
551
+ OptionCustomPtr iaddr (new OptionCustom (LibDHCP::D6O_IAADDR_DEF (),
552
+ Option::V6));
553
+ iaddr->writeAddress (IOAddress (" 2001:db8:1::1" ), 0 );
554
+ iaddr->writeInteger <uint32_t >(3000 , 1 );
555
+ iaddr->writeInteger <uint32_t >(4000 , 2 );
556
+ addr_reg_inf->addOption (iaddr);
557
+
558
+ // Pass it to the server.
559
+ AllocEngine::ClientContext6 ctx;
560
+ bool drop = !srv_->earlyGHRLookup (addr_reg_inf, ctx);
561
+ ASSERT_FALSE (drop);
562
+ ctx.subnet_ = srv_->selectSubnet (addr_reg_inf, drop);
563
+ ASSERT_FALSE (drop);
564
+ srv_->initContext (ctx, drop);
565
+ ASSERT_FALSE (drop);
566
+ ASSERT_TRUE (ctx.subnet_ );
567
+
568
+ // Two IAADDR options: no response.
569
+ EXPECT_FALSE (srv_->processAddrRegInform (ctx));
570
+
571
+ string expected = " DHCP6_ADDR_REG_INFORM_FAIL " ;
572
+ expected += " error on ADDR-REG-INFORM from client fe80::abcd: " ;
573
+ expected += " can't convert the IAADDR option" ;
574
+ EXPECT_EQ (1 , countFile (expected));
575
+ }
576
+
538
577
// Test that addresses must match.
539
578
TEST_F (AddrRegTest, noAddrMatch) {
540
579
IfaceMgrTestConfig test_config (true );
0 commit comments