Subject: | get_embedded_ipv4 |
I suspect the get_embedded_ipv4() method doesn't honour the extraction
of embeded IPv4 addresses according to the format specified at
http://en.wikipedia.org/wiki/IPv6#IPv4-mapped_IPv6_addresses, where by
IPv6 addresses can be represented by "::ffff:1.2.3.4"
This version seems to return embedded IPv4s from IPv6 addresses:
sub get_embeddded_ipv6 {
my $ipv6 = shift;
my @parts = split /:/, $ipv6;
for (0..4) {
return unless defined($parts[$_]) && $parts[$_] eq "0000";
}
return unless defined($parts[$5]) && $parts[5] eq "ffff";
return unless defined($parts[6]) && defined($parts[7]);
my $ipv4 = join('.', unpack ('C4', pack('H*', $parts[6]. $parts[7])));
return $ipv4 if ip_is_ipv4($ipv4);
}