forked from extern/shorewall_code
Several fixes to IPv6 Address Handling
This commit is contained in:
parent
9d85d0ff7a
commit
1710f9ce7c
@ -485,17 +485,13 @@ sub valid_6address( $ ) {
|
|||||||
return 0 unless ( @address == $max ) || $address =~ /::/;
|
return 0 unless ( @address == $max ) || $address =~ /::/;
|
||||||
return 0 if $address =~ /:::/ || $address =~ /::.*::/;
|
return 0 if $address =~ /:::/ || $address =~ /::.*::/;
|
||||||
|
|
||||||
if ( $address =~ /^:/ ) {
|
|
||||||
unless ( $address eq '::' ) {
|
unless ( $address eq '::' ) {
|
||||||
return 0 if $address =~ /:$/ || $address =~ /^:.*::/;
|
return 0 if $address =~ /^:/ || $address =~ /:$/;
|
||||||
}
|
|
||||||
} elsif ( $address =~ /:$/ ) {
|
|
||||||
return 0 if $address =~ /::.*:$/;
|
|
||||||
}
|
|
||||||
|
|
||||||
for my $a ( @address ) {
|
for my $a ( @address ) {
|
||||||
return 0 unless $a eq '' || ( $a =~ /^[a-fA-f\d]+$/ && oct "0x$a" < 65536 );
|
return 0 unless $a eq '' || ( $a =~ /^[a-fA-f\d]+$/ && oct "0x$a" < 65536 );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
}
|
}
|
||||||
@ -543,16 +539,27 @@ sub validate_6net( $$ ) {
|
|||||||
sub normalize_6addr( $ ) {
|
sub normalize_6addr( $ ) {
|
||||||
my $addr = shift;
|
my $addr = shift;
|
||||||
|
|
||||||
while ( $addr =~ tr/:/:/ < 6 ) {
|
if ( $addr eq '::' ) {
|
||||||
|
'0:0:0:0:0:0:0:0';
|
||||||
|
} else {
|
||||||
|
#
|
||||||
|
# Suppress leading zeros
|
||||||
|
#
|
||||||
|
$addr =~ s/^0+//;
|
||||||
|
$addr =~ s/:0+/:/g;
|
||||||
|
$addr =~ s/^:/0:/;
|
||||||
|
$addr =~ s/:$/:0/;
|
||||||
|
|
||||||
|
while ( $addr =~ tr/:/:/ < 7 ) {
|
||||||
$addr =~ s/::/:0::/;
|
$addr =~ s/::/:0::/;
|
||||||
}
|
}
|
||||||
|
|
||||||
$addr =~ s/::/:0:/;
|
$addr =~ s/::/:0:/;
|
||||||
$addr =~ s/:0+/:0/g;
|
|
||||||
$addr =~ s/^0+:/0:/;
|
$addr =~ s/^0+:/0:/;
|
||||||
|
|
||||||
$addr;
|
$addr;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sub validate_6range( $$ ) {
|
sub validate_6range( $$ ) {
|
||||||
my ( $low, $high ) = @_;
|
my ( $low, $high ) = @_;
|
||||||
|
Loading…
Reference in New Issue
Block a user