diff --git a/LANforge/Utils.pm b/LANforge/Utils.pm index c0d56c51..e65ec0ec 100644 --- a/LANforge/Utils.pm +++ b/LANforge/Utils.pm @@ -3,7 +3,8 @@ use strict; use warnings; use Carp; use Net::Telnet; -use bigint; +#use bigint; +use Math::BigInt; $| = 1; #$SIG{ __DIE__ } = sub { Carp::confess( @_ ) }; #$SIG{ __WARN__ } = sub { Carp::confess( @_ ) }; @@ -1160,18 +1161,23 @@ sub expand_unit_str { } sub mac_add { - my ($first_mac, $second_dec) = @_; + my ($self, $first_mac, $second_dec) = @_; $first_mac =~ s/[:]//g if ($first_mac =~ /[:]/); - $first_mac = "0x".$first_mac if ($first_mac !~ /^0x/); - - my $newdec = (0+$second_dec) + hex($first_mac); - my $newhex = sprintf("%x", $newdec); + my $newdec = Math::BigInt->new($first_mac); + $newdec->badd(0+$second_dec); + my $pad = Math::BigInt->new('0x1000000000000'); + $newdec->badd($pad); + my $newhex = "".$newdec->as_hex(); my $rv = ""; + $newhex = substr($newhex, -12); # we begin 0x100...much bigger than we need for (my $i = length($newhex); $i > 0; $i-=2) { $rv = substr($newhex, $i-2, 2).":$rv"; } - return substr($newhex, 0, -1); + $rv =substr($rv, 0, -1); + undef($newdec); + undef($pad); + return $rv; }