Backport of svn 395 and 434:

395: Bob Ciora's patch for lazy UpnpAcceptSubscription().
434: Fixed a buffer overflow due to a bug in the calculation of the
     CONTENT-TYPE header line size, the length was beeing calculated with
     the wrong string, there was a missing colon.


git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@461 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
Marcelo Roberto Jimenez 2008-07-25 02:56:04 +00:00
parent 423808a095
commit 515233ca56
7 changed files with 2091 additions and 2305 deletions

View File

@ -21,6 +21,53 @@ Version 1.6.7
* Added an m4 macro to deal with finding libupnp in the users'
configure script.
2008-06-11 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Fixed a buffer overflow due to a bug in the calculation of the
CONTENT-TYPE header line size, the length was beeing calculated with
the wrong string, there was a missing colon.
2008-05-26 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* SF Bug Tracker [ 1903069 ]
Subs (not services) not marked 'active'
Submitted By: Bob Ciora - bobciora
If the UpnpAcceptSubscription is not called, the subscription is not marked
as "active", so no state variables will ever be sent.
I have a "lazy" architecture where a service may not be ready to publish
any state data at the time of a subscription. Subscriptions are still
accepted, there's just nothing to send, so UpnpAcceptSubscription is never
called. As a result, the subscription is never marked as "active" via the
genaInitNotify functions.
A best course of action would be to modify UpnpAcceptSubscription<...>
functions so that they can accept *no* initial state information, but can
still result in the subscription being marked as active. Technically,
then, the "active" flag should be set here, not in the genaInitNotify<...>
functions.
But the UpnpAccept functions don't muck with the subscription table, and
it's more work than it's worth to move that code from the gena fucntions to
the upnpapi functions.
So--- what I've done to correct this problem is to modify both
UpnpAcceptSubscription<...> functions (in upnppapi.c) to accept an empty
state list and still call the gena layer functions. The gena layer
genaInitNotify<...> functions (gena_device.c) then mark the subscription as
"active" *before* checking for an empty state set.
In genaInitNotify, a check for "var_count <= 0" is added immediately after
the "subs->active = 1;" line. If this occurs, then all cleanup is
performed and the function returns GENA_SUCCESS (since now, an empty state
list is not an error). The same check is made for "PropSet == 0" in
genaInitNotifyExt (just after the "subs->active = 1;" line).
I've modifified my proxy layer to call UpnpAcceptSubscriptionExt even when
there is no state data to send. With the suggested changes to
gena_device.c, later state changes are sent correctly.
This has solved my problem.
2008-04-28 Marcelo Jimenez <mroberto(at)users.sourceforge.net>
* Fix in function SetSeed() in threadutil/src/ThreadPool.c for CYGWIN
compilation. Thanks to Gary Chan.

View File

@ -2355,10 +2355,13 @@ UpnpAcceptSubscription( IN UpnpDevice_Handle Hnd,
HandleUnlock();
return UPNP_E_INVALID_PARAM;
}
/* Now accepts an empty state list, so the code below is commented out */
#if 0
if( VarName == NULL || NewVal == NULL || cVariables < 0 ) {
HandleUnlock();
return UPNP_E_INVALID_PARAM;
}
#endif
HandleUnlock();
retVal =
@ -2431,11 +2434,13 @@ UpnpAcceptSubscriptionExt( IN UpnpDevice_Handle Hnd,
HandleUnlock();
return UPNP_E_INVALID_PARAM;
}
/* Now accepts an empty state list, so the code below is commented out */
#if 0
if( PropSet == NULL ) {
HandleUnlock();
return UPNP_E_INVALID_PARAM;
}
#endif
HandleUnlock();
retVal = genaInitNotifyExt( Hnd, DevID, ServName, PropSet, SubsId );

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,33 +1,34 @@
///////////////////////////////////////////////////////////////////////////
//
// 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.
*
******************************************************************************/
/************************************************************************
* Purpose: This file defines the functions for services. It defines
@ -116,25 +117,8 @@ RemoveSubscriptionSID( Upnp_SID sid,
}
/************************************************************************
* Function : GetSubscriptionSID
*
* Parameters :
* Upnp_SID sid ; subscription ID
* service_info * service ; service object providing the list of
* subscriptions
*
* Description : Return the subscription from the service table
* that matches const Upnp_SID sid value.
*
* Return : subscription * - Pointer to the matching subscription
* node;
*
* Note :
************************************************************************/
subscription *
GetSubscriptionSID( Upnp_SID sid,
service_info * service )
subscription *GetSubscriptionSID(const Upnp_SID sid, service_info *service)
{
subscription *next = service->subscriptionList;
subscription *previous = NULL;

View File

@ -1,65 +1,82 @@
///////////////////////////////////////////////////////////////////////////
//
// 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 GENA_H
#define GENA_H
/*!
* \file
*/
#ifndef _GENA_
#define _GENA_
#include "config.h"
#include "service_table.h"
#include "miniserver.h"
#include "uri.h"
#include "upnp.h"
#include <time.h>
#include "ThreadPool.h"
#include <string.h>
#include <time.h>
#include "client_table.h"
#include "httpparser.h"
#include "miniserver.h"
#include "service_table.h"
#include "sock.h"
#include "ThreadPool.h"
#include "upnp.h"
#include "uri.h"
#ifdef __cplusplus
#define EXTERN_C extern "C"
#else
#else /* __cplusplus */
#ifndef EXTERN_C
#define EXTERN_C
#endif
#endif
#endif /* EXTERN_C */
#endif /* __cplusplus */
/*!
* \brief XML version comment. Not used because it is not interopeable with
* other UPnP vendors.
*/
#define XML_VERSION "<?xml version='1.0' encoding='ISO-8859-1' ?>\n"
#define XML_PROPERTYSET_HEADER \
"<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">\n"
#define UNABLE_MEMORY "HTTP/1.1 500 Internal Server Error\r\n\r\n"
#define UNABLE_SERVICE_UNKNOWN "HTTP/1.1 404 Not Found\r\n\r\n"
#define UNABLE_SERVICE_NOT_ACCEPT \
"HTTP/1.1 503 Service Not Available\r\n\r\n"
#define UNABLE_SERVICE_NOT_ACCEPT "HTTP/1.1 503 Service Not Available\r\n\r\n"
#define NOT_IMPLEMENTED "HTTP/1.1 501 Not Implemented\r\n\r\n"
@ -74,6 +91,8 @@
#define MAX_SECONDS 10
#define MAX_EVENTS 20
#define MAX_PORT_SIZE 10
#define GENA_E_BAD_RESPONSE UPNP_E_BAD_RESPONSE
#define GENA_E_BAD_SERVICE UPNP_E_INVALID_SERVICE
#define GENA_E_SUBSCRIPTION_UNACCEPTED UPNP_E_SUBSCRIBE_UNACCEPTED
@ -82,16 +101,23 @@
#define GENA_E_NOTIFY_UNACCEPTED UPNP_E_NOTIFY_UNACCEPTED
#define GENA_E_NOTIFY_UNACCEPTED_REMOVE_SUB -9
#define GENA_E_BAD_HANDLE UPNP_E_INVALID_HANDLE
#define XML_ERROR -5
#define XML_SUCCESS UPNP_E_SUCCESS
#define GENA_SUCCESS UPNP_E_SUCCESS
#define CALLBACK_SUCCESS 0
#define DEFAULT_TIMEOUT 1801
extern ithread_mutex_t GlobalClientSubscribeMutex;
// Lock the subscription
/*!
* \brief Locks the subscription.
*/
#define SubscribeLock() \
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, \
"Trying Subscribe Lock"); \
@ -99,7 +125,10 @@ extern ithread_mutex_t GlobalClientSubscribeMutex;
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, \
"Subscribe Lock");
// Unlock the subscription
/*!
* \brief Unlocks the subscription.
*/
#define SubscribeUnlock() \
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, \
"Trying Subscribe UnLock"); \
@ -108,7 +137,9 @@ extern ithread_mutex_t GlobalClientSubscribeMutex;
"Subscribe UnLock");
// Structure to send NOTIFY message to all subscribed control points
/*!
* Structure to send NOTIFY message to all subscribed control points
*/
typedef struct NOTIFY_THREAD_STRUCT {
char *headers;
DOMString propertySet;
@ -121,282 +152,233 @@ typedef struct NOTIFY_THREAD_STRUCT {
} notify_thread_struct;
/************************************************************************
* Function : genaCallback
*
* Parameters:
* IN http_parser_t *parser: represents the parse state of the request
* IN http_message_t* request: HTTP message containing GENA request
* INOUT SOCKINFO *info: Structure containing information about the socket
*
* Description:
* This is the callback function called by the miniserver to handle
/*!
* \brief This is the callback function called by the miniserver to handle
* incoming GENA requests.
*
* Returns: int
* UPNP_E_SUCCESS if successful else appropriate error
***************************************************************************/
EXTERN_C void genaCallback (IN http_parser_t *parser,
IN http_message_t* request,
IN SOCKINFO *info);
* \return UPNP_E_SUCCESS if successful, otherwise appropriate error code.
*/
EXTERN_C void genaCallback(
/*! [in] represents the parse state of the request */
http_parser_t *parser,
/*! [in] HTTP message containing GENA request */
http_message_t* request,
/*! [in,out] Structure containing information about the socket */
SOCKINFO *info);
/************************************************************************
* Function : genaSubscribe
/*!
* \brief This function subscribes to a PublisherURL (also mentioned as EventURL
* in some places).
*
* Parameters:
* IN UpnpClient_Handle client_handle:
* IN char * PublisherURL: NULL Terminated, of the form :
* "http://134.134.156.80:4000/RedBulb/Event"
* INOUT int * TimeOut: requested Duration, if -1, then "infinite".
* in the OUT case: actual Duration granted
* by Service, -1 for infinite
* OUT Upnp_SID out_sid:sid of subscription, memory passed in by caller
* It sends SUBSCRIBE http request to service processes request. Finally adds a
* Subscription to the clients subscription list, if service responds with OK.
*
* Description:
* This function subscribes to a PublisherURL ( also mentioned as EventURL
* some places). It sends SUBSCRIBE http request to service processes
* request. Finally adds a Subscription to
* the clients subscription list, if service responds with OK
*
* Returns: int
* return UPNP_E_SUCCESS if service response is OK else
* returns appropriate error
***************************************************************************/
* \return UPNP_E_SUCCESS if service response is OK, otherwise returns the
* appropriate error code
*/
#ifdef INCLUDE_CLIENT_APIS
EXTERN_C int genaSubscribe(
/*! [in] The client handle. */
UpnpClient_Handle client_handle,
char * PublisherURL,
/*! [in] Of the form: "http://134.134.156.80:4000/RedBulb/Event */
const char *PublisherURL,
/*! [in,out] requested Duration:
* \li if -1, then "infinite".
* \li in the OUT case: actual Duration granted by Service,
* -1 for infinite. */
int *TimeOut,
/*! [out] sid of subscription, memory passed in by caller. */
Upnp_SID out_sid);
#endif
#endif /* INCLUDE_CLIENT_APIS */
/************************************************************************
* Function : genaUnSubscribe
/*!
* \brief Unsubscribes a SID.
*
* Parameters:
* IN UpnpClient_Handle client_handle: UPnP client handle
* IN SID in_sid: The subscription ID
* It first validates the SID and client_handle,copies the subscription, sends
* UNSUBSCRIBE http request to service processes request and finally removes
* the subscription.
*
* Description:
* This function unsubscribes a SID. It first validates the SID and
* client_handle,copies the subscription, sends UNSUBSCRIBE http request
* to service processes request and finally removes the subscription
*
* Returns: int
* return UPNP_E_SUCCESS if service response is OK else
* returns appropriate error
***************************************************************************/
* \return UPNP_E_SUCCESS if service response is OK, otherwise returns the
* appropriate error code.
*/
#ifdef INCLUDE_CLIENT_APIS
EXTERN_C int genaUnSubscribe(
/*! [in] UPnP client handle. */
UpnpClient_Handle client_handle,
/*! [in] The subscription ID. */
const Upnp_SID in_sid);
#endif
#endif /* INCLUDE_CLIENT_APIS */
/************************************************************************
* Function : genaUnregisterClient
/*!
* \brief Unsubcribes all the outstanding subscriptions and cleans the
* subscription list.
*
* Parameters:
* IN UpnpClient_Handle client_handle: Handle containing all the control
* point related information
* This function is called when control point unregisters.
*
* Description:
* This function unsubcribes all the outstanding subscriptions and cleans
* the subscription list. This function is called when control point
* unregisters.
*
* Returns: int
* return UPNP_E_SUCCESS if successful else returns appropriate error
***************************************************************************/
* \returns UPNP_E_SUCCESS if successful, otherwise returns the appropriate
* error code.
*/
#ifdef INCLUDE_CLIENT_APIS
EXTERN_C int genaUnregisterClient(UpnpClient_Handle client_handle);
#endif
EXTERN_C int genaUnregisterClient(
/*! [in] Handle containing all the control point related information. */
UpnpClient_Handle client_handle);
#endif /* INCLUDE_CLIENT_APIS */
//server
/************************************************************************
* Function : genaUnregisterDevice
/*
* DEVICE
*/
/*!
* \brief Cleans the service table of the device.
*
* Parameters:
* IN UpnpDevice_Handle device_handle: Handle of the root device
*
* Description:
* This function cleans the service table of the device.
*
* Returns: int
* returns UPNP_E_SUCCESS if successful else returns GENA_E_BAD_HANDLE
****************************************************************************/
* \return UPNP_E_SUCCESS if successful, otherwise returns GENA_E_BAD_HANDLE
*/
#ifdef INCLUDE_DEVICE_APIS
EXTERN_C int genaUnregisterDevice(UpnpDevice_Handle device_handle);
#endif
EXTERN_C int genaUnregisterDevice(
/*! [in] Handle of the root device */
UpnpDevice_Handle device_handle);
#endif /* INCLUDE_CLIENT_APIS */
/************************************************************************
* Function : genaRenewSubscription
/*!
* \brief Renews a SID.
*
* Parameters:
* IN UpnpClient_Handle client_handle: Client handle
* IN const Upnp_SID in_sid: subscription ID
* INOUT int * TimeOut: requested Duration, if -1, then "infinite".
* in the OUT case: actual Duration granted
* by Service, -1 for infinite
*
* Description:
* This function renews a SID. It first validates the SID and
* client_handle and copies the subscription. It sends RENEW
* (modified SUBSCRIBE) http request to service and processes
* It first validates the SID and client_handle and copies the subscription.
* It sends RENEW (modified SUBSCRIBE) http request to service and processes
* the response.
*
* Returns: int
* return UPNP_E_SUCCESS if service response is OK else
* returns appropriate error
***************************************************************************/
* \return UPNP_E_SUCCESS if service response is OK, otherwise the
* appropriate error code.
*/
#ifdef INCLUDE_CLIENT_APIS
EXTERN_C int genaRenewSubscription(
IN UpnpClient_Handle client_handle,
IN const Upnp_SID in_sid,
OUT int * TimeOut);
#endif
/****************************************************************************
* Function : genaNotifyAll
/*! [in] Client handle. */
UpnpClient_Handle client_handle,
/*! [in] Subscription ID. */
const Upnp_SID in_sid,
/*! [in,out] requested Duration, if -1, then "infinite". In the OUT case:
* actual Duration granted by Service, -1 for infinite. */
int *TimeOut);
#endif /* INCLUDE_CLIENT_APIS */
/*!
* \brief Sends a notification to all the subscribed control points.
*
* Parameters :
* IN UpnpDevice_Handle device_handle : Device handle
* IN char *UDN : Device udn
* IN char *servId : Service ID
* IN char **VarNames : array of varible names
* IN char **VarValues : array of variable values
* IN int var_count : number of variables
* \return int
*
* Description : This function sends a notification to all the subscribed
* control points
*
* Return : int
*
* Note : This function is similar to the genaNotifyAllExt. The only difference
* \note This function is similar to the genaNotifyAllExt. The only difference
* is it takes event variable array instead of xml document.
****************************************************************************/
*/
#ifdef INCLUDE_DEVICE_APIS
EXTERN_C int genaNotifyAll(
/*! [in] Device handle. */
UpnpDevice_Handle device_handle,
/*! [in] Device udn. */
char *UDN,
/*! [in] Service ID. */
char *servId,
/*! [in] Array of varible names. */
char **VarNames,
/*! [in] Array of variable values. */
char **VarValues,
/*! [in] Number of variables. */
int var_count);
#endif
#endif /* INCLUDE_DEVICE_APIS */
/****************************************************************************
* Function : genaNotifyAllExt
/*!
* \brief Sends a notification to all the subscribed control points.
*
* Parameters :
* IN UpnpDevice_Handle device_handle : Device handle
* IN char *UDN : Device udn
* IN char *servId : Service ID
* IN IXML_Document *PropSet : XML document Event varible property set
* \return int
*
* Description : This function sends a notification to all the subscribed
* control points
*
* Return : int
*
* Note : This function is similar to the genaNotifyAll. the only difference
* is it takes the document instead of event variable array
****************************************************************************/
* \note This function is similar to the genaNotifyAll. the only difference
* is it takes the document instead of event variable array.
*/
#ifdef INCLUDE_DEVICE_APIS
EXTERN_C int genaNotifyAllExt(
/*! [in] Device handle. */
UpnpDevice_Handle device_handle,
/*! [in] Device udn. */
char *UDN,
/*! [in] Service ID. */
char *servId,
IN IXML_Document *PropSet);
#endif
/*! [in] XML document Event varible property set. */
IXML_Document *PropSet);
#endif /* INCLUDE_DEVICE_APIS */
/****************************************************************************
* Function : genaInitNotify
/*!
* \brief Sends the intial state table dump to newly subscribed control point.
*
* Parameters :
* IN UpnpDevice_Handle device_handle : Device handle
* IN char *UDN : Device udn
* IN char *servId : Service ID
* IN char **VarNames : Array of variable names
* IN char **VarValues : Array of variable values
* IN int var_count : array size
* IN Upnp_SID sid : subscription ID
* \return GENA_E_SUCCESS if successful, otherwise the appropriate error code.
*
* Description : This function sends the intial state table dump to
* newly subscribed control point.
*
* Return : int
* returns GENA_E_SUCCESS if successful else returns appropriate error
*
* Note : No other event will be sent to this control point before the
* \note No other event will be sent to this control point before the
* intial state table dump.
****************************************************************************/
*/
#ifdef INCLUDE_DEVICE_APIS
EXTERN_C int genaInitNotify(IN UpnpDevice_Handle device_handle,
IN char *UDN,
IN char *servId,
IN char **VarNames,
IN char **VarValues,
IN int var_count,
IN Upnp_SID sid);
#endif
EXTERN_C int genaInitNotify(
/*! [in] Device handle. */
UpnpDevice_Handle device_handle,
/*! [in] Device udn. */
char *UDN,
/*! [in] Service ID. */
char *servId,
/*! [in] Array of variable names. */
char **VarNames,
/*! [in] Array of variable values. */
char **VarValues,
/*! [in] Array size. */
int var_count,
/*! [in] Subscription ID. */
const Upnp_SID sid);
#endif /* INCLUDE_DEVICE_APIS */
/****************************************************************************
* Function : genaInitNotifyExt
/*!
* \brief Similar to the genaInitNofity. The only difference is that it
* takes the xml document for the state table and sends the intial state
* table dump to newly subscribed control point.
*
* Parameters :
* IN UpnpDevice_Handle device_handle : Device handle
* IN char *UDN : Device udn
* IN char *servId : Service ID
* IN IXML_Document *PropSet : Document of the state table
* IN Upnp_SID sid : subscription ID
* \return GENA_E_SUCCESS if successful, otherwise the appropriate error code.
*
* Description : This function is similar to the genaInitNofity. The only
* difference is that it takes the xml document for the state table and
* sends the intial state table dump to newly subscribed control point.
*
* Return : int
* returns GENA_E_SUCCESS if successful else returns appropriate error
*
* Note : No other event will be sent to this control point before the
* \note No other event will be sent to this control point before the
* intial state table dump.
****************************************************************************/
*/
#ifdef INCLUDE_DEVICE_APIS
EXTERN_C int genaInitNotifyExt(
IN UpnpDevice_Handle device_handle,
IN char *UDN,
IN char *servId,
IN IXML_Document *PropSet,
IN Upnp_SID sid);
#endif
/*! [in] Device handle. */
UpnpDevice_Handle device_handle,
/*! [in] Device udn. */
char *UDN,
/*! [in] Service ID. */
char *servId,
/*! [in] Document of the state table. */
IXML_Document *PropSet,
/*! [in] subscription ID. */
const Upnp_SID sid);
#endif /* INCLUDE_DEVICE_APIS */
/************************************************************************
* Function : error_respond
/*!
* \brief Sends an error message to the control point in the case of incorrect
* GENA requests.
*
* Parameters:
* IN SOCKINFO *info: Structure containing information about the socket
* IN int error_code: error code that will be in the GENA response
* IN http_message_t* hmsg: GENA request Packet
*
* Description:
* This function send an error message to the control point in the case
* incorrect GENA requests.
*
* Returns: int
* UPNP_E_SUCCESS if successful else appropriate error
***************************************************************************/
void error_respond( IN SOCKINFO *info, IN int error_code,
IN http_message_t* hmsg );
#endif // GENA
* \return UPNP_E_SUCCESS if successful, otherwise appropriate error code.
*/
void error_respond(
/*! [in] Structure containing information about the socket. */
SOCKINFO *info,
/*! [in] error code that will be in the GENA response. */
int error_code,
/*! [in] GENA request Packet. */
http_message_t* hmsg);
#endif /* GENA_H */

View File

@ -1,54 +1,65 @@
///////////////////////////////////////////////////////////////////////////
//
// 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 SERVICE_TABLE_H
#define SERVICE_TABLE_H
/*!
* \file
*/
#ifndef _SERVICE_TABLE
#define _SERVICE_TABLE
#ifdef __cplusplus
extern "C" {
#endif
#include "config.h"
#include "uri.h"
#include "ixml.h"
#include "upnp.h"
#include <stdio.h>
//#include <malloc.h>
#include <time.h>
#define SID_SIZE 41
#ifdef INCLUDE_DEVICE_APIS
typedef struct SUBSCRIPTION {
Upnp_SID sid;
int eventKey;
@ -83,57 +94,42 @@ typedef struct SERVICE_TABLE {
/* Functions for Subscriptions */
/************************************************************************
* Function : copy_subscription
*
* Parameters :
* subscription *in ; Source subscription
* subscription *out ; Destination subscription
*
* Description : Makes a copy of the subscription
*
* Return : int ;
* HTTP_SUCCESS - On Sucess
*
* Note :
************************************************************************/
int copy_subscription(subscription *in, subscription *out);
/************************************************************************
* Function : RemoveSubscriptionSID
/*!
* \brief Makes a copy of the subscription.
*
* Parameters :
* Upnp_SID sid ; subscription ID
* service_info * service ; service object providing the list of
* subscriptions
*
* Description : Remove the subscription represented by the
* const Upnp_SID sid parameter from the service table and update
* the service table.
*
* Return : void ;
*
* Note :
************************************************************************/
void RemoveSubscriptionSID(Upnp_SID sid, service_info * service);
* \return HTTP_SUCCESS on Sucess.
*/
int copy_subscription(
/*! [in] Source subscription. */
subscription *in,
/*! [in] Destination subscription. */
subscription *out);
/************************************************************************
* Function : GetSubscriptionSID
/*
* \brief Remove the subscription represented by the const Upnp_SID sid parameter
* from the service table and update the service table.
*/
void RemoveSubscriptionSID(
/*! [in] Subscription ID. */
Upnp_SID sid,
/*! [in] Service object providing the list of subscriptions. */
service_info *service);
/*!
* \brief Return the subscription from the service table that matches
* const Upnp_SID sid value.
*
* Parameters :
* Upnp_SID sid ; subscription ID
* service_info * service ; service object providing the list of
* subscriptions
*
* Description : Return the subscription from the service table
* that matches const Upnp_SID sid value.
*
* Return : subscription * - Pointer to the matching subscription
* node;
*
* Note :
************************************************************************/
subscription * GetSubscriptionSID(Upnp_SID sid,service_info * service);
* \return Pointer to the matching subscription node.
*/
subscription *GetSubscriptionSID(
/*! [in] Subscription ID. */
const Upnp_SID sid,
/*! [in] Service object providing the list of subscriptions. */
service_info *service);
//returns a pointer to the subscription with the SID, NULL if not found