> I amended the relay plugin with the IPv6 code shown in the prior email, 
> that provides nibble boundary matching. 

There are still problems. This Net::IP::ip_expand_address function does
not seem to work properly with CIDR specification. 2001:db8:123::/64
is returned as "2001:0db8:1234:0000:0000:0000:0000:0/64".

Also it would probably make sense to convert non CIDR entries simply
into CIDR entries and then let the same code (which uses Net::IP)
handle it. This would make the plugin simpler.

Here is some code which just does that:

| $ip = '2001:db8:123';      
| $ipv6 = 1;
| 
| if ( $ipv6 && $ip !~ /::/ && ip !~ m|/| ) { # non CIDR IPv6 
| 
|   # Count the number of colons
|   my $cntcolons = scalar(@{[$ip =~ /:/g]});
|  
|   # Get the length of the last segment
|   my $lastseglen = length( (split(/:/,$ip))[$cntcolons] );
|  
|   # And now calculate the number of significant bits and append
|   $ip .= '/' . ( $cntcolons*16 + $lastseglen*4 );
|
| };

It will return for the given example '2001:db8:123/44' which as I
understands is the correct meaning of '2001:db8:123' when we split
at nibble endings.

Regards
Michael

-- 
It's an insane world, but i'm proud to be a part of it. -- Bill Hicks

Reply via email to