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:
20
ChangeLog
20
ChangeLog
@@ -2,15 +2,23 @@
|
|||||||
Version 1.6.2
|
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>
|
2007-11-09 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
* Added a isleep() call to the error handler of select() in
|
* Added a isleep() call to the error handler of select() in
|
||||||
RunMiniServer(), so that it does not take 100% cpu in case select()
|
RunMiniServer(), so that it does not take 100% cpu in case select()
|
||||||
fails repeatedly.
|
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
|
Version 1.6.1
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
@@ -129,6 +137,10 @@ Version 1.6.0
|
|||||||
an interface change in the library and the minor library version was
|
an interface change in the library and the minor library version was
|
||||||
bumped. Also, the libtool library numbers were changed accordingly.
|
bumped. Also, the libtool library numbers were changed accordingly.
|
||||||
|
|
||||||
|
*******************************************************************************
|
||||||
|
Version 1.4.7
|
||||||
|
*******************************************************************************
|
||||||
|
|
||||||
2007-05-26 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
2007-05-26 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
* Added support for the Basic Device
|
* Added support for the Basic Device
|
||||||
(http://www.upnp.org/standardizeddcps/basic.asp) as suggested by
|
(http://www.upnp.org/standardizeddcps/basic.asp) as suggested by
|
||||||
|
2
THANKS
2
THANKS
@@ -16,6 +16,8 @@ exempt of errors.
|
|||||||
- Erik Johansson
|
- Erik Johansson
|
||||||
- Eric Tanguy
|
- Eric Tanguy
|
||||||
- Erwan Velu
|
- Erwan Velu
|
||||||
|
- Eugene Christensen
|
||||||
|
- Fabrice Fontaine
|
||||||
- Fredrik Svensson
|
- Fredrik Svensson
|
||||||
- Glen Masgai
|
- Glen Masgai
|
||||||
- Jiri Zouhar
|
- Jiri Zouhar
|
||||||
|
@@ -92,10 +92,8 @@ CLIENTONLY( ithread_mutex_t GlobalClientSubscribeMutex; )
|
|||||||
|
|
||||||
TimerThread gTimerThread;
|
TimerThread gTimerThread;
|
||||||
|
|
||||||
ThreadPool gRecvThreadPool;
|
|
||||||
|
|
||||||
ThreadPool gSendThreadPool;
|
ThreadPool gSendThreadPool;
|
||||||
|
ThreadPool gRecvThreadPool;
|
||||||
ThreadPool gMiniServerThreadPool;
|
ThreadPool gMiniServerThreadPool;
|
||||||
|
|
||||||
//Flag to indicate the state of web server
|
//Flag to indicate the state of web server
|
||||||
@@ -415,8 +413,9 @@ UpnpFinish()
|
|||||||
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
|
||||||
"UpnpFinish : UpnpSdkInit is ONE\n" );
|
"UpnpFinish : UpnpSdkInit is ONE\n" );
|
||||||
}
|
}
|
||||||
PrintThreadPoolStats(&gRecvThreadPool, __FILE__, __LINE__, "Recv Thread Pool");
|
|
||||||
PrintThreadPoolStats(&gSendThreadPool, __FILE__, __LINE__, "Send 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
|
#ifdef INCLUDE_DEVICE_APIS
|
||||||
if( GetDeviceHandleInfo( &device_handle, &temp ) == HND_DEVICE )
|
if( GetDeviceHandleInfo( &device_handle, &temp ) == HND_DEVICE )
|
||||||
@@ -435,11 +434,13 @@ UpnpFinish()
|
|||||||
web_server_destroy();
|
web_server_destroy();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ThreadPoolShutdown(&gSendThreadPool);
|
ThreadPoolShutdown(&gMiniServerThreadPool);
|
||||||
ThreadPoolShutdown(&gRecvThreadPool);
|
ThreadPoolShutdown(&gRecvThreadPool);
|
||||||
|
ThreadPoolShutdown(&gSendThreadPool);
|
||||||
|
|
||||||
PrintThreadPoolStats(&gRecvThreadPool, __FILE__, __LINE__, "Recv Thread Pool");
|
|
||||||
PrintThreadPoolStats(&gSendThreadPool, __FILE__, __LINE__, "Send 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
|
#ifdef INCLUDE_CLIENT_APIS
|
||||||
ithread_mutex_destroy(&GlobalClientSubscribeMutex);
|
ithread_mutex_destroy(&GlobalClientSubscribeMutex);
|
||||||
|
@@ -115,11 +115,13 @@ SetHTTPGetCallback( MiniServerCallback callback )
|
|||||||
*
|
*
|
||||||
* Return: void
|
* Return: void
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
#ifdef INCLUDE_DEVICE_APIS
|
||||||
void
|
void
|
||||||
SetSoapCallback( MiniServerCallback callback )
|
SetSoapCallback( MiniServerCallback callback )
|
||||||
{
|
{
|
||||||
gSoapCallback = callback;
|
gSoapCallback = callback;
|
||||||
}
|
}
|
||||||
|
#endif /* INCLUDE_DEVICE_APIS */
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: SetGenaCallback
|
* Function: SetGenaCallback
|
||||||
|
@@ -29,10 +29,10 @@
|
|||||||
//
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/************************************************************************
|
/******************************************************************************
|
||||||
* Purpose: This file defines the Web Server and has functions to carry out
|
* Purpose: This file defines the Web Server and has functions to carry out
|
||||||
* operations of the Web Server.
|
* operations of the Web Server.
|
||||||
************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@@ -64,7 +64,11 @@
|
|||||||
/*
|
/*
|
||||||
Response Types
|
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 };
|
RESP_POST };
|
||||||
|
|
||||||
// mapping of file extension to content-type of document
|
// mapping of file extension to content-type of document
|
||||||
@@ -182,12 +186,9 @@ static const char *gEncodedMediaTypes =
|
|||||||
"zip\0" APPLICATION_STR "zip\0" "\0";
|
"zip\0" APPLICATION_STR "zip\0" "\0";
|
||||||
// *** end ***
|
// *** end ***
|
||||||
|
|
||||||
/***********************************************************************/
|
/************************************************************************
|
||||||
/*
|
|
||||||
module variables - Globals, static and externs
|
module variables - Globals, static and externs
|
||||||
*/
|
************************************************************************/
|
||||||
|
|
||||||
/***********************************************************************/
|
|
||||||
static struct document_type_t gMediaTypeList[NUM_MEDIA_TYPES];
|
static struct document_type_t gMediaTypeList[NUM_MEDIA_TYPES];
|
||||||
membuffer gDocumentRootDir; // a local dir which serves as webserver root
|
membuffer gDocumentRootDir; // a local dir which serves as webserver root
|
||||||
static struct xml_alias_t gAliasDoc; // XML document
|
static struct xml_alias_t gAliasDoc; // XML document
|
||||||
@@ -589,10 +590,9 @@ web_server_destroy( void )
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* IN const char* filename ; Filename having the description document
|
* IN const char* filename ; Filename having the description document
|
||||||
* OUT struct File_Info * info ; File information object having file
|
* OUT struct File_Info * info ; File information object having file
|
||||||
* attributes such as filelength, when was
|
* attributes such as filelength, when was the file last
|
||||||
* the file last modified, whether a file
|
* modified, whether a file or a directory and whether the
|
||||||
* or a directory and whether the file or
|
* file or directory is readable.
|
||||||
* directory is readable.
|
|
||||||
*
|
*
|
||||||
* Description: Release memory allocated for the global web server root
|
* Description: Release memory allocated for the global web server root
|
||||||
* directory and the global XML document
|
* 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
|
* OUT struct xml_alias_t* alias ; xml alias object which has a file name
|
||||||
* stored
|
* stored
|
||||||
* OUT struct File_Info * info ; File information object which will be
|
* OUT struct File_Info * info ; File information object which will be
|
||||||
* filled up if the file comparison
|
* filled up if the file comparison succeeds
|
||||||
* succeeds
|
|
||||||
*
|
*
|
||||||
* Description: Compare the files names between the one on the XML alias
|
* Description: Compare the files names between the one on the XML alias
|
||||||
* the one passed in as the input parameter. If equal extract file
|
* 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 * FirstByte ; gets the first byte of the token
|
||||||
* OUT int * LastByte ; gets the last 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 ;
|
* Returns: int ;
|
||||||
* always returns 1;
|
* always returns 1;
|
||||||
@@ -929,8 +928,8 @@ GetNextRange( char **SrcRangeStr,
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* char * ByteRangeSpecifier ; String containing the range
|
* char * ByteRangeSpecifier ; String containing the range
|
||||||
* long FileLength ; Length of the file
|
* long FileLength ; Length of the file
|
||||||
* OUT struct SendInstruction * Instr ; SendInstruction object where the
|
* OUT struct SendInstruction * Instr ; SendInstruction object
|
||||||
* range operations will be stored
|
* where the range operations will be stored
|
||||||
*
|
*
|
||||||
* Description: Fills in the Offset, read size and contents to send out
|
* Description: Fills in the Offset, read size and contents to send out
|
||||||
* as an HTTP Range Response
|
* as an HTTP Range Response
|
||||||
@@ -1764,3 +1763,4 @@ web_server_callback( IN http_parser_t * parser,
|
|||||||
membuffer_destroy( &headers );
|
membuffer_destroy( &headers );
|
||||||
membuffer_destroy( &filename );
|
membuffer_destroy( &filename );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,63 +1,67 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
//
|
*
|
||||||
// * Redistributions of source code must retain the above copyright notice,
|
* * Redistributions of source code must retain the above copyright notice,
|
||||||
// this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
// * Neither name of Intel Corporation nor the names of its contributors
|
* Neither name of Intel Corporation nor the names of its contributors
|
||||||
// may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
************************************************************************/
|
||||||
|
|
||||||
#ifndef MINISERVER_H
|
#ifndef MINISERVER_H
|
||||||
#define MINISERVER_H
|
#define MINISERVER_H
|
||||||
|
|
||||||
|
|
||||||
#include "sock.h"
|
#include "sock.h"
|
||||||
#include "httpparser.h"
|
#include "httpparser.h"
|
||||||
|
|
||||||
|
|
||||||
extern SOCKET gMiniServerStopSock;
|
extern SOCKET gMiniServerStopSock;
|
||||||
|
|
||||||
|
|
||||||
typedef struct MServerSockArray {
|
typedef struct MServerSockArray {
|
||||||
int miniServerSock; //socket for listening for miniserver
|
/* socket for listening for miniserver requests */
|
||||||
//requests
|
int miniServerSock;
|
||||||
int miniServerStopSock; //socket for stopping miniserver
|
/* socket for stopping miniserver */
|
||||||
int ssdpSock; //socket for incoming advertisments and search requests
|
int miniServerStopSock;
|
||||||
|
/* socket for incoming advertisments and search requests */
|
||||||
|
int ssdpSock;
|
||||||
|
|
||||||
int stopPort;
|
int stopPort;
|
||||||
int miniServerPort;
|
int miniServerPort;
|
||||||
|
|
||||||
CLIENTONLY(int ssdpReqSock;) //socket for sending search
|
/* socket for sending search requests and receiving search replies */
|
||||||
//requests and receiving
|
CLIENTONLY(int ssdpReqSock;)
|
||||||
// search replies
|
|
||||||
|
|
||||||
} MiniServerSockArray;
|
} 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 http_message_t* request,
|
||||||
IN SOCKINFO *info );
|
IN SOCKINFO *info );
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@@ -71,8 +75,6 @@ extern "C" {
|
|||||||
* Description: Set HTTP Get Callback
|
* Description: Set HTTP Get Callback
|
||||||
*
|
*
|
||||||
* Return: void
|
* Return: void
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
void SetHTTPGetCallback( MiniServerCallback callback );
|
void SetHTTPGetCallback( MiniServerCallback callback );
|
||||||
|
|
||||||
@@ -85,14 +87,12 @@ void SetHTTPGetCallback( MiniServerCallback callback );
|
|||||||
* Description: Set SOAP Callback
|
* Description: Set SOAP Callback
|
||||||
*
|
*
|
||||||
* Return: void
|
* Return: void
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
#ifdef INCLUDE_DEVICE_APIS
|
#ifdef INCLUDE_DEVICE_APIS
|
||||||
void SetSoapCallback( MiniServerCallback callback );
|
void SetSoapCallback( MiniServerCallback callback );
|
||||||
#else
|
#else /* INCLUDE_DEVICE_APIS */
|
||||||
static inline void SetSoapCallback( MiniServerCallback callback ) {}
|
static inline void SetSoapCallback( MiniServerCallback callback ) {}
|
||||||
#endif
|
#endif /* INCLUDE_DEVICE_APIS */
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function: SetGenaCallback
|
* Function: SetGenaCallback
|
||||||
@@ -100,11 +100,9 @@ static inline void SetSoapCallback( MiniServerCallback callback ) {}
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* MiniServerCallback callback; - GENA Callback to be invoked
|
* MiniServerCallback callback; - GENA Callback to be invoked
|
||||||
*
|
*
|
||||||
* Description : Set GENA Callback
|
* D6escription: Set GENA Callback
|
||||||
*
|
*
|
||||||
* Return: void
|
* Return: void
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
void SetGenaCallback( MiniServerCallback callback );
|
void SetGenaCallback( MiniServerCallback callback );
|
||||||
|
|
||||||
@@ -126,7 +124,6 @@ void SetGenaCallback( MiniServerCallback callback );
|
|||||||
* Return: int;
|
* Return: int;
|
||||||
* Actual port socket is bound to - On Success:
|
* Actual port socket is bound to - On Success:
|
||||||
* A negative number UPNP_E_XXX - On Error
|
* A negative number UPNP_E_XXX - On Error
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int StartMiniServer( unsigned short listen_port );
|
int StartMiniServer( unsigned short listen_port );
|
||||||
|
|
||||||
@@ -136,19 +133,18 @@ int StartMiniServer( unsigned short listen_port );
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* void;
|
* void;
|
||||||
*
|
*
|
||||||
* Description : Stop and Shutdown the MiniServer and free socket
|
* Description: Stop and Shutdown the MiniServer and free socket resources.
|
||||||
* resources.
|
|
||||||
*
|
*
|
||||||
* Return : int;
|
* Return : int;
|
||||||
* Always returns 0
|
* Always returns 0
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int StopMiniServer( void );
|
int StopMiniServer();
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern C */
|
} /* extern C */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif /* MINISERVER_H */
|
#endif /* MINISERVER_H */
|
||||||
|
|
||||||
|
@@ -50,8 +50,7 @@
|
|||||||
|
|
||||||
#define MAX_TIME_TOREAD 45
|
#define MAX_TIME_TOREAD 45
|
||||||
|
|
||||||
CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
CLIENTONLY( SOCKET gSsdpReqSocket = 0; )
|
||||||
)
|
|
||||||
|
|
||||||
void RequestHandler();
|
void RequestHandler();
|
||||||
Event ErrotEvt;
|
Event ErrotEvt;
|
||||||
@@ -61,11 +60,10 @@ CLIENTONLY( SOCKET gSsdpReqSocket = 0;
|
|||||||
unsigned short ssdpStopPort;
|
unsigned short ssdpStopPort;
|
||||||
|
|
||||||
struct SSDPSockArray {
|
struct SSDPSockArray {
|
||||||
int ssdpSock; //socket for incoming advertisments and search requests
|
// socket for incoming advertisments and search requests
|
||||||
CLIENTONLY( int ssdpReqSock;
|
int ssdpSock;
|
||||||
) //socket for sending search
|
// socket for sending search requests and receiving search replies
|
||||||
//requests and receiving
|
CLIENTONLY( int ssdpReqSock; )
|
||||||
// search replies
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef INCLUDE_DEVICE_APIS
|
#ifdef INCLUDE_DEVICE_APIS
|
||||||
@@ -129,7 +127,6 @@ int AdvertiseAndReply( IN int AdFlag,
|
|||||||
return UPNP_E_INVALID_HANDLE;
|
return UPNP_E_INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
defaultExp = SInfo->MaxAge;
|
defaultExp = SInfo->MaxAge;
|
||||||
nodeList = NULL;
|
|
||||||
|
|
||||||
//get server info
|
//get server info
|
||||||
|
|
||||||
@@ -398,8 +395,8 @@ int AdvertiseAndReply( IN int AdFlag,
|
|||||||
|
|
||||||
} /****************** End of AdvertiseAndReply *********************/
|
} /****************** End of AdvertiseAndReply *********************/
|
||||||
|
|
||||||
#endif
|
#endif /* EXCLUDE_SSDP == 0 */
|
||||||
#endif
|
#endif /* INCLUDE_DEVICE_APIS */
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Function : Make_Socket_NoBlocking
|
* Function : Make_Socket_NoBlocking
|
||||||
@@ -737,8 +734,7 @@ ssdp_event_handler_thread( void *the_data )
|
|||||||
// send msg to device or ctrlpt
|
// send msg to device or ctrlpt
|
||||||
if( ( hmsg->method == HTTPMETHOD_NOTIFY ) ||
|
if( ( hmsg->method == HTTPMETHOD_NOTIFY ) ||
|
||||||
( hmsg->request_method == HTTPMETHOD_MSEARCH ) ) {
|
( hmsg->request_method == HTTPMETHOD_MSEARCH ) ) {
|
||||||
CLIENTONLY( ssdp_handle_ctrlpt_msg( hmsg, &data->dest_addr,
|
CLIENTONLY( ssdp_handle_ctrlpt_msg( hmsg, &data->dest_addr, FALSE, NULL );)
|
||||||
FALSE, NULL ););
|
|
||||||
} else {
|
} else {
|
||||||
ssdp_handle_device_request( hmsg, &data->dest_addr );
|
ssdp_handle_device_request( hmsg, &data->dest_addr );
|
||||||
}
|
}
|
||||||
@@ -860,17 +856,16 @@ readFromSSDPSocket( SOCKET socket )
|
|||||||
int
|
int
|
||||||
get_ssdp_sockets( MiniServerSockArray * out )
|
get_ssdp_sockets( MiniServerSockArray * out )
|
||||||
{
|
{
|
||||||
SOCKET ssdpSock;
|
|
||||||
|
|
||||||
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;
|
||||||
struct sockaddr_in ssdpAddr;
|
struct sockaddr_in ssdpAddr;
|
||||||
int option = 1;
|
int option = 1;
|
||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
|
SOCKET ssdpSock;
|
||||||
|
#if INCLUDE_CLIENT_APIS
|
||||||
|
SOCKET ssdpReqSock;
|
||||||
|
|
||||||
CLIENTONLY(
|
|
||||||
if( ( ssdpReqSock = socket( AF_INET, SOCK_DGRAM, 0 ) ) == 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__,
|
||||||
@@ -880,15 +875,15 @@ CLIENTONLY(
|
|||||||
setsockopt( ssdpReqSock, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof( ttl ) );
|
setsockopt( ssdpReqSock, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof( ttl ) );
|
||||||
// just do it, regardless if fails or not.
|
// just do it, regardless if fails or not.
|
||||||
Make_Socket_NoBlocking( ssdpReqSock );
|
Make_Socket_NoBlocking( ssdpReqSock );
|
||||||
gSsdpReqSocket = ssdpReqSock; )
|
gSsdpReqSocket = ssdpReqSock;
|
||||||
// END CLIENTONLY
|
#endif /* INCLUDE_CLIENT_APIS */
|
||||||
|
|
||||||
if( ( ssdpSock = socket( AF_INET, SOCK_DGRAM, 0 ) ) == UPNP_INVALID_SOCKET ) {
|
if( ( ssdpSock = 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" );
|
||||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ); )
|
||||||
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
|
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ); )
|
||||||
return UPNP_E_OUTOF_SOCKET;
|
return UPNP_E_OUTOF_SOCKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -898,8 +893,8 @@ CLIENTONLY(
|
|||||||
UpnpPrintf( UPNP_CRITICAL,
|
UpnpPrintf( UPNP_CRITICAL,
|
||||||
SSDP, __FILE__, __LINE__,
|
SSDP, __FILE__, __LINE__,
|
||||||
"Error in set reuse addr !!!\n" );
|
"Error in set reuse addr !!!\n" );
|
||||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ); )
|
||||||
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
|
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ); )
|
||||||
shutdown( ssdpSock, SD_BOTH );
|
shutdown( ssdpSock, SD_BOTH );
|
||||||
UpnpCloseSocket( ssdpSock );
|
UpnpCloseSocket( ssdpSock );
|
||||||
return UPNP_E_SOCKET_ERROR;
|
return UPNP_E_SOCKET_ERROR;
|
||||||
@@ -911,13 +906,13 @@ CLIENTONLY(
|
|||||||
UpnpPrintf( UPNP_CRITICAL,
|
UpnpPrintf( UPNP_CRITICAL,
|
||||||
SSDP, __FILE__, __LINE__,
|
SSDP, __FILE__, __LINE__,
|
||||||
"Error in set reuse port !!!\n" );
|
"Error in set reuse port !!!\n" );
|
||||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ); )
|
||||||
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
|
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ); )
|
||||||
shutdown( ssdpSock, SD_BOTH );
|
shutdown( ssdpSock, SD_BOTH );
|
||||||
UpnpCloseSocket( ssdpSock );
|
UpnpCloseSocket( ssdpSock );
|
||||||
return UPNP_E_SOCKET_ERROR;
|
return UPNP_E_SOCKET_ERROR;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* __FreeBSD__ */
|
||||||
|
|
||||||
memset( ( void * )&ssdpAddr, 0, sizeof( struct sockaddr_in ) );
|
memset( ( void * )&ssdpAddr, 0, sizeof( struct sockaddr_in ) );
|
||||||
ssdpAddr.sin_family = AF_INET;
|
ssdpAddr.sin_family = AF_INET;
|
||||||
@@ -931,8 +926,8 @@ CLIENTONLY(
|
|||||||
"Error in binding !!!\n" );
|
"Error in binding !!!\n" );
|
||||||
shutdown( ssdpSock, SD_BOTH );
|
shutdown( ssdpSock, SD_BOTH );
|
||||||
UpnpCloseSocket( ssdpSock );
|
UpnpCloseSocket( ssdpSock );
|
||||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ); )
|
||||||
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
|
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ); )
|
||||||
return UPNP_E_SOCKET_BIND;
|
return UPNP_E_SOCKET_BIND;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -945,9 +940,9 @@ CLIENTONLY(
|
|||||||
SSDP, __FILE__, __LINE__,
|
SSDP, __FILE__, __LINE__,
|
||||||
"Error in joining" " multicast group !!!\n" );
|
"Error in joining" " multicast group !!!\n" );
|
||||||
shutdown( ssdpSock, SD_BOTH );
|
shutdown( ssdpSock, SD_BOTH );
|
||||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ); )
|
||||||
UpnpCloseSocket( ssdpSock );
|
UpnpCloseSocket( ssdpSock );
|
||||||
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
|
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ); )
|
||||||
return UPNP_E_SOCKET_ERROR;
|
return UPNP_E_SOCKET_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -961,7 +956,7 @@ CLIENTONLY(
|
|||||||
/* This is probably not a critical error, so let's continue. */
|
/* 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,
|
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,
|
||||||
@@ -970,16 +965,16 @@ CLIENTONLY(
|
|||||||
SSDP, __FILE__, __LINE__,
|
SSDP, __FILE__, __LINE__,
|
||||||
"Error in setting broadcast !!!\n" );
|
"Error in setting broadcast !!!\n" );
|
||||||
shutdown( ssdpSock, SD_BOTH );
|
shutdown( ssdpSock, SD_BOTH );
|
||||||
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ) );
|
CLIENTONLY( shutdown( ssdpReqSock, SD_BOTH ); )
|
||||||
UpnpCloseSocket( ssdpSock );
|
UpnpCloseSocket( ssdpSock );
|
||||||
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ) );
|
CLIENTONLY( UpnpCloseSocket( ssdpReqSock ); )
|
||||||
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 */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user