More doxygen.

git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@368 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
Marcelo Roberto Jimenez 2008-05-05 00:25:22 +00:00
parent 537a9a4d93
commit 164dce7fc2
5 changed files with 1405 additions and 1626 deletions

View File

@ -462,7 +462,7 @@ WARN_LOGFILE =
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
INPUT = ./upnp ./ixml ./threadutil
INPUT = upnp ixml threadutil
# This tag can be used to specify the character encoding of the source files that
# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default

File diff suppressed because it is too large Load Diff

View File

@ -821,17 +821,19 @@ EXPORT_SPEC char *UpnpGetServerIpAddress();
EXPORT_SPEC char *UpnpGetServerIp6Address();
/*! \b UpnpRegisterRootDevice registers a device application with
* the SDK. A device application cannot make any other API
* calls until it registers using this function. Device applications
* can also register as control points (see \b UpnpRegisterClient
* to get a control point handle to perform control point
* functionality).
/*! \brief Registers a device application with the UPnP Library.
*
* \b UpnpRegisterRootDevice is synchronous and does not generate
* any callbacks. Callbacks can occur as soon as this function returns.
* A device application cannot make any other API calls until it registers
* using this function.
*
* \return [int] An integer representing one of the following:
* Device applications can also register as control points (see
* \b UpnpRegisterClient to get a control point handle to perform control
* point functionality).
*
* \b UpnpRegisterRootDevice is synchronous and does not generate any
* callbacks. Callbacks can occur as soon as this function returns.
*
* \return An integer representing one of the following:
* \li \c UPNP_E_SUCCESS: The operation completed successfully.
* \li \c UPNP_E_FINISH: The SDK is already terminated or is not
* initialized.
@ -865,70 +867,71 @@ EXPORT_SPEC int UpnpRegisterRootDevice(
/*! Pointer to a variable to store the new device handle. */
OUT UpnpDevice_Handle *Hnd);
/*! \b UpnpRegisterRootDevice2 is similar to \b UpnpRegisterRootDevice,
* except that it also allows the description document to be specified as a
* file or a memory buffer. The description can also be configured to have the
* correct IP and port address.
/*! \brief Similar to \b UpnpRegisterRootDevice, except that it also allows
* the description document to be specified as a file or a memory buffer.
*
* NOTE: For the configuration to be functional, the internal web server
* MUST be present. In addition, the web server MUST be activated
* (using \b UpnpSetWebServerRootDir) before calling this function.
* The only condition where the web server can be absent is if the
* description document is specified as a URL and no configuration is
* required (i.e. <tt>config_baseURL = 0</tt>.)
* The description can also be configured to have the correct IP and port
* address.
*
* \b UpnpRegisterRootDevice2 is synchronous and does not generate
* any callbacks. Callbacks can occur as soon as this function returns.
* NOTE: For the configuration to be functional, the internal web server
* MUST be present. In addition, the web server MUST be activated
* (using \b UpnpSetWebServerRootDir) before calling this function.
* The only condition where the web server can be absent is if the
* description document is specified as a URL and no configuration is
* required (i.e. <tt>config_baseURL = 0</tt>.)
*
* Examples of using different types of description documents:
* \verbatim
1) Description specified as a URL:
descriptionType == UPNPREG_URL_DESC
description is the URL
bufferLen = 0 (ignored)
2) Description specified as a file:
descriptionType == UPNPREG_FILENAME_DESC
description is a filename
bufferLen = 0 (ignored)
3) Description specified as a memory buffer:
descriptionType == UPNPREG_BUF_DESC
description is pointer to a memory buffer
bufferLen == length of memory buffer
\endverbatim
* This is synchronous and does not generate any callbacks. Callbacks can occur
* as soon as this function returns.
*
* \return [int] An integer representing one of the following:
* \li \c UPNP_E_SUCCESS: The operation completed successfully.
* \li \c UPNP_E_FINISH: The SDK is already terminated or
* is not initialized.
* \li \c UPNP_E_INVALID_DESC: The description document is not
* a valid device description.
* \li \c UPNP_E_INVALID_PARAM: Either \b Callback or \b Hnd
* is not a valid pointer or \b DescURL is \c NULL.
* \li \c UPNP_E_NETWORK_ERROR: A network error occurred.
* \li \c UPNP_E_SOCKET_WRITE: An error or timeout occurred writing
* to a socket.
* \li \c UPNP_E_SOCKET_READ: An error or timeout occurred reading
* from a socket.
* \li \c UPNP_E_SOCKET_BIND: An error occurred binding a socket.
* \li \c UPNP_E_SOCKET_CONNECT: An error occurred connecting the
* socket.
* \li \c UPNP_E_OUTOF_SOCKET: Too many sockets are currently
* allocated.
* \li \c UPNP_E_OUTOF_MEMORY: There are insufficient resources to
* register this root device.
* \li \c UPNP_E_URL_TOO_BIG: Length of the URL is bigger than the
* internal buffer.
* \li \c UPNP_E_FILE_NOT_FOUND: The description file could not
* be found.
* \li \c UPNP_E_FILE_READ_ERROR: An error occurred reading the
* description file.
* \li \c UPNP_E_INVALID_URL: The URL to the description document
* is invalid.
* \li \c UPNP_E_EXT_NOT_XML: The URL to the description document
* or file should have a <tt>.xml</tt> extension.
* \li \c UPNP_E_NO_WEB_SERVER: The internal web server has been
* compiled out; the SDK cannot configure itself from the
* description document.
* Examples of using different types of description documents:
* \verbatim
1) Description specified as a URL:
descriptionType == UPNPREG_URL_DESC
description is the URL
bufferLen = 0 (ignored)
2) Description specified as a file:
descriptionType == UPNPREG_FILENAME_DESC
description is a filename
bufferLen = 0 (ignored)
3) Description specified as a memory buffer:
descriptionType == UPNPREG_BUF_DESC
description is pointer to a memory buffer
bufferLen == length of memory buffer
\endverbatim
*
* \return An integer representing one of the following:
* \li \c UPNP_E_SUCCESS: The operation completed successfully.
* \li \c UPNP_E_FINISH: The SDK is already terminated or
* is not initialized.
* \li \c UPNP_E_INVALID_DESC: The description document is not
* a valid device description.
* \li \c UPNP_E_INVALID_PARAM: Either \b Callback or \b Hnd
* is not a valid pointer or \b DescURL is \c NULL.
* \li \c UPNP_E_NETWORK_ERROR: A network error occurred.
* \li \c UPNP_E_SOCKET_WRITE: An error or timeout occurred writing
* to a socket.
* \li \c UPNP_E_SOCKET_READ: An error or timeout occurred reading
* from a socket.
* \li \c UPNP_E_SOCKET_BIND: An error occurred binding a socket.
* \li \c UPNP_E_SOCKET_CONNECT: An error occurred connecting the
* socket.
* \li \c UPNP_E_OUTOF_SOCKET: Too many sockets are currently
* allocated.
* \li \c UPNP_E_OUTOF_MEMORY: There are insufficient resources to
* register this root device.
* \li \c UPNP_E_URL_TOO_BIG: Length of the URL is bigger than the
* internal buffer.
* \li \c UPNP_E_FILE_NOT_FOUND: The description file could not
* be found.
* \li \c UPNP_E_FILE_READ_ERROR: An error occurred reading the
* description file.
* \li \c UPNP_E_INVALID_URL: The URL to the description document
* is invalid.
* \li \c UPNP_E_EXT_NOT_XML: The URL to the description document
* or file should have a <tt>.xml</tt> extension.
* \li \c UPNP_E_NO_WEB_SERVER: The internal web server has been
* compiled out; the SDK cannot configure itself from the
* description document.
*/
EXPORT_SPEC int UpnpRegisterRootDevice2(
/*! The type of the description document. */
@ -951,38 +954,39 @@ EXPORT_SPEC int UpnpRegisterRootDevice2(
OUT UpnpDevice_Handle* Hnd);
/*! \b UpnpRegisterRootDevice3 registers a device application for a
* specific address family with the SDK. A device application cannot
* make any other API calls until it registers using this function.
* Device applications can also register as control points (see
* \b UpnpRegisterClient to get a control point handle to perform
* control point functionality).
/*! \brief Registers a device application for a specific address family with
* the UPnP library.
*
* \b UpnpRegisterRootDevice is synchronous and does not generate
* any callbacks. Callbacks can occur as soon as this function returns.
* A device application cannot make any other API calls until it registers
* using this function. Device applications can also register as control
* points (see \b UpnpRegisterClient to get a control point handle to perform
* control point functionality).
*
* \return [int] An integer representing one of the following:
* \li \c UPNP_E_SUCCESS: The operation completed successfully.
* \li \c UPNP_E_FINISH: The SDK is already terminated or
* is not initialized.
* \li \c UPNP_E_INVALID_DESC: The description document was not
* a valid device description.
* \li \c UPNP_E_INVALID_URL: The URL for the description document
* is not valid.
* \li \c UPNP_E_INVALID_PARAM: Either \b Callback or \b Hnd
* is not a valid pointer or \b DescURL is \c NULL.
* \li \c UPNP_E_NETWORK_ERROR: A network error occurred.
* \li \c UPNP_E_SOCKET_WRITE: An error or timeout occurred writing
* to a socket.
* \li \c UPNP_E_SOCKET_READ: An error or timeout occurred reading
* from a socket.
* \li \c UPNP_E_SOCKET_BIND: An error occurred binding a socket.
* \li \c UPNP_E_SOCKET_CONNECT: An error occurred connecting the
* socket.
* \li \c UPNP_E_OUTOF_SOCKET: Too many sockets are currently
* allocated.
* \li \c UPNP_E_OUTOF_MEMORY: There are insufficient resources to
* register this root device.
* This is synchronous and does not generate any callbacks. Callbacks can occur
* as soon as this function returns.
*
* \return An integer representing one of the following:
* \li \c UPNP_E_SUCCESS: The operation completed successfully.
* \li \c UPNP_E_FINISH: The SDK is already terminated or
* is not initialized.
* \li \c UPNP_E_INVALID_DESC: The description document was not
* a valid device description.
* \li \c UPNP_E_INVALID_URL: The URL for the description document
* is not valid.
* \li \c UPNP_E_INVALID_PARAM: Either \b Callback or \b Hnd
* is not a valid pointer or \b DescURL is \c NULL.
* \li \c UPNP_E_NETWORK_ERROR: A network error occurred.
* \li \c UPNP_E_SOCKET_WRITE: An error or timeout occurred writing
* to a socket.
* \li \c UPNP_E_SOCKET_READ: An error or timeout occurred reading
* from a socket.
* \li \c UPNP_E_SOCKET_BIND: An error occurred binding a socket.
* \li \c UPNP_E_SOCKET_CONNECT: An error occurred connecting the
* socket.
* \li \c UPNP_E_OUTOF_SOCKET: Too many sockets are currently
* allocated.
* \li \c UPNP_E_OUTOF_MEMORY: There are insufficient resources to
* register this root device.
*/
EXPORT_SPEC int UpnpRegisterRootDevice3(
/*! Pointer to a string containing the description URL for this root
@ -1000,6 +1004,25 @@ EXPORT_SPEC int UpnpRegisterRootDevice3(
IN const int AddressFamily);
/*! \brief Unregisters a root device registered with \b UpnpRegisterRootDevice or
* \b UpnpRegisterRootDevice2.
*
* After this call, the \b UpnpDevice_Handle is no longer valid. For all
* advertisements that have not yet expired, the SDK sends a device unavailable
* message automatically.
*
* This is a synchronous call and generates no callbacks. Once this call
* returns, the SDK will no longer generate callbacks to the application.
*
* \return An integer representing one of the following:
* \li \c UPNP_E_SUCCESS: The operation completed successfully.
* \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid device handle.
*/
EXPORT_SPEC int UpnpUnRegisterRootDevice(
/*! The handle of the root device instance to unregister. */
IN UpnpDevice_Handle);
/*! \brief Registers a control point application with the UPnP Library.
*
* A control point application cannot make any other API calls until it
@ -1046,25 +1069,6 @@ EXPORT_SPEC int UpnpUnRegisterClient(
IN UpnpClient_Handle Hnd);
/*! \brief Unregisters a root device registered with \b UpnpRegisterRootDevice or
* \b UpnpRegisterRootDevice2. After this call, the
* \b UpnpDevice_Handle is no longer valid. For all advertisements that
* have not yet expired, the SDK sends a device unavailable message
* automatically.
*
* \b UpnpUnRegisterRootDevice is a synchronous call and generates no
* callbacks. Once this call returns, the SDK will no longer
* generate callbacks to the application.
*
* \return [int] An integer representing one of the following:
* \li \c UPNP_E_SUCCESS: The operation completed successfully.
* \li \c UPNP_E_INVALID_HANDLE: The handle is not a valid device handle.
*/
EXPORT_SPEC int UpnpUnRegisterRootDevice(
/*! The handle of the root device instance to unregister. */
IN UpnpDevice_Handle);
/*! \deprecated Use \b UpnpSetMaxContentLength instead.
* Warning: the Handle argument provided here is not used, so the effect
* of this function is global to the SDK (= same as

View File

@ -50,15 +50,15 @@ extern "C" {
#endif
/** @name Other debugging features
The UPnP SDK contains other features to aid in debugging.
/** \name Other debugging features
*
* The UPnP SDK contains other features to aid in debugging.
*/
/*@{*/
/*! @{ */
/** @name Upnp_LogLevel
/** \name Upnp_LogLevel
* The user has the option to select 4 different types of debugging levels,
* see {\tt UpnpSetLogLevel}.
* see \c UpnpSetLogLevel.
* The critical level will show only those messages
* which can halt the normal processing of the library, like memory
* allocation errors. The remaining three levels are just for debugging
@ -67,12 +67,10 @@ extern "C" {
* Info Level displays the other important operational information
* regarding the working of the library. If the user selects All,
* then the library displays all the debugging information that it has.
* \begin{itemize}
* \item {\tt UPNP_CRITICAL [0]}
* \item {\tt UPNP_PACKET [1]}
* \item {\tt UPNP_INFO [2]}
* \item {\tt UPNP_ALL [3]}
* \end{itemize}
* \li \c UPNP_CRITICAL [0]
* \li \c UPNP_PACKET [1]
* \li \c UPNP_INFO [2]
* \li \c UPNP_ALL [3]
*/
typedef enum Upnp_Module {
@ -86,18 +84,18 @@ typedef enum Upnp_Module {
HTTP
} Dbg_Module;
/*! @{ */
/*@{*/
typedef enum Upnp_LogLevel_e {
UPNP_CRITICAL,
UPNP_PACKET,
UPNP_INFO,
UPNP_ALL
} Upnp_LogLevel;
/*! @} */
/*@}*/
/**
* Default log level : see {\tt Upnp_LogLevel}
* Default log level : see \c Upnp_LogLevel
*/
#define UPNP_DEFAULT_LOG_LEVEL UPNP_ALL
@ -128,7 +126,7 @@ static UPNP_INLINE int UpnpInitLog() { return UPNP_E_SUCCESS; }
* Parameters: Upnp_LogLevel log_level
*
* Description:
* This functions set the log level (see {\tt Upnp_LogLevel}
* This functions set the log level (see \c Upnp_LogLevel)
* Returns: void
***************************************************************************/
#ifdef DEBUG
@ -308,7 +306,7 @@ static UPNP_INLINE void UpnpDisplayFileAndLine(
* \param [in] fd file descriptor where the banner will be written
* \param [in] lines: The buffer that will be written
* \param [in] size: Size of the buffer
* \param [in] starLength: This parameter provides the width of the banner
* \param [in] starlength: This parameter provides the width of the banner
*/
#ifdef DEBUG
void UpnpDisplayBanner(
@ -349,7 +347,7 @@ static UPNP_INLINE void PrintThreadPoolStats(
#endif
/*! @} */
/*@}*/
#ifdef __cplusplus
}

View File

@ -163,6 +163,17 @@ int UpnpSdkDeviceregisteredV6 = 0;
Upnp_SID gUpnpSdkNLSuuid;
// FIXME Put this declaration in the proper header file
static int
GetDescDocumentAndURL( IN Upnp_DescType descriptionType,
IN char *description,
IN unsigned int bufferLen,
IN int config_baseURL,
IN int AddressFamily,
OUT IXML_Document ** xmlDoc,
OUT char descURL[LINE_SIZE] );
/******************************************************************************/
int UpnpInit(IN const char *HostIP, IN unsigned short DestPort)
{
@ -368,7 +379,7 @@ unsigned short UpnpGetServerPort6()
return LOCAL_PORT_V6;
}
/*****************************************************************************/
/******************************************************************************/
char *UpnpGetServerIpAddress()
{
if (UpnpSdkInit != 1) {
@ -378,7 +389,7 @@ char *UpnpGetServerIpAddress()
return gIF_IPV4;
}
/*****************************************************************************/
/******************************************************************************/
char *UpnpGetServerIp6Address()
{
if( UpnpSdkInit != 1 ) {
@ -389,33 +400,13 @@ char *UpnpGetServerIp6Address()
}
/******************************************************************************/
#ifdef INCLUDE_DEVICE_APIS
/****************************************************************************
* Function: UpnpRegisterRootDevice
*
* Parameters:
* IN const char *DescUrl:Pointer to a string containing the
* description URL for this root device instance.
* IN Upnp_FunPtr Callback: Pointer to the callback function for
* receiving asynchronous events.
* IN const void *Cookie: Pointer to user data returned with the
* callback function when invoked.
* OUT UpnpDevice_Handle *Hnd: Pointer to a variable to store the
* new device handle.
*
* Description:
* This function registers a device application with
* the UPnP Library. A device application cannot make any other API
* calls until it registers using this function.
*
* Return Values:
* UPNP_E_SUCCESS on success, nonzero on failure.
*****************************************************************************/
int
UpnpRegisterRootDevice( IN const char *DescUrl,
IN Upnp_FunPtr Fun,
IN const void *Cookie,
OUT UpnpDevice_Handle * Hnd )
int UpnpRegisterRootDevice(
IN const char *DescUrl,
IN Upnp_FunPtr Fun,
IN const void *Cookie,
OUT UpnpDevice_Handle * Hnd )
{
struct Handle_Info *HInfo;
@ -533,24 +524,261 @@ UpnpRegisterRootDevice( IN const char *DescUrl,
#ifdef INCLUDE_DEVICE_APIS
/****************************************************************************
* Function: UpnpUnRegisterRootDevice
*
* Parameters:
* IN UpnpDevice_Handle Hnd: The handle of the device instance
* to unregister
* Description:
* This function unregisters a root device registered with
* UpnpRegisterRootDevice} or UpnpRegisterRootDevice2. After this call, the
* UpnpDevice_Handle Hnd is no longer valid. For all advertisements that
* have not yet expired, the UPnP library sends a device unavailable message
* automatically.
*
* Return Values:
* UPNP_E_SUCCESS on success, nonzero on failure.
*****************************************************************************/
int
UpnpUnRegisterRootDevice( IN UpnpDevice_Handle Hnd )
/******************************************************************************/
int UpnpRegisterRootDevice2(
IN Upnp_DescType descriptionType,
IN const char *description_const,
IN size_t bufferLen, // ignored unless descType == UPNPREG_BUF_DESC
IN int config_baseURL,
IN Upnp_FunPtr Fun,
IN const void *Cookie,
OUT UpnpDevice_Handle * Hnd )
{
struct Handle_Info *HInfo;
int retVal = 0;
char *description = ( char * )description_const;
if( UpnpSdkInit != 1 ) {
return UPNP_E_FINISH;
}
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"Inside UpnpRegisterRootDevice2\n" );
if( Hnd == NULL || Fun == NULL ) {
return UPNP_E_INVALID_PARAM;
}
HandleLock();
if( UpnpSdkDeviceRegisteredV4 == 1 ) {
HandleUnlock();
return UPNP_E_ALREADY_REGISTERED;
}
if( ( *Hnd = GetFreeHandle() ) == UPNP_E_OUTOF_HANDLE ) {
HandleUnlock();
return UPNP_E_OUTOF_MEMORY;
}
HInfo = ( struct Handle_Info * )malloc( sizeof( struct Handle_Info ) );
if( HInfo == NULL ) {
HandleUnlock();
return UPNP_E_OUTOF_MEMORY;
}
HandleTable[*Hnd] = HInfo;
// prevent accidental removal of a non-existent alias
HInfo->aliasInstalled = 0;
retVal = GetDescDocumentAndURL(
descriptionType, description, bufferLen,
config_baseURL, AF_INET,
&HInfo->DescDocument, HInfo->DescURL );
if( retVal != UPNP_E_SUCCESS ) {
FreeHandle( *Hnd );
HandleUnlock();
return retVal;
}
HInfo->aliasInstalled = ( config_baseURL != 0 );
HInfo->HType = HND_DEVICE;
HInfo->Callback = Fun;
HInfo->Cookie = ( void * )Cookie;
HInfo->MaxAge = DEFAULT_MAXAGE;
HInfo->DeviceList = NULL;
HInfo->ServiceList = NULL;
CLIENTONLY( ListInit( &HInfo->SsdpSearchList, NULL, NULL ); )
CLIENTONLY( HInfo->ClientSubList = NULL; )
HInfo->MaxSubscriptions = UPNP_INFINITE;
HInfo->MaxSubscriptionTimeOut = UPNP_INFINITE;
HInfo->DeviceAf = AF_INET;
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"UpnpRegisterRootDevice2: Valid Description\n" );
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"UpnpRegisterRootDevice2: DescURL : %s\n",
HInfo->DescURL );
HInfo->DeviceList =
ixmlDocument_getElementsByTagName( HInfo->DescDocument, "device" );
if( !HInfo->DeviceList ) {
CLIENTONLY( ListDestroy( &HInfo->SsdpSearchList, 0 ); )
ixmlDocument_free( HInfo->DescDocument );
FreeHandle( *Hnd );
HandleUnlock();
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"UpnpRegisterRootDevice2: No devices found for RootDevice\n" );
return UPNP_E_INVALID_DESC;
}
HInfo->ServiceList = ixmlDocument_getElementsByTagName(
HInfo->DescDocument, "serviceList" );
if( !HInfo->ServiceList ) {
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"UpnpRegisterRootDevice2: No services found for RootDevice\n" );
}
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"UpnpRegisterRootDevice2: Gena Check\n" );
//*******************************
// GENA SET UP
//*******************************
if( getServiceTable( ( IXML_Node * ) HInfo->DescDocument,
&HInfo->ServiceTable, HInfo->DescURL ) ) {
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"UpnpRegisterRootDevice2: GENA Service Table\n" );
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"Here are the known services: \n" );
printServiceTable( &HInfo->ServiceTable, UPNP_INFO, API );
} else {
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"\nUpnpRegisterRootDevice2: Empty service table\n" );
}
UpnpSdkDeviceRegisteredV4 = 1;
HandleUnlock();
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"Exiting RegisterRootDevice2 Successfully\n" );
return UPNP_E_SUCCESS;
}
#endif // INCLUDE_DEVICE_APIS
#ifdef INCLUDE_DEVICE_APIS
/******************************************************************************/
int UpnpRegisterRootDevice3(
IN const char *DescUrl,
IN Upnp_FunPtr Fun,
IN const void *Cookie,
OUT UpnpDevice_Handle * Hnd,
IN const int AddressFamily )
{
struct Handle_Info *HInfo;
int retVal = 0;
if( UpnpSdkInit != 1 ) {
return UPNP_E_FINISH;
}
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"Inside UpnpRegisterRootDevice\n" );
HandleLock();
if( Hnd == NULL || Fun == NULL ||
DescUrl == NULL || strlen( DescUrl ) == 0 ||
(AddressFamily != AF_INET && AddressFamily != AF_INET6) ) {
HandleUnlock();
return UPNP_E_INVALID_PARAM;
}
if( ( AddressFamily == AF_INET && UpnpSdkDeviceRegisteredV4 == 1 ) ||
( AddressFamily == AF_INET6 && UpnpSdkDeviceregisteredV6 == 1 ) ) {
HandleUnlock();
return UPNP_E_ALREADY_REGISTERED;
}
if( ( *Hnd = GetFreeHandle() ) == UPNP_E_OUTOF_HANDLE ) {
HandleUnlock();
return UPNP_E_OUTOF_MEMORY;
}
HInfo = ( struct Handle_Info * )malloc( sizeof( struct Handle_Info ) );
if( HInfo == NULL ) {
HandleUnlock();
return UPNP_E_OUTOF_MEMORY;
}
HandleTable[*Hnd] = HInfo;
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"Root device URL is %s\n", DescUrl );
HInfo->aliasInstalled = 0;
HInfo->HType = HND_DEVICE;
strcpy( HInfo->DescURL, DescUrl );
HInfo->Callback = Fun;
HInfo->Cookie = ( void * )Cookie;
HInfo->MaxAge = DEFAULT_MAXAGE;
HInfo->DeviceList = NULL;
HInfo->ServiceList = NULL;
HInfo->DescDocument = NULL;
CLIENTONLY( ListInit( &HInfo->SsdpSearchList, NULL, NULL ); )
CLIENTONLY( HInfo->ClientSubList = NULL; )
HInfo->MaxSubscriptions = UPNP_INFINITE;
HInfo->MaxSubscriptionTimeOut = UPNP_INFINITE;
HInfo->DeviceAf = AddressFamily;
if( ( retVal =
UpnpDownloadXmlDoc( HInfo->DescURL, &( HInfo->DescDocument ) ) )
!= UPNP_E_SUCCESS ) {
CLIENTONLY( ListDestroy( &HInfo->SsdpSearchList, 0 ) );
FreeHandle( *Hnd );
HandleUnlock();
return retVal;
}
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"UpnpRegisterRootDevice: Valid Description\n" );
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"UpnpRegisterRootDevice: DescURL : %s\n",
HInfo->DescURL );
HInfo->DeviceList =
ixmlDocument_getElementsByTagName( HInfo->DescDocument, "device" );
if( !HInfo->DeviceList ) {
CLIENTONLY( ListDestroy( &HInfo->SsdpSearchList, 0 ) );
ixmlDocument_free( HInfo->DescDocument );
FreeHandle( *Hnd );
HandleUnlock();
UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__,
"UpnpRegisterRootDevice: No devices found for RootDevice\n" );
return UPNP_E_INVALID_DESC;
}
HInfo->ServiceList = ixmlDocument_getElementsByTagName(
HInfo->DescDocument, "serviceList" );
if( !HInfo->ServiceList ) {
UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__,
"UpnpRegisterRootDevice: No services found for RootDevice\n" );
}
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"UpnpRegisterRootDevice: Gena Check\n" );
//*******************************
// GENA SET UP
//*******************************
if( getServiceTable( ( IXML_Node * ) HInfo->DescDocument,
&HInfo->ServiceTable, HInfo->DescURL ) ) {
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"UpnpRegisterRootDevice: GENA Service Table \n" );
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"Here are the known services: \n" );
printServiceTable( &HInfo->ServiceTable, UPNP_INFO, API );
} else {
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"\nUpnpRegisterRootDevice2: Empty service table\n" );
}
if( AddressFamily == AF_INET )
UpnpSdkDeviceRegisteredV4 = 1;
else
UpnpSdkDeviceregisteredV6 = 1;
HandleUnlock();
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"Exiting RegisterRootDevice Successfully\n" );
return UPNP_E_SUCCESS;
}
#endif // INCLUDE_DEVICE_APIS
#ifdef INCLUDE_DEVICE_APIS
int UpnpUnRegisterRootDevice(IN UpnpDevice_Handle Hnd)
{
int retVal = 0;
struct Handle_Info *HInfo = NULL;
@ -613,9 +841,121 @@ UpnpUnRegisterRootDevice( IN UpnpDevice_Handle Hnd )
return retVal;
} /****************** End of UpnpUnRegisterRootDevice *********************/
}
#endif // INCLUDE_DEVICE_APIS
/*****************************************************************************/
#ifdef INCLUDE_CLIENT_APIS
int UpnpRegisterClient(
IN Upnp_FunPtr Fun,
IN const void *Cookie,
OUT UpnpClient_Handle *Hnd)
{
struct Handle_Info *HInfo;
if( UpnpSdkInit != 1 ) {
return UPNP_E_FINISH;
}
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"Inside UpnpRegisterClient \n" );
if( Fun == NULL || Hnd == NULL ) {
return UPNP_E_INVALID_PARAM;
}
HandleLock();
if( UpnpSdkClientRegistered ) {
HandleUnlock();
return UPNP_E_ALREADY_REGISTERED;
}
if( ( *Hnd = GetFreeHandle() ) == UPNP_E_OUTOF_HANDLE ) {
HandleUnlock();
return UPNP_E_OUTOF_MEMORY;
}
HInfo = ( struct Handle_Info * )malloc( sizeof( struct Handle_Info ) );
if( HInfo == NULL ) {
HandleUnlock();
return UPNP_E_OUTOF_MEMORY;
}
HInfo->HType = HND_CLIENT;
HInfo->Callback = Fun;
HInfo->Cookie = ( void * )Cookie;
HInfo->ClientSubList = NULL;
ListInit( &HInfo->SsdpSearchList, NULL, NULL );
#ifdef INCLUDE_DEVICE_APIS
HInfo->MaxAge = 0;
HInfo->MaxSubscriptions = UPNP_INFINITE;
HInfo->MaxSubscriptionTimeOut = UPNP_INFINITE;
#endif
HandleTable[*Hnd] = HInfo;
UpnpSdkClientRegistered = 1;
HandleUnlock();
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"Exiting UpnpRegisterClient \n" );
return UPNP_E_SUCCESS;
}
#endif // INCLUDE_CLIENT_APIS
/*****************************************************************************/
#ifdef INCLUDE_CLIENT_APIS
int UpnpUnRegisterClient(IN UpnpClient_Handle Hnd)
{
struct Handle_Info *HInfo;
ListNode *node = NULL;
SsdpSearchArg *searchArg = NULL;
if( UpnpSdkInit != 1 ) {
return UPNP_E_FINISH;
}
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"Inside UpnpUnRegisterClient \n" );
HandleLock();
if( !UpnpSdkClientRegistered ) {
HandleUnlock();
return UPNP_E_INVALID_HANDLE;
}
HandleUnlock();
#if EXCLUDE_GENA == 0
if( genaUnregisterClient( Hnd ) != UPNP_E_SUCCESS )
return UPNP_E_INVALID_HANDLE;
#endif
HandleLock();
if( GetHandleInfo( Hnd, &HInfo ) == UPNP_E_INVALID_HANDLE ) {
HandleUnlock();
return UPNP_E_INVALID_HANDLE;
}
//clean up search list
node = ListHead( &HInfo->SsdpSearchList );
while( node != NULL ) {
searchArg = ( SsdpSearchArg * ) node->item;
if( searchArg ) {
free( searchArg->searchTarget );
free( searchArg );
}
ListDelNode( &HInfo->SsdpSearchList, node, 0 );
node = ListHead( &HInfo->SsdpSearchList );
}
ListDestroy( &HInfo->SsdpSearchList, 0 );
FreeHandle( Hnd );
UpnpSdkClientRegistered = 0;
HandleUnlock();
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"Exiting UpnpUnRegisterClient \n" );
return UPNP_E_SUCCESS;
}
#endif // INCLUDE_CLIENT_APIS
#endif //INCLUDE_DEVICE_APIS
// *************************************************************
#ifdef INCLUDE_DEVICE_APIS
@ -903,421 +1243,8 @@ GetDescDocumentAndURL( IN Upnp_DescType descriptionType,
}
#endif // INTERNAL_WEB_SERVER
// ********************************************************
/****************************************************************************
* Function: UpnpRegisterRootDevice2
*
* Parameters:
* IN Upnp_DescType descriptionType: The type of description document.
* IN const char* description: Treated as a URL, file name or
* memory buffer depending on description type.
* IN size_t bufferLen: Length of memory buffer if passing a description
* in a buffer, otherwize ignored.
* IN int config_baseURL: If nonzero, URLBase of description document is
* configured and the description is served using the internal
* web server.
* IN Upnp_FunPtr Fun: Pointer to the callback function for
* receiving asynchronous events.
* IN const void* Cookie: Pointer to user data returned with the
* callback function when invoked.
* OUT UpnpDevice_Handle* Hnd: Pointer to a variable to store
* the new device handle.
*
* Description:
* This function is similar to UpnpRegisterRootDevice except that
* it also allows the description document to be specified as a file or
* a memory buffer. The description can also be configured to have the
* correct IP and port address.
*
* Return Values:
* UPNP_E_SUCCESS on success, nonzero on failure.
*****************************************************************************/
int
UpnpRegisterRootDevice2( IN Upnp_DescType descriptionType,
IN const char *description_const,
IN size_t bufferLen, // ignored unless descType == UPNPREG_BUF_DESC
IN int config_baseURL,
IN Upnp_FunPtr Fun,
IN const void *Cookie,
OUT UpnpDevice_Handle * Hnd )
{
struct Handle_Info *HInfo;
int retVal = 0;
char *description = ( char * )description_const;
if( UpnpSdkInit != 1 ) {
return UPNP_E_FINISH;
}
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"Inside UpnpRegisterRootDevice2\n" );
if( Hnd == NULL || Fun == NULL ) {
return UPNP_E_INVALID_PARAM;
}
HandleLock();
if( UpnpSdkDeviceRegisteredV4 == 1 ) {
HandleUnlock();
return UPNP_E_ALREADY_REGISTERED;
}
if( ( *Hnd = GetFreeHandle() ) == UPNP_E_OUTOF_HANDLE ) {
HandleUnlock();
return UPNP_E_OUTOF_MEMORY;
}
HInfo = ( struct Handle_Info * )malloc( sizeof( struct Handle_Info ) );
if( HInfo == NULL ) {
HandleUnlock();
return UPNP_E_OUTOF_MEMORY;
}
HandleTable[*Hnd] = HInfo;
// prevent accidental removal of a non-existent alias
HInfo->aliasInstalled = 0;
retVal = GetDescDocumentAndURL(
descriptionType, description, bufferLen,
config_baseURL, AF_INET,
&HInfo->DescDocument, HInfo->DescURL );
if( retVal != UPNP_E_SUCCESS ) {
FreeHandle( *Hnd );
HandleUnlock();
return retVal;
}
HInfo->aliasInstalled = ( config_baseURL != 0 );
HInfo->HType = HND_DEVICE;
HInfo->Callback = Fun;
HInfo->Cookie = ( void * )Cookie;
HInfo->MaxAge = DEFAULT_MAXAGE;
HInfo->DeviceList = NULL;
HInfo->ServiceList = NULL;
CLIENTONLY( ListInit( &HInfo->SsdpSearchList, NULL, NULL ); )
CLIENTONLY( HInfo->ClientSubList = NULL; )
HInfo->MaxSubscriptions = UPNP_INFINITE;
HInfo->MaxSubscriptionTimeOut = UPNP_INFINITE;
HInfo->DeviceAf = AF_INET;
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"UpnpRegisterRootDevice2: Valid Description\n" );
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"UpnpRegisterRootDevice2: DescURL : %s\n",
HInfo->DescURL );
HInfo->DeviceList =
ixmlDocument_getElementsByTagName( HInfo->DescDocument, "device" );
if( !HInfo->DeviceList ) {
CLIENTONLY( ListDestroy( &HInfo->SsdpSearchList, 0 ); )
ixmlDocument_free( HInfo->DescDocument );
FreeHandle( *Hnd );
HandleUnlock();
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"UpnpRegisterRootDevice2: No devices found for RootDevice\n" );
return UPNP_E_INVALID_DESC;
}
HInfo->ServiceList = ixmlDocument_getElementsByTagName(
HInfo->DescDocument, "serviceList" );
if( !HInfo->ServiceList ) {
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"UpnpRegisterRootDevice2: No services found for RootDevice\n" );
}
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"UpnpRegisterRootDevice2: Gena Check\n" );
//*******************************
// GENA SET UP
//*******************************
if( getServiceTable( ( IXML_Node * ) HInfo->DescDocument,
&HInfo->ServiceTable, HInfo->DescURL ) ) {
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"UpnpRegisterRootDevice2: GENA Service Table\n" );
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"Here are the known services: \n" );
printServiceTable( &HInfo->ServiceTable, UPNP_INFO, API );
} else {
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"\nUpnpRegisterRootDevice2: Empty service table\n" );
}
UpnpSdkDeviceRegisteredV4 = 1;
HandleUnlock();
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"Exiting RegisterRootDevice2 Successfully\n" );
return UPNP_E_SUCCESS;
}
/****************************************************************************
* Function: UpnpRegisterRootDevice3
*
* Parameters:
* IN const char *DescUrl:Pointer to a string containing the
* description URL for this root device instance.
* IN Upnp_FunPtr Callback: Pointer to the callback function for
* receiving asynchronous events.
* IN const void *Cookie: Pointer to user data returned with the
* callback function when invoked.
* OUT UpnpDevice_Handle *Hnd: Pointer to a variable to store the
* new device handle.
* IN const int AddressFamily: Registration address family. Can be AF_INET
* or AF_INET6.
*
* Description:
* This function registers a device application with
* the UPnP Library. A device application cannot make any other API
* calls until it registers using this function.
*
* Return Values:
* UPNP_E_SUCCESS on success, nonzero on failure.
*****************************************************************************/
int
UpnpRegisterRootDevice3( IN const char *DescUrl,
IN Upnp_FunPtr Fun,
IN const void *Cookie,
OUT UpnpDevice_Handle * Hnd,
IN const int AddressFamily )
{
struct Handle_Info *HInfo;
int retVal = 0;
if( UpnpSdkInit != 1 ) {
return UPNP_E_FINISH;
}
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"Inside UpnpRegisterRootDevice\n" );
HandleLock();
if( Hnd == NULL || Fun == NULL ||
DescUrl == NULL || strlen( DescUrl ) == 0 ||
(AddressFamily != AF_INET && AddressFamily != AF_INET6) ) {
HandleUnlock();
return UPNP_E_INVALID_PARAM;
}
if( ( AddressFamily == AF_INET && UpnpSdkDeviceRegisteredV4 == 1 ) ||
( AddressFamily == AF_INET6 && UpnpSdkDeviceregisteredV6 == 1 ) ) {
HandleUnlock();
return UPNP_E_ALREADY_REGISTERED;
}
if( ( *Hnd = GetFreeHandle() ) == UPNP_E_OUTOF_HANDLE ) {
HandleUnlock();
return UPNP_E_OUTOF_MEMORY;
}
HInfo = ( struct Handle_Info * )malloc( sizeof( struct Handle_Info ) );
if( HInfo == NULL ) {
HandleUnlock();
return UPNP_E_OUTOF_MEMORY;
}
HandleTable[*Hnd] = HInfo;
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"Root device URL is %s\n", DescUrl );
HInfo->aliasInstalled = 0;
HInfo->HType = HND_DEVICE;
strcpy( HInfo->DescURL, DescUrl );
HInfo->Callback = Fun;
HInfo->Cookie = ( void * )Cookie;
HInfo->MaxAge = DEFAULT_MAXAGE;
HInfo->DeviceList = NULL;
HInfo->ServiceList = NULL;
HInfo->DescDocument = NULL;
CLIENTONLY( ListInit( &HInfo->SsdpSearchList, NULL, NULL ); )
CLIENTONLY( HInfo->ClientSubList = NULL; )
HInfo->MaxSubscriptions = UPNP_INFINITE;
HInfo->MaxSubscriptionTimeOut = UPNP_INFINITE;
HInfo->DeviceAf = AddressFamily;
if( ( retVal =
UpnpDownloadXmlDoc( HInfo->DescURL, &( HInfo->DescDocument ) ) )
!= UPNP_E_SUCCESS ) {
CLIENTONLY( ListDestroy( &HInfo->SsdpSearchList, 0 ) );
FreeHandle( *Hnd );
HandleUnlock();
return retVal;
}
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"UpnpRegisterRootDevice: Valid Description\n" );
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"UpnpRegisterRootDevice: DescURL : %s\n",
HInfo->DescURL );
HInfo->DeviceList =
ixmlDocument_getElementsByTagName( HInfo->DescDocument, "device" );
if( !HInfo->DeviceList ) {
CLIENTONLY( ListDestroy( &HInfo->SsdpSearchList, 0 ) );
ixmlDocument_free( HInfo->DescDocument );
FreeHandle( *Hnd );
HandleUnlock();
UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__,
"UpnpRegisterRootDevice: No devices found for RootDevice\n" );
return UPNP_E_INVALID_DESC;
}
HInfo->ServiceList = ixmlDocument_getElementsByTagName(
HInfo->DescDocument, "serviceList" );
if( !HInfo->ServiceList ) {
UpnpPrintf( UPNP_CRITICAL, API, __FILE__, __LINE__,
"UpnpRegisterRootDevice: No services found for RootDevice\n" );
}
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"UpnpRegisterRootDevice: Gena Check\n" );
//*******************************
// GENA SET UP
//*******************************
if( getServiceTable( ( IXML_Node * ) HInfo->DescDocument,
&HInfo->ServiceTable, HInfo->DescURL ) ) {
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"UpnpRegisterRootDevice: GENA Service Table \n" );
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"Here are the known services: \n" );
printServiceTable( &HInfo->ServiceTable, UPNP_INFO, API );
} else {
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"\nUpnpRegisterRootDevice2: Empty service table\n" );
}
if( AddressFamily == AF_INET )
UpnpSdkDeviceRegisteredV4 = 1;
else
UpnpSdkDeviceregisteredV6 = 1;
HandleUnlock();
UpnpPrintf( UPNP_INFO, API, __FILE__, __LINE__,
"Exiting RegisterRootDevice Successfully\n" );
return UPNP_E_SUCCESS;
}
#endif // INCLUDE_DEVICE_APIS
#ifdef INCLUDE_CLIENT_APIS
/*****************************************************************************/
int UpnpRegisterClient(
IN Upnp_FunPtr Fun,
IN const void *Cookie,
OUT UpnpClient_Handle *Hnd)
{
struct Handle_Info *HInfo;
if( UpnpSdkInit != 1 ) {
return UPNP_E_FINISH;
}
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"Inside UpnpRegisterClient \n" );
if( Fun == NULL || Hnd == NULL ) {
return UPNP_E_INVALID_PARAM;
}
HandleLock();
if( UpnpSdkClientRegistered ) {
HandleUnlock();
return UPNP_E_ALREADY_REGISTERED;
}
if( ( *Hnd = GetFreeHandle() ) == UPNP_E_OUTOF_HANDLE ) {
HandleUnlock();
return UPNP_E_OUTOF_MEMORY;
}
HInfo = ( struct Handle_Info * )malloc( sizeof( struct Handle_Info ) );
if( HInfo == NULL ) {
HandleUnlock();
return UPNP_E_OUTOF_MEMORY;
}
HInfo->HType = HND_CLIENT;
HInfo->Callback = Fun;
HInfo->Cookie = ( void * )Cookie;
HInfo->ClientSubList = NULL;
ListInit( &HInfo->SsdpSearchList, NULL, NULL );
#ifdef INCLUDE_DEVICE_APIS
HInfo->MaxAge = 0;
HInfo->MaxSubscriptions = UPNP_INFINITE;
HInfo->MaxSubscriptionTimeOut = UPNP_INFINITE;
#endif
HandleTable[*Hnd] = HInfo;
UpnpSdkClientRegistered = 1;
HandleUnlock();
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"Exiting UpnpRegisterClient \n" );
return UPNP_E_SUCCESS;
}
#endif // INCLUDE_CLIENT_APIS
/*****************************************************************************/
#ifdef INCLUDE_CLIENT_APIS
int UpnpUnRegisterClient(IN UpnpClient_Handle Hnd)
{
struct Handle_Info *HInfo;
ListNode *node = NULL;
SsdpSearchArg *searchArg = NULL;
if( UpnpSdkInit != 1 ) {
return UPNP_E_FINISH;
}
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"Inside UpnpUnRegisterClient \n" );
HandleLock();
if( !UpnpSdkClientRegistered ) {
HandleUnlock();
return UPNP_E_INVALID_HANDLE;
}
HandleUnlock();
#if EXCLUDE_GENA == 0
if( genaUnregisterClient( Hnd ) != UPNP_E_SUCCESS )
return UPNP_E_INVALID_HANDLE;
#endif
HandleLock();
if( GetHandleInfo( Hnd, &HInfo ) == UPNP_E_INVALID_HANDLE ) {
HandleUnlock();
return UPNP_E_INVALID_HANDLE;
}
//clean up search list
node = ListHead( &HInfo->SsdpSearchList );
while( node != NULL ) {
searchArg = ( SsdpSearchArg * ) node->item;
if( searchArg ) {
free( searchArg->searchTarget );
free( searchArg );
}
ListDelNode( &HInfo->SsdpSearchList, node, 0 );
node = ListHead( &HInfo->SsdpSearchList );
}
ListDestroy( &HInfo->SsdpSearchList, 0 );
FreeHandle( Hnd );
UpnpSdkClientRegistered = 0;
HandleUnlock();
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
"Exiting UpnpUnRegisterClient \n" );
return UPNP_E_SUCCESS;
}
#endif // INCLUDE_CLIENT_APIS
//-----------------------------------------------------------------------------
//