add IPv6 subroutine prefixtomask
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6496 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
dc1b2ef8a4
commit
53b4fdb42e
@ -371,4 +371,46 @@ sub setup_ip_forwarding
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
=head3 prefixtomask
|
||||
Convert the IPv6 prefix length(e.g. 64) to the netmask(e.g. ffff:ffff:ffff:ffff:0000:0000:0000:0000).
|
||||
Till now, the netmask format ffff:ffff:ffff:: only works for AIX NIM
|
||||
|
||||
Arguments:
|
||||
prefix length
|
||||
Returns:
|
||||
netmask - netmask like ffff:ffff:ffff:ffff:0000:0000:0000:0000
|
||||
0 - if the prefix length is not correct
|
||||
Globals:
|
||||
Error:
|
||||
none
|
||||
Example:
|
||||
my #netmask = xCAT::NetworkUtils->prefixtomask($prefixlength);
|
||||
Comments:
|
||||
none
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
sub prefixtomask {
|
||||
my ($class, $prefixlength) = @_;
|
||||
|
||||
if (($prefixlength < 1) || ($prefixlength > 128))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
# can not do this without Net::IP module
|
||||
if (!$netipmodule)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
my $ip = new Net::IP ("fe80::/$prefixlength") or die (Net::IP::Error());
|
||||
|
||||
my $mask = $ip->mask();
|
||||
|
||||
return $mask;
|
||||
|
||||
}
|
||||
1;
|
||||
|
Loading…
Reference in New Issue
Block a user