diff --git a/mythtv/libs/libmythbase/msocketdevice.cpp b/mythtv/libs/libmythbase/msocketdevice.cpp index 76afc03..5f7e7d8 100644 --- a/mythtv/libs/libmythbase/msocketdevice.cpp +++ b/mythtv/libs/libmythbase/msocketdevice.cpp @@ -42,6 +42,7 @@ ****************************************************************************/ #include "msocketdevice.h" +#include "mythverbose.h" #include "qwindowdefs.h" #include @@ -189,7 +190,11 @@ MSocketDevice::MSocketDevice( Type type ) this, type ); #endif init(); - //setSocket( createNewSocket(), type ); + + // For the time being, if it's of type Datagram create the socket now + // rather than later during connect (since there wont be one with udp) + if (type == Datagram) + setSocket( createNewSocket(), type ); } /*! @@ -549,7 +554,19 @@ quint16 MSocketDevice::port() const */ QHostAddress MSocketDevice::address() const { - return a; + + QString ipaddress; + if (a.toString().startsWith("0:0:0:0:0:FFFF:")) + { + Q_IPV6ADDR addr = a.toIPv6Address(); + // addr contains 16 unsigned characters + + ipaddress = QString("%1.%2.%3.%4").arg(addr[12]).arg(addr[13]).arg(addr[14]).arg(addr[15]); + } + else + ipaddress = a.toString(); + + return QHostAddress(ipaddress); } diff --git a/mythtv/libs/libmythupnp/upnpdevice.cpp b/mythtv/libs/libmythupnp/upnpdevice.cpp index d121dcb..6b49297 100644 --- a/mythtv/libs/libmythupnp/upnpdevice.cpp +++ b/mythtv/libs/libmythupnp/upnpdevice.cpp @@ -357,14 +357,14 @@ void UPnpDeviceDesc::GetValidXML( QString BaseAddr; QHostAddress addr(sBaseAddress); + BaseAddr = sBaseAddress; + #if !defined(QT_NO_IPV6) // Basically if it appears to be an IPv6 IP surround the IP with [] otherwise don't bother - if (( addr.protocol() == QAbstractSocket::IPv6Protocol ) || (sBaseAddress.contains(":"))) + if (sBaseAddress.contains(":")) BaseAddr = "[" + sBaseAddress + "]"; else #endif - if ( addr.protocol() == QAbstractSocket::IPv4Protocol ) - BaseAddr = sBaseAddress; os << "\n" "\n" diff --git a/mythtv/libs/libmythupnp/upnptasksearch.cpp b/mythtv/libs/libmythupnp/upnptasksearch.cpp index 20d6d8e..cb7c0d6 100644 --- a/mythtv/libs/libmythupnp/upnptasksearch.cpp +++ b/mythtv/libs/libmythupnp/upnptasksearch.cpp @@ -108,9 +108,15 @@ void UPnpSearchTask::SendMsg( MSocketDevice *pSocket, it != m_addressList.end(); ++it ) { + QString ipaddress = *it; + + // If this looks like an IPv6 address, then enclose it in []'s + if (ipaddress.contains(":")) + ipaddress = "[" + ipaddress + "]"; + QString sHeader = QString ( "HTTP/1.1 200 OK\r\n" - "LOCATION: http://[%1]:%2/getDeviceDesc\r\n" ) - .arg( *it ) + "LOCATION: http://%1:%2/getDeviceDesc\r\n" ) + .arg( ipaddress ) .arg( m_nServicePort);