Use SSDP_COPY to send multiple SSDP advertisements.

Currently, SSDP_COPY is used only to send multiple M-SEARCH requests (in
ssdp_ctrlpt.c). With this patch, SSDP_COPY is also used to send multiple
copies of each advertisements packets (in ssdp_device.c).
This commit is contained in:
Fabrice Fontaine 2010-11-05 14:28:50 +01:00 committed by Marcelo Roberto Jimenez
parent 8e846368e0
commit 96dc968f18
2 changed files with 48 additions and 20 deletions

View File

@ -2,6 +2,14 @@
Version 1.6.9 Version 1.6.9
******************************************************************************* *******************************************************************************
2010-11-05 Fabrice Fontaine <fabrice.fontaine(at)orange-ftgroup.com>
Use SSDP_COPY to send multiple SSDP advertisements.
Currently, SSDP_COPY is used only to send multiple M-SEARCH requests (in
ssdp_ctrlpt.c). With this patch, SSDP_COPY is also used to send multiple
copies of each advertisements packets (in ssdp_device.c).
2010-11-01 Carl Benson <carl.benson(at)windriver.com> 2010-11-01 Carl Benson <carl.benson(at)windriver.com>
Fix for Android build. Fix for Android build.

View File

@ -502,7 +502,7 @@ DeviceAdvertisement( IN char *DevType,
//char Mil_Nt[LINE_SIZE] //char Mil_Nt[LINE_SIZE]
char Mil_Usn[LINE_SIZE]; char Mil_Usn[LINE_SIZE];
char *msgs[3]; char *msgs[3];
int ret_code; int ret_code = UPNP_E_SUCCESS;
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__, UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
"In function DeviceAdvertisement\n" ); "In function DeviceAdvertisement\n" );
@ -554,13 +554,18 @@ DeviceAdvertisement( IN char *DevType,
return UPNP_E_OUTOF_MEMORY; return UPNP_E_OUTOF_MEMORY;
} }
// send packets // send packets
if( RootDev ) { int NumCopy = 0;
// send 3 msg types while( ret_code == UPNP_E_SUCCESS && NumCopy < NUM_SSDP_COPY ) {
ret_code = NewRequestHandler( (struct sockaddr*)&__ss, 3, &msgs[0] ); if( RootDev ) {
} else // sub-device // send 3 msg types
{ ret_code = NewRequestHandler( (struct sockaddr*)&__ss, 3, &msgs[0] );
// send 2 msg types } else // sub-device
ret_code = NewRequestHandler( (struct sockaddr*)&__ss, 2, &msgs[1] ); {
// send 2 msg types
ret_code = NewRequestHandler( (struct sockaddr*)&__ss, 2, &msgs[1] );
}
NumCopy++;
imillisleep(SSDP_PAUSE);
} }
// free msgs // free msgs
@ -751,7 +756,7 @@ ServiceAdvertisement( IN char *Udn,
{ {
char Mil_Usn[LINE_SIZE]; char Mil_Usn[LINE_SIZE];
char *szReq[1]; char *szReq[1];
int RetVal; int RetVal = UPNP_E_SUCCESS;
struct sockaddr_storage __ss; struct sockaddr_storage __ss;
struct sockaddr_in* DestAddr4 = (struct sockaddr_in*)&__ss; struct sockaddr_in* DestAddr4 = (struct sockaddr_in*)&__ss;
struct sockaddr_in6* DestAddr6 = (struct sockaddr_in6*)&__ss; struct sockaddr_in6* DestAddr6 = (struct sockaddr_in6*)&__ss;
@ -783,7 +788,12 @@ ServiceAdvertisement( IN char *Udn,
return UPNP_E_OUTOF_MEMORY; return UPNP_E_OUTOF_MEMORY;
} }
RetVal = NewRequestHandler( (struct sockaddr*)&__ss, 1, szReq ); int NumCopy = 0;
while( RetVal == UPNP_E_SUCCESS && NumCopy < NUM_SSDP_COPY ) {
RetVal = NewRequestHandler( (struct sockaddr*)&__ss, 1, szReq );
NumCopy++;
imillisleep(SSDP_PAUSE);
}
free( szReq[0] ); free( szReq[0] );
return RetVal; return RetVal;
@ -860,7 +870,7 @@ ServiceShutdown( IN char *Udn,
struct sockaddr_storage __ss; struct sockaddr_storage __ss;
struct sockaddr_in* DestAddr4 = (struct sockaddr_in*)&__ss; struct sockaddr_in* DestAddr4 = (struct sockaddr_in*)&__ss;
struct sockaddr_in6* DestAddr6 = (struct sockaddr_in6*)&__ss; struct sockaddr_in6* DestAddr6 = (struct sockaddr_in6*)&__ss;
int RetVal; int RetVal = UPNP_E_SUCCESS;
memset( &__ss, 0, sizeof(__ss) ); memset( &__ss, 0, sizeof(__ss) );
if( AddressFamily == AF_INET ) { if( AddressFamily == AF_INET ) {
@ -888,7 +898,12 @@ ServiceShutdown( IN char *Udn,
if( szReq[0] == NULL ) { if( szReq[0] == NULL ) {
return UPNP_E_OUTOF_MEMORY; return UPNP_E_OUTOF_MEMORY;
} }
RetVal = NewRequestHandler( (struct sockaddr*)&__ss, 1, szReq ); int NumCopy = 0;
while( RetVal == UPNP_E_SUCCESS && NumCopy < NUM_SSDP_COPY ) {
RetVal = NewRequestHandler( (struct sockaddr*)&__ss, 1, szReq );
NumCopy++;
imillisleep(SSDP_PAUSE);
}
free( szReq[0] ); free( szReq[0] );
return RetVal; return RetVal;
@ -926,7 +941,7 @@ DeviceShutdown( IN char *DevType,
struct sockaddr_in6* DestAddr6 = (struct sockaddr_in6*)&__ss; struct sockaddr_in6* DestAddr6 = (struct sockaddr_in6*)&__ss;
char *msgs[3]; char *msgs[3];
char Mil_Usn[LINE_SIZE]; char Mil_Usn[LINE_SIZE];
int ret_code; int ret_code = UPNP_E_SUCCESS;
msgs[0] = NULL; msgs[0] = NULL;
msgs[1] = NULL; msgs[1] = NULL;
@ -975,13 +990,18 @@ DeviceShutdown( IN char *DevType,
return UPNP_E_OUTOF_MEMORY; return UPNP_E_OUTOF_MEMORY;
} }
// send packets // send packets
if( RootDev ) { int NumCopy = 0;
// send 3 msg types while( ret_code == UPNP_E_SUCCESS && NumCopy < NUM_SSDP_COPY ) {
ret_code = NewRequestHandler( (struct sockaddr*)&__ss, 3, &msgs[0] ); if( RootDev ) {
} else // sub-device // send 3 msg types
{ ret_code = NewRequestHandler( (struct sockaddr*)&__ss, 3, &msgs[0] );
// send 2 msg types } else // sub-device
ret_code = NewRequestHandler( (struct sockaddr*)&__ss, 2, &msgs[1] ); {
// send 2 msg types
ret_code = NewRequestHandler( (struct sockaddr*)&__ss, 2, &msgs[1] );
}
NumCopy++;
imillisleep(SSDP_PAUSE);
} }
// free msgs // free msgs