5
0
mirror of git://git.proxmox.com/git/pve-common.git synced 2024-12-26 07:21:26 +03:00

provide Tools::unpack_sockaddr_in46

This commit is contained in:
Wolfgang Bumiller 2015-05-08 12:24:42 +02:00 committed by Dietmar Maurer
parent 00dc9d0fa9
commit 8df6b79439

View File

@ -4,6 +4,7 @@ use strict;
use warnings;
use POSIX qw(EINTR);
use IO::Socket::IP;
use Socket qw(AF_INET AF_INET6);
use IO::Select;
use File::Basename;
use File::Path qw(make_path);
@ -1043,4 +1044,12 @@ sub fnv31a {
sub fnv31a_hex { return sprintf("%X", fnv31a(@_)); }
sub unpack_sockaddr_in46 {
my ($sin) = @_;
my $family = Socket::sockaddr_family($sin);
my ($port, $host) = ($family == AF_INET6 ? Socket::unpack_sockaddr_in6($sin)
: Socket::unpack_sockaddr_in($sin));
return ($family, $port, $host);
}
1;