2010-05-31 08:32:19 +00:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
# IBM(c) 2010 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
#
|
|
|
|
#####################################################
|
|
|
|
#
|
|
|
|
# This script will calculate the IPv6 link local address
|
|
|
|
# from the mac address
|
|
|
|
# the mac address can be something like
|
|
|
|
# 00215ea68cd9 or 00:21:5e:a6:8c:d9
|
|
|
|
# example mac2linklocal 00215ea68cd9
|
|
|
|
#
|
|
|
|
#####################################################
|
|
|
|
|
|
|
|
BEGIN
|
|
|
|
{
|
|
|
|
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
|
|
|
|
}
|
|
|
|
|
|
|
|
use lib "$::XCATROOT/lib/perl";
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use Getopt::Long;
|
|
|
|
|
|
|
|
if (
|
|
|
|
!GetOptions("h|help" => \$::HELP,
|
|
|
|
"m=s" => \$::MACADDR,)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
&usage;
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($::HELP)
|
|
|
|
{
|
|
|
|
&usage;
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:48:24 +00:00
|
|
|
require xCAT::NetworkUtils;
|
|
|
|
|
2010-05-31 08:32:19 +00:00
|
|
|
if ($::MACADDR)
|
|
|
|
{
|
|
|
|
my $linklocal = xCAT::NetworkUtils->linklocaladdr($::MACADDR);
|
|
|
|
print "$linklocal";
|
|
|
|
}
|
|
|
|
|
|
|
|
sub usage
|
|
|
|
{
|
2013-03-13 23:48:24 +00:00
|
|
|
print "Usage: mac2linklocal -m <mac_address>\n\n";
|
2013-03-14 14:20:31 +00:00
|
|
|
print "Determines the IPv6 link local address that is appropriate for a NIC, based on its MAC.\n\n";
|
|
|
|
print "Author: Li, Guang Cheng\n";
|
2010-05-31 08:32:19 +00:00
|
|
|
return;
|
|
|
|
}
|