Triggered by discussion [c759af31]: first SIP message using IPv6 address is rejected with error 504 by the server. The log shows an error message when SIPE tries to determine the local socket address:
(10:37:20) sipe: transport_connect - hostname: sipfed0B.online.lync.com port: 443
(10:37:20) sipe: using SSL
(10:37:20) dnsquery: Performing DNS lookup for sipfed0B.online.lync.com
(10:37:20) dnsquery: IP resolved for sipfed0B.online.lync.com
(10:37:20) proxy: Attempting connection to 2603:1037:0:2::b
...
(10:37:20) proxy: Connected to sipfed0B.online.lync.com:443.
...
(10:37:20) network: getsockname: Windows socket error #10014
(10:37:20) sipe: sip_transport_connected: sipfed0B.online.lync.com:443
...
(10:37:20) sipe: sipe_backend_transport_ip_address: 2601:602:ca80:3574:d109:5d9e:f239:c98e
This looks like a valid IPv6 address to me, but because of the error message I think it might be the wrong one. Looking at the code of sipe_backend_transport_ip_address() in src/purple/purple.c that would mean that despite the error message in the log getsockname() does return 0, i.e. no error.
Related links:
sipe_backend_transport_ip_address()
Forums: c759af31
Forums: Unable to Connect to Skype For Business O365 - ADFS
Forums: Unable to Connect to Skype For Business O365 - ADFS
Release Notes: 2018/02/pidgin-sipe-release-1231
I've now been able to reproduce this on a Window 10 VM which I configured to use my IPv6 tunnel:
The IPv6 local address is correct, but the port number is 0 which is definitely incorrect. I should be able to debug this now.
I have been able to root cause the issue to a bug in Windows Pidgin. On Windows calling
purple_network_get_port_from_fd()on an IPv6 socket always generates the error messagenetwork: getsockname: Windows socket error #10014and then returns the default port 0. This incorrect port then leads to a 504 error from the SIP server.As a workaround I have replaced the broken function with our own implementation, using the guidance from the above mentioned StackOverflow question, in git commit f49fd3d4.
I've provided an updated Windows DLL in the development area.
Closing as FIXED.
Forgot to use
ntohs()when reading the port number from the data structure. It seems the SIP server doesn't really check the port number, but let's be correct on all systems and return the correct port number (git commit 1a15a1af).Updated the Windows DLL too.
Now all places in purple backend that call getsockname() are updated (git commit d5915e68)
Updated the Windows DLL again.