1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822 | // Copyright (C) 2022-2024 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <config.h>
#include <asiolink/io_address.h>
#include <dhcpsrv/iterative_allocator.h>
#include <dhcpsrv/testutils/alloc_engine_utils.h>
#include <gtest/gtest.h><--- Include file: not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <sstream><--- Include file: not found. Please note: Cppcheck does not need standard library headers to get proper results.
using namespace isc::asiolink;
using namespace isc::dhcp;
using namespace std;
namespace isc {
namespace dhcp {
namespace test {
using IterativeAllocatorTest4 = AllocEngine4Test;
// Test that the allocator returns the correct type.
TEST_F(IterativeAllocatorTest4, getType) {
IterativeAllocator alloc(Lease::TYPE_V4, subnet_);
EXPECT_EQ("iterative", alloc.getType());
}
// This test verifies that the allocator picks addresses that belong to the
// pool
TEST_F(IterativeAllocatorTest4, basic) {<--- syntax error
boost::scoped_ptr<Allocator> alloc(new IterativeAllocator(Lease::TYPE_V4, subnet_));
for (int i = 0; i < 1000; ++i) {
IOAddress candidate = alloc->pickAddress(cc_, clientid_, IOAddress("0.0.0.0"));
EXPECT_TRUE(subnet_->inPool(Lease::TYPE_V4, candidate));
}
}
// This test verifies that the allocator picks addresses that belong to the
// pool using classification
TEST_F(IterativeAllocatorTest4, clientClass) {
boost::scoped_ptr<Allocator> alloc(new IterativeAllocator(Lease::TYPE_V4, subnet_));
// Restrict pool_ to the foo class. Add a second pool with bar class.
pool_->allowClientClass("foo");
Pool4Ptr pool(new Pool4(IOAddress("192.0.2.200"),
IOAddress("192.0.2.209")));
pool->allowClientClass("bar");
subnet_->addPool(pool);
// Clients are in bar
cc_.insert("bar");
for (int i = 0; i < 1000; ++i) {
IOAddress candidate = alloc->pickAddress(cc_, clientid_, IOAddress("0.0.0.0"));
EXPECT_TRUE(subnet_->inPool(Lease::TYPE_V4, candidate));
EXPECT_TRUE(subnet_->inPool(Lease::TYPE_V4, candidate, cc_));
}
}
// This test verifies that the iterative allocator really walks over all addresses
// in all pools in specified subnet. It also must not pick the same address twice
// unless it runs out of pool space.
TEST_F(IterativeAllocatorTest4, manyPools) {
IterativeAllocator alloc(Lease::TYPE_V4, subnet_);
// Let's start from 2, as there is 2001:db8:1::10 - 2001:db8:1::20 pool already.
for (int i = 2; i < 10; ++i) {
stringstream min, max;
min << "192.0.2." << i * 10 + 1;
max << "192.0.2." << i * 10 + 9;
Pool4Ptr pool(new Pool4(IOAddress(min.str()),
IOAddress(max.str())));
// cout << "Adding pool: " << min.str() << "-" << max.str() << endl;
subnet_->addPool(pool);
}
int total = 10 + 8 * 9; // first pool (.100 - .109) has 10 addresses in it,
// there are 8 extra pools with 9 addresses in each.
// Let's keep picked addresses here and check their uniqueness.
std::set<IOAddress> generated_addrs;
int cnt = 0;
while (++cnt) {
IOAddress candidate = alloc.pickAddress(cc_, clientid_, IOAddress("0.0.0.0"));
EXPECT_TRUE(subnet_->inPool(Lease::TYPE_V4, candidate));
// One way to easily verify that the iterative allocator really works is
// to uncomment the following line and observe its output that it
// covers all defined subnets.
// cout << candidate.toText() << endl;
if (generated_addrs.find(candidate) == generated_addrs.end()) {
// We haven't had this
generated_addrs.insert(candidate);
} else {
// We have seen this address before. That should mean that we
// iterated over all addresses.
if (generated_addrs.size() == total) {
// We have exactly the number of address in all pools
break;
}
ADD_FAILURE() << "Too many or not enough unique addresses generated.";
break;
}
if (cnt > total) {
ADD_FAILURE() << "Too many unique addresses generated.";
break;
}
}
}
using IterativeAllocatorTest6 = AllocEngine6Test;
// Test that the allocator returns the correct type.
TEST_F(IterativeAllocatorTest6, getType) {
IterativeAllocator allocNA(Lease::TYPE_NA, subnet_);
EXPECT_EQ("iterative", allocNA.getType());
IterativeAllocator allocPD(Lease::TYPE_PD, subnet_);
EXPECT_EQ("iterative", allocPD.getType());
}
// This test verifies that the allocator picks addresses that belong to the
// pool
TEST_F(IterativeAllocatorTest6, basic) {
boost::scoped_ptr<Allocator> alloc(new NakedIterativeAllocator(Lease::TYPE_NA, subnet_));
for (int i = 0; i < 1000; ++i) {
IOAddress candidate = alloc->pickAddress(cc_, duid_, IOAddress("::"));
EXPECT_TRUE(subnet_->inPool(Lease::TYPE_NA, candidate));
}
}
// This test verifies that the allocator picks addresses that belong to the
// pool using classification
TEST_F(IterativeAllocatorTest6, clientClass) {
boost::scoped_ptr<Allocator> alloc(new NakedIterativeAllocator(Lease::TYPE_NA, subnet_));
// Restrict pool_ to the foo class. Add a second pool with bar class.
pool_->allowClientClass("foo");
Pool6Ptr pool(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1::100"),
IOAddress("2001:db8:1::109")));
pool->allowClientClass("bar");
subnet_->addPool(pool);
// Clients are in bar
cc_.insert("bar");
for (int i = 0; i < 1000; ++i) {
IOAddress candidate = alloc->pickAddress(cc_, duid_, IOAddress("::"));
EXPECT_TRUE(subnet_->inPool(Lease::TYPE_NA, candidate));
EXPECT_TRUE(subnet_->inPool(Lease::TYPE_NA, candidate, cc_));
}
}
// This test verifies that the iterative allocator really walks over all addresses
// in all pools in specified subnet. It also must not pick the same address twice.
// unless it runs out of pool space.
TEST_F(IterativeAllocatorTest6, manyPools) {
NakedIterativeAllocator alloc(Lease::TYPE_NA, subnet_);
// let's start from 2, as there is 2001:db8:1::10 - 2001:db8:1::20 pool already.
for (int i = 2; i < 10; ++i) {
stringstream min, max;
min << "2001:db8:1::" << hex << i * 16 + 1;
max << "2001:db8:1::" << hex << i * 16 + 9;
Pool6Ptr pool(new Pool6(Lease::TYPE_NA, IOAddress(min.str()),
IOAddress(max.str())));
subnet_->addPool(pool);
}
int total = 17 + 8 * 9; // First pool (::10 - ::20) has 17 addresses in it,
// there are 8 extra pools with 9 addresses in each.
// Let's keep picked addresses here and check their uniqueness.
std::set<IOAddress> generated_addrs;
int cnt = 0;
while (++cnt) {
IOAddress candidate = alloc.pickAddress(cc_, duid_, IOAddress("::"));
EXPECT_TRUE(subnet_->inPool(Lease::TYPE_NA, candidate));
// One way to easily verify that the iterative allocator really works is
// to uncomment the following line and observe its output that it
// covers all defined pools.
// cout << candidate.toText() << endl;
if (generated_addrs.find(candidate) == generated_addrs.end()) {
// We haven't had this.
generated_addrs.insert(candidate);
} else {
// We have seen this address before. That should mean that we
// iterated over all addresses.
if (generated_addrs.size() == total) {
// We have exactly the number of address in all pools.
break;
}
ADD_FAILURE() << "Too many or not enough unique addresses generated.";
break;
}
if (cnt > total) {
ADD_FAILURE() << "Too many unique addresses generated.";
break;
}
}
}
// This test verifies that the allocator walks over the addresses in the
// non-contiguous pools.
TEST_F(IterativeAllocatorTest6, addrStep) {
subnet_->delPools(Lease::TYPE_NA); // Get rid of default pool
Pool6Ptr pool1(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1::1"),
IOAddress("2001:db8:1::5")));
Pool6Ptr pool2(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1::100"),
IOAddress("2001:db8:1::100")));
Pool6Ptr pool3(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1::105"),
IOAddress("2001:db8:1::106")));
subnet_->addPool(pool1);
subnet_->addPool(pool2);
subnet_->addPool(pool3);
NakedIterativeAllocator alloc(Lease::TYPE_NA, subnet_);
// Let's check the first pool (5 addresses here)
EXPECT_EQ("2001:db8:1::1",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
EXPECT_EQ("2001:db8:1::2",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
EXPECT_EQ("2001:db8:1::3",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
EXPECT_EQ("2001:db8:1::4",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
EXPECT_EQ("2001:db8:1::5",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
// The second pool is easy - only one address here
EXPECT_EQ("2001:db8:1::100",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
// This is the third and last pool, with 2 addresses in it
EXPECT_EQ("2001:db8:1::105",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
EXPECT_EQ("2001:db8:1::106",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
// We iterated over all addresses and reached to the end of the last pool.
// Let's wrap around and start from the beginning
EXPECT_EQ("2001:db8:1::1",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
EXPECT_EQ("2001:db8:1::2",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
}
// This test verifies that the allocator walks over the addresses in the
// non-contiguous pools when pools contain class guards.
TEST_F(IterativeAllocatorTest6, addrStepInClass) {
subnet_->delPools(Lease::TYPE_NA); // Get rid of default pool
Pool6Ptr pool1(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1::1"),
IOAddress("2001:db8:1::5")));
Pool6Ptr pool2(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1::100"),
IOAddress("2001:db8:1::100")));
Pool6Ptr pool3(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1::105"),
IOAddress("2001:db8:1::106")));
// Set pool1 and pool3 but not pool2 in foo class
pool1->allowClientClass("foo");
pool3->allowClientClass("foo");
subnet_->addPool(pool1);
subnet_->addPool(pool2);
subnet_->addPool(pool3);
NakedIterativeAllocator alloc(Lease::TYPE_NA, subnet_);
// Clients are in foo
cc_.insert("foo");
// Let's check the first pool (5 addresses here)
EXPECT_EQ("2001:db8:1::1",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
EXPECT_EQ("2001:db8:1::2",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
EXPECT_EQ("2001:db8:1::3",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
EXPECT_EQ("2001:db8:1::4",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
EXPECT_EQ("2001:db8:1::5",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
// The second pool is easy - only one address here
EXPECT_EQ("2001:db8:1::100",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
// This is the third and last pool, with 2 addresses in it
EXPECT_EQ("2001:db8:1::105",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
EXPECT_EQ("2001:db8:1::106",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
// We iterated over all addresses and reached to the end of the last pool.
// Let's wrap around and start from the beginning
EXPECT_EQ("2001:db8:1::1",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
EXPECT_EQ("2001:db8:1::2",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
}
// This test verifies that the allocator omits pools with non-matching class guards.
TEST_F(IterativeAllocatorTest6, addrStepOutClass) {
subnet_->delPools(Lease::TYPE_NA); // Get rid of default pool
Pool6Ptr pool1(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1::1"),
IOAddress("2001:db8:1::5")));
Pool6Ptr pool2(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1::100"),
IOAddress("2001:db8:1::100")));
Pool6Ptr pool3(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1::105"),
IOAddress("2001:db8:1::106")));
// Set pool2 in foo
pool2->allowClientClass("foo");
subnet_->addPool(pool1);
subnet_->addPool(pool2);
subnet_->addPool(pool3);
NakedIterativeAllocator alloc(Lease::TYPE_NA, subnet_);
// Let's check the first pool (5 addresses here)
EXPECT_EQ("2001:db8:1::1",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
EXPECT_EQ("2001:db8:1::2",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
EXPECT_EQ("2001:db8:1::3",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
EXPECT_EQ("2001:db8:1::4",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
EXPECT_EQ("2001:db8:1::5",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
// The second pool is skipped
// This is the third and last pool, with 2 addresses in it
EXPECT_EQ("2001:db8:1::105",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
EXPECT_EQ("2001:db8:1::106",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
// We iterated over all addresses and reached to the end of the last pool.
// Let's wrap around and start from the beginning
EXPECT_EQ("2001:db8:1::1",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
EXPECT_EQ("2001:db8:1::2",
alloc.pickAddress(cc_, duid_, IOAddress("::")).toText());
}
// This test verifies that the allocator picks delegated prefixes from several
// pools.
TEST_F(IterativeAllocatorTest6, prefixStep) {
subnet_ = Subnet6::create(IOAddress("2001:db8::"), 32, 1, 2, 3, 4, SubnetID(1));
Pool6Ptr pool1(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8::"), 56, 60));
Pool6Ptr pool2(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:1::"), 48, 48));
Pool6Ptr pool3(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:2::"), 56, 64));
subnet_->addPool(pool1);
subnet_->addPool(pool2);
subnet_->addPool(pool3);
NakedIterativeAllocator alloc(Lease::TYPE_PD, subnet_);
Pool6Ptr pool;
// We have a 2001:db8::/48 subnet that has 3 pools defined in it:
// 2001:db8::/56 split into /60 prefixes (16 leases) (or 2001:db8:0:X0::)
// 2001:db8:1::/48 split into a single /48 prefix (just 1 lease)
// 2001:db8:2::/56 split into /64 prefixes (256 leases) (or 2001:db8:2:XX::)
// First pool check (Let's check over all 16 leases)
EXPECT_EQ("2001:db8::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:10::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:20::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:30::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:40::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:50::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:60::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:70::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:80::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:90::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:a0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:b0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:c0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:d0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:e0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:f0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
// Second pool (just one lease here)
EXPECT_EQ("2001:db8:1::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
// Third pool (256 leases, let's check first and last explicitly and the
// rest over in a pool
EXPECT_EQ("2001:db8:2::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
for (int i = 1; i < 255; i++) {
stringstream exp;
exp << "2001:db8:2:" << hex << i << dec << "::";
EXPECT_EQ(exp.str(),
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
}
EXPECT_EQ("2001:db8:2:ff::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
// Ok, we've iterated over all prefixes in all pools. We now wrap around.
// We're looping over now (iterating over first pool again)
EXPECT_EQ("2001:db8::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:10::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
}
// This test verifies that the allocator picks delegated prefixes from several
// pools.
TEST_F(IterativeAllocatorTest6, prefixStepPreferLower) {
subnet_ = Subnet6::create(IOAddress("2001:db8::"),
32, 1, 2, 3, 4, SubnetID(1));
Pool6Ptr pool1(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8::"), 56, 60));
Pool6Ptr pool2(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:1::"), 48, 48));
Pool6Ptr pool3(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:2::"), 56, 64));
subnet_->addPool(pool1);
subnet_->addPool(pool2);
subnet_->addPool(pool3);
NakedIterativeAllocator alloc(Lease::TYPE_PD, subnet_);
Pool6Ptr pool;
// We have a 2001:db8::/48 subnet that has 3 pools defined in it:
// 2001:db8::/56 split into /60 prefixes (16 leases) (or 2001:db8:0:X0::)
// 2001:db8:1::/48 split into a single /48 prefix (just 1 lease)
// 2001:db8:2::/56 split into /64 prefixes (256 leases) (or 2001:db8:2:XX::)
// First pool check (Let's check over all 16 leases)
EXPECT_EQ("2001:db8::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:10::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:20::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:30::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:40::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:50::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:60::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:70::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:80::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:90::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:a0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:b0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:c0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:d0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:e0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:f0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
// Second pool (just one lease here)
EXPECT_EQ("2001:db8:1::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
// Ok, we've iterated over all prefixes in all pools. We now wrap around.
// We're looping over now (iterating over first pool again)
EXPECT_EQ("2001:db8::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:10::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
}
// This test verifies that the allocator picks delegated prefixes from several
// pools.
TEST_F(IterativeAllocatorTest6, prefixStepPreferEqual) {
subnet_ = Subnet6::create(IOAddress("2001:db8::"), 32, 1, 2, 3, 4, SubnetID(1));
Pool6Ptr pool1(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8::"), 56, 60));
Pool6Ptr pool2(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:1::"), 48, 48));
Pool6Ptr pool3(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:2::"), 56, 64));
subnet_->addPool(pool1);
subnet_->addPool(pool2);
subnet_->addPool(pool3);
NakedIterativeAllocator alloc(Lease::TYPE_PD, subnet_);
Pool6Ptr pool;
// We have a 2001:db8::/48 subnet that has 3 pools defined in it:
// 2001:db8::/56 split into /60 prefixes (16 leases) (or 2001:db8:0:X0::)
// 2001:db8:1::/48 split into a single /48 prefix (just 1 lease)
// 2001:db8:2::/56 split into /64 prefixes (256 leases) (or 2001:db8:2:XX::)
// Second pool (just one lease here)
EXPECT_EQ("2001:db8:1::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_EQUAL, IOAddress("::"), 48).toText());
// Ok, we've iterated over all prefixes in all pools. We now wrap around.
// We're looping over now (iterating over second pool again)
EXPECT_EQ("2001:db8:1::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_EQUAL, IOAddress("::"), 48).toText());
}
// This test verifies that the allocator picks delegated prefixes from several
// pools.
TEST_F(IterativeAllocatorTest6, prefixStepPreferHigher) {
subnet_ = Subnet6::create(IOAddress("2001:db8::"), 32, 1, 2, 3, 4, SubnetID(1));
Pool6Ptr pool1(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8::"), 56, 60));
Pool6Ptr pool2(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:1::"), 48, 48));
Pool6Ptr pool3(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:2::"), 56, 64));
subnet_->addPool(pool1);
subnet_->addPool(pool2);
subnet_->addPool(pool3);
NakedIterativeAllocator alloc(Lease::TYPE_PD, subnet_);
Pool6Ptr pool;
// We have a 2001:db8::/48 subnet that has 3 pools defined in it:
// 2001:db8::/56 split into /60 prefixes (16 leases) (or 2001:db8:0:X0::)
// 2001:db8:1::/48 split into a single /48 prefix (just 1 lease)
// 2001:db8:2::/56 split into /64 prefixes (256 leases) (or 2001:db8:2:XX::)
// Third pool (256 leases, let's check first and last explicitly and the
// rest over in a pool
EXPECT_EQ("2001:db8:2::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 60).toText());
for (int i = 1; i < 255; i++) {
stringstream exp;
exp << "2001:db8:2:" << hex << i << dec << "::";
EXPECT_EQ(exp.str(),
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 60).toText());
}
EXPECT_EQ("2001:db8:2:ff::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 60).toText());
// Ok, we've iterated over all prefixes in all pools. We now wrap around.
// We're looping over now (iterating over third pool again)
EXPECT_EQ("2001:db8:2::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 60).toText());
}
// This test verifies that the allocator picks delegated prefixes from the pools
// with class guards.
TEST_F(IterativeAllocatorTest6, prefixStepInClass) {
subnet_ = Subnet6::create(IOAddress("2001:db8::"), 32, 1, 2, 3, 4, SubnetID(1));
Pool6Ptr pool1(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8::"), 56, 60));
Pool6Ptr pool2(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:1::"), 48, 48));
Pool6Ptr pool3(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:2::"), 56, 64));
// Set pool1 and pool3 but not pool2 in foo class
pool1->allowClientClass("foo");
pool3->allowClientClass("foo");
subnet_->addPool(pool1);
subnet_->addPool(pool2);
subnet_->addPool(pool3);
NakedIterativeAllocator alloc(Lease::TYPE_PD, subnet_);
Pool6Ptr pool;
// Clients are in foo
cc_.insert("foo");
// We have a 2001:db8::/48 subnet that has 3 pools defined in it:
// 2001:db8::/56 split into /60 prefixes (16 leases) (or 2001:db8:0:X0::)
// 2001:db8:1::/48 split into a single /48 prefix (just 1 lease)
// 2001:db8:2::/56 split into /64 prefixes (256 leases) (or 2001:db8:2:XX::)
// First pool check (Let's check over all 16 leases)
EXPECT_EQ("2001:db8::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:10::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:20::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:30::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:40::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:50::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:60::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:70::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:80::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:90::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:a0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:b0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:c0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:d0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:e0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:f0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
// Second pool (just one lease here)
EXPECT_EQ("2001:db8:1::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
// Third pool (256 leases, let's check first and last explicitly and the
// rest over in a pool
EXPECT_EQ("2001:db8:2::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
for (int i = 1; i < 255; i++) {
stringstream exp;
exp << "2001:db8:2:" << hex << i << dec << "::";
EXPECT_EQ(exp.str(),
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
}
EXPECT_EQ("2001:db8:2:ff::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
// Ok, we've iterated over all prefixes in all pools. We now wrap around.
// We're looping over now (iterating over first pool again)
EXPECT_EQ("2001:db8::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:10::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
}
// This test verifies that the allocator omits pools with non-matching client classes.
TEST_F(IterativeAllocatorTest6, prefixStepOutClass) {
subnet_ = Subnet6::create(IOAddress("2001:db8::"), 32, 1, 2, 3, 4, SubnetID(1));
Pool6Ptr pool1(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8::"), 56, 60));
Pool6Ptr pool2(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:1::"), 48, 48));
Pool6Ptr pool3(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:2::"), 56, 64));
// Set pool2 in foo
pool2->allowClientClass("foo");
subnet_->addPool(pool1);
subnet_->addPool(pool2);
subnet_->addPool(pool3);
NakedIterativeAllocator alloc(Lease::TYPE_PD, subnet_);
Pool6Ptr pool;
// We have a 2001:db8::/48 subnet that has 3 pools defined in it:
// 2001:db8::/56 split into /60 prefixes (16 leases) (or 2001:db8:0:X0::)
// 2001:db8:1::/48 split into a single /48 prefix (just 1 lease)
// 2001:db8:2::/56 split into /64 prefixes (256 leases) (or 2001:db8:2:XX::)
// First pool check (Let's check over all 16 leases)
EXPECT_EQ("2001:db8::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:10::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:20::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:30::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:40::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:50::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:60::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:70::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:80::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:90::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:a0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:b0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:c0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:d0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:e0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:f0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
// The second pool is skipped
// Third pool (256 leases, let's check first and last explicitly and the
// rest over in a pool
EXPECT_EQ("2001:db8:2::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
for (int i = 1; i < 255; i++) {
stringstream exp;
exp << "2001:db8:2:" << hex << i << dec << "::";
EXPECT_EQ(exp.str(),
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
}
EXPECT_EQ("2001:db8:2:ff::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
// Ok, we've iterated over all prefixes in all pools. We now wrap around.
// We're looping over now (iterating over first pool again)
EXPECT_EQ("2001:db8::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:10::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
}
// This test verifies that the iterative allocator can step over addresses.
TEST_F(IterativeAllocatorTest6, addressIncrease) {
NakedIterativeAllocator alloc(Lease::TYPE_NA, subnet_);
// Let's pick the first address
IOAddress addr1 = alloc.pickAddress(cc_, duid_, IOAddress("2001:db8:1::10"));
// Check that we can indeed pick the first address from the pool
EXPECT_EQ("2001:db8:1::10", addr1.toText());
// Check that addresses can be increased properly
checkAddrIncrease(alloc, "2001:db8::9", "2001:db8::a");
checkAddrIncrease(alloc, "2001:db8::f", "2001:db8::10");
checkAddrIncrease(alloc, "2001:db8::10", "2001:db8::11");
checkAddrIncrease(alloc, "2001:db8::ff", "2001:db8::100");
checkAddrIncrease(alloc, "2001:db8::ffff", "2001:db8::1:0");
checkAddrIncrease(alloc, "::", "::1");
checkAddrIncrease(alloc, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", "::");
}
// This test verifies that the allocator can step over prefixes.
TEST_F(IterativeAllocatorTest6, prefixIncrease) {
NakedIterativeAllocator alloc(Lease::TYPE_PD, subnet_);
// For /128 prefix, increasePrefix should work the same as addressIncrease
checkPrefixIncrease(alloc, "2001:db8::9", 128, "2001:db8::a");
checkPrefixIncrease(alloc, "2001:db8::f", 128, "2001:db8::10");
checkPrefixIncrease(alloc, "2001:db8::10", 128, "2001:db8::11");
checkPrefixIncrease(alloc, "2001:db8::ff", 128, "2001:db8::100");
checkPrefixIncrease(alloc, "2001:db8::ffff", 128, "2001:db8::1:0");
checkPrefixIncrease(alloc, "::", 128, "::1");
checkPrefixIncrease(alloc, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", 128, "::");
// Check that /64 prefixes can be generated
checkPrefixIncrease(alloc, "2001:db8::", 64, "2001:db8:0:1::");
// Check that prefix length not divisible by 8 are working
checkPrefixIncrease(alloc, "2001:db8::", 128, "2001:db8::1");
checkPrefixIncrease(alloc, "2001:db8::", 127, "2001:db8::2");
checkPrefixIncrease(alloc, "2001:db8::", 126, "2001:db8::4");
checkPrefixIncrease(alloc, "2001:db8::", 125, "2001:db8::8");
checkPrefixIncrease(alloc, "2001:db8::", 124, "2001:db8::10");
checkPrefixIncrease(alloc, "2001:db8::", 123, "2001:db8::20");
checkPrefixIncrease(alloc, "2001:db8::", 122, "2001:db8::40");
checkPrefixIncrease(alloc, "2001:db8::", 121, "2001:db8::80");
checkPrefixIncrease(alloc, "2001:db8::", 120, "2001:db8::100");
// These are not really useful cases, because there are bits set
// int the last (128 - prefix_len) bits. Nevertheless, it shows
// that the algorithm is working even in such cases
checkPrefixIncrease(alloc, "2001:db8::1", 128, "2001:db8::2");
checkPrefixIncrease(alloc, "2001:db8::1", 127, "2001:db8::3");
checkPrefixIncrease(alloc, "2001:db8::1", 126, "2001:db8::5");
checkPrefixIncrease(alloc, "2001:db8::1", 125, "2001:db8::9");
checkPrefixIncrease(alloc, "2001:db8::1", 124, "2001:db8::11");
checkPrefixIncrease(alloc, "2001:db8::1", 123, "2001:db8::21");
checkPrefixIncrease(alloc, "2001:db8::1", 122, "2001:db8::41");
checkPrefixIncrease(alloc, "2001:db8::1", 121, "2001:db8::81");
checkPrefixIncrease(alloc, "2001:db8::1", 120, "2001:db8::101");
// Let's try out couple real life scenarios
checkPrefixIncrease(alloc, "2001:db8:1:abcd::", 64, "2001:db8:1:abce::");
checkPrefixIncrease(alloc, "2001:db8:1:abcd::", 60, "2001:db8:1:abdd::");
checkPrefixIncrease(alloc, "2001:db8:1:abcd::", 56, "2001:db8:1:accd::");
checkPrefixIncrease(alloc, "2001:db8:1:abcd::", 52, "2001:db8:1:bbcd::");
// And now let's try something over the top
checkPrefixIncrease(alloc, "::", 1, "8000::");
}
} // end of namespace isc::dhcp::test
} // end of namespace isc::dhcp
} // end of namespace isc
|