Slightly better debug messages and lots of white spaces.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@225 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
parent
b29de32110
commit
fd80e5a8ff
@ -475,11 +475,13 @@ http_SendMessage( IN SOCKINFO * info,
|
|||||||
buf_length = ( size_t ) va_arg( argp, size_t );
|
buf_length = ( size_t ) va_arg( argp, size_t );
|
||||||
if( buf_length > 0 ) {
|
if( buf_length > 0 ) {
|
||||||
num_written = sock_write( info, buf, buf_length, TimeOut );
|
num_written = sock_write( info, buf, buf_length, TimeOut );
|
||||||
|
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
||||||
|
">>> (SENT) >>>\n"
|
||||||
|
"%.*s\nbuf_length=%d, num_written=%d\n"
|
||||||
|
"------------\n",
|
||||||
|
(int)buf_length, buf, (int)buf_length, num_written );
|
||||||
if( ( size_t ) num_written != buf_length )
|
if( ( size_t ) num_written != buf_length )
|
||||||
goto end;
|
goto end;
|
||||||
UpnpPrintf( UPNP_INFO, HTTP, __FILE__, __LINE__,
|
|
||||||
">>> (SENT) >>>\n%.*s\n------------\n",
|
|
||||||
( int )buf_length, buf );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,8 +75,10 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
|||||||
* Function : AdvertiseAndReply
|
* Function : AdvertiseAndReply
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* IN int AdFlag: -1 = Send shutdown, 0 = send reply,
|
* IN int AdFlag:
|
||||||
* 1 = Send Advertisement
|
* -1 = Send shutdown,
|
||||||
|
* 0 = send reply,
|
||||||
|
* 1 = Send Advertisement
|
||||||
* IN UpnpDevice_Handle Hnd: Device handle
|
* IN UpnpDevice_Handle Hnd: Device handle
|
||||||
* IN enum SsdpSearchType SearchType:Search type for sending replies
|
* IN enum SsdpSearchType SearchType:Search type for sending replies
|
||||||
* IN struct sockaddr_in *DestAddr:Destination address
|
* IN struct sockaddr_in *DestAddr:Destination address
|
||||||
@ -445,7 +447,7 @@ Make_Socket_NoBlocking( int sock )
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* IN char *cmd: Service Name string
|
* IN char *cmd: Service Name string
|
||||||
* OUT SsdpEvent *Evt: The SSDP event structure partially filled
|
* OUT SsdpEvent *Evt: The SSDP event structure partially filled
|
||||||
* by all the function.
|
* by all the function.
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* This function fills the fields of the event structure like DeviceType,
|
* This function fills the fields of the event structure like DeviceType,
|
||||||
@ -819,18 +821,20 @@ readFromSSDPSocket( SOCKET socket )
|
|||||||
( struct sockaddr * )&clientAddr, &socklen );
|
( struct sockaddr * )&clientAddr, &socklen );
|
||||||
|
|
||||||
if( byteReceived > 0 ) {
|
if( byteReceived > 0 ) {
|
||||||
|
|
||||||
requestBuf[byteReceived] = '\0';
|
requestBuf[byteReceived] = '\0';
|
||||||
UpnpPrintf( UPNP_INFO, SSDP,
|
UpnpPrintf( UPNP_INFO, SSDP,
|
||||||
__FILE__, __LINE__,
|
__FILE__, __LINE__,
|
||||||
"Received response !!! "
|
"Start of received response ----------------------------------------------------\n"
|
||||||
"%s From host %s \n",
|
"%s\n"
|
||||||
requestBuf,
|
"End of received response ------------------------------------------------------\n"
|
||||||
inet_ntoa( clientAddr.sin_addr ) );
|
"From host %s\n",
|
||||||
|
requestBuf,
|
||||||
|
inet_ntoa( clientAddr.sin_addr ) );
|
||||||
UpnpPrintf( UPNP_PACKET, SSDP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_PACKET, SSDP, __FILE__, __LINE__,
|
||||||
"Received multicast packet:"
|
"Start of received multicast packet --------------------------------------------\n"
|
||||||
"\n %s\n", requestBuf );
|
"%s\n"
|
||||||
|
"End of received multicast packet ----------------------------------------------\n",
|
||||||
|
requestBuf );
|
||||||
//add thread pool job to handle request
|
//add thread pool job to handle request
|
||||||
if( data != NULL ) {
|
if( data != NULL ) {
|
||||||
data->parser.msg.msg.length += byteReceived;
|
data->parser.msg.msg.length += byteReceived;
|
||||||
@ -869,8 +873,7 @@ get_ssdp_sockets( MiniServerSockArray * out )
|
|||||||
{
|
{
|
||||||
SOCKET ssdpSock;
|
SOCKET ssdpSock;
|
||||||
|
|
||||||
CLIENTONLY( SOCKET ssdpReqSock;
|
CLIENTONLY( SOCKET ssdpReqSock; )
|
||||||
)
|
|
||||||
int onOff = 1;
|
int onOff = 1;
|
||||||
u_char ttl = 4;
|
u_char ttl = 4;
|
||||||
struct ip_mreq ssdpMcastAddr;
|
struct ip_mreq ssdpMcastAddr;
|
||||||
@ -878,32 +881,31 @@ get_ssdp_sockets( MiniServerSockArray * out )
|
|||||||
int option = 1;
|
int option = 1;
|
||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
|
|
||||||
CLIENTONLY( if( ( ssdpReqSock = socket( AF_INET, SOCK_DGRAM, 0 ) )
|
CLIENTONLY(
|
||||||
== UPNP_INVALID_SOCKET ) {
|
if( ( ssdpReqSock = socket( AF_INET, SOCK_DGRAM, 0 ) ) == UPNP_INVALID_SOCKET ) {
|
||||||
UpnpPrintf( UPNP_CRITICAL,
|
UpnpPrintf( UPNP_CRITICAL,
|
||||||
SSDP, __FILE__, __LINE__,
|
SSDP, __FILE__, __LINE__,
|
||||||
"Error in socket operation !!!\n" );
|
"Error in socket operation !!!\n" );
|
||||||
return UPNP_E_OUTOF_SOCKET;}
|
|
||||||
setsockopt( ssdpReqSock,
|
|
||||||
IPPROTO_IP,
|
|
||||||
IP_MULTICAST_TTL, &ttl, sizeof( ttl ) );
|
|
||||||
// just do it, regardless if fails or not.
|
|
||||||
Make_Socket_NoBlocking( ssdpReqSock ); gSsdpReqSocket = ssdpReqSock; ) //CLIENTONLY
|
|
||||||
|
|
||||||
if( ( ssdpSock = socket( AF_INET, SOCK_DGRAM, 0 ) )
|
|
||||||
== UPNP_INVALID_SOCKET ) {
|
|
||||||
UpnpPrintf( UPNP_CRITICAL,
|
|
||||||
SSDP, __FILE__, __LINE__,
|
|
||||||
"Error in socket operation !!!\n" );
|
|
||||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
|
||||||
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
|
|
||||||
return UPNP_E_OUTOF_SOCKET;
|
return UPNP_E_OUTOF_SOCKET;
|
||||||
}
|
}
|
||||||
|
setsockopt( ssdpReqSock, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof( ttl ) );
|
||||||
|
// just do it, regardless if fails or not.
|
||||||
|
Make_Socket_NoBlocking( ssdpReqSock );
|
||||||
|
gSsdpReqSocket = ssdpReqSock; )
|
||||||
|
// END CLIENTONLY
|
||||||
|
|
||||||
|
if( ( ssdpSock = socket( AF_INET, SOCK_DGRAM, 0 ) ) == UPNP_INVALID_SOCKET ) {
|
||||||
|
UpnpPrintf( UPNP_CRITICAL,
|
||||||
|
SSDP, __FILE__, __LINE__,
|
||||||
|
"Error in socket operation !!!\n" );
|
||||||
|
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
||||||
|
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
|
||||||
|
return UPNP_E_OUTOF_SOCKET;
|
||||||
|
}
|
||||||
|
|
||||||
onOff = 1;
|
onOff = 1;
|
||||||
if( setsockopt( ssdpSock, SOL_SOCKET, SO_REUSEADDR,
|
if( setsockopt( ssdpSock, SOL_SOCKET, SO_REUSEADDR,
|
||||||
( char * )&onOff, sizeof( onOff ) ) != 0 ) {
|
( char * )&onOff, sizeof( onOff ) ) != 0 ) {
|
||||||
|
|
||||||
UpnpPrintf( UPNP_CRITICAL,
|
UpnpPrintf( UPNP_CRITICAL,
|
||||||
SSDP, __FILE__, __LINE__,
|
SSDP, __FILE__, __LINE__,
|
||||||
"Error in set reuse addr !!!\n" );
|
"Error in set reuse addr !!!\n" );
|
||||||
@ -916,8 +918,7 @@ get_ssdp_sockets( MiniServerSockArray * out )
|
|||||||
|
|
||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
if( setsockopt( ssdpSock, SOL_SOCKET, SO_REUSEPORT,
|
if( setsockopt( ssdpSock, SOL_SOCKET, SO_REUSEPORT,
|
||||||
( char * )&onOff, sizeof( onOff ) ) != 0 ) {
|
( char * )&onOff, sizeof( onOff ) ) != 0 ) {
|
||||||
|
|
||||||
UpnpPrintf( UPNP_CRITICAL,
|
UpnpPrintf( UPNP_CRITICAL,
|
||||||
SSDP, __FILE__, __LINE__,
|
SSDP, __FILE__, __LINE__,
|
||||||
"Error in set reuse port !!!\n" );
|
"Error in set reuse port !!!\n" );
|
||||||
@ -934,9 +935,8 @@ get_ssdp_sockets( MiniServerSockArray * out )
|
|||||||
// ssdpAddr.sin_addr.s_addr = inet_addr(LOCAL_HOST);
|
// ssdpAddr.sin_addr.s_addr = inet_addr(LOCAL_HOST);
|
||||||
ssdpAddr.sin_addr.s_addr = htonl( INADDR_ANY );
|
ssdpAddr.sin_addr.s_addr = htonl( INADDR_ANY );
|
||||||
ssdpAddr.sin_port = htons( SSDP_PORT );
|
ssdpAddr.sin_port = htons( SSDP_PORT );
|
||||||
if( bind
|
if( bind( ssdpSock, ( struct sockaddr * )&ssdpAddr,
|
||||||
( ssdpSock, ( struct sockaddr * )&ssdpAddr,
|
sizeof( ssdpAddr ) ) != 0 ) {
|
||||||
sizeof( ssdpAddr ) ) != 0 ) {
|
|
||||||
UpnpPrintf( UPNP_CRITICAL,
|
UpnpPrintf( UPNP_CRITICAL,
|
||||||
SSDP, __FILE__, __LINE__,
|
SSDP, __FILE__, __LINE__,
|
||||||
"Error in binding !!!\n" );
|
"Error in binding !!!\n" );
|
||||||
@ -951,8 +951,7 @@ get_ssdp_sockets( MiniServerSockArray * out )
|
|||||||
ssdpMcastAddr.imr_interface.s_addr = inet_addr( LOCAL_HOST );
|
ssdpMcastAddr.imr_interface.s_addr = inet_addr( LOCAL_HOST );
|
||||||
ssdpMcastAddr.imr_multiaddr.s_addr = inet_addr( SSDP_IP );
|
ssdpMcastAddr.imr_multiaddr.s_addr = inet_addr( SSDP_IP );
|
||||||
if( setsockopt( ssdpSock, IPPROTO_IP, IP_ADD_MEMBERSHIP,
|
if( setsockopt( ssdpSock, IPPROTO_IP, IP_ADD_MEMBERSHIP,
|
||||||
( char * )&ssdpMcastAddr,
|
( char * )&ssdpMcastAddr, sizeof( struct ip_mreq ) ) != 0 ) {
|
||||||
sizeof( struct ip_mreq ) ) != 0 ) {
|
|
||||||
UpnpPrintf( UPNP_CRITICAL,
|
UpnpPrintf( UPNP_CRITICAL,
|
||||||
SSDP, __FILE__, __LINE__,
|
SSDP, __FILE__, __LINE__,
|
||||||
"Error in joining" " multicast group !!!\n" );
|
"Error in joining" " multicast group !!!\n" );
|
||||||
@ -966,8 +965,8 @@ get_ssdp_sockets( MiniServerSockArray * out )
|
|||||||
/* Set multicast interface. */
|
/* Set multicast interface. */
|
||||||
memset( ( void * )&addr, 0, sizeof( struct in_addr ));
|
memset( ( void * )&addr, 0, sizeof( struct in_addr ));
|
||||||
addr.s_addr = inet_addr(LOCAL_HOST);
|
addr.s_addr = inet_addr(LOCAL_HOST);
|
||||||
if (setsockopt(ssdpSock, IPPROTO_IP, IP_MULTICAST_IF,
|
if ( setsockopt(ssdpSock, IPPROTO_IP, IP_MULTICAST_IF,
|
||||||
(char *)&addr, sizeof addr) != 0) {
|
(char *)&addr, sizeof addr) != 0) {
|
||||||
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||||
"Couldn't set multicast interface.\n" );
|
"Couldn't set multicast interface.\n" );
|
||||||
/* This is probably not a critical error, so let's continue. */
|
/* This is probably not a critical error, so let's continue. */
|
||||||
@ -977,7 +976,7 @@ get_ssdp_sockets( MiniServerSockArray * out )
|
|||||||
setsockopt( ssdpSock, IPPROTO_IP,
|
setsockopt( ssdpSock, IPPROTO_IP,
|
||||||
IP_MULTICAST_TTL, &ttl, sizeof( ttl ) );
|
IP_MULTICAST_TTL, &ttl, sizeof( ttl ) );
|
||||||
if( setsockopt( ssdpSock, SOL_SOCKET, SO_BROADCAST,
|
if( setsockopt( ssdpSock, SOL_SOCKET, SO_BROADCAST,
|
||||||
( char * )&option, sizeof( option ) ) != 0 ) {
|
(char *)&option, sizeof(option) ) != 0) {
|
||||||
UpnpPrintf( UPNP_CRITICAL,
|
UpnpPrintf( UPNP_CRITICAL,
|
||||||
SSDP, __FILE__, __LINE__,
|
SSDP, __FILE__, __LINE__,
|
||||||
"Error in setting broadcast !!!\n" );
|
"Error in setting broadcast !!!\n" );
|
||||||
@ -988,10 +987,10 @@ get_ssdp_sockets( MiniServerSockArray * out )
|
|||||||
return UPNP_E_NETWORK_ERROR;
|
return UPNP_E_NETWORK_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
CLIENTONLY( out->ssdpReqSock = ssdpReqSock;
|
CLIENTONLY( out->ssdpReqSock = ssdpReqSock; );
|
||||||
);
|
|
||||||
out->ssdpSock = ssdpSock;
|
out->ssdpSock = ssdpSock;
|
||||||
return UPNP_E_SUCCESS;
|
return UPNP_E_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // EXCLUDE_SSDP
|
#endif // EXCLUDE_SSDP
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user