Skip to content

Commit

Permalink
UPnP: Fix SSDP Notify messages.
Browse files Browse the repository at this point in the history
At some point in the dim and distant past, the socket used for SSDP
alive/byebye messaging was converted to QMulticastSocket. The conversion
however did not pick up the use of the member variables from the new
subclass and hence SSDP notify messages are typically being sent to
0.0.0.0.

The fix just ensures we use the QMulticastSocket object properly. There
may be a slightly simpler fix to re-use the address and port in the
MSocketDevice parent class but I have no idea if that would be safe.
  • Loading branch information
Mark Kendall committed May 14, 2011
1 parent 057213c commit 9836c10
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions mythtv/libs/libmythupnp/upnptasknotify.cpp
Expand Up @@ -69,9 +69,9 @@ UPnpNotifyTask::~UPnpNotifyTask()
//
/////////////////////////////////////////////////////////////////////////////

void UPnpNotifyTask::SendNotifyMsg( MSocketDevice *pSocket,
QString sNT,
QString sUDN )
void UPnpNotifyTask::SendNotifyMsg( QMulticastSocket *pSocket,
QString sNT,
QString sUDN )
{
QString sUSN;

Expand All @@ -94,8 +94,8 @@ void UPnpNotifyTask::SendNotifyMsg( MSocketDevice *pSocket,
.arg( m_nMaxAge );

VERBOSE(VB_UPNP, QString("UPnpNotifyTask::SendNotifyMsg : %1:%2 : %3 : %4")
.arg( pSocket->address().toString() )
.arg( pSocket->port() )
.arg( pSocket->m_address.toString() )
.arg( pSocket->m_port )
.arg( sNT )
.arg( sUSN ));

Expand All @@ -122,8 +122,8 @@ void UPnpNotifyTask::SendNotifyMsg( MSocketDevice *pSocket,
QString sHeader = QString( "NOTIFY * HTTP/1.1\r\n"
"HOST: %1:%2\r\n"
"LOCATION: http://%3:%4/getDeviceDesc\r\n" )
.arg( SSDP_GROUP ) // pSocket->address().toString() )
.arg( SSDP_PORT ) // pSocket->port() )
.arg( pSocket->m_address.toString() )
.arg( pSocket->m_port )
.arg( *it )
.arg( m_nServicePort);

Expand All @@ -134,9 +134,9 @@ void UPnpNotifyTask::SendNotifyMsg( MSocketDevice *pSocket,
// Send Packet to Socket (Send same packet twice)
// ------------------------------------------------------------------

pSocket->writeBlock( scPacket, scPacket.length(), pSocket->address(), pSocket->port() );
pSocket->writeBlock( scPacket, scPacket.length(), pSocket->m_address, pSocket->m_port );
usleep( rand() % 250000 );
pSocket->writeBlock( scPacket, scPacket.length(), pSocket->address(), pSocket->port() );
pSocket->writeBlock( scPacket, scPacket.length(), pSocket->m_address, pSocket->m_port );
}
}

Expand All @@ -149,7 +149,7 @@ void UPnpNotifyTask::SendNotifyMsg( MSocketDevice *pSocket,
void UPnpNotifyTask::Execute( TaskQueue *pQueue )
{

MSocketDevice *pMulticast = new QMulticastSocket(SSDP_GROUP, SSDP_PORT);
QMulticastSocket *pMulticast = new QMulticastSocket(SSDP_GROUP, SSDP_PORT);
// QSocketDevice *pBroadcast = new QBroadcastSocket( "255.255.255.255", SSDP_PORT );

// ----------------------------------------------------------------------
Expand Down Expand Up @@ -192,7 +192,7 @@ void UPnpNotifyTask::Execute( TaskQueue *pQueue )
/////////////////////////////////////////////////////////////////////////////

void UPnpNotifyTask::ProcessDevice(
MSocketDevice *pSocket, UPnpDevice *pDevice)
QMulticastSocket *pSocket, UPnpDevice *pDevice)
{
// ----------------------------------------------------------------------
// Loop for each device and send the 2 required messages
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythupnp/upnptasknotify.h
Expand Up @@ -77,8 +77,8 @@ class UPnpNotifyTask : public Task

virtual ~UPnpNotifyTask();

void ProcessDevice( MSocketDevice *pSocket, UPnpDevice *pDevice );
void SendNotifyMsg( MSocketDevice *pSocket, QString sNT, QString sUDN );
void ProcessDevice( QMulticastSocket *pSocket, UPnpDevice *pDevice );
void SendNotifyMsg( QMulticastSocket *pSocket, QString sNT, QString sUDN );

public:

Expand Down

0 comments on commit 9836c10

Please sign in to comment.