Ticket #9820: upnp-v6-1.diff

File upnp-v6-1.diff, 3.1 KB (added by greg, 9 years ago)
  • mythtv/libs/libmythbase/msocketdevice.cpp

    diff --git a/mythtv/libs/libmythbase/msocketdevice.cpp b/mythtv/libs/libmythbase/msocketdevice.cpp
    index 76afc03..5f7e7d8 100644
    a b  
    4242****************************************************************************/
    4343
    4444#include "msocketdevice.h"
     45#include "mythverbose.h"
    4546
    4647#include "qwindowdefs.h"
    4748#include <string.h>
    MSocketDevice::MSocketDevice( Type type ) 
    189190           this, type );
    190191#endif
    191192    init();
    192     //setSocket( createNewSocket(), type );
     193
     194    // For the time being, if it's of type Datagram create the socket now
     195    // rather than later during connect (since there wont be one with udp)
     196    if (type == Datagram)
     197        setSocket( createNewSocket(), type );
    193198}
    194199
    195200/*!
    quint16 MSocketDevice::port() const 
    549554*/
    550555QHostAddress MSocketDevice::address() const
    551556{
    552     return a;
     557
     558    QString ipaddress;
     559    if (a.toString().startsWith("0:0:0:0:0:FFFF:"))
     560    {
     561        Q_IPV6ADDR addr = a.toIPv6Address();
     562         // addr contains 16 unsigned characters
     563
     564        ipaddress = QString("%1.%2.%3.%4").arg(addr[12]).arg(addr[13]).arg(addr[14]).arg(addr[15]);
     565    }
     566    else
     567        ipaddress = a.toString();
     568
     569    return QHostAddress(ipaddress);
    553570}
    554571
    555572
  • mythtv/libs/libmythupnp/upnpdevice.cpp

    diff --git a/mythtv/libs/libmythupnp/upnpdevice.cpp b/mythtv/libs/libmythupnp/upnpdevice.cpp
    index d121dcb..6b49297 100644
    a b void UPnpDeviceDesc::GetValidXML( 
    357357    QString BaseAddr;
    358358    QHostAddress addr(sBaseAddress);
    359359
     360    BaseAddr = sBaseAddress;
     361
    360362#if !defined(QT_NO_IPV6)
    361363    // Basically if it appears to be an IPv6 IP surround the IP with [] otherwise don't bother
    362     if (( addr.protocol() == QAbstractSocket::IPv6Protocol ) || (sBaseAddress.contains(":")))
     364    if (sBaseAddress.contains(":"))
    363365        BaseAddr = "[" + sBaseAddress + "]";
    364366    else
    365367#endif
    366     if ( addr.protocol() == QAbstractSocket::IPv4Protocol )
    367         BaseAddr = sBaseAddress;
    368368
    369369    os << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
    370370          "<root xmlns=\"urn:schemas-upnp-org:device-1-0\"  xmlns:mythtv=\"mythtv.org\">\n"
  • mythtv/libs/libmythupnp/upnptasksearch.cpp

    diff --git a/mythtv/libs/libmythupnp/upnptasksearch.cpp b/mythtv/libs/libmythupnp/upnptasksearch.cpp
    index 20d6d8e..cb7c0d6 100644
    a b void UPnpSearchTask::SendMsg( MSocketDevice *pSocket, 
    108108                                it != m_addressList.end();
    109109                              ++it )
    110110    {
     111        QString ipaddress = *it;
     112
     113        // If this looks like an IPv6 address, then enclose it in []'s
     114        if (ipaddress.contains(":"))
     115            ipaddress = "[" + ipaddress + "]";
     116
    111117        QString sHeader = QString ( "HTTP/1.1 200 OK\r\n"
    112                                     "LOCATION: http://[%1]:%2/getDeviceDesc\r\n" )
    113                             .arg( *it )
     118                                    "LOCATION: http://%1:%2/getDeviceDesc\r\n" )
     119                            .arg( ipaddress )
    114120                            .arg( m_nServicePort);