Merge of trunk into branch 1.6.x.

git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@263 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
Marcelo Roberto Jimenez
2007-12-10 22:56:56 +00:00
parent 0475a46680
commit 0a074d1989
7 changed files with 651 additions and 643 deletions

View File

@@ -2,15 +2,23 @@
Version 1.6.2
*******************************************************************************
2007-12-10 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Fixed a compilation error due to a missing #ifdef in
upnp/src/genlib/miniserver/miniserver.c. Thanks to Eugene Christensen.
2007-11-12 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* "make check" was failing because ixml/test/test_document.sh did not
have the executable flag set. Thanks to Steve Bresson.
2007-11-12 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Fixed a memory leak in upnpapi.c to delete gMiniServerThreadPool in
the call to UpnpFinish(). Thanks to Fabrice Fontaine.
2007-11-09 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Added a isleep() call to the error handler of select() in
RunMiniServer(), so that it does not take 100% cpu in case select()
fails repeatedly.
2007-11-12 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* "make check" was failing because ixml/test/test_document.sh did not
have the executable flag set. Thanks to Steve Bresson.
*******************************************************************************
Version 1.6.1
*******************************************************************************
@@ -129,6 +137,10 @@ Version 1.6.0
an interface change in the library and the minor library version was
bumped. Also, the libtool library numbers were changed accordingly.
*******************************************************************************
Version 1.4.7
*******************************************************************************
2007-05-26 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Added support for the Basic Device
(http://www.upnp.org/standardizeddcps/basic.asp) as suggested by

2
THANKS
View File

@@ -16,6 +16,8 @@ exempt of errors.
- Erik Johansson
- Eric Tanguy
- Erwan Velu
- Eugene Christensen
- Fabrice Fontaine
- Fredrik Svensson
- Glen Masgai
- Jiri Zouhar

View File

@@ -92,10 +92,8 @@ CLIENTONLY( ithread_mutex_t GlobalClientSubscribeMutex; )
TimerThread gTimerThread;
ThreadPool gRecvThreadPool;
ThreadPool gSendThreadPool;
ThreadPool gRecvThreadPool;
ThreadPool gMiniServerThreadPool;
//Flag to indicate the state of web server
@@ -415,8 +413,9 @@ UpnpFinish()
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"UpnpFinish : UpnpSdkInit is ONE\n" );
}
PrintThreadPoolStats(&gRecvThreadPool, __FILE__, __LINE__, "Recv Thread Pool");
PrintThreadPoolStats(&gSendThreadPool, __FILE__, __LINE__, "Send Thread Pool");
PrintThreadPoolStats(&gRecvThreadPool, __FILE__, __LINE__, "Recv Thread Pool");
PrintThreadPoolStats(&gMiniServerThreadPool, __FILE__, __LINE__, "MiniServer Thread Pool");
#ifdef INCLUDE_DEVICE_APIS
if( GetDeviceHandleInfo( &device_handle, &temp ) == HND_DEVICE )
@@ -435,11 +434,13 @@ UpnpFinish()
web_server_destroy();
#endif
ThreadPoolShutdown(&gSendThreadPool);
ThreadPoolShutdown(&gMiniServerThreadPool);
ThreadPoolShutdown(&gRecvThreadPool);
ThreadPoolShutdown(&gSendThreadPool);
PrintThreadPoolStats(&gRecvThreadPool, __FILE__, __LINE__, "Recv Thread Pool");
PrintThreadPoolStats(&gSendThreadPool, __FILE__, __LINE__, "Send Thread Pool");
PrintThreadPoolStats(&gRecvThreadPool, __FILE__, __LINE__, "Recv Thread Pool");
PrintThreadPoolStats(&gMiniServerThreadPool, __FILE__, __LINE__, "MiniServer Thread Pool");
#ifdef INCLUDE_CLIENT_APIS
ithread_mutex_destroy(&GlobalClientSubscribeMutex);

View File

@@ -115,11 +115,13 @@ SetHTTPGetCallback( MiniServerCallback callback )
*
* Return: void
************************************************************************/
#ifdef INCLUDE_DEVICE_APIS
void
SetSoapCallback( MiniServerCallback callback )
{
gSoapCallback = callback;
}
#endif /* INCLUDE_DEVICE_APIS */
/************************************************************************
* Function: SetGenaCallback

View File

@@ -29,10 +29,10 @@
//
///////////////////////////////////////////////////////////////////////////
/************************************************************************
/******************************************************************************
* Purpose: This file defines the Web Server and has functions to carry out
* operations of the Web Server.
************************************************************************/
******************************************************************************/
#include "config.h"
#include <assert.h>
@@ -64,7 +64,11 @@
/*
Response Types
*/
enum resp_type { RESP_FILEDOC, RESP_XMLDOC, RESP_HEADERS, RESP_WEBDOC,
enum resp_type {
RESP_FILEDOC,
RESP_XMLDOC,
RESP_HEADERS,
RESP_WEBDOC,
RESP_POST };
// mapping of file extension to content-type of document
@@ -182,12 +186,9 @@ static const char *gEncodedMediaTypes =
"zip\0" APPLICATION_STR "zip\0" "\0";
// *** end ***
/***********************************************************************/
/*
/************************************************************************
module variables - Globals, static and externs
*/
/***********************************************************************/
************************************************************************/
static struct document_type_t gMediaTypeList[NUM_MEDIA_TYPES];
membuffer gDocumentRootDir; // a local dir which serves as webserver root
static struct xml_alias_t gAliasDoc; // XML document
@@ -589,10 +590,9 @@ web_server_destroy( void )
* Parameters:
* IN const char* filename ; Filename having the description document
* OUT struct File_Info * info ; File information object having file
* attributes such as filelength, when was
* the file last modified, whether a file
* or a directory and whether the file or
* directory is readable.
* attributes such as filelength, when was the file last
* modified, whether a file or a directory and whether the
* file or directory is readable.
*
* Description: Release memory allocated for the global web server root
* directory and the global XML document
@@ -689,8 +689,7 @@ web_server_set_root_dir( IN const char *root_dir )
* OUT struct xml_alias_t* alias ; xml alias object which has a file name
* stored
* OUT struct File_Info * info ; File information object which will be
* filled up if the file comparison
* succeeds
* filled up if the file comparison succeeds
*
* Description: Compare the files names between the one on the XML alias
* the one passed in as the input parameter. If equal extract file
@@ -870,7 +869,7 @@ StrTok( char **Src,
* OUT int * FirstByte ; gets the first byte of the token
* OUT int * LastByte ; gets the last byte of the token
*
* Description: Returns a range of integers from a sring
* Description: Returns a range of integers from a string
*
* Returns: int ;
* always returns 1;
@@ -929,8 +928,8 @@ GetNextRange( char **SrcRangeStr,
* Parameters:
* char * ByteRangeSpecifier ; String containing the range
* long FileLength ; Length of the file
* OUT struct SendInstruction * Instr ; SendInstruction object where the
* range operations will be stored
* OUT struct SendInstruction * Instr ; SendInstruction object
* where the range operations will be stored
*
* Description: Fills in the Offset, read size and contents to send out
* as an HTTP Range Response
@@ -1764,3 +1763,4 @@ web_server_callback( IN http_parser_t * parser,
membuffer_destroy( &headers );
membuffer_destroy( &filename );
}

View File

@@ -1,63 +1,67 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000-2003 Intel Corporation
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither name of Intel Corporation nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
/************************************************************************
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************/
#ifndef MINISERVER_H
#define MINISERVER_H
#include "sock.h"
#include "httpparser.h"
extern SOCKET gMiniServerStopSock;
typedef struct MServerSockArray {
int miniServerSock; //socket for listening for miniserver
//requests
int miniServerStopSock; //socket for stopping miniserver
int ssdpSock; //socket for incoming advertisments and search requests
/* socket for listening for miniserver requests */
int miniServerSock;
/* socket for stopping miniserver */
int miniServerStopSock;
/* socket for incoming advertisments and search requests */
int ssdpSock;
int stopPort;
int miniServerPort;
CLIENTONLY(int ssdpReqSock;) //socket for sending search
//requests and receiving
// search replies
/* socket for sending search requests and receiving search replies */
CLIENTONLY(int ssdpReqSock;)
} MiniServerSockArray;
//typedef void (*MiniServerCallback) ( const char* document, int sockfd );
typedef void (*MiniServerCallback) ( IN http_parser_t *parser,
typedef void (*MiniServerCallback)(
IN http_parser_t *parser,
IN http_message_t* request,
IN SOCKINFO *info );
#ifdef __cplusplus
extern "C" {
#endif
@@ -71,8 +75,6 @@ extern "C" {
* Description: Set HTTP Get Callback
*
* Return: void
*
* Note :
************************************************************************/
void SetHTTPGetCallback( MiniServerCallback callback );
@@ -85,14 +87,12 @@ void SetHTTPGetCallback( MiniServerCallback callback );
* Description: Set SOAP Callback
*
* Return: void
*
* Note :
************************************************************************/
#ifdef INCLUDE_DEVICE_APIS
void SetSoapCallback( MiniServerCallback callback );
#else
#else /* INCLUDE_DEVICE_APIS */
static inline void SetSoapCallback( MiniServerCallback callback ) {}
#endif
#endif /* INCLUDE_DEVICE_APIS */
/************************************************************************
* Function: SetGenaCallback
@@ -100,11 +100,9 @@ static inline void SetSoapCallback( MiniServerCallback callback ) {}
* Parameters:
* MiniServerCallback callback; - GENA Callback to be invoked
*
* Description : Set GENA Callback
* D6escription: Set GENA Callback
*
* Return: void
*
* Note :
************************************************************************/
void SetGenaCallback( MiniServerCallback callback );
@@ -126,7 +124,6 @@ void SetGenaCallback( MiniServerCallback callback );
* Return: int;
* Actual port socket is bound to - On Success:
* A negative number UPNP_E_XXX - On Error
* Note :
************************************************************************/
int StartMiniServer( unsigned short listen_port );
@@ -136,19 +133,18 @@ int StartMiniServer( unsigned short listen_port );
* Parameters:
* void;
*
* Description : Stop and Shutdown the MiniServer and free socket
* resources.
* Description: Stop and Shutdown the MiniServer and free socket resources.
*
* Return : int;
* Always returns 0
*
* Note :
************************************************************************/
int StopMiniServer( void );
int StopMiniServer();
#ifdef __cplusplus
} /* extern C */
#endif
#endif /* MINISERVER_H */

View File

@@ -50,8 +50,7 @@
#define MAX_TIME_TOREAD 45
CLIENTONLY( SOCKET gSsdpReqSocket = 0;
)
CLIENTONLY( SOCKET gSsdpReqSocket = 0; )
void RequestHandler();
Event ErrotEvt;
@@ -61,11 +60,10 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
unsigned short ssdpStopPort;
struct SSDPSockArray {
int ssdpSock; //socket for incoming advertisments and search requests
CLIENTONLY( int ssdpReqSock;
) //socket for sending search
//requests and receiving
// search replies
// socket for incoming advertisments and search requests
int ssdpSock;
// socket for sending search requests and receiving search replies
CLIENTONLY( int ssdpReqSock; )
};
#ifdef INCLUDE_DEVICE_APIS
@@ -129,7 +127,6 @@ int AdvertiseAndReply( IN int AdFlag,
return UPNP_E_INVALID_HANDLE;
}
defaultExp = SInfo->MaxAge;
nodeList = NULL;
//get server info
@@ -398,8 +395,8 @@ int AdvertiseAndReply( IN int AdFlag,
} /****************** End of AdvertiseAndReply *********************/
#endif
#endif
#endif /* EXCLUDE_SSDP == 0 */
#endif /* INCLUDE_DEVICE_APIS */
/************************************************************************
* Function : Make_Socket_NoBlocking
@@ -737,8 +734,7 @@ ssdp_event_handler_thread( void *the_data )
// send msg to device or ctrlpt
if( ( hmsg->method == HTTPMETHOD_NOTIFY ) ||
( hmsg->request_method == HTTPMETHOD_MSEARCH ) ) {
CLIENTONLY( ssdp_handle_ctrlpt_msg( hmsg, &data->dest_addr,
FALSE, NULL ););
CLIENTONLY( ssdp_handle_ctrlpt_msg( hmsg, &data->dest_addr, FALSE, NULL );)
} else {
ssdp_handle_device_request( hmsg, &data->dest_addr );
}
@@ -860,17 +856,16 @@ readFromSSDPSocket( SOCKET socket )
int
get_ssdp_sockets( MiniServerSockArray * out )
{
SOCKET ssdpSock;
CLIENTONLY( SOCKET ssdpReqSock; )
int onOff = 1;
u_char ttl = 4;
struct ip_mreq ssdpMcastAddr;
struct sockaddr_in ssdpAddr;
int option = 1;
struct in_addr addr;
SOCKET ssdpSock;
#if INCLUDE_CLIENT_APIS
SOCKET ssdpReqSock;
CLIENTONLY(
if( ( ssdpReqSock = socket( AF_INET, SOCK_DGRAM, 0 ) ) == UPNP_INVALID_SOCKET ) {
UpnpPrintf( UPNP_CRITICAL,
SSDP, __FILE__, __LINE__,
@@ -880,15 +875,15 @@ CLIENTONLY(
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
gSsdpReqSocket = ssdpReqSock;
#endif /* INCLUDE_CLIENT_APIS */
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 ) );
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ); )
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ); )
return UPNP_E_OUTOF_SOCKET;
}
@@ -898,8 +893,8 @@ CLIENTONLY(
UpnpPrintf( UPNP_CRITICAL,
SSDP, __FILE__, __LINE__,
"Error in set reuse addr !!!\n" );
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ); )
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ); )
shutdown( ssdpSock, SD_BOTH );
UpnpCloseSocket( ssdpSock );
return UPNP_E_SOCKET_ERROR;
@@ -911,13 +906,13 @@ CLIENTONLY(
UpnpPrintf( UPNP_CRITICAL,
SSDP, __FILE__, __LINE__,
"Error in set reuse port !!!\n" );
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ); )
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ); )
shutdown( ssdpSock, SD_BOTH );
UpnpCloseSocket( ssdpSock );
return UPNP_E_SOCKET_ERROR;
}
#endif
#endif /* __FreeBSD__ */
memset( ( void * )&ssdpAddr, 0, sizeof( struct sockaddr_in ) );
ssdpAddr.sin_family = AF_INET;
@@ -931,8 +926,8 @@ CLIENTONLY(
"Error in binding !!!\n" );
shutdown( ssdpSock, SD_BOTH );
UpnpCloseSocket( ssdpSock );
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ); )
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ); )
return UPNP_E_SOCKET_BIND;
}
@@ -945,9 +940,9 @@ CLIENTONLY(
SSDP, __FILE__, __LINE__,
"Error in joining" " multicast group !!!\n" );
shutdown( ssdpSock, SD_BOTH );
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ); )
UpnpCloseSocket( ssdpSock );
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ); )
return UPNP_E_SOCKET_ERROR;
}
@@ -961,7 +956,7 @@ CLIENTONLY(
/* This is probably not a critical error, so let's continue. */
}
// result is not checked becuase it will fail in WinMe and Win9x.
/* result is not checked becuase it will fail in WinMe and Win9x. */
setsockopt( ssdpSock, IPPROTO_IP,
IP_MULTICAST_TTL, &ttl, sizeof( ttl ) );
if( setsockopt( ssdpSock, SOL_SOCKET, SO_BROADCAST,
@@ -970,16 +965,16 @@ CLIENTONLY(
SSDP, __FILE__, __LINE__,
"Error in setting broadcast !!!\n" );
shutdown( ssdpSock, SD_BOTH );
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ); )
UpnpCloseSocket( ssdpSock );
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ); )
return UPNP_E_NETWORK_ERROR;
}
CLIENTONLY( out->ssdpReqSock = ssdpReqSock; );
CLIENTONLY( out->ssdpReqSock = ssdpReqSock; )
out->ssdpSock = ssdpSock;
return UPNP_E_SUCCESS;
}
#endif // EXCLUDE_SSDP
#endif /* EXCLUDE_SSDP */