mirror of
https://gitlab.com/shorewall/code.git
synced 2024-11-27 10:03:41 +01:00
Several fixes to IPv6 Address Handling
This commit is contained in:
parent
9d85d0ff7a
commit
1710f9ce7c
@ -485,16 +485,12 @@ sub valid_6address( $ ) {
|
||||
return 0 unless ( @address == $max ) || $address =~ /::/;
|
||||
return 0 if $address =~ /:::/ || $address =~ /::.*::/;
|
||||
|
||||
if ( $address =~ /^:/ ) {
|
||||
unless ( $address eq '::' ) {
|
||||
return 0 if $address =~ /:$/ || $address =~ /^:.*::/;
|
||||
}
|
||||
} elsif ( $address =~ /:$/ ) {
|
||||
return 0 if $address =~ /::.*:$/;
|
||||
}
|
||||
unless ( $address eq '::' ) {
|
||||
return 0 if $address =~ /^:/ || $address =~ /:$/;
|
||||
|
||||
for my $a ( @address ) {
|
||||
return 0 unless $a eq '' || ( $a =~ /^[a-fA-f\d]+$/ && oct "0x$a" < 65536 );
|
||||
for my $a ( @address ) {
|
||||
return 0 unless $a eq '' || ( $a =~ /^[a-fA-f\d]+$/ && oct "0x$a" < 65536 );
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
@ -543,15 +539,26 @@ sub validate_6net( $$ ) {
|
||||
sub normalize_6addr( $ ) {
|
||||
my $addr = shift;
|
||||
|
||||
while ( $addr =~ tr/:/:/ < 6 ) {
|
||||
$addr =~ s/::/:0::/;
|
||||
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+:/0:/;
|
||||
|
||||
$addr;
|
||||
}
|
||||
|
||||
$addr =~ s/::/:0:/;
|
||||
$addr =~ s/:0+/:0/g;
|
||||
$addr =~ s/^0+:/0:/;
|
||||
|
||||
$addr;
|
||||
}
|
||||
|
||||
sub validate_6range( $$ ) {
|
||||
|
Loading…
Reference in New Issue
Block a user