Problem with setsockopt(IPPROTO_IPV6,IPV6_ONLY) on Redhat
Development toolkit for Web Services and XML data bindings for C & C++
Brought to you by:
engelen
Running 2.8.1 on Redhat Server 5.5. In soap_bind (line 4670 of stdsoap2.cpp), setsockopt(soap->master, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&unset, sizeof(int)) fails with "Protocol not supported"
'uname -s -r -v -p -i -o' returns
Linux 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64 x86_64 GNU/Linux
'gcc --version' returns
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-50)
Apparantly, to make things work on various Windows platforms, we had to the change this code from 2.7.13 original
#ifdef IPV6_V6ONLY
if (setsockopt(soap->master, level, IPV6_V6ONLY, (char*)&unset, sizeof(int)))
{ soap->errnum = soap_socket_errno(soap->master);
soap_set_receiver_error(soap, tcp_error(soap), "setsockopt IPV6_V6ONLY failed in soap_bind()", SOAP_TCP_ERROR);
return SOAP_INVALID_SOCKET;
}
#endif
To this:
#ifdef GSOAP_WINDOWS // Preprocessor defined only in Windows
xfutility::WindowsSystemInfo sysInfo;
xfutility::WindowsVersion version = sysInfo.GetWindowsVersion();
if (version == xfutility::WindowsVista ||
version == xfutility::WindowsServer2008 ||
version == xfutility::WindowsServer2008R2 ||
version == xfutility::Windows7)
{
if (setsockopt(soap->master, level, IPV6_V6ONLY, (char*)&unset, sizeof(int)))
{ soap->errnum = soap_socket_errno(soap->master);
soap_set_receiver_error(soap, tcp_error(soap), "setsockopt IPV6_V6ONLY failed in soap_bind()", SOAP_TCP_ERROR);
return SOAP_INVALID_SOCKET;
}
}
#endif
This had the effect of removing the setsockopt call on our Linux builds as well. The attempt to set IPV6_V6ONLY option also
fails on an embedded linux platform we use running Freescale Linux
In the upcoming 2.8.2 release you can explicitly enable/disable this feature.
The code in stdsoap2.c/.cpp 2.8.2 checks for WITH_IPV6_V6ONLY rather than IPV6_V6ONLY:
#ifdef WITH_IPV6
#ifdef WITH_IPV6_V6ONLY
if (setsockopt(soap->master, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&set, sizeof(int)))
...
#ifdef WITH_NO_IPV6_V6ONLY
if (setsockopt(soap->master, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&unset, sizeof(int))
and IPv6-IPv6 switch is enabled by default:
#ifdef WITH_IPV6
# ifdef IPV6_V6ONLY
# if !defined(WITH_NO_IPV6_V6ONLY) && !defined(WITH_IPV6_V6ONLY)
# define WITH_NO_IPV6_V6ONLY /* turn on IPv6-IPv4 switching */
# endif
# endif
#endif
This should hopefully resolve issues.
This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).