From a5c9947f4305b4a214741ff50345f486232dff56 Mon Sep 17 00:00:00 2001 From: Benjamin Rokseth Date: Thu, 13 Nov 2014 20:34:25 +0100 Subject: [PATCH] Bug 13252 - SIP2 server should accept IPv6 connections This small patch adds a check on the SIP2 socket connection if it is IPv6 and resolves socket address accordingly. Any newer Debian distro would probably default to IPv6 so it would eventually affect all SIP servers. Tests against running SIP server on an IPv6 box: http://wiki.koha-community.org/wiki/Koha_SIP2_server_setup#Testing_with_Telnet before patch: disconnects immediately. Log output: Bad arg length for Socket::unpack_sockaddr_in, length is 28, should be 16 after patch: operates normally Signed-off-by: Colin Campbell Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- C4/SIP/SIPServer.pm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/C4/SIP/SIPServer.pm b/C4/SIP/SIPServer.pm index 45d8007027..7e9c620218 100755 --- a/C4/SIP/SIPServer.pm +++ b/C4/SIP/SIPServer.pm @@ -88,8 +88,16 @@ sub process_request { $self->{config} = $config; my $sockname = getsockname(STDIN); - ($port, $sockaddr) = sockaddr_in($sockname); - $sockaddr = inet_ntoa($sockaddr); + + # Check if socket connection is IPv6 before resolving address + my $family = Socket::sockaddr_family($sockname); + if ($family == AF_INET6) { + ($port, $sockaddr) = sockaddr_in6($sockname); + $sockaddr = Socket::inet_ntop(AF_INET6, $sockaddr); + } else { + ($port, $sockaddr) = sockaddr_in($sockname); + $sockaddr = inet_ntoa($sockaddr); + } $proto = $self->{server}->{client}->NS_proto(); $self->{service} = $config->find_service($sockaddr, $port, $proto); -- 2.39.5