diff --git a/upnp/inc/upnp.h b/upnp/inc/upnp.h index 96c9da5..5465459 100644 --- a/upnp/inc/upnp.h +++ b/upnp/inc/upnp.h @@ -29,6 +29,7 @@ * ******************************************************************************/ + #ifndef UPNP_H #define UPNP_H diff --git a/upnp/src/api/upnpapi.c b/upnp/src/api/upnpapi.c index 0128cdc..7ef9e51 100644 --- a/upnp/src/api/upnpapi.c +++ b/upnp/src/api/upnpapi.c @@ -1,4 +1,4 @@ -/************************************************************************** +/******************************************************************************* * * Copyright (c) 2000-2003 Intel Corporation * All rights reserved. @@ -27,7 +27,7 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - **************************************************************************/ + ******************************************************************************/ #include "config.h" @@ -2206,52 +2206,69 @@ int UpnpAcceptSubscription( int cVariables, IN const Upnp_SID SubsId) { - struct Handle_Info *SInfo = NULL; - int retVal; - char *DevID = ( char * )DevID_const; - char *ServName = ( char * )ServName_const; - char **VarName = ( char ** )VarName_const; - char **NewVal = ( char ** )NewVal_const; + int ret = 0; + int line = 0; + struct Handle_Info *SInfo = NULL; + char *DevID = (char *)DevID_const; + char *ServName = (char *)ServName_const; + char **VarName = (char **)VarName_const; + char **NewVal = (char **)NewVal_const; - if( UpnpSdkInit != 1 ) { - return UPNP_E_FINISH; - } + UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__, + "Inside UpnpAcceptSubscription\n"); - UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Inside UpnpAcceptSubscription \n" ); + if (UpnpSdkInit != 1) { + line = __LINE__; + ret = UPNP_E_FINISH; + goto ExitFunction; + } - HandleReadLock(); - if( GetHandleInfo( Hnd, &SInfo ) != HND_DEVICE ) { - HandleUnlock(); - return UPNP_E_INVALID_HANDLE; - } - if( DevID == NULL ) { - HandleUnlock(); - return UPNP_E_INVALID_PARAM; - } - if( ServName == NULL ) { - HandleUnlock(); - return UPNP_E_INVALID_PARAM; - } - if( SubsId == NULL ) { - HandleUnlock(); - return UPNP_E_INVALID_PARAM; - } - if( VarName == NULL || NewVal == NULL || cVariables < 0 ) { - HandleUnlock(); - return UPNP_E_INVALID_PARAM; - } + HandleReadLock(); - HandleUnlock(); - retVal = - genaInitNotify( Hnd, DevID, ServName, VarName, NewVal, cVariables, - SubsId ); + if (GetHandleInfo(Hnd, &SInfo) != HND_DEVICE) { + HandleUnlock(); + line = __LINE__; + ret = UPNP_E_INVALID_HANDLE; + goto ExitFunction; + } + if (DevID == NULL) { + HandleUnlock(); + line = __LINE__; + ret = UPNP_E_INVALID_PARAM; + goto ExitFunction; + } + if (ServName == NULL) { + HandleUnlock(); + line = __LINE__; + ret = UPNP_E_INVALID_PARAM; + goto ExitFunction; + } + if (SubsId == NULL) { + HandleUnlock(); + line = __LINE__; + ret = UPNP_E_INVALID_PARAM; + goto ExitFunction; + } + if (VarName == NULL || NewVal == NULL || cVariables < 0) { + HandleUnlock(); + line = __LINE__; + ret = UPNP_E_INVALID_PARAM; + goto ExitFunction; + } - UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting UpnpAcceptSubscription \n" ); - return retVal; + HandleUnlock(); + + line = __LINE__; + ret = genaInitNotify( + Hnd, DevID, ServName, VarName, NewVal, cVariables, SubsId); + +ExitFunction: + UpnpPrintf(UPNP_ALL, API, __FILE__, line, + "Exiting UpnpAcceptSubscription, ret = %d\n", ret); + + return ret; +} -} /***************** End of UpnpAcceptSubscription *********************/ /************************************************************************** * Function: UpnpAcceptSubscriptionExt @@ -2277,57 +2294,73 @@ int UpnpAcceptSubscription( * Return Values: int * UPNP_E_SUCCESS if successful else sends appropriate error. ***************************************************************************/ -int -UpnpAcceptSubscriptionExt( IN UpnpDevice_Handle Hnd, - IN const char *DevID_const, - IN const char *ServName_const, - IN IXML_Document * PropSet, - IN Upnp_SID SubsId ) +int UpnpAcceptSubscriptionExt( + IN UpnpDevice_Handle Hnd, + IN const char *DevID_const, + IN const char *ServName_const, + IN IXML_Document *PropSet, + IN Upnp_SID SubsId) { - struct Handle_Info *SInfo = NULL; - int retVal; - char *DevID = ( char * )DevID_const; - char *ServName = ( char * )ServName_const; + int ret = 0; + int line = 0; + struct Handle_Info *SInfo = NULL; + char *DevID = (char *)DevID_const; + char *ServName = (char *)ServName_const; - if( UpnpSdkInit != 1 ) { - return UPNP_E_FINISH; - } + UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__, + "Inside UpnpAcceptSubscription\n"); - UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Inside UpnpAcceptSubscription \n" ); + if (UpnpSdkInit != 1) { + line = __LINE__; + ret = UPNP_E_FINISH; + goto ExitFunction; + } - HandleReadLock(); - if( GetHandleInfo( Hnd, &SInfo ) != HND_DEVICE ) { - HandleUnlock(); - return UPNP_E_INVALID_HANDLE; - } - if( DevID == NULL ) { - HandleUnlock(); - return UPNP_E_INVALID_PARAM; - } - if( ServName == NULL ) { - HandleUnlock(); - return UPNP_E_INVALID_PARAM; - } - if( SubsId == NULL ) { - HandleUnlock(); - return UPNP_E_INVALID_PARAM; - } + HandleReadLock(); - if( PropSet == NULL ) { - HandleUnlock(); - return UPNP_E_INVALID_PARAM; - } + if (GetHandleInfo(Hnd, &SInfo) != HND_DEVICE) { + HandleUnlock(); + line = __LINE__; + ret = UPNP_E_INVALID_HANDLE; + goto ExitFunction; + } + if (DevID == NULL) { + HandleUnlock(); + line = __LINE__; + ret = UPNP_E_INVALID_PARAM; + goto ExitFunction; + } + if (ServName == NULL) { + HandleUnlock(); + line = __LINE__; + ret = UPNP_E_INVALID_PARAM; + goto ExitFunction; + } + if (SubsId == NULL) { + HandleUnlock(); + line = __LINE__; + ret = UPNP_E_INVALID_PARAM; + goto ExitFunction; + } - HandleUnlock(); - retVal = genaInitNotifyExt( Hnd, DevID, ServName, PropSet, SubsId ); + if (PropSet == NULL) { + HandleUnlock(); + line = __LINE__; + ret = UPNP_E_INVALID_PARAM; + goto ExitFunction; + } - UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, - "Exiting UpnpAcceptSubscription \n" ); + HandleUnlock(); - return retVal; + line = __LINE__; + ret = genaInitNotifyExt(Hnd, DevID, ServName, PropSet, SubsId); -} /****************** End of UpnpAcceptSubscription *********************/ +ExitFunction: + UpnpPrintf(UPNP_ALL, API, __FILE__, line, + "Exiting UpnpAcceptSubscription, ret = %d.\n", ret); + + return ret; +} #endif // INCLUDE_DEVICE_APIS #endif // EXCLUDE_GENA == 0 diff --git a/upnp/src/gena/gena_ctrlpt.c b/upnp/src/gena/gena_ctrlpt.c index 5d29d3c..5ef5458 100644 --- a/upnp/src/gena/gena_ctrlpt.c +++ b/upnp/src/gena/gena_ctrlpt.c @@ -1,33 +1,33 @@ -/////////////////////////////////////////////////////////////////////////// -// -// 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. + * + ******************************************************************************/ #include "config.h" @@ -47,23 +47,17 @@ #include "uuid.h" #include "upnpapi.h" + extern ithread_mutex_t GlobalClientSubscribeMutex; -/************************************************************************ -* Function : GenaAutoRenewSubscription -* -* Parameters: -* IN void *input: Thread data(upnp_timeout *) needed to send the renewal -* -* Description: -* This is a thread function to send the renewal just before the -* subscription times out. -* -* Returns: VOID -* -***************************************************************************/ -static void -GenaAutoRenewSubscription( IN void *input ) + +/*! + * \brief This is a thread function to send the renewal just before the + * subscription times out. + */ +static void GenaAutoRenewSubscription( + /*! [in] Thread data(upnp_timeout *) needed to send the renewal. */ + IN void *input) { upnp_timeout *event = (upnp_timeout *) input; UpnpEventSubscribe *sub_struct = (UpnpEventSubscribe *)event->Event; @@ -117,24 +111,18 @@ GenaAutoRenewSubscription( IN void *input ) } -/************************************************************************ - * Function : ScheduleGenaAutoRenew +/*! + * \brief Schedules a job to renew the subscription just before time out. * - * Parameters: - * IN int client_handle: Handle that also contains the subscription list - * IN int TimeOut: The time out value of the subscription - * IN client_subscription * sub: Subscription being renewed - * - * Description: - * This function schedules a job to renew the subscription just before - * time out. - * - * Returns: int - * return GENA_E_SUCCESS if successful else returns appropriate error - ***************************************************************************/ + * \return GENA_E_SUCCESS if successful, otherwise returns the appropriate + * error code. + */ static int ScheduleGenaAutoRenew( + /*! [in] Handle that also contains the subscription list. */ IN int client_handle, + /*! [in] The time out value of the subscription. */ IN int TimeOut, + /*! [in] Subscription being renewed. */ IN ClientSubscription *sub) { UpnpEventSubscribe *RenewEventStruct = NULL; @@ -190,24 +178,19 @@ static int ScheduleGenaAutoRenew( return GENA_SUCCESS; } -/************************************************************************ - * Function : gena_unsubscribe + +/*! + * \brief Sends the UNSUBCRIBE gena request and recieves the response from the + * device and returns it as a parameter. * - * Parameters: - * IN const UpnpString *url: Event URL of the service - * IN const UpnpString *sid: The subcription ID. - * OUT http_parser_t *response: The UNSUBCRIBE response from the device - * - * Description: - * This function sends the UNSUBCRIBE gena request and recieves the - * response from the device and returns it as a parameter - * - * Returns: int - * return 0 if successful else returns appropriate error - ***************************************************************************/ + * \returns 0 if successful, otherwise returns the appropriate error code. + */ static int gena_unsubscribe( + /*! [in] Event URL of the service. */ IN const UpnpString *url, + /*! [in] The subcription ID. */ IN const UpnpString *sid, + /*! [out] The UNSUBCRIBE response from the device. */ OUT http_parser_t *response ) { int return_code; @@ -256,27 +239,21 @@ static int gena_unsubscribe( return return_code; } -/************************************************************************ - * Function: gena_subscribe + +/*! + * \brief Subscribes or renew subscription. * - * Parameters: - * IN const UpnpString *url: url of service to subscribe - * INOUT int* timeout: subscription time desired (in secs) - * IN const UpnpString *renewal_sid: for renewal, this contains a currently h - * held subscription SID. For first time - * subscription, this must be NULL - * OUT UpnpString *sid: SID returned by the subscription or renew msg - * - * Description: - * This function subscribes or renew subscription - * - * Returns: int - * return 0 if successful else returns appropriate error - ***************************************************************************/ + * \return 0 if successful, otherwise returns the appropriate error code. + */ static int gena_subscribe( + /*! [in] URL of service to subscribe. */ IN const UpnpString *url, + /*! [in,out] Subscription time desired (in secs). */ INOUT int *timeout, + /*! [in] for renewal, this contains a currently held subscription SID. + * For first time subscription, this must be NULL. */ IN const UpnpString *renewal_sid, + /*! [out] SID returned by the subscription or renew msg. */ OUT UpnpString *sid) { int return_code; @@ -400,21 +377,7 @@ static int gena_subscribe( return UPNP_E_SUCCESS; } -/************************************************************************ - * Function: genaUnregisterClient - * - * Parameters: - * IN UpnpClient_Handle client_handle: - * Handle containing all the control point related information - * - * 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 - ***************************************************************************/ + int genaUnregisterClient(IN UpnpClient_Handle client_handle) { ClientSubscription *sub_copy = UpnpClientSubscription_new(); @@ -460,22 +423,6 @@ exit_function: } -/************************************************************************ - * Function: genaUnSubscribe - * - * Parameters: - * IN UpnpClient_Handle client_handle: UPnP client handle - * IN const UpnpString *in_sid: The subscription ID - * - * 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 - ***************************************************************************/ #ifdef INCLUDE_CLIENT_APIS int genaUnSubscribe( IN UpnpClient_Handle client_handle, @@ -528,28 +475,6 @@ exit_function: #endif /* INCLUDE_CLIENT_APIS */ -/************************************************************************ - * Function: genaSubscribe - * - * Parameters: - * IN UpnpClient_Handle client_handle: - * IN const UpnpString *PublisherURL: 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 UpnpString *out_sid: sid of subscription, memory passed in by caller - * - * 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 - ***************************************************************************/ #ifdef INCLUDE_CLIENT_APIS int genaSubscribe( IN UpnpClient_Handle client_handle, @@ -633,26 +558,6 @@ error_handler: #endif /* INCLUDE_CLIENT_APIS */ -/************************************************************************ - * Function : genaRenewSubscription - * - * Parameters: - * IN UpnpClient_Handle client_handle: Client handle - * IN const UpnpString *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 - * the response. - * - * Returns: int - * return UPNP_E_SUCCESS if service response is OK else - * returns appropriate error - ***************************************************************************/ int genaRenewSubscription( IN UpnpClient_Handle client_handle, IN const UpnpString *in_sid, @@ -751,24 +656,9 @@ exit_function: } -/************************************************************************ - * Function: gena_process_notification_event - * - * Parameters: - * IN SOCKINFO *info: Socket structure containing the device socket - * information - * IN http_message_t *event: The http message contains the GENA - * notification - * - * Description: - * This function processes NOTIFY events that are sent by devices. - * called by genacallback() - * - * Returns: void - * - * Note : called by genacallback() - ****************************************************************************/ -void gena_process_notification_event(IN SOCKINFO *info, IN http_message_t *event) +void gena_process_notification_event( + IN SOCKINFO *info, + IN http_message_t *event) { UpnpEvent *event_struct = UpnpEvent_new(); IXML_Document *ChangedVars = NULL; @@ -896,6 +786,7 @@ exit_function: UpnpEvent_delete(event_struct); } -#endif // INCLUDE_CLIENT_APIS -#endif // EXCLUDE_GENA + +#endif /* INCLUDE_CLIENT_APIS */ +#endif /* EXCLUDE_GENA */ diff --git a/upnp/src/gena/gena_device.c b/upnp/src/gena/gena_device.c index 6d2d2b2..797605d 100644 --- a/upnp/src/gena/gena_device.c +++ b/upnp/src/gena/gena_device.c @@ -1,107 +1,99 @@ -/////////////////////////////////////////////////////////////////////////// -// -// 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. + * + ******************************************************************************/ + #include "config.h" + + #if EXCLUDE_GENA == 0 #ifdef INCLUDE_DEVICE_APIS + #include "gena.h" -#include "sysdep.h" -#include "uuid.h" -#include "upnpapi.h" -#include "parsetools.h" -#include "statcodes.h" #include "httpparser.h" #include "httpreadwrite.h" +#include "parsetools.h" #include "ssdplib.h" - +#include "statcodes.h" +#include "sysdep.h" #include "unixutil.h" +#include "upnpapi.h" +#include "uuid.h" -/************************************************************************ -* Function : genaUnregisterDevice -* -* 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 -****************************************************************************/ -int -genaUnregisterDevice( IN UpnpDevice_Handle device_handle ) + +/*! + * \brief Unregisters a device. + * + * \return UPNP_E_SUCCESS on success, GENA_E_BAD_HANDLE on failure. + */ +int genaUnregisterDevice( + /*! [in] Device handle. */ + IN UpnpDevice_Handle device_handle) { - struct Handle_Info *handle_info; + int ret = 0; + struct Handle_Info *handle_info; - HandleLock(); - if( GetHandleInfo( device_handle, &handle_info ) != HND_DEVICE ) { + HandleLock(); + if (GetHandleInfo(device_handle, &handle_info) != HND_DEVICE) { + UpnpPrintf(UPNP_CRITICAL, GENA, __FILE__, __LINE__, + "genaUnregisterDevice: BAD Handle: %d\n", + device_handle); + ret = GENA_E_BAD_HANDLE; + } else { + freeServiceTable(&handle_info->ServiceTable); + ret = UPNP_E_SUCCESS; + } + HandleUnlock(); - UpnpPrintf( UPNP_CRITICAL, GENA, __FILE__, __LINE__, - "genaUnregisterDevice : BAD Handle : %d\n", - device_handle ); - - HandleUnlock(); - return GENA_E_BAD_HANDLE; - } - - freeServiceTable( &handle_info->ServiceTable ); - HandleUnlock(); - - return UPNP_E_SUCCESS; + return ret; } -/************************************************************************ -* Function : GeneratePropertySet -* -* Parameters: -* IN char **names : Array of variable names (go in the event notify) -* IN char ** values : Array of variable values (go in the event notify) -* IN int count : number of variables -* OUT DOMString *out: PropertySet node in the string format -* -* Description: -* This function to generate XML propery Set for notifications -* -* Returns: int -* returns UPNP_E_SUCCESS if successful else returns GENA_E_BAD_HANDLE -* -* Note: XML_VERSION comment is NOT sent due to interop issues with other -* UPnP vendors -****************************************************************************/ -static int -GeneratePropertySet( IN char **names, - IN char **values, - IN int count, - OUT DOMString * out ) + +/*! + * \brief Generates XML property set for notifications. + * + * \return UPNP_E_SUCCESS if successful else returns GENA_E_BAD_HANDLE. + * + * \note XML_VERSION comment is NOT sent due to interop issues with other + * UPnP vendors. + */ +static int GeneratePropertySet( + /*! [in] Array of variable names (go in the event notify). */ + IN char **names, + /*! [in] Array of variable values (go in the event notify). */ + IN char **values, + /*! [in] number of variables. */ + IN int count, + /*! [out] PropertySet node in the string format. */ + OUT DOMString *out) { char *buffer; int counter = 0; @@ -140,24 +132,18 @@ GeneratePropertySet( IN char **names, strcat( buffer, "\n\n" ); ( *out ) = ixmlCloneDOMString( buffer ); free( buffer ); + return XML_SUCCESS; } -/************************************************************************ -* Function : free_notify_struct -* -* Parameters: -* IN notify_thread_struct * input : Notify structure -* -* Description: -* This function frees memory used in notify_threads if the reference -* count is 0 otherwise decrements the refrence count -* -* Returns: VOID -* -****************************************************************************/ -static void -free_notify_struct( IN notify_thread_struct * input ) + +/*! + * \brief Frees memory used in notify_threads if the reference count is 0, + * otherwise decrements the refrence count. + */ +static void free_notify_struct( + /*! [in] Notify structure. */ + IN notify_thread_struct *input) { ( *input->reference_count )--; if( ( *input->reference_count ) == 0 ) { @@ -170,29 +156,23 @@ free_notify_struct( IN notify_thread_struct * input ) free( input ); } -/**************************************************************************** -* Function : notify_send_and_recv -* -* Parameters : -* IN uri_type* destination_url : subscription callback URL -* (URL of the control point) -* IN membuffer* mid_msg : Common HTTP headers -* IN char* propertySet : The evented XML -* OUT http_parser_t* response : The response from the control point. -* -* Description : This function sends the notify message and returns a -* reply. -* -* Return : int -* on success: returns UPNP_E_SUCCESS; else returns a UPNP error -* -* Note : called by genaNotify -****************************************************************************/ -static UPNP_INLINE int -notify_send_and_recv( IN uri_type * destination_url, - IN membuffer * mid_msg, - IN char *propertySet, - OUT http_parser_t * response ) + +/*! + * \brief Sends the notify message and returns a reply. + * + * \return on success returns UPNP_E_SUCCESS, otherwise returns a UPNP error. + * + * \note called by genaNotify + */ +static UPNP_INLINE int notify_send_and_recv( + /*! [in] subscription callback URL (URL of the control point). */ + IN uri_type *destination_url, + /*! [in] Common HTTP headers. */ + IN membuffer *mid_msg, + /*! [in] The evented XML. */ + IN char *propertySet, + /*! [out] The response from the control point. */ + OUT http_parser_t *response) { uri_type url; int conn_fd; @@ -260,32 +240,25 @@ notify_send_and_recv( IN uri_type * destination_url, return UPNP_E_SUCCESS; } -/**************************************************************************** -* Function : genaNotify -* -* Parameters : -* IN char *headers : (null terminated) (includes all headers -* (including \r\n) except SID and SEQ) -* IN char *propertySet : The evented XML -* IN subscription* sub : subscription to be Notified, -* Assumes this is valid for life of function) -* -* Description : Function to Notify a particular subscription of a -* particular event. In general the service should NOT be -* blocked around this call. (this may cause deadlock -* with a client) NOTIFY http request is sent and the -* reply is processed. -* -* Return : int -* GENA_SUCCESS if the event was delivered else returns appropriate -* error -* -* Note : -****************************************************************************/ -int -genaNotify( IN char *headers, - IN char *propertySet, - IN subscription * sub ) + +/*! + * \brief Function to Notify a particular subscription of a particular event. + * + * In general the service should NOT be blocked around this call (this may + * cause deadlock with a client). + * + * NOTIFY http request is sent and the reply is processed. + * + * \return GENA_SUCCESS if the event was delivered, otherwise returns the + * appropriate error code. + */ +static int genaNotify( + /*! [in] Null terminated, includes all headers (including \r\n) except SID and SEQ. */ + IN char *headers, + /*! [in] The evented XML. */ + IN char *propertySet, + /*! [in] subscription to be Notified, assumes this is valid for life of function. */ + IN subscription *sub) { int i; membuffer mid_msg; @@ -338,25 +311,19 @@ genaNotify( IN char *headers, return return_code; } -/**************************************************************************** -* Function : genaNotifyThread -* -* Parameters : -* IN void * input : notify thread structure containing all the -* headers and property set info -* -* Description : Thread job to Notify a control point. It validates the -* subscription and copies the subscription. Also make sure that -* events are sent in order. -* -* Return : void -* -* Note : calls the genaNotify to do the actual work -****************************************************************************/ -static void -genaNotifyThread( IN void *input ) -{ +/*! + * \brief Thread job to Notify a control point. + * + * It validates the subscription and copies the subscription. Also make sure + * that events are sent in order. + * + * \note calls the genaNotify to do the actual work. + */ +static void genaNotifyThread( + /*! [in] notify thread structure containing all the headers and property set info. */ + IN void *input) +{ subscription *sub; service_info *service; subscription sub_copy; @@ -443,166 +410,156 @@ int genaInitNotify( IN int var_count, IN const Upnp_SID sid) { - char *UDN_copy = NULL; - char *servId_copy = NULL; - char *propertySet = NULL; - char *headers = NULL; - subscription *sub = NULL; - service_info *service = NULL; - int return_code = GENA_SUCCESS; - int headers_size; - int *reference_count = NULL; - struct Handle_Info *handle_info; - ThreadPoolJob job; + int ret = GENA_SUCCESS; + int line = 0; - notify_thread_struct *thread_struct = NULL; + int *reference_count = NULL; + char *UDN_copy = NULL; + char *servId_copy = NULL; + DOMString propertySet = NULL; + char *headers = NULL; + notify_thread_struct *thread_struct = NULL; - UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, - "GENA BEGIN INITIAL NOTIFY " ); + subscription *sub = NULL; + service_info *service = NULL; + int headers_size; + struct Handle_Info *handle_info; + ThreadPoolJob job; - reference_count = ( int * )malloc( sizeof( int ) ); + UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, + "GENA BEGIN INITIAL NOTIFY"); - if( reference_count == NULL ) - return UPNP_E_OUTOF_MEMORY; + reference_count = (int *)malloc(sizeof (int)); + if (reference_count == NULL) { + line = __LINE__; + ret = UPNP_E_OUTOF_MEMORY; + goto ExitFunction; + } + *reference_count = 0; + + UDN_copy = (char *)malloc(strlen(UDN) + 1); + if (UDN_copy == NULL) { + line = __LINE__; + ret = UPNP_E_OUTOF_MEMORY; + goto ExitFunction; + } - ( *reference_count ) = 0; + servId_copy = (char *)malloc(strlen(servId) + 1); + if( servId_copy == NULL ) { + line = __LINE__; + ret = UPNP_E_OUTOF_MEMORY; + goto ExitFunction; + } - UDN_copy = ( char * )malloc( strlen( UDN ) + 1 ); + strcpy(UDN_copy, UDN); + strcpy(servId_copy, servId); - if( UDN_copy == NULL ) { - free( reference_count ); - return UPNP_E_OUTOF_MEMORY; - } - servId_copy = ( char * )malloc( strlen( servId ) + 1 ); + HandleLock(); - if( servId_copy == NULL ) { - free( UDN_copy ); - free( reference_count ); - return UPNP_E_OUTOF_MEMORY; - } + if (GetHandleInfo(device_handle, &handle_info) != HND_DEVICE) { + line = __LINE__; + ret = GENA_E_BAD_HANDLE; + goto ExitFunction; + } - strcpy( UDN_copy, UDN ); - strcpy( servId_copy, servId ); + service = FindServiceId(&handle_info->ServiceTable, servId, UDN); + if (service == NULL) { + line = __LINE__; + ret = GENA_E_BAD_SERVICE; + goto ExitFunction; + } + UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, + "FOUND SERVICE IN INIT NOTFY: UDN %s, ServID: %s", + UDN, servId); - HandleLock(); + sub = GetSubscriptionSID(sid, service); + if (sub == NULL || sub->active) { + line = __LINE__; + ret = GENA_E_BAD_SID; + goto ExitFunction; + } + UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, + "FOUND SUBSCRIPTION IN INIT NOTIFY: SID %s", sid); + sub->active = 1; - if( GetHandleInfo( device_handle, &handle_info ) != HND_DEVICE ) { - free( UDN_copy ); - free( reference_count ); - free( servId_copy ); - HandleUnlock(); - return GENA_E_BAD_HANDLE; - } + ret = GeneratePropertySet(VarNames, VarValues, var_count, &propertySet ); + if (ret != XML_SUCCESS) { + line = __LINE__; + goto ExitFunction; + } + UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, + "GENERATED PROPERY SET IN INIT NOTIFY: %s", + propertySet); - if( ( service = FindServiceId( &handle_info->ServiceTable, - servId, UDN ) ) == NULL ) { - free( UDN_copy ); - free( reference_count ); - free( servId_copy ); - HandleUnlock(); - return GENA_E_BAD_SERVICE; - } + headers_size = + strlen("CONTENT-TYPE text/xml\r\n") + + strlen("CONTENT-LENGTH: \r\n") + MAX_CONTENT_LENGTH + + strlen("NT: upnp:event\r\n") + + strlen("NTS: upnp:propchange\r\n") + 1; + headers = (char *)malloc(headers_size); + if (headers == NULL) { + line = __LINE__; + ret = UPNP_E_OUTOF_MEMORY; + goto ExitFunction; + } - UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, - "FOUND SERVICE IN INIT NOTFY: UDN %s, ServID: %s ", - UDN, servId); + sprintf(headers, + "CONTENT-TYPE: text/xml\r\n" + "CONTENT-LENGTH: %"PRIzu"\r\n" + "NT: upnp:event\r\n" + "NTS: upnp:propchange\r\n", + strlen(propertySet) + 1); - sub = GetSubscriptionSID(sid, service); - if (sub == NULL || sub->active) { - free( UDN_copy ); - free( reference_count ); - free( servId_copy ); - HandleUnlock(); - return GENA_E_BAD_SID; - } + /* schedule thread for initial notification */ - UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, - "FOUND SUBSCRIPTION IN INIT NOTIFY: SID %s ", sid ); + thread_struct = (notify_thread_struct *)malloc(sizeof (notify_thread_struct)); + if (thread_struct == NULL) { + line = __LINE__; + ret = UPNP_E_OUTOF_MEMORY; + } else { + *reference_count = 1; + thread_struct->servId = servId_copy; + thread_struct->UDN = UDN_copy; + thread_struct->headers = headers; + thread_struct->propertySet = propertySet; + strcpy(thread_struct->sid, sid); + thread_struct->eventKey = sub->eventKey++; + thread_struct->reference_count = reference_count; + thread_struct->device_handle = device_handle; - sub->active = 1; + TPJobInit(&job, (start_routine)genaNotifyThread, thread_struct); + TPJobSetFreeFunction(&job, (free_routine)free_notify_struct); + TPJobSetPriority(&job, MED_PRIORITY); - if( ( return_code = GeneratePropertySet( VarNames, VarValues, - var_count, - &propertySet ) ) != - XML_SUCCESS ) { - free( UDN_copy ); - free( reference_count ); - free( servId_copy ); - HandleUnlock(); - return return_code; - } + ret = ThreadPoolAdd(&gSendThreadPool, &job, NULL); + if (ret != 0) { + if (ret == EOUTOFMEM) { + line = __LINE__; + ret = UPNP_E_OUTOF_MEMORY; + } + } else { + line = __LINE__; + ret = GENA_SUCCESS; + } + } - UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, - "GENERATED PROPERY SET IN INIT NOTIFY: \n'%s'\n", - propertySet ); +ExitFunction: + if (ret != GENA_SUCCESS) { + free(thread_struct); + free(headers); + ixmlFreeDOMString(propertySet); + free(servId_copy); + free(UDN_copy); + free(reference_count); + } - headers_size = strlen( "CONTENT-TYPE text/xml\r\n" ) + - strlen( "CONTENT-LENGTH: \r\n" ) + MAX_CONTENT_LENGTH + - strlen( "NT: upnp:event\r\n" ) + - strlen( "NTS: upnp:propchange\r\n" ) + 1; + HandleUnlock(); - headers = ( char * )malloc( headers_size ); + UpnpPrintf(UPNP_INFO, GENA, __FILE__, line, + "GENA END INITIAL NOTIFY, ret = %d", + ret); - if( headers == NULL ) { - ixmlFreeDOMString( propertySet ); - free( UDN_copy ); - free( servId_copy ); - free( reference_count ); - HandleUnlock(); - return UPNP_E_OUTOF_MEMORY; - } - - sprintf( headers, "CONTENT-TYPE: text/xml\r\nCONTENT-LENGTH: " - "%"PRIzu"\r\nNT: upnp:event\r\nNTS: upnp:propchange\r\n", - strlen( propertySet ) + 1 ); - - //schedule thread for initial notification - - thread_struct = - ( notify_thread_struct * ) - malloc( sizeof( notify_thread_struct ) ); - - if( thread_struct == NULL ) { - return_code = UPNP_E_OUTOF_MEMORY; - } else { - ( *reference_count ) = 1; - thread_struct->servId = servId_copy; - thread_struct->UDN = UDN_copy; - thread_struct->headers = headers; - thread_struct->propertySet = propertySet; - strcpy( thread_struct->sid, sid ); - thread_struct->eventKey = sub->eventKey++; - thread_struct->reference_count = reference_count; - thread_struct->device_handle = device_handle; - - TPJobInit( &job, ( start_routine ) genaNotifyThread, - thread_struct ); - TPJobSetFreeFunction( &job, ( free_routine ) free_notify_struct ); - TPJobSetPriority( &job, MED_PRIORITY ); - - if( ( return_code = - ThreadPoolAdd( &gSendThreadPool, &job, NULL ) ) != 0 ) { - if( return_code == EOUTOFMEM ) { - return_code = UPNP_E_OUTOF_MEMORY; - } - } else { - return_code = GENA_SUCCESS; - } - } - - if( return_code != GENA_SUCCESS ) { - - free( reference_count ); - free( UDN_copy ); - free( servId_copy ); - free( thread_struct ); - ixmlFreeDOMString( propertySet ); - free( headers ); - } - - HandleUnlock(); - - return return_code; + return ret; } @@ -613,504 +570,479 @@ int genaInitNotifyExt( IN IXML_Document *PropSet, IN const Upnp_SID sid) { - char *UDN_copy = NULL; - char *servId_copy = NULL; - char *headers = NULL; - subscription *sub = NULL; - service_info *service = NULL; - int return_code = GENA_SUCCESS; - int headers_size; - int *reference_count = NULL; - struct Handle_Info *handle_info; - DOMString propertySet = NULL; + int ret = GENA_SUCCESS; + int line = 0; - ThreadPoolJob job; + int *reference_count = NULL; + char *UDN_copy = NULL; + char *servId_copy = NULL; + DOMString propertySet = NULL; + char *headers = NULL; + notify_thread_struct *thread_struct = NULL; - notify_thread_struct *thread_struct = NULL; + subscription *sub = NULL; + service_info *service = NULL; + int headers_size; + struct Handle_Info *handle_info; + ThreadPoolJob job; - UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, - "GENA BEGIN INITIAL NOTIFY EXT" ); - reference_count = ( int * )malloc( sizeof( int ) ); + UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, + "GENA BEGIN INITIAL NOTIFY EXT"); + + reference_count = (int *)malloc(sizeof (int)); + if (reference_count == NULL) { + line = __LINE__; + ret = UPNP_E_OUTOF_MEMORY; + goto ExitFunction; + } + *reference_count = 0; + + UDN_copy = (char *)malloc(strlen(UDN) + 1); + if (UDN_copy == NULL) { + line = __LINE__; + ret = UPNP_E_OUTOF_MEMORY; + goto ExitFunction; + } - if( reference_count == NULL ) { - return UPNP_E_OUTOF_MEMORY; - } + servId_copy = (char *)malloc(strlen(servId) + 1); + if( servId_copy == NULL ) { + line = __LINE__; + ret = UPNP_E_OUTOF_MEMORY; + goto ExitFunction; + } - ( *reference_count ) = 0; + strcpy(UDN_copy, UDN); + strcpy(servId_copy, servId); - UDN_copy = ( char * )malloc( strlen( UDN ) + 1 ); - if( UDN_copy == NULL ) { - free( reference_count ); - return UPNP_E_OUTOF_MEMORY; - } + HandleLock(); - servId_copy = ( char * )malloc( strlen( servId ) + 1 ); - if( servId_copy == NULL ) { - free( UDN_copy ); - free( reference_count ); - return UPNP_E_OUTOF_MEMORY; - } + if (GetHandleInfo(device_handle, &handle_info) != HND_DEVICE) { + line = __LINE__; + ret = GENA_E_BAD_HANDLE; + goto ExitFunction; + } - strcpy( UDN_copy, UDN ); - strcpy( servId_copy, servId ); + service = FindServiceId(&handle_info->ServiceTable, servId, UDN); + if (service == NULL) { + line = __LINE__; + ret = GENA_E_BAD_SERVICE; + goto ExitFunction; + } + UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, + "FOUND SERVICE IN INIT NOTFY EXT: UDN %s, ServID: %s", + UDN, servId); - HandleLock(); + sub = GetSubscriptionSID(sid, service); + if (sub == NULL || sub->active) { + line = __LINE__; + ret = GENA_E_BAD_SID; + goto ExitFunction; + } + UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, + "FOUND SUBSCRIPTION IN INIT NOTIFY EXT: SID %s", sid); + sub->active = 1; - if( GetHandleInfo( device_handle, &handle_info ) != HND_DEVICE ) { - free( UDN_copy ); - free( reference_count ); - free( servId_copy ); - HandleUnlock(); - return GENA_E_BAD_HANDLE; - } + propertySet = ixmlPrintNode((IXML_Node *)PropSet); + if( propertySet == NULL ) { + line = __LINE__; + ret = UPNP_E_INVALID_PARAM; + goto ExitFunction; + } + UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, + "GENERATED PROPERY SET IN INIT EXT NOTIFY: %s", + propertySet); - if( ( service = FindServiceId( &handle_info->ServiceTable, - servId, UDN ) ) == NULL ) { - free( UDN_copy ); - free( reference_count ); - free( servId_copy ); - HandleUnlock(); - return GENA_E_BAD_SERVICE; - } - UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, - "FOUND SERVICE IN INIT NOTFY EXT: UDN %s, ServID: %s\n", - UDN, servId ); + headers_size = + strlen( "CONTENT-TYPE text/xml\r\n" ) + + strlen( "CONTENT-LENGTH: \r\n" ) + MAX_CONTENT_LENGTH + + strlen( "NT: upnp:event\r\n" ) + + strlen( "NTS: upnp:propchange\r\n" ) + 1; + headers = (char *)malloc(headers_size); + if (headers == NULL) { + line = __LINE__; + ret = UPNP_E_OUTOF_MEMORY; + goto ExitFunction; + } - if( ( ( sub = GetSubscriptionSID( sid, service ) ) == NULL ) || - ( sub->active ) ) { - free( UDN_copy ); - free( reference_count ); - free( servId_copy ); - HandleUnlock(); - return GENA_E_BAD_SID; - } - UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, - "FOUND SUBSCRIPTION IN INIT NOTIFY EXT: SID %s", sid ); + sprintf(headers, + "CONTENT-TYPE: text/xml\r\n" + "CONTENT-LENGTH: %"PRIzu"\r\n" + "NT: upnp:event\r\n" + "NTS: upnp:propchange\r\n", + strlen(propertySet) + 1); - sub->active = 1; + /* schedule thread for initial notification */ - propertySet = ixmlPrintNode( ( IXML_Node * ) PropSet ); - if( propertySet == NULL ) { - free( UDN_copy ); - free( reference_count ); - free( servId_copy ); - HandleUnlock(); - return UPNP_E_INVALID_PARAM; - } + thread_struct = (notify_thread_struct *)malloc(sizeof (notify_thread_struct)); + if (thread_struct == NULL) { + line = __LINE__; + ret = UPNP_E_OUTOF_MEMORY; + } else { + *reference_count = 1; + thread_struct->servId = servId_copy; + thread_struct->UDN = UDN_copy; + thread_struct->headers = headers; + thread_struct->propertySet = propertySet; + strcpy(thread_struct->sid, sid); + thread_struct->eventKey = sub->eventKey++; + thread_struct->reference_count = reference_count; + thread_struct->device_handle = device_handle; - UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, - "GENERATED PROPERY SET IN INIT EXT NOTIFY: %s", - propertySet ); + TPJobInit(&job, (start_routine)genaNotifyThread, thread_struct); + TPJobSetFreeFunction(&job, (free_routine)free_notify_struct); + TPJobSetPriority(&job, MED_PRIORITY); - headers_size = strlen( "CONTENT-TYPE text/xml\r\n" ) + - strlen( "CONTENT-LENGTH: \r\n" ) + MAX_CONTENT_LENGTH + - strlen( "NT: upnp:event\r\n" ) + - strlen( "NTS: upnp:propchange\r\n" ) + 1; + ret = ThreadPoolAdd(&gSendThreadPool, &job, NULL); + if (ret != 0) { + if (ret == EOUTOFMEM) { + line = __LINE__; + ret = UPNP_E_OUTOF_MEMORY; + } + } else { + line = __LINE__; + ret = GENA_SUCCESS; + } + } - headers = ( char * )malloc( headers_size ); - if( headers == NULL ) { - free( UDN_copy ); - free( servId_copy ); - free( reference_count ); - ixmlFreeDOMString( propertySet ); - HandleUnlock(); - return UPNP_E_OUTOF_MEMORY; - } +ExitFunction: + if (ret != GENA_SUCCESS) { + free(thread_struct); + free(headers); + ixmlFreeDOMString(propertySet); + free(servId_copy); + free(UDN_copy); + free(reference_count); + } - sprintf( headers, "CONTENT-TYPE: text/xml\r\nCONTENT-LENGTH: " - "%ld\r\nNT: upnp:event\r\nNTS: upnp:propchange\r\n", - (long) strlen( propertySet ) + 1 ); + HandleUnlock(); - //schedule thread for initial notification + UpnpPrintf(UPNP_INFO, GENA, __FILE__, line, + "GENA END INITIAL NOTIFY EXT, ret = %d", + ret); - thread_struct = - ( notify_thread_struct * ) - malloc( sizeof( notify_thread_struct ) ); - - if( thread_struct == NULL ) { - return_code = UPNP_E_OUTOF_MEMORY; - } else { - ( *reference_count ) = 1; - thread_struct->servId = servId_copy; - thread_struct->UDN = UDN_copy; - thread_struct->headers = headers; - thread_struct->propertySet = propertySet; - strcpy( thread_struct->sid, sid ); - thread_struct->eventKey = sub->eventKey++; - thread_struct->reference_count = reference_count; - thread_struct->device_handle = device_handle; - - TPJobInit( &job, ( start_routine ) genaNotifyThread, - thread_struct ); - TPJobSetFreeFunction( &job, ( free_routine ) free_notify_struct ); - TPJobSetPriority( &job, MED_PRIORITY ); - - if( ( return_code = - ThreadPoolAdd( &gSendThreadPool, &job, NULL ) ) != 0 ) { - if( return_code == EOUTOFMEM ) { - return_code = UPNP_E_OUTOF_MEMORY; - } - } else { - return_code = GENA_SUCCESS; - } - } - - if( return_code != GENA_SUCCESS ) { - ixmlFreeDOMString( propertySet ); - free( reference_count ); - free( UDN_copy ); - free( servId_copy ); - free( thread_struct ); - free( headers ); - } - HandleUnlock(); - - return return_code; + return ret; } -/**************************************************************************** -* Function : genaNotifyAllExt -* -* 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 -* -* 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 -****************************************************************************/ -int -genaNotifyAllExt( IN UpnpDevice_Handle device_handle, - IN char *UDN, - IN char *servId, - IN IXML_Document * PropSet ) + +int genaNotifyAllExt( + IN UpnpDevice_Handle device_handle, + IN char *UDN, + IN char *servId, + IN IXML_Document *PropSet) { - char *headers = NULL; - int headers_size; - int return_code = GENA_SUCCESS; - char *UDN_copy = NULL; - char *servId_copy = NULL; - int *reference_count = NULL; - struct Handle_Info *handle_info; - DOMString propertySet = NULL; - ThreadPoolJob job; - subscription *finger = NULL; + int ret = GENA_SUCCESS; + int line = 0; - notify_thread_struct *thread_struct = NULL; + int *reference_count = NULL; + char *UDN_copy = NULL; + char *servId_copy = NULL; + DOMString propertySet = NULL; + char *headers = NULL; + notify_thread_struct *thread_struct = NULL; - service_info *service = NULL; + subscription *finger = NULL; + service_info *service = NULL; + int headers_size; + struct Handle_Info *handle_info; + ThreadPoolJob job; - reference_count = ( int * )malloc( sizeof( int ) ); + UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, + "GENA BEGIN NOTIFY ALL EXT"); - if( reference_count == NULL ) - return UPNP_E_OUTOF_MEMORY; + reference_count = (int *)malloc(sizeof (int)); + if (reference_count == NULL) { + line = __LINE__; + ret = UPNP_E_OUTOF_MEMORY; + goto ExitFunction; + } + *reference_count = 0; + + UDN_copy = (char *)malloc(strlen(UDN) + 1); + if (UDN_copy == NULL) { + line = __LINE__; + ret = UPNP_E_OUTOF_MEMORY; + goto ExitFunction; + } - ( *reference_count = 0 ); + servId_copy = (char *)malloc(strlen(servId) + 1); + if( servId_copy == NULL ) { + line = __LINE__; + ret = UPNP_E_OUTOF_MEMORY; + goto ExitFunction; + } - UDN_copy = ( char * )malloc( strlen( UDN ) + 1 ); + strcpy(UDN_copy, UDN); + strcpy(servId_copy, servId); - if( UDN_copy == NULL ) { - free( reference_count ); - return UPNP_E_OUTOF_MEMORY; - } + propertySet = ixmlPrintNode((IXML_Node *)PropSet); + if (propertySet == NULL) { + line = __LINE__; + ret = UPNP_E_INVALID_PARAM; + goto ExitFunction; + } + UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, + "GENERATED PROPERY SET IN EXT NOTIFY: %s", + propertySet); - servId_copy = ( char * )malloc( strlen( servId ) + 1 ); + headers_size = + strlen( "CONTENT-TYPE text/xml\r\n" ) + + strlen( "CONTENT-LENGTH: \r\n" ) + MAX_CONTENT_LENGTH + + strlen( "NT: upnp:event\r\n" ) + + strlen( "NTS: upnp:propchange\r\n" ) + 1; + headers = (char *)malloc(headers_size); + if (headers == NULL) { + line = __LINE__; + ret = UPNP_E_OUTOF_MEMORY; + goto ExitFunction; + } - if( servId_copy == NULL ) { - free( UDN_copy ); - free( reference_count ); - return UPNP_E_OUTOF_MEMORY; - } + sprintf(headers, + "CONTENT-TYPE: text/xml\r\n" + "CONTENT-LENGTH: %"PRIzu"\r\n" + "NT: upnp:event\r\n" + "NTS: upnp:propchange\r\n", + strlen(propertySet) + 1); - strcpy( UDN_copy, UDN ); - strcpy( servId_copy, servId ); + HandleLock(); - propertySet = ixmlPrintNode( ( IXML_Node * ) PropSet ); - if( propertySet == NULL ) { - free( UDN_copy ); - free( servId_copy ); - free( reference_count ); - return UPNP_E_INVALID_PARAM; - } + if (GetHandleInfo(device_handle, &handle_info) != HND_DEVICE) { + line = __LINE__; + ret = GENA_E_BAD_HANDLE; + } else { + service = FindServiceId(&handle_info->ServiceTable, servId, UDN); + if (service != NULL) { + finger = GetFirstSubscription(service); + while (finger) { + thread_struct = (notify_thread_struct *)malloc(sizeof (notify_thread_struct)); + if (thread_struct == NULL) { + line = __LINE__; + ret = UPNP_E_OUTOF_MEMORY; + break; + } - headers_size = strlen( "CONTENT-TYPE text/xml\r\n" ) + - strlen( "CONTENT-LENGTH: \r\n" ) + MAX_CONTENT_LENGTH + - strlen( "NT: upnp:event\r\n" ) + - strlen( "NTS: upnp:propchange\r\n" ) + 1; + (*reference_count)++; + thread_struct->reference_count = reference_count; + thread_struct->UDN = UDN_copy; + thread_struct->servId = servId_copy; + thread_struct->headers = headers; + thread_struct->propertySet = propertySet; + strcpy(thread_struct->sid, finger->sid); + thread_struct->eventKey = finger->eventKey++; + thread_struct->device_handle = device_handle; + /* if overflow, wrap to 1 */ + if (finger->eventKey < 0) { + finger->eventKey = 1; + } - headers = ( char * )malloc( headers_size ); - if( headers == NULL ) { - free( UDN_copy ); - free( servId_copy ); - ixmlFreeDOMString( propertySet ); - free( reference_count ); - return UPNP_E_OUTOF_MEMORY; - } - //changed to add null terminator at end of content - //content length = (length in bytes of property set) + null char - sprintf( headers, "CONTENT-TYPE: text/xml\r\nCONTENT-LENGTH: " - "%ld\r\nNT: upnp:event\r\nNTS: upnp:propchange\r\n", - (long) strlen( propertySet ) + 1 ); + TPJobInit(&job, (start_routine)genaNotifyThread, thread_struct); + TPJobSetFreeFunction(&job, (free_routine)free_notify_struct); + TPJobSetPriority(&job, MED_PRIORITY); + ret = ThreadPoolAdd(&gSendThreadPool, &job, NULL); + if (ret != 0) { + line = __LINE__; + if (ret == EOUTOFMEM) { + line = __LINE__; + ret = UPNP_E_OUTOF_MEMORY; + } + break; + } - HandleLock(); + finger = GetNextSubscription(service, finger); + } + } else { + line = __LINE__; + ret = GENA_E_BAD_SERVICE; + } + } - if( GetHandleInfo( device_handle, &handle_info ) != HND_DEVICE ) - return_code = GENA_E_BAD_HANDLE; - else { - if( ( service = FindServiceId( &handle_info->ServiceTable, - servId, UDN ) ) != NULL ) { - finger = GetFirstSubscription( service ); +ExitFunction: + if (ret != GENA_SUCCESS || *reference_count == 0) { + free(headers); + ixmlFreeDOMString(propertySet); + free(servId_copy); + free(UDN_copy); + free(reference_count); + } - while( finger ) { - thread_struct = - ( notify_thread_struct * ) - malloc( sizeof( notify_thread_struct ) ); - if( thread_struct == NULL ) { - break; - return_code = UPNP_E_OUTOF_MEMORY; - } + HandleUnlock(); - ( *reference_count )++; - thread_struct->reference_count = reference_count; - thread_struct->UDN = UDN_copy; - thread_struct->servId = servId_copy; - thread_struct->headers = headers; - thread_struct->propertySet = propertySet; - strcpy( thread_struct->sid, finger->sid ); - thread_struct->eventKey = finger->eventKey++; - thread_struct->device_handle = device_handle; - //if overflow, wrap to 1 - if( finger->eventKey < 0 ) { - finger->eventKey = 1; - } + UpnpPrintf(UPNP_INFO, GENA, __FILE__, line, + "GENA END NOTIFY ALL EXT, ret = %d", + ret); - TPJobInit( &job, ( start_routine ) genaNotifyThread, - thread_struct ); - TPJobSetFreeFunction( &job, - ( free_routine ) - free_notify_struct ); - TPJobSetPriority( &job, MED_PRIORITY ); - if( ( return_code = ThreadPoolAdd( &gSendThreadPool, - &job, NULL ) ) != 0 ) { - if( return_code == EOUTOFMEM ) { - return_code = UPNP_E_OUTOF_MEMORY; - } - break; - } - - finger = GetNextSubscription( service, finger ); - } - } else - return_code = GENA_E_BAD_SERVICE; - } - - if( ( *reference_count ) == 0 ) { - free( reference_count ); - free( headers ); - ixmlFreeDOMString( propertySet ); - free( UDN_copy ); - free( servId_copy ); - } - - HandleUnlock(); - - return return_code; + return ret; } -/**************************************************************************** -* Function : genaNotifyAll -* -* 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 -* -* 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 -* is it takes event variable array instead of xml document. -****************************************************************************/ -int -genaNotifyAll( IN UpnpDevice_Handle device_handle, - IN char *UDN, - IN char *servId, - IN char **VarNames, - IN char **VarValues, - IN int var_count ) + +int genaNotifyAll( + IN UpnpDevice_Handle device_handle, + IN char *UDN, + IN char *servId, + IN char **VarNames, + IN char **VarValues, + IN int var_count ) { - char *headers = NULL; - char *propertySet = NULL; - int headers_size; - int return_code = GENA_SUCCESS; - char *UDN_copy = NULL; - char *servId_copy = NULL; - int *reference_count = NULL; - struct Handle_Info *handle_info; - ThreadPoolJob job; + int ret = GENA_SUCCESS; + int line = 0; - subscription *finger = NULL; + int *reference_count = NULL; + char *UDN_copy = NULL; + char *servId_copy = NULL; + DOMString propertySet = NULL; + char *headers = NULL; + notify_thread_struct *thread_struct = NULL; - notify_thread_struct *thread_struct = NULL; + subscription *finger = NULL; + service_info *service = NULL; + int headers_size; + struct Handle_Info *handle_info; + ThreadPoolJob job; - service_info *service = NULL; + UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, + "GENA BEGIN NOTIFY ALL"); - reference_count = ( int * )malloc( sizeof( int ) ); + reference_count = (int *)malloc(sizeof (int)); + if (reference_count == NULL) { + line = __LINE__; + ret = UPNP_E_OUTOF_MEMORY; + goto ExitFunction; + } + *reference_count = 0; + + UDN_copy = (char *)malloc(strlen(UDN) + 1); + if (UDN_copy == NULL) { + line = __LINE__; + ret = UPNP_E_OUTOF_MEMORY; + goto ExitFunction; + } - if( reference_count == NULL ) { - return UPNP_E_OUTOF_MEMORY; - } + servId_copy = (char *)malloc(strlen(servId) + 1); + if( servId_copy == NULL ) { + line = __LINE__; + ret = UPNP_E_OUTOF_MEMORY; + goto ExitFunction; + } - ( *reference_count = 0 ); + strcpy(UDN_copy, UDN); + strcpy(servId_copy, servId); - UDN_copy = ( char * )malloc( strlen( UDN ) + 1 ); + ret = GeneratePropertySet(VarNames, VarValues, var_count, &propertySet); + if (ret != XML_SUCCESS) { + line = __LINE__; + goto ExitFunction; + } + UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, + "GENERATED PROPERY SET IN EXT NOTIFY: %s", + propertySet); - if( UDN_copy == NULL ) { - free( reference_count ); - return UPNP_E_OUTOF_MEMORY; - } + headers_size = + strlen( "CONTENT-TYPE text/xml\r\n" ) + + strlen( "CONTENT-LENGTH: \r\n" ) + MAX_CONTENT_LENGTH + + strlen( "NT: upnp:event\r\n" ) + + strlen( "NTS: upnp:propchange\r\n" ) + 1; + headers = (char *)malloc(headers_size); + if (headers == NULL) { + line = __LINE__; + ret = UPNP_E_OUTOF_MEMORY; + goto ExitFunction; + } - servId_copy = ( char * )malloc( strlen( servId ) + 1 ); - if( servId_copy == NULL ) { - free( UDN_copy ); - free( reference_count ); - return UPNP_E_OUTOF_MEMORY; - } + sprintf(headers, + "CONTENT-TYPE: text/xml\r\n" + "CONTENT-LENGTH: %"PRIzu"\r\n" + "NT: upnp:event\r\n" + "NTS: upnp:propchange\r\n", + strlen(propertySet) + 1); - strcpy( UDN_copy, UDN ); - strcpy( servId_copy, servId ); + HandleLock(); - if( ( return_code = GeneratePropertySet( VarNames, VarValues, - var_count, - &propertySet ) ) != - XML_SUCCESS ) { - free( UDN_copy ); - free( servId_copy ); - free( reference_count ); - return return_code; - } + if (GetHandleInfo(device_handle, &handle_info) != HND_DEVICE) { + line = __LINE__; + ret = GENA_E_BAD_HANDLE; + } else { + service = FindServiceId(&handle_info->ServiceTable, servId, UDN); + if (service != NULL) { + finger = GetFirstSubscription(service); + while (finger) { + thread_struct = (notify_thread_struct *)malloc(sizeof (notify_thread_struct)); + if (thread_struct == NULL) { + line = __LINE__; + ret = UPNP_E_OUTOF_MEMORY; + break; + } - headers_size = strlen( "CONTENT-TYPE text/xml\r\n" ) + - strlen( "CONTENT-LENGTH: \r\n" ) + MAX_CONTENT_LENGTH + - strlen( "NT: upnp:event\r\n" ) + - strlen( "NTS: upnp:propchange\r\n" ) + 1; + (*reference_count)++; + thread_struct->reference_count = reference_count; + thread_struct->UDN = UDN_copy; + thread_struct->servId = servId_copy; + thread_struct->headers = headers; + thread_struct->propertySet = propertySet; + strcpy(thread_struct->sid, finger->sid); + thread_struct->eventKey = finger->eventKey++; + thread_struct->device_handle = device_handle; + /* if overflow, wrap to 1 */ + if (finger->eventKey < 0) { + finger->eventKey = 1; + } - headers = ( char * )malloc( headers_size ); - if( headers == NULL ) { - free( UDN_copy ); - free( servId_copy ); - ixmlFreeDOMString( propertySet ); - free( reference_count ); - return UPNP_E_OUTOF_MEMORY; - } - //changed to add null terminator at end of content - //content length = (length in bytes of property set) + null char - sprintf( headers, "CONTENT-TYPE: text/xml\r\nCONTENT-LENGTH: %ld\r\nNT:" - " upnp:event\r\nNTS: upnp:propchange\r\n", - (long) strlen( propertySet ) + 1 ); - HandleLock(); + TPJobInit(&job, (start_routine)genaNotifyThread, thread_struct); + TPJobSetFreeFunction(&job, (free_routine)free_notify_struct); + TPJobSetPriority(&job, MED_PRIORITY); + ret = ThreadPoolAdd(&gSendThreadPool, &job, NULL); + if (ret != 0) { + line = __LINE__; + if (ret == EOUTOFMEM) { + line = __LINE__; + ret = UPNP_E_OUTOF_MEMORY; + } + break; + } - if( GetHandleInfo( device_handle, &handle_info ) != HND_DEVICE ) { - return_code = GENA_E_BAD_HANDLE; - } else { - if( ( service = FindServiceId( &handle_info->ServiceTable, - servId, UDN ) ) != NULL ) { - finger = GetFirstSubscription( service ); + finger = GetNextSubscription(service, finger); + } + } else { + line = __LINE__; + ret = GENA_E_BAD_SERVICE; + } + } - while( finger ) { - thread_struct = - ( notify_thread_struct * ) - malloc( sizeof( notify_thread_struct ) ); - if( thread_struct == NULL ) { - return_code = UPNP_E_OUTOF_MEMORY; - break; - } - ( *reference_count )++; - thread_struct->reference_count = reference_count; - thread_struct->UDN = UDN_copy; - thread_struct->servId = servId_copy; - thread_struct->headers = headers; - thread_struct->propertySet = propertySet; - strcpy( thread_struct->sid, finger->sid ); - thread_struct->eventKey = finger->eventKey++; - thread_struct->device_handle = device_handle; - //if overflow, wrap to 1 - if( finger->eventKey < 0 ) { - finger->eventKey = 1; - } +ExitFunction: + if (ret != GENA_SUCCESS || *reference_count == 0) { + free(headers); + ixmlFreeDOMString(propertySet); + free(servId_copy); + free(UDN_copy); + free(reference_count); + } - TPJobInit( &job, ( start_routine ) genaNotifyThread, - thread_struct ); - TPJobSetFreeFunction( &job, - ( free_routine ) - free_notify_struct ); - TPJobSetPriority( &job, MED_PRIORITY ); + HandleUnlock(); - if( ( return_code = - ThreadPoolAdd( &gSendThreadPool, &job, NULL ) ) - != 0 ) { - if( return_code == EOUTOFMEM ) { - return_code = UPNP_E_OUTOF_MEMORY; - break; - } - } + UpnpPrintf(UPNP_INFO, GENA, __FILE__, line, + "GENA END NOTIFY ALL, ret = %d", + ret); - finger = GetNextSubscription( service, finger ); - - } - } else { - return_code = GENA_E_BAD_SERVICE; - } - } - - if( ( *reference_count ) == 0 ) { - free( reference_count ); - free( headers ); - ixmlFreeDOMString( propertySet ); - free( UDN_copy ); - free( servId_copy ); - } - HandleUnlock(); - - return return_code; + return ret; } -/**************************************************************************** -* Function : respond_ok -* -* Parameters : -* IN SOCKINFO *info : socket connection of request -* IN int time_out : accepted duration -* IN subscription *sub : accepted subscription -* IN http_message_t* request : http request -* -* Description : Function to return OK message in the case -* of a subscription request. -* -* Return : static int -* returns UPNP_E_SUCCESS if successful else returns appropriate error -* Note : -****************************************************************************/ -static int -respond_ok( IN SOCKINFO * info, - IN int time_out, - IN subscription * sub, - IN http_message_t * request ) + +/*! + * \brief Returns OK message in the case of a subscription request. + * + * \return UPNP_E_SUCCESS if successful, otherwise the appropriate error code. + */ +static int respond_ok( + /*! [in] Socket connection of request. */ + IN SOCKINFO *info, + /*! [in] Accepted duration. */ + IN int time_out, + /*! [in] Accepted subscription. */ + IN subscription *sub, + /*! [in] Http request. */ + IN http_message_t *request) { - int major, - minor; + int major; + int minor; membuffer response; int return_code; char timeout_str[100]; @@ -1148,28 +1080,22 @@ respond_ok( IN SOCKINFO * info, return return_code; } -/**************************************************************************** -* Function : create_url_list -* -* Parameters : -* IN memptr* url_list : -* OUT URL_list *out : -* -* Description : Function to parse the Callback header value in -* subscription requests takes in a buffer containing URLS delimited by -* '<' and '>'. The entire buffer is copied into dynamic memory -* and stored in the URL_list. Pointers to the individual urls within -* this buffer are allocated and stored in the URL_list. Only URLs with -* network addresses are considered(i.e. host:port or domain name) -* -* Return : int -* if successful returns the number of URLs parsed -* else UPNP_E_OUTOF_MEMORY -* Note : -****************************************************************************/ -static int -create_url_list( IN memptr * url_list, - OUT URL_list * out ) + +/*! + * \brief Function to parse the Callback header value in subscription requests. + * + * Takes in a buffer containing URLS delimited by '<' and '>'. The entire buffer + * is copied into dynamic memory and stored in the URL_list. Pointers to the + * individual urls within this buffer are allocated and stored in the URL_list. + * Only URLs with network addresses are considered (i.e. host:port or domain name). + * + * \return The number of URLs parsed if successful, otherwise UPNP_E_OUTOF_MEMORY. + */ +static int create_url_list( + /*! [in] . */ + IN memptr *url_list, + /*! [out] . */ + OUT URL_list *out) { int URLcount = 0; int i; @@ -1241,19 +1167,7 @@ create_url_list( IN memptr * url_list, return URLcount; } -/**************************************************************************** - * Function: gena_process_subscription_request - * - * Parameters: - * IN SOCKINFO *info: socket info of the device - * IN http_message_t* request: - * SUBSCRIPTION request from the control point - * - * Description: This function handles a subscription request from a - * ctrl point. The socket is not closed on return. - * - * Return: void - ****************************************************************************/ + void gena_process_subscription_request( IN SOCKINFO *info, IN http_message_t *request) @@ -1436,24 +1350,10 @@ exit_function: UpnpSubscriptionRequest_delete(request_struct); } -/**************************************************************************** -* Function : gena_process_subscription_renewal_request -* -* Parameters : -* IN SOCKINFO *info : socket info of the device -* IN http_message_t* request : subscription renewal request from the -* control point -* -* Description : This function handles a subscription renewal request -* from a ctrl point. The connection is not destroyed on return. -* -* Return : void -* -* Note : -****************************************************************************/ -void -gena_process_subscription_renewal_request( IN SOCKINFO * info, - IN http_message_t * request ) + +void gena_process_subscription_renewal_request( + IN SOCKINFO *info, + IN http_message_t *request) { Upnp_SID sid; subscription *sub; @@ -1562,24 +1462,10 @@ gena_process_subscription_renewal_request( IN SOCKINFO * info, HandleUnlock(); } -/**************************************************************************** -* Function : gena_process_unsubscribe_request -* -* Parameters : -* IN SOCKINFO *info : socket info of the device -* IN http_message_t* request : UNSUBSCRIBE request from the control -* point -* -* Description : This function Handles a subscription cancellation request -* from a ctrl point. The connection is not destroyed on return. -* -* Return : void -* -* Note : -****************************************************************************/ -void -gena_process_unsubscribe_request( IN SOCKINFO * info, - IN http_message_t * request ) + +void gena_process_unsubscribe_request( + IN SOCKINFO *info, + IN http_message_t *request) { Upnp_SID sid; service_info *service; @@ -1635,11 +1521,13 @@ gena_process_unsubscribe_request( IN SOCKINFO * info, return; } - RemoveSubscriptionSID( sid, service ); - error_respond( info, HTTP_OK, request ); // success + RemoveSubscriptionSID(sid, service); + error_respond(info, HTTP_OK, request); // success HandleUnlock(); } -#endif // INCLUDE_DEVICE_APIS -#endif // EXCLUDE_GENA + +#endif /* INCLUDE_DEVICE_APIS */ +#endif /* EXCLUDE_GENA */ + diff --git a/upnp/src/inc/gena.h b/upnp/src/inc/gena.h index 8ad8912..649813d 100644 --- a/upnp/src/inc/gena.h +++ b/upnp/src/inc/gena.h @@ -1,38 +1,44 @@ -/////////////////////////////////////////////////////////////////////////// -// -// 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 + */ + + #include "config.h" @@ -45,10 +51,10 @@ #include "miniserver.h" #include "service_table.h" #include "sock.h" -#include "UpnpString.h" #include "ThreadPool.h" -#include "uri.h" #include "upnp.h" +#include "UpnpString.h" +#include "uri.h" #ifdef __cplusplus @@ -64,6 +70,7 @@ #define XML_PROPERTYSET_HEADER \ "\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 \ @@ -83,6 +90,7 @@ #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 @@ -92,17 +100,22 @@ #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 + +/*! + * Lock the subscription + */ #define SubscribeLock() \ UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, \ "Trying Subscribe Lock"); \ @@ -110,7 +123,10 @@ extern ithread_mutex_t GlobalClientSubscribeMutex; UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, \ "Subscribe Lock"); -// Unlock the subscription + +/*! + * Unlock the subscription + */ #define SubscribeUnlock() \ UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, \ "Trying Subscribe UnLock"); \ @@ -119,7 +135,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; @@ -132,279 +150,231 @@ 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 - ***************************************************************************/ + * \Return UPNP_E_SUCCESS if successful, otherwise appropriate error code. + */ EXTERN_C void genaCallback( + /*! [in] represents the parse state of the request */ IN http_parser_t *parser, - IN http_message_t* request, + /*! [in] HTTP message containing GENA request */ + IN http_message_t* request, + /*! [in,out] Structure containing information about the socket */ IN 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 const UpnpString *PublisherURL: 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 UpnpString *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. */ IN UpnpClient_Handle client_handle, + /*! [in] Of the form: "http://134.134.156.80:4000/RedBulb/Event */ IN const UpnpString *PublisherURL, + /*! [in,out] requested Duration: + * \li if -1, then "infinite". + * \li in the OUT case: actual Duration granted by Service, + * -1 for infinite. */ INOUT int *TimeOut, + /*! [out] sid of subscription, memory passed in by caller. */ OUT UpnpString *out_sid); #endif /* INCLUDE_CLIENT_APIS */ -/************************************************************************ - * Function: genaUnSubscribe +/*! + * \brief Unsubscribes a SID. * - * Parameters: - * IN UpnpClient_Handle client_handle: UPnP client handle - * IN const UpnpString *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. */ IN UpnpClient_Handle client_handle, + /*! [in] The subscription ID. */ IN const UpnpString *in_sid); #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); +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); +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 UpnpString *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 + * 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. * - * 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 - * 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] Client handle. */ IN UpnpClient_Handle client_handle, + /*! [in] Subscription ID. */ IN const UpnpString *in_sid, + /*! [out] requested Duration, if -1, then "infinite". In the OUT case: + * actual Duration granted by Service, -1 for infinite. */ OUT int * TimeOut); #endif /* INCLUDE_CLIENT_APIS */ -/**************************************************************************** - * Function: genaNotifyAll + +/*! + * \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 /* 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] XML document Event varible property set. */ IN 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 - * - * 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 + * \return GENA_E_SUCCESS if successful, otherwise the appropriate error code. * - * 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, +EXTERN_C int genaInitNotify( + /*! [in] Device handle. */ + IN UpnpDevice_Handle device_handle, + /*! [in] Device udn. */ IN char *UDN, + /*! [in] Service ID. */ IN char *servId, + /*! [in] Array of variable names. */ IN char **VarNames, + /*! [in] Array of variable values. */ IN char **VarValues, + /*! [in] Array size. */ IN int var_count, + /*! [in] Subscription ID. */ IN 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 - * - * 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 + * \return GENA_E_SUCCESS if successful, otherwise the appropriate error code. * - * 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] Device handle. */ IN UpnpDevice_Handle device_handle, + /*! [in] Device udn. */ IN char *UDN, + /*! [in] Service ID. */ IN char *servId, + /*! [in] Document of the state table. */ IN IXML_Document *PropSet, + /*! [in] subscription ID. */ IN 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 - ***************************************************************************/ + * \return UPNP_E_SUCCESS if successful, otherwise appropriate error code. + */ void error_respond( + /*! [in] Structure containing information about the socket. */ IN SOCKINFO *info, + /*! [in] error code that will be in the GENA response. */ IN int error_code, + /*! [in] GENA request Packet. */ IN http_message_t* hmsg); diff --git a/upnp/src/inc/gena_ctrlpt.h b/upnp/src/inc/gena_ctrlpt.h index 5896be2..dc20400 100644 --- a/upnp/src/inc/gena_ctrlpt.h +++ b/upnp/src/inc/gena_ctrlpt.h @@ -1,52 +1,64 @@ -/////////////////////////////////////////////////////////////////////////// -// -// 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_CTRLPT_H +#define GENA_CTRLPT_H + + +/*! + * \file + */ + #include "sock.h" -/************************************************************************ -* Function : gena_process_notification_event -* -* Parameters: -* IN SOCKINFO *info: Socket structure containing the device socket -* information -* IN http_message_t* event: The http message contains the GENA -* notification -* -* Description: -* This function processes NOTIFY events that are sent by devices. -* called by genacallback() -* -* Returns: void -* -* Note : called by genacallback() -****************************************************************************/ -void gena_process_notification_event( INOUT SOCKINFO *info, - IN http_message_t* request ); + +/*! + * \brief This function processes NOTIFY events that are sent by devices. + * + * Parameters: + * IN SOCKINFO *info: Socket structure containing the device socket + * information + * IN http_message_t *event: The http message contains the GENA + * notification + * + * \note called by genacallback() + */ +void gena_process_notification_event( + /*! [in] Socket info of the device. */ + IN SOCKINFO *info, + /*! [in] The http message contains the GENA notification. */ + IN http_message_t *event); + + +#endif /* GENA_CTRLPT_H */ + diff --git a/upnp/src/inc/gena_device.h b/upnp/src/inc/gena_device.h index 42077d0..5ac7a30 100644 --- a/upnp/src/inc/gena_device.h +++ b/upnp/src/inc/gena_device.h @@ -1,88 +1,79 @@ -/////////////////////////////////////////////////////////////////////////// -// -// 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_DEVICE_H +#define GENA_DEVICE_H + + +/*! + * \file + */ + #include "sock.h" -/**************************************************************************** -* Function : gena_process_subscription_request -* -* Parameters : -* IN SOCKINFO *info : socket info of the device -* IN http_message_t* request : SUBSCRIPTION request from the control -* point -* -* Description : This function handles a subscription request from a -* ctrl point. The socket is not closed on return. -* -* Return : void -* -* Note : -****************************************************************************/ -void gena_process_subscription_request( IN SOCKINFO *info, - IN http_message_t* request ); + +/*! + * \brief Handles a subscription request from a ctrl point. The socket is not + * closed on return. + */ +void gena_process_subscription_request( + /*! [in] Socket info of the device. */ + IN SOCKINFO *info, + /*! [in] Subscription request from the control point. */ + IN http_message_t *request); -/**************************************************************************** -* Function : gena_process_subscription_renewal_request -* -* Parameters : -* IN SOCKINFO *info : socket info of the device -* IN http_message_t* request : subscription renewal request from the -* control point -* -* Description : This function handles a subscription renewal request -* from a ctrl point. The connection is not destroyed on return. -* -* Return : void -* -* Note : -****************************************************************************/ -void gena_process_subscription_renewal_request( IN SOCKINFO *info, - IN http_message_t* request ); +/*! + * \brief Handles a subscription renewal request from a ctrl point. + * The connection is not destroyed on return. + */ +void gena_process_subscription_renewal_request( + /*! [in] Socket info of the device. */ + IN SOCKINFO *info, + /*! [in] Subscription renewal request from the control point. */ + IN http_message_t *request); -/**************************************************************************** -* Function : gena_process_unsubscribe_request -* -* Parameters : -* IN SOCKINFO *info : socket info of the device -* IN http_message_t* request : UNSUBSCRIBE request from the control -* point -* -* Description : This function Handles a subscription cancellation request -* from a ctrl point. The connection is not destroyed on return. -* -* Return : void -* -* Note : -****************************************************************************/ -void gena_process_unsubscribe_request( IN SOCKINFO *info, - IN http_message_t* request ); +/*! + * \brief Handles a subscription cancellation request from a ctrl point. + * The connection is not destroyed on return. + */ +void gena_process_unsubscribe_request( + /*! [in] Socket info of the device. */ + IN SOCKINFO *info, + /*! [in] UNSUBSCRIBE request from the control point. */ + IN http_message_t *request); + + +#endif /* GENA_DEVICE_H */ +