From d75d747b19ef25f9083eb6425c032128f3875398 Mon Sep 17 00:00:00 2001 From: ligc Date: Tue, 11 May 2010 14:03:58 +0000 Subject: [PATCH] ipv6 fix, replace the Socket library calls with NetworkUtils subroutines git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6060 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/NetworkUtils.pm | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/NetworkUtils.pm b/perl-xCAT/xCAT/NetworkUtils.pm index 7671b1f58..00122390a 100755 --- a/perl-xCAT/xCAT/NetworkUtils.pm +++ b/perl-xCAT/xCAT/NetworkUtils.pm @@ -101,6 +101,15 @@ sub gethostname() { my ($class, $iporhost) = @_; + if (ref($iporhost) eq 'ARRAY') + { + $iporhost = @{$iporhost}[0]; + if (!$iporhost) + { + return undef; + } + } + my $socket6support = eval { require Socket6 }; if (($iporhost !~ /\d+\.\d+\.\d+\.\d+/) && ($iporhost !~ /:/)) @@ -163,6 +172,14 @@ sub getipaddr() { my ($class, $iporhost) = @_; + if (ref($iporhost) eq 'ARRAY') + { + $iporhost = @{$iporhost}[0]; + if (!$iporhost) + { + return undef; + } + } my $socket6support = eval { require Socket6 }; if (($iporhost =~ /\d+\.\d+\.\d+\.\d+/) || ($iporhost =~ /:/)) @@ -189,7 +206,13 @@ sub getipaddr() } else { - return inet_ntoa(inet_aton($iporhost)) + #return inet_ntoa(inet_aton($iporhost)) + my $packed_ip = inet_aton($iporhost); + if (!$packed_ip) + { + return undef; + } + return inet_ntoa($packed_ip); } } }