@@ -262,6 +262,17 @@ TEST_F(AddrRegTest, sanityCheck) {
262
262
EXPECT_FALSE (srv_.sanityCheck (addr_reg_inf));
263
263
}
264
264
265
+ // Test that more than one client-id are forbidden for Addr-reg-inform messages
266
+ TEST_F (AddrRegTest, sanityCheck2) {
267
+ Pkt6Ptr addr_reg_inf = Pkt6Ptr (new Pkt6 (DHCPV6_ADDR_REG_INFORM, 1234 ));
268
+
269
+ // A message with more than one client-id options should fail.
270
+ OptionPtr clientid = generateClientId ();
271
+ addr_reg_inf->addOption (clientid);
272
+ addr_reg_inf->addOption (clientid);
273
+ EXPECT_FALSE (srv_.sanityCheck (addr_reg_inf));
274
+ }
275
+
265
276
// Test that subnet selection must return a subnet for processAddrRegInform.
266
277
TEST_F (AddrRegTest, noSubnet) {
267
278
Pkt6Ptr addr_reg_inf = Pkt6Ptr (new Pkt6 (DHCPV6_ADDR_REG_INFORM, 1234 ));
@@ -312,7 +323,7 @@ TEST_F(AddrRegTest, noIA_NA) {
312
323
EXPECT_FALSE (srv_.processAddrRegInform (ctx));
313
324
314
325
string expected = " DHCP6_ADDR_REG_INFORM_FAIL " ;
315
- expected += " error on addr-reg-inform from client fe80::abcd: " ;
326
+ expected += " error on ADDR-REG-INFORM from client fe80::abcd: " ;
316
327
expected += " Exactly 1 IA_NA option expected, but 0 received" ;
317
328
EXPECT_EQ (1 , countFile (expected));
318
329
}
@@ -346,7 +357,7 @@ TEST_F(AddrRegTest, twoIA_NAs) {
346
357
EXPECT_FALSE (srv_.processAddrRegInform (ctx));
347
358
348
359
string expected = " DHCP6_ADDR_REG_INFORM_FAIL " ;
349
- expected += " error on addr-reg-inform from client fe80::abcd: " ;
360
+ expected += " error on ADDR-REG-INFORM from client fe80::abcd: " ;
350
361
expected += " Exactly 1 IA_NA option expected, but 2 received" ;
351
362
EXPECT_EQ (1 , countFile (expected));
352
363
}
@@ -379,7 +390,7 @@ TEST_F(AddrRegTest, noIA_NAsub) {
379
390
EXPECT_FALSE (srv_.processAddrRegInform (ctx));
380
391
381
392
string expected = " DHCP6_ADDR_REG_INFORM_FAIL " ;
382
- expected += " error on addr-reg-inform from client fe80::abcd: " ;
393
+ expected += " error on ADDR-REG-INFORM from client fe80::abcd: " ;
383
394
expected += " Exactly 1 IA_NA sub-option expected, but 0 received" ;
384
395
EXPECT_EQ (1 , countFile (expected));
385
396
}
@@ -415,7 +426,7 @@ TEST_F(AddrRegTest, twoIA_NAsub) {
415
426
EXPECT_FALSE (srv_.processAddrRegInform (ctx));
416
427
417
428
string expected = " DHCP6_ADDR_REG_INFORM_FAIL " ;
418
- expected += " error on addr-reg-inform from client fe80::abcd: " ;
429
+ expected += " error on ADDR-REG-INFORM from client fe80::abcd: " ;
419
430
expected += " Exactly 1 IA_NA sub-option expected, but 2 received" ;
420
431
EXPECT_EQ (1 , countFile (expected));
421
432
}
@@ -450,7 +461,7 @@ TEST_F(AddrRegTest, noAddrMatch) {
450
461
EXPECT_FALSE (srv_.processAddrRegInform (ctx));
451
462
452
463
string expected = " DHCP6_ADDR_REG_INFORM_FAIL " ;
453
- expected += " error on addr-reg-inform from client fe80::abcd: " ;
464
+ expected += " error on ADDR-REG-INFORM from client fe80::abcd: " ;
454
465
expected += " Address mismatch: client at fe80::abcd " ;
455
466
expected += " wants to register 2001:db8:1::1" ;
456
467
EXPECT_EQ (1 , countFile (expected));
@@ -492,7 +503,7 @@ TEST_F(AddrRegTest, noAddrMatchRelay) {
492
503
EXPECT_FALSE (srv_.processAddrRegInform (ctx));
493
504
494
505
string expected = " DHCP6_ADDR_REG_INFORM_FAIL " ;
495
- expected += " error on addr-reg-inform from client fe80::ef01: " ;
506
+ expected += " error on ADDR-REG-INFORM from client fe80::ef01: " ;
496
507
expected += " Address mismatch: client at fe80::ef01 " ;
497
508
expected += " wants to register 2001:db8:1::1" ;
498
509
EXPECT_EQ (1 , countFile (expected));
@@ -540,7 +551,7 @@ TEST_F(AddrRegTest, noAddrMatch2Relays) {
540
551
EXPECT_FALSE (srv_.processAddrRegInform (ctx));
541
552
542
553
string expected = " DHCP6_ADDR_REG_INFORM_FAIL " ;
543
- expected += " error on addr-reg-inform from client fe80::2345: " ;
554
+ expected += " error on ADDR-REG-INFORM from client fe80::2345: " ;
544
555
expected += " Address mismatch: client at fe80::2345 " ;
545
556
expected += " wants to register 2001:db8:1::1" ;
546
557
EXPECT_EQ (1 , countFile (expected));
@@ -576,7 +587,7 @@ TEST_F(AddrRegTest, noInSubnet) {
576
587
EXPECT_FALSE (srv_.processAddrRegInform (ctx));
577
588
578
589
string expected = " DHCP6_ADDR_REG_INFORM_FAIL " ;
579
- expected += " error on addr-reg-inform from client 2001:db8::1: " ;
590
+ expected += " error on ADDR-REG-INFORM from client 2001:db8::1: " ;
580
591
expected += " Address 2001:db8::1 is not in subnet " ;
581
592
expected += " 2001:db8:1::/64 (id 1)" ;
582
593
EXPECT_EQ (1 , countFile (expected));
@@ -612,7 +623,7 @@ TEST_F(AddrRegTest, reserved) {
612
623
EXPECT_FALSE (srv_.processAddrRegInform (ctx));
613
624
614
625
string expected = " DHCP6_ADDR_REG_INFORM_FAIL " ;
615
- expected += " error on addr-reg-inform from client 2001:db8:1::10: " ;
626
+ expected += " error on ADDR-REG-INFORM from client 2001:db8:1::10: " ;
616
627
expected += " Address 2001:db8:1::10 is reserved" ;
617
628
EXPECT_EQ (1 , countFile (expected));
618
629
}
@@ -655,7 +666,7 @@ AddrRegTest::testAddressInUse(const uint32_t state) {
655
666
EXPECT_FALSE (srv_.processAddrRegInform (ctx));
656
667
657
668
string expected = " DHCP6_ADDR_REG_INFORM_FAIL " ;
658
- expected += " error on addr-reg-inform from client 2001:db8:1::1: " ;
669
+ expected += " error on ADDR-REG-INFORM from client 2001:db8:1::1: " ;
659
670
expected += " Address 2001:db8:1::1 already in use Type:" ;
660
671
EXPECT_EQ (1 , countFile (expected));
661
672
}
@@ -942,7 +953,7 @@ AddrRegTest::testAnother() {
942
953
expected += " updating IPv6 lease for address 2001:db8:1::1" ;
943
954
EXPECT_EQ (1 , countFile (expected));
944
955
expected = " DHCP6_ADDR_REG_INFORM_CLIENT_CHANGE " ;
945
- expected += " received an addr-reg-inform for 2001:db8:1::1 from client '" ;
956
+ expected += " received an ADDR-REG-INFORM for 2001:db8:1::1 from client '" ;
946
957
expected += duid_->toText ();
947
958
expected += " ' but the address was registered by another client " ;
948
959
expected += " '44:44:44:44:44:44:44:44'" ;
@@ -1480,6 +1491,8 @@ TEST_F(AddrRegTest, stats) {
1480
1491
static_cast <int64_t >(5 ));
1481
1492
StatsMgr::instance ().setValue (cumulative_registered_nas_name_,
1482
1493
static_cast <int64_t >(10 ));
1494
+ StatsMgr::instance ().setValue (" cumulative-registered-nas" ,
1495
+ static_cast <int64_t >(20 ));
1483
1496
1484
1497
testBasic ();
1485
1498
@@ -1491,6 +1504,8 @@ TEST_F(AddrRegTest, stats) {
1491
1504
stat = StatsMgr::instance ().getObservation (cumulative_registered_nas_name_);
1492
1505
ASSERT_TRUE (stat);
1493
1506
EXPECT_EQ (11 , stat->getInteger ().first );
1507
+ stat = StatsMgr::instance ().getObservation (" cumulative-registered-nas" );
1508
+ EXPECT_EQ (21 , stat->getInteger ().first );
1494
1509
}
1495
1510
1496
1511
// Check the statictics for the renew scenario.
@@ -1503,6 +1518,8 @@ TEST_F(AddrRegTest, statsRenew) {
1503
1518
static_cast <int64_t >(5 ));
1504
1519
StatsMgr::instance ().setValue (cumulative_registered_nas_name_,
1505
1520
static_cast <int64_t >(10 ));
1521
+ StatsMgr::instance ().setValue (" cumulative-registered-nas" ,
1522
+ static_cast <int64_t >(20 ));
1506
1523
1507
1524
testRenew ();
1508
1525
@@ -1514,6 +1531,8 @@ TEST_F(AddrRegTest, statsRenew) {
1514
1531
stat = StatsMgr::instance ().getObservation (cumulative_registered_nas_name_);
1515
1532
ASSERT_TRUE (stat);
1516
1533
EXPECT_EQ (10 , stat->getInteger ().first );
1534
+ stat = StatsMgr::instance ().getObservation (" cumulative-registered-nas" );
1535
+ EXPECT_EQ (20 , stat->getInteger ().first );
1517
1536
}
1518
1537
1519
1538
} // end of anonymous namespace
0 commit comments