#build the tree
my $root = Tree::DAG_Node->new;
$root->attributes({
original=>"permit ip any any",
source=>['0.0.0.0/0'],
destination=>['0.0.0.0/0']
});
foreach my $node (@node_list){
my $location;
$root->walk_down({
callback => sub {
my $this_node = shift;
if (compare_nodes($node,$this_node)){
$location = $this_node->address;
1;
}
else{
0;
}
}
});
$root->address($location)->add_daughter($node)
if defined $root->address($location);
}
####
0-255 (root)
/ \
100-200(joe) 220-255(bob)
####
0-255 (root)
/ \
100-200(joe) 220-255(bob)
|
150-200(sue.1)
####
0-255 (root)
/ | \
/ | \
/ | \
100-200(joe) 151-220(sue.3) 220-255(bob)
| |
150-200(sue.1) 221-250(sue.4)
####
0-255
(root;256)
/ | \
/ | \
/ | \
/ | \
100-200 151-220 220-255
(joe;100) (sue.3;100) (bob;35)
| |
150-200 221-250
(sue.1;100) (sue.4;100)