diff --git a/upnp/inc/upnp.h b/upnp/inc/upnp.h
index ba5391f..5cd407b 100644
--- a/upnp/inc/upnp.h
+++ b/upnp/inc/upnp.h
@@ -707,7 +707,8 @@ enum Upnp_DescType_e {
typedef enum Upnp_DescType_e Upnp_DescType;
-/*! All callback functions share the same prototype, documented below.
+/*!
+ * All callback functions share the same prototype, documented below.
* Note that any memory passed to the callback function
* is valid only during the callback and should be copied if it
* needs to persist. This callback function needs to be thread
@@ -728,10 +729,16 @@ typedef enum Upnp_DescType_e Upnp_DescType;
* See \b Upnp_EventType for more information on the callback values and
* the associated \b Event parameter.
*
- * The return value of the callback is currently ignored. It may be used
+ * The return value of the callback is currently ignored. It may be used
* in the future to communicate results back to the SDK.
*/
-typedef int (*Upnp_FunPtr)(IN Upnp_EventType EventType, IN void *Event, IN void *Cookie);
+typedef int (*Upnp_FunPtr)(
+ /*! [in] .*/
+ Upnp_EventType EventType,
+ /*! [in] .*/
+ void *Event,
+ /*! [in] .*/
+ void *Cookie);
/* @} Constants and Types */
@@ -1037,7 +1044,7 @@ EXPORT_SPEC int UpnpRegisterRootDevice2(
* the description is served using the internal web server. */
int config_baseURL,
/*! [in] Pointer to the callback function for receiving asynchronous events. */
- IN Upnp_FunPtr Fun,
+ Upnp_FunPtr Fun,
/*! [in] Pointer to user data returned with the callback function when
* invoked. */
const void* Cookie,
@@ -1224,6 +1231,10 @@ EXPORT_SPEC int UpnpSetMaxContentLength(
* matching root device, device, or service. The application specifies the
* search type by the \b Target parameter.
*
+ * This function searches for the devices for the provided maximum time.
+ * It is an asynchronous function. It schedules a search job and returns.
+ * The client is notified about the search results after search timer.
+ *
* Note that there is no way for the SDK to distinguish which client
* instance issued a particular search. Therefore, the client can get
* search callbacks that do not match the original criteria of the search.
@@ -1237,17 +1248,17 @@ EXPORT_SPEC int UpnpSetMaxContentLength(
*/
EXPORT_SPEC int UpnpSearchAsync(
/*! The handle of the client performing the search. */
- IN UpnpClient_Handle Hnd,
+ UpnpClient_Handle Hnd,
/*! The time, in seconds, to wait for responses. If the time is greater
* than \c MAX_SEARCH_TIME then the time is set to \c MAX_SEARCH_TIME.
* If the time is less than \c MIN_SEARCH_TIME then the time is set to
* \c MIN_SEARCH_TIME. */
- IN int Mx,
+ int Mx,
/*! The search target as defined in the UPnP Device Architecture v1.0
* specification. */
- IN const char *Target,
+ const char *TTarget_constarget_const,
/*! The user data to pass when the callback function is invoked. */
- IN const void *Cookie);
+ const void *Cookie_const);
/*!
* \brief Sends out the discovery announcements for all devices and services
@@ -1266,9 +1277,9 @@ EXPORT_SPEC int UpnpSearchAsync(
*/
EXPORT_SPEC int UpnpSendAdvertisement(
/*! The device handle for which to send out the announcements. */
- IN UpnpDevice_Handle Hnd,
+ UpnpDevice_Handle Hnd,
/*! The expiration age, in seconds, of the announcements. */
- IN int Exp);
+ int Exp);
/* @} Discovery */
@@ -1316,16 +1327,16 @@ EXPORT_SPEC int UpnpSendAdvertisement(
* according to the device.
*/
EXPORT_SPEC int UpnpGetServiceVarStatus(
- /*! The handle of the control point. */
- IN UpnpClient_Handle Hnd,
- /*! The URL of the service. */
- IN const char *ActionURL,
- /*! The name of the variable to query. */
- IN const char *VarName,
- /*! The pointer to store the value for \b VarName. The SDK allocates
+ /*! [in] The handle of the control point. */
+ UpnpClient_Handle Hnd,
+ /*! [in] The URL of the service. */
+ const char *ActionURL,
+ /*! [in] The name of the variable to query. */
+ const char *VarName,
+ /*! [out] The pointer to store the value for \b VarName. The SDK allocates
* this string and the caller needs to free it using
* \b ixmlFreeDOMString. */
- OUT DOMString *StVarVal);
+ DOMString *StVarVal);
/*!
@@ -1346,17 +1357,17 @@ EXPORT_SPEC int UpnpGetServiceVarStatus(
* complete this operation.
*/
EXPORT_SPEC int UpnpGetServiceVarStatusAsync(
- /*! The handle of the control point. */
- IN UpnpClient_Handle Hnd,
- /*! The URL of the service. */
- IN const char *ActionURL,
- /*! The name of the variable to query. */
- IN const char *VarName,
- /*! Pointer to a callback function to be invoked when the operation
+ /*! [in] The handle of the control point. */
+ UpnpClient_Handle Hnd,
+ /*! [in] The URL of the service. */
+ const char *ActionURL,
+ /*! [in] The name of the variable to query. */
+ const char *VarName,
+ /*! [in] Pointer to a callback function to be invoked when the operation
* is complete. */
- IN Upnp_FunPtr Fun,
- /*! Pointer to user data to pass to the callback function when invoked. */
- IN const void *Cookie);
+ Upnp_FunPtr Fun,
+ /*! [in] Pointer to user data to pass to the callback function when invoked. */
+ const void *Cookie);
/*!
@@ -1383,19 +1394,19 @@ EXPORT_SPEC int UpnpGetServiceVarStatusAsync(
* complete this operation.
*/
EXPORT_SPEC int UpnpSendAction(
- /*! The handle of the control point sending the action. */
- IN UpnpClient_Handle Hnd,
- /*! The action URL of the service. */
- IN const char *ActionURL,
- /*! The type of the service. */
- IN const char *ServiceType,
- /*! This parameter is ignored and must be \c NULL. */
- IN const char *DevUDN,
- /*! The DOM document for the action. */
- IN IXML_Document *Action,
- /*! The DOM document for the response to the action. The SDK allocates
+ /*! [in] The handle of the control point sending the action. */
+ UpnpClient_Handle Hnd,
+ /*! [in] The action URL of the service. */
+ const char *ActionURL,
+ /*! [in] The type of the service. */
+ const char *ServiceType,
+ /*! [in] This parameter is ignored and must be \c NULL. */
+ const char *DevUDN,
+ /*! [in] The DOM document for the action. */
+ IXML_Document *Action,
+ /*! [out] The DOM document for the response to the action. The SDK allocates
* this document and the caller needs to free it. */
- OUT IXML_Document **RespNode);
+ IXML_Document **RespNode);
/*!
@@ -1422,22 +1433,22 @@ EXPORT_SPEC int UpnpSendAction(
* complete this operation.
*/
EXPORT_SPEC int UpnpSendActionEx(
- /*! The handle of the control point sending the action. */
- IN UpnpClient_Handle Hnd,
- /*! The action URL of the service. */
- IN const char *ActionURL,
- /*! The type of the service. */
- IN const char *ServiceType,
- /*! This parameter is ignored and must be \c NULL. */
- IN const char *DevUDN,
- /*! The DOM document for the SOAP header. This may be \c NULL if the
+ /*! [in] The handle of the control point sending the action. */
+ UpnpClient_Handle Hnd,
+ /*! [in] The action URL of the service. */
+ const char *ActionURL,
+ /*! [in] The type of the service. */
+ const char *ServiceType,
+ /*! [in] This parameter is ignored and must be \c NULL. */
+ const char *DevUDN,
+ /*! [in] The DOM document for the SOAP header. This may be \c NULL if the
* header is not required. */
- IN IXML_Document *Header,
- /*! The DOM document for the action. */
- IN IXML_Document *Action,
- /*! The DOM document for the response to the action. The SDK allocates
+ IXML_Document *Header,
+ /*! [in] The DOM document for the action. */
+ IXML_Document *Action,
+ /*! [out] The DOM document for the response to the action. The SDK allocates
* this document and the caller needs to free it. */
- OUT IXML_Document **RespNode);
+ IXML_Document **RespNode);
/*!
@@ -1462,22 +1473,22 @@ EXPORT_SPEC int UpnpSendActionEx(
* complete this operation.
*/
EXPORT_SPEC int UpnpSendActionAsync(
- /*! The handle of the control point sending the action. */
- IN UpnpClient_Handle Hnd,
- /*! The action URL of the service. */
- IN const char *ActionURL,
- /*! The type of the service. */
- IN const char *ServiceType,
- /*! This parameter is ignored and must be \c NULL. */
- IN const char *DevUDN,
- /*! The DOM document for the action to perform on this device. */
- IN IXML_Document *Action,
- /*! Pointer to a callback function to be invoked when the operation
+ /*! [in] The handle of the control point sending the action. */
+ UpnpClient_Handle Hnd,
+ /*! [in] The action URL of the service. */
+ const char *ActionURL,
+ /*! [in] The type of the service. */
+ const char *ServiceType,
+ /*! [in] This parameter is ignored and must be \c NULL. */
+ const char *DevUDN,
+ /*! [in] The DOM document for the action to perform on this device. */
+ IXML_Document *Action,
+ /*! [in] Pointer to a callback function to be invoked when the operation
* completes. */
- IN Upnp_FunPtr Fun,
- /*! Pointer to user data that to be passed to the callback when
+ Upnp_FunPtr Fun,
+ /*! [in] Pointer to user data that to be passed to the callback when
* invoked. */
- IN const void *Cookie);
+ const void *Cookie);
/*!
@@ -1502,28 +1513,30 @@ EXPORT_SPEC int UpnpSendActionAsync(
* complete this operation.
*/
EXPORT_SPEC int UpnpSendActionExAsync(
- /*! The handle of the control point sending the action. */
- IN UpnpClient_Handle Hnd,
- /*! The action URL of the service. */
- IN const char *ActionURL,
- /*! The type of the service. */
- IN const char *ServiceType,
- /*! This parameter is ignored and must be \c NULL. */
- IN const char *DevUDN,
- /*! The DOM document for the SOAP header. This may be \c NULL if the
+ /*! [in] The handle of the control point sending the action. */
+ UpnpClient_Handle Hnd,
+ /*! [in] The action URL of the service. */
+ const char *ActionURL,
+ /*! [in] The type of the service. */
+ const char *ServiceType,
+ /*! [in] This parameter is ignored and must be \c NULL. */
+ const char *DevUDN,
+ /*! [in] The DOM document for the SOAP header. This may be \c NULL if the
* header is not required. */
- IN IXML_Document *Header,
- /*! The DOM document for the action to perform on this device. */
- IN IXML_Document *Action,
- /*! Pointer to a callback function to be invoked when the operation
+ IXML_Document *Header,
+ /*! [in] The DOM document for the action to perform on this device. */
+ IXML_Document *Action,
+ /*! [in] Pointer to a callback function to be invoked when the operation
* completes. */
- IN Upnp_FunPtr Fun,
- /*! Pointer to user data that to be passed to the callback when
+ Upnp_FunPtr Fun,
+ /*! [in] Pointer to user data that to be passed to the callback when
* invoked. */
- IN const void *Cookie);
+ const void *Cookie);
+
/*! @} Control */
+
/******************************************************************************
******************************************************************************
* *
@@ -1564,20 +1577,20 @@ EXPORT_SPEC int UpnpSendActionExAsync(
* complete this operation.
*/
EXPORT_SPEC int UpnpAcceptSubscription(
- /*! The handle of the device. */
- IN UpnpDevice_Handle Hnd,
- /*! The device ID of the subdevice of the service generating the event. */
- IN const char *DevID,
- /*! The unique service identifier of the service generating the event. */
- IN const char *ServID,
- /*! Pointer to an array of event variables. */
- IN const char **VarName,
- /*! Pointer to an array of values for the event variables. */
- IN const char **NewVal,
- /*! The number of event variables in \b VarName. */
- IN int cVariables,
- /*! The subscription ID of the newly registered control point. */
- IN const Upnp_SID SubsId);
+ /*! [in] The handle of the device. */
+ UpnpDevice_Handle Hnd,
+ /*! [in] The device ID of the subdevice of the service generating the event. */
+ const char *DevID,
+ /*! [in] The unique service identifier of the service generating the event. */
+ const char *ServID,
+ /*! [in] Pointer to an array of event variables. */
+ const char **VarName,
+ /*! [in] Pointer to an array of values for the event variables. */
+ const char **NewVal,
+ /*! [in] The number of event variables in \b VarName. */
+ int cVariables,
+ /*! [in] The subscription ID of the newly registered control point. */
+ const Upnp_SID SubsId);
/*!
@@ -1604,18 +1617,18 @@ EXPORT_SPEC int UpnpAcceptSubscription(
* complete this operation.
*/
EXPORT_SPEC int UpnpAcceptSubscriptionExt(
- /*! The handle of the device. */
- IN UpnpDevice_Handle Hnd,
- /*! The device ID of the subdevice of the service generating the event. */
- IN const char *DevID,
- /*! The unique service identifier of the service generating the event. */
- IN const char *ServID,
- /*! The DOM document for the property set. Property set documents must
+ /*! [in] The handle of the device. */
+ UpnpDevice_Handle Hnd,
+ /*! [in] The device ID of the subdevice of the service generating the event. */
+ const char *DevID,
+ /*! [in] The unique service identifier of the service generating the event. */
+ const char *ServID,
+ /*! [in] The DOM document for the property set. Property set documents must
* conform to the XML schema defined in section 4.3 of the Universal
* Plug and Play Device Architecture specification. */
- IN IXML_Document *PropSet,
- /*! The subscription ID of the newly registered control point. */
- IN Upnp_SID SubsId);
+ IXML_Document *PropSet,
+ /*! [in] The subscription ID of the newly registered control point. */
+ Upnp_SID SubsId);
/*!
@@ -1640,18 +1653,18 @@ EXPORT_SPEC int UpnpAcceptSubscriptionExt(
* complete this operation.
*/
EXPORT_SPEC int UpnpNotify(
- /*! The handle to the device sending the event. */
- IN UpnpDevice_Handle,
- /*! The device ID of the subdevice of the service generating the event. */
- IN const char *DevID,
- /*! The unique identifier of the service generating the event. */
- IN const char *ServID,
- /*! Pointer to an array of variables that have changed. */
- IN const char **VarName,
- /*! Pointer to an array of new values for those variables. */
- IN const char **NewVal,
- /*! The count of variables included in this notification. */
- IN int cVariables);
+ /*! [in] The handle to the device sending the event. */
+ UpnpDevice_Handle,
+ /*! [in] The device ID of the subdevice of the service generating the event. */
+ const char *DevID,
+ /*! [in] The unique identifier of the service generating the event. */
+ const char *ServID,
+ /*! [in] Pointer to an array of variables that have changed. */
+ const char **VarName,
+ /*! [in] Pointer to an array of new values for those variables. */
+ const char **NewVal,
+ /*! [in] The count of variables included in this notification. */
+ int cVariables);
/*!
@@ -1676,16 +1689,16 @@ EXPORT_SPEC int UpnpNotify(
* complete this operation.
*/
EXPORT_SPEC int UpnpNotifyExt(
- /*! The handle to the device sending the event. */
- IN UpnpDevice_Handle,
- /*! The device ID of the subdevice of the service generating the event. */
- IN const char *DevID,
- /*! The unique identifier of the service generating the event. */
- IN const char *ServID,
- /*! The DOM document for the property set. Property set documents must
+ /*! [in] The handle to the device sending the event. */
+ UpnpDevice_Handle,
+ /*! [in] The device ID of the subdevice of the service generating the event. */
+ const char *DevID,
+ /*! [in] The unique identifier of the service generating the event. */
+ const char *ServID,
+ /*! [in] The DOM document for the property set. Property set documents must
* conform to the XML schema defined in section 4.3 of the Universal
* Plug and Play Device Architecture specification. */
- IN IXML_Document *PropSet);
+ IXML_Document *PropSet);
/*!
@@ -1717,13 +1730,13 @@ EXPORT_SPEC int UpnpNotifyExt(
* complete this operation.
*/
EXPORT_SPEC int UpnpRenewSubscription(
- /*! The handle of the control point that is renewing the subscription. */
- IN UpnpClient_Handle Hnd,
- /*! Pointer to a variable containing the requested subscription time.
+ /*! [in] The handle of the control point that is renewing the subscription. */
+ UpnpClient_Handle Hnd,
+ /*! [in,out] Pointer to a variable containing the requested subscription time.
* Upon return, it contains the actual renewal time. */
- INOUT int *TimeOut,
- /*! The ID for the subscription to renew. */
- IN const Upnp_SID SubsId);
+ int *TimeOut,
+ /*! [in] The ID for the subscription to renew. */
+ const Upnp_SID SubsId);
/*!
@@ -1774,18 +1787,18 @@ EXPORT_SPEC int UpnpRenewSubscription(
* UpnpEventSubscribe.ErrCode field as part of the callback).
*/
EXPORT_SPEC int UpnpRenewSubscriptionAsync(
- /*! The handle of the control point that is renewing the subscription. */
- IN UpnpClient_Handle Hnd,
- /*! The requested subscription time. The actual timeout value is
+ /*! [in] The handle of the control point that is renewing the subscription. */
+ UpnpClient_Handle Hnd,
+ /*! [in] The requested subscription time. The actual timeout value is
* returned when the callback function is called. */
- IN int TimeOut,
- /*! The ID for the subscription to renew. */
- IN Upnp_SID SubsId,
- /*! Pointer to a callback function to be invoked when the renewal is
+ int TimeOut,
+ /*! [in] The ID for the subscription to renew. */
+ Upnp_SID SubsId,
+ /*! [in] Pointer to a callback function to be invoked when the renewal is
* complete. */
- IN Upnp_FunPtr Fun,
- /*! Pointer to user data passed to the callback function when invoked. */
- IN const void *Cookie);
+ Upnp_FunPtr Fun,
+ /*! [in] Pointer to user data passed to the callback function when invoked. */
+ const void *Cookie);
/*!
@@ -1804,9 +1817,9 @@ EXPORT_SPEC int UpnpRenewSubscriptionAsync(
EXPORT_SPEC int UpnpSetMaxSubscriptions(
/*! The handle of the device for which the maximum number of
* subscriptions is being set. */
- IN UpnpDevice_Handle Hnd,
+ UpnpDevice_Handle Hnd,
/*! The maximum number of subscriptions to be allowed per service. */
- IN int MaxSubscriptions);
+ int MaxSubscriptions);
/*!
@@ -1826,9 +1839,9 @@ EXPORT_SPEC int UpnpSetMaxSubscriptions(
EXPORT_SPEC int UpnpSetMaxSubscriptionTimeOut(
/*! The handle of the device for which the maximum subscription
* time-out is being set. */
- IN UpnpDevice_Handle Hnd,
+ UpnpDevice_Handle Hnd,
/*! The maximum subscription time-out to be accepted. */
- IN int MaxSubscriptionTimeOut);
+ int MaxSubscriptionTimeOut);
/*!
@@ -1861,16 +1874,16 @@ EXPORT_SPEC int UpnpSetMaxSubscriptionTimeOut(
* complete this operation.
*/
EXPORT_SPEC int UpnpSubscribe(
- /*! The handle of the control point. */
- IN UpnpClient_Handle Hnd,
- /*! The URL of the service to subscribe to. */
- IN const char *PublisherUrl,
- /*! Pointer to a variable containing the requested subscription time.
+ /*! [in] The handle of the control point. */
+ UpnpClient_Handle Hnd,
+ /*! [in] The URL of the service to subscribe to. */
+ const char *PublisherUrl,
+ /*! [in,out]Pointer to a variable containing the requested subscription time.
* Upon return, it contains the actual subscription time returned from
* the service. */
- INOUT int *TimeOut,
- /*! Pointer to a variable to receive the subscription ID (SID). */
- OUT Upnp_SID SubsId);
+ int *TimeOut,
+ /*! [out] Pointer to a variable to receive the subscription ID (SID). */
+ Upnp_SID SubsId);
/*!
@@ -1923,16 +1936,16 @@ EXPORT_SPEC int UpnpSubscribe(
*/
EXPORT_SPEC int UpnpSubscribeAsync(
/*! The handle of the control point that is subscribing. */
- IN UpnpClient_Handle Hnd,
+ UpnpClient_Handle Hnd,
/*! The URL of the service to subscribe to. */
- IN const char *PublisherUrl,
+ const char *PublisherUrl,
/*! The requested subscription time. Upon return, it contains the actual
* subscription time returned from the service. */
- IN int TimeOut,
+ int TimeOut,
/*! Pointer to the callback function for this subscribe request. */
- IN Upnp_FunPtr Fun,
+ Upnp_FunPtr Fun,
/*! A user data value passed to the callback function when invoked. */
- IN const void *Cookie);
+ const void *Cookie);
/*!
@@ -1965,10 +1978,10 @@ EXPORT_SPEC int UpnpSubscribeAsync(
* complete this operation.
*/
EXPORT_SPEC int UpnpUnSubscribe(
- /*! The handle of the subscribed control point. */
- IN UpnpClient_Handle Hnd,
- /*! The ID returned when the control point subscribed to the service. */
- IN const Upnp_SID SubsId);
+ /*! [in] The handle of the subscribed control point. */
+ UpnpClient_Handle Hnd,
+ /*! [in] The ID returned when the control point subscribed to the service. */
+ const Upnp_SID SubsId);
/*!
@@ -2018,15 +2031,15 @@ EXPORT_SPEC int UpnpUnSubscribe(
* UpnpEventSubscribe.ErrCode field as part of the callback).
*/
EXPORT_SPEC int UpnpUnSubscribeAsync(
- /*! The handle of the subscribed control point. */
- IN UpnpClient_Handle Hnd,
- /*! The ID returned when the control point subscribed to the service. */
- IN Upnp_SID SubsId,
- /*! Pointer to a callback function to be called when the operation is
+ /*! [in] The handle of the subscribed control point. */
+ UpnpClient_Handle Hnd,
+ /*! [in] The ID returned when the control point subscribed to the service. */
+ Upnp_SID SubsId,
+ /*! [in] Pointer to a callback function to be called when the operation is
* complete. */
- IN Upnp_FunPtr Fun,
- /*! Pointer to user data to pass to the callback function when invoked. */
- IN const void *Cookie);
+ Upnp_FunPtr Fun,
+ /*! [in] Pointer to user data to pass to the callback function when invoked. */
+ const void *Cookie);
/*! @} Eventing */
@@ -2470,10 +2483,10 @@ typedef void *UpnpWebFileHandle;
* \brief Get-info callback function prototype.
*/
typedef int (*VDCallback_GetInfo)(
- /*! The name of the file to query. */
- IN const char *filename,
- /*! Pointer to a structure to store the information on the file. */
- OUT UpnpFileInfo *info);
+ /*! [in] The name of the file to query. */
+ const char *filename,
+ /*! [out] Pointer to a structure to store the information on the file. */
+ UpnpFileInfo *info);
/*!
* \brief Sets the get_info callback function to be used to access a virtual
@@ -2490,11 +2503,11 @@ EXPORT_SPEC int UpnpVirtualDir_set_GetInfoCallback(VDCallback_GetInfo callback);
* \brief Open callback function prototype.
*/
typedef UpnpWebFileHandle (*VDCallback_Open)(
- /*! The name of the file to open. */
- IN const char *filename,
- /*! The mode in which to open the file.
+ /*! [in] The name of the file to open. */
+ const char *filename,
+ /*! [in] The mode in which to open the file.
* Valid values are \c UPNP_READ or \c UPNP_WRITE. */
- IN enum UpnpOpenFileMode Mode);
+ enum UpnpOpenFileMode Mode);
/*!
@@ -2512,12 +2525,12 @@ EXPORT_SPEC int UpnpVirtualDir_set_OpenCallback(VDCallback_Open callback);
* \brief Read callback function prototype.
*/
typedef int (*VDCallback_Read)(
- /*! The handle of the file to read. */
- IN UpnpWebFileHandle fileHnd,
- /*! The buffer in which to place the data. */
- OUT char *buf,
- /*! The size of the buffer (i.e. the number of bytes to read). */
- IN size_t buflen);
+ /*! [in] The handle of the file to read. */
+ UpnpWebFileHandle fileHnd,
+ /*! [out] The buffer in which to place the data. */
+ char *buf,
+ /*! [in] The size of the buffer (i.e. the number of bytes to read). */
+ size_t buflen);
/*!
@@ -2535,12 +2548,12 @@ EXPORT_SPEC int UpnpVirtualDir_set_ReadCallback(VDCallback_Read callback);
* \brief Write callback function prototype.
*/
typedef int (*VDCallback_Write)(
- /*! The handle of the file to write. */
- IN UpnpWebFileHandle fileHnd,
- /*! The buffer with the bytes to write. */
- IN char *buf,
- /*! The number of bytes to write. */
- IN size_t buflen);
+ /*! [in] The handle of the file to write. */
+ UpnpWebFileHandle fileHnd,
+ /*! [in] The buffer with the bytes to write. */
+ char *buf,
+ /*! [in] The number of bytes to write. */
+ size_t buflen);
/*!
@@ -2558,17 +2571,17 @@ EXPORT_SPEC int UpnpVirtualDir_set_WriteCallback(VDCallback_Write callback);
* \brief Seek callback function prototype.
*/
typedef int (*VDCallback_Seek) (
- /*! The handle of the file to move the file pointer. */
- IN UpnpWebFileHandle fileHnd,
- /*! The number of bytes to move in the file. Positive values
+ /*! [in] The handle of the file to move the file pointer. */
+ UpnpWebFileHandle fileHnd,
+ /*! [in] The number of bytes to move in the file. Positive values
* move foward and negative values move backward. Note that
* this must be positive if the \b origin is \c SEEK_SET. */
- IN off_t offset,
- /*! The position to move relative to. It can be \c SEEK_CUR
+ off_t offset,
+ /*! [in] The position to move relative to. It can be \c SEEK_CUR
* to move relative to the current position, \c SEEK_END to
* move relative to the end of the file, or \c SEEK_SET to
* specify an absolute offset. */
- IN int origin);
+ int origin);
/*!
@@ -2586,8 +2599,8 @@ EXPORT_SPEC int UpnpVirtualDir_set_SeekCallback(VDCallback_Seek callback);
* \brief Close callback function prototype.
*/
typedef int (*VDCallback_Close)(
- /*! The handle of the file to close. */
- IN UpnpWebFileHandle fileHnd);
+ /*! [in] The handle of the file to close. */
+ UpnpWebFileHandle fileHnd);
/*!
diff --git a/upnp/inc/upnpdebug.h b/upnp/inc/upnpdebug.h
index 5c8ecaa..15866d1 100644
--- a/upnp/inc/upnpdebug.h
+++ b/upnp/inc/upnpdebug.h
@@ -101,50 +101,36 @@ typedef enum Upnp_LogLevel_e {
-/***************************************************************************
- * Function : UpnpInitLog
+/*!
+ * \brief Initialize the log files.
*
- * Parameters: void
- *
- * Description:
- * This functions initializes the log files
- *
- * Returns: int
- * -1 : If fails
- * UPNP_E_SUCCESS : if success
- ***************************************************************************/
+ * \return -1 if fails or UPNP_E_SUCCESS if succeeds.
+ */
#ifdef DEBUG
int UpnpInitLog();
#else
-static UPNP_INLINE int UpnpInitLog() { return UPNP_E_SUCCESS; }
+static UPNP_INLINE int UpnpInitLog()
+{
+ return UPNP_E_SUCCESS;
+}
#endif
-/***************************************************************************
- * Function : UpnpSetLogLevel
- *
- * Parameters: Upnp_LogLevel log_level
- *
- * Description:
- * This functions set the log level (see \c Upnp_LogLevel)
- * Returns: void
- ***************************************************************************/
+/*!
+ * \brief Set the log level (see \c Upnp_LogLevel).
+ */
#ifdef DEBUG
-void UpnpSetLogLevel(Upnp_LogLevel log_level);
+void UpnpSetLogLevel(
+ /*! [in] Log level. */
+ Upnp_LogLevel log_level);
#else
static UPNP_INLINE void UpnpSetLogLevel(Upnp_LogLevel log_level) {}
#endif
-/***************************************************************************
- * Function : UpnpCloseLog
- *
- * Parameters: void
- *
- * Description:
- * This functions closes the log files
- * Returns: void
- ***************************************************************************/
+/*!
+ * \brief Closes the log files.
+ */
#ifdef DEBUG
void UpnpCloseLog();
#else
@@ -152,23 +138,14 @@ static UPNP_INLINE void UpnpCloseLog() {}
#endif
-/***************************************************************************
- * Function : UpnpSetLogFileNames
- *
- * Parameters:
- * IN const char* ErrFileName: name of the error file
- * IN const char *InfoFileName: name of the information file
- * IN int size: Size of the buffer
- * IN int starLength: This parameter provides the width of the banner
- *
- * Description:
- * This functions takes the buffer and writes the buffer in the file as
- * per the requested banner
- * Returns: void
- ***************************************************************************/
+/*!
+ * \brief Set the name for error and information files, respectively.
+ */
#ifdef DEBUG
void UpnpSetLogFileNames(
+ /*! [in] Name of the error file. */
const char *ErrFileName,
+ /*! [in] Name of the information file. */
const char *InfoFileName);
#else
static UPNP_INLINE void UpnpSetLogFileNames(
@@ -177,24 +154,20 @@ static UPNP_INLINE void UpnpSetLogFileNames(
#endif
-/***************************************************************************
- * Function : UpnpGetDebugFile
- *
- * Parameters:
- * IN Upnp_LogLevel DLevel: The level of the debug logging. It will decide
- * whether debug statement will go to standard output,
- * or any of the log files.
- * IN Dbg_Module Module: debug will go in the name of this module
- *
- * Description:
- * This function checks if the module is turned on for debug
- * and returns the file descriptor corresponding to the debug level
- * Returns: FILE *
- * NULL : if the module is turn off for debug
- * else returns the right file descriptor
- ***************************************************************************/
+/*!
+ * \brief Check if the module is turned on for debug and returns the file
+ * descriptor corresponding to the debug level
+ *
+ * \return NULL if the module is turn off for debug otheriwse returns the
+ * right file descriptor.
+ */
#ifdef DEBUG
-FILE *UpnpGetDebugFile(Upnp_LogLevel level, Dbg_Module module);
+FILE *UpnpGetDebugFile(
+ /*! [in] The level of the debug logging. It will decide whether debug
+ * statement will go to standard output, or any of the log files. */
+ Upnp_LogLevel level,
+ /*! [in] debug will go in the name of this module. */
+ Dbg_Module module);
#else
static UPNP_INLINE FILE *UpnpGetDebugFile(Upnp_LogLevel level, Dbg_Module module)
{
@@ -203,36 +176,32 @@ static UPNP_INLINE FILE *UpnpGetDebugFile(Upnp_LogLevel level, Dbg_Module module
#endif
-/***************************************************************************
- * Function : DebugAtThisLevel
- *
- * Parameters:
- * IN Upnp_LogLevel DLevel: The level of the debug logging. It will decide
- * whether debug statement will go to standard output,
- * or any of the log files.
- * IN Dbg_Module Module: debug will go in the name of this module
- *
- * Description:
- * This functions returns true if debug output should be done in this
- * module.
+/*!
+ * \brief Returns true if debug output should be done in this module.
*
- * Returns: int
- ***************************************************************************/
+ * \return Nonzero value if true, zero if false.
+ */
#ifdef DEBUG
int DebugAtThisLevel(
- IN Upnp_LogLevel DLevel,
- IN Dbg_Module Module);
+ /*! [in] The level of the debug logging. It will decide whether debug
+ * statement will go to standard output, or any of the log files. */
+ Upnp_LogLevel DLevel,
+ /*! [in] Debug will go in the name of this module. */
+ Dbg_Module Module);
#else
static UPNP_INLINE int DebugAtThisLevel(
- IN Upnp_LogLevel DLevel,
- IN Dbg_Module Module) { return 0; }
+ Upnp_LogLevel DLevel,
+ Dbg_Module Module)
+{
+ return 0;
+}
#endif
/*!
* \brief Prints the debug statement either on the standard output or log file
* along with the information from where this debug statement is coming.
- **/
+ */
#ifdef DEBUG
void UpnpPrintf(
/*! [in] The level of the debug logging. It will decide whether debug
@@ -261,28 +230,23 @@ static UPNP_INLINE void UpnpPrintf(
const char* DbgFileName,
int DbgLineNo,
const char* FmtStr,
- ...) {}
+ ...)
+{
+}
#endif /* DEBUG */
-/***************************************************************************
- * Function : UpnpDisplayFileAndLine
- *
- * Parameters:
- * IN FILE *fd: File descriptor where line number and file name will be
- * written
- * IN char *DbgFileName: Name of the file
- * IN int DbgLineNo : Line number of the file
- *
- * Description:
- * This function writes the file name and file number from where
- * debug statement is coming to the log file
- * Returns: void
- ***************************************************************************/
+/*!
+ * \brief Writes the file name and file number from where debug statement is
+ * coming to the log file.
+ */
#ifdef DEBUG
void UpnpDisplayFileAndLine(
+ /*! [in] File descriptor where line number and file name will be written. */
FILE *fd,
+ /*! [in] Name of the file. */
const char *DbgFileName,
+ /*! [in] Line number of the file. */
int DbgLineNo);
#else
static UPNP_INLINE void UpnpDisplayFileAndLine(
@@ -292,18 +256,18 @@ static UPNP_INLINE void UpnpDisplayFileAndLine(
#endif
-/*! \brief Writes the buffer in the file as per the requested banner
- *
- * \param [in] fd file descriptor where the banner will be written
- * \param [in] lines: The buffer that will be written
- * \param [in] size: Size of the buffer
- * \param [in] starlength: This parameter provides the width of the banner
+/*!
+ * \brief Writes the buffer in the file as per the requested banner
*/
#ifdef DEBUG
void UpnpDisplayBanner(
+ /*! [in] file descriptor where the banner will be written. */
FILE *fd,
+ /*! [in] The buffer that will be written. */
const char **lines,
+ /*! [in] Size of the buffer. */
size_t size,
+ /*! [in] This parameter provides the width of the banner. */
int starlength);
#else
static UPNP_INLINE void UpnpDisplayBanner(
@@ -314,27 +278,27 @@ static UPNP_INLINE void UpnpDisplayBanner(
#endif
-/*! \brief Prints thread pool statistics.
- *
- * \param [in] tp The thread pool
- * \param [in] DbgFileName the file name that called this function, use the
- * macro __FILE__.
- * \param [in] DbgLineNo the line number that the function was called, use
- * the macro __LINE__.
- * \param [in] msg message.
+/*!
+ * \brief Prints thread pool statistics.
*/
#ifdef DEBUG
void PrintThreadPoolStats(
+ /* [in] The thread pool. */
ThreadPool *tp,
+ /* [in] The file name that called this function, use the macro __FILE__. */
const char *DbgFileName,
+ /* [in] The line number that the function was called, use the macro __LINE__. */
int DbgLineNo,
+ /* [in] The message. */
const char *msg);
#else
static UPNP_INLINE void PrintThreadPoolStats(
ThreadPool *tp,
const char *DbgFileName,
int DbgLineNo,
- const char *msg) {}
+ const char *msg)
+{
+}
#endif
diff --git a/upnp/src/api/upnpapi.c b/upnp/src/api/upnpapi.c
index 645229d..54f281a 100644
--- a/upnp/src/api/upnpapi.c
+++ b/upnp/src/api/upnpapi.c
@@ -95,21 +95,21 @@
#endif // INTERNAL_WEB_SERVER
-// This structure is for virtual directory callbacks
+/*! This structure is for virtual directory callbacks */
struct VirtualDirCallbacks virtualDirCallback;
-//
+/*! */
virtualDirList *pVirtualDirList;
-// Mutex to synchronize the subscription handling at the client side
#ifdef INCLUDE_CLIENT_APIS
+/*! Mutex to synchronize the subscription handling at the client side */
ithread_mutex_t GlobalClientSubscribeMutex;
#endif /* INCLUDE_CLIENT_APIS */
-// rwlock to synchronize handles (root device or control point handle)
+/*! rwlock to synchronize handles (root device or control point handle) */
ithread_rwlock_t GlobalHndRWLock;
-// Mutex to synchronize the uuid creation process
+/*! Mutex to synchronize the uuid creation process */
ithread_mutex_t gUUIDMutex;
ithread_mutex_t gSDKInitMutex = PTHREAD_MUTEX_INITIALIZER;
@@ -120,65 +120,74 @@ ThreadPool gSendThreadPool;
ThreadPool gRecvThreadPool;
ThreadPool gMiniServerThreadPool;
-// Flag to indicate the state of web server
+/*! Flag to indicate the state of web server */
WebServerState bWebServerState = WEB_SERVER_DISABLED;
-// Static buffer to contain interface name. (extern'ed in upnp.h)
+/*! Static buffer to contain interface name. (extern'ed in upnp.h) */
char gIF_NAME[LINE_SIZE] = { '\0' };
-// Static buffer to contain interface IPv4 address. (extern'ed in upnp.h)
+/*! Static buffer to contain interface IPv4 address. (extern'ed in upnp.h) */
char gIF_IPV4[22]/* INET_ADDRSTRLEN*/ = { '\0' };
-// Static buffer to contain interface IPv6 address. (extern'ed in upnp.h)
+/*! Static buffer to contain interface IPv6 address. (extern'ed in upnp.h) */
char gIF_IPV6[65]/* INET6_ADDRSTRLEN*/ = { '\0' };
-// Contains interface index. (extern'ed in upnp.h)
+/*! Contains interface index. (extern'ed in upnp.h) */
int gIF_INDEX = -1;
-// local IPv4 and IPv6 ports for the mini-server
+/*! local IPv4 and IPv6 ports for the mini-server */
unsigned short LOCAL_PORT_V4;
unsigned short LOCAL_PORT_V6;
-// UPnP device and control point handle table
+/*! UPnP device and control point handle table */
void *HandleTable[NUM_HANDLE];
-// a local dir which serves as webserver root
+/*! a local dir which serves as webserver root */
extern membuffer gDocumentRootDir;
-// Maximum content-length that the SDK will process on an incoming packet.
-// Content-Length exceeding this size will be not processed and error 413
-// (HTTP Error Code) will be returned to the remote end point.
-size_t g_maxContentLength = DEFAULT_SOAP_CONTENT_LENGTH; // in bytes
+/*! Maximum content-length (in bytes) that the SDK will process on an incoming
+ * packet. Content-Length exceeding this size will be not processed and
+ * error 413 (HTTP Error Code) will be returned to the remote end point. */
+size_t g_maxContentLength = DEFAULT_SOAP_CONTENT_LENGTH;
-// Global variable to denote the state of Upnp SDK
-// = 0 if uninitialized, = 1 if initialized.
+/*! Global variable to denote the state of Upnp SDK == 0 if uninitialized,
+ * == 1 if initialized. */
int UpnpSdkInit = 0;
-// Global variable to denote the state of Upnp SDK client registration.
-// = 0 if unregistered, = 1 if registered.
+/*! Global variable to denote the state of Upnp SDK client registration.
+ * == 0 if unregistered, == 1 if registered. */
int UpnpSdkClientRegistered = 0;
-// Global variable to denote the state of Upnp SDK IPv4 device registration.
-// = 0 if unregistered, = 1 if registered.
+/*! Global variable to denote the state of Upnp SDK IPv4 device registration.
+ * == 0 if unregistered, == 1 if registered. */
int UpnpSdkDeviceRegisteredV4 = 0;
-// Global variable to denote the state of Upnp SDK IPv6 device registration.
-// = 0 if unregistered, = 1 if registered.
+/*! Global variable to denote the state of Upnp SDK IPv6 device registration.
+ * == 0 if unregistered, == 1 if registered. */
int UpnpSdkDeviceregisteredV6 = 0;
-// Global variable used in discovery notifications.
+/*! Global variable used in discovery notifications. */
Upnp_SID gUpnpSdkNLSuuid;
-// FIXME Put this declaration in the proper header file
+/*!
+ * \brief Fills the sockadr_in with miniserver information.
+ */
static int GetDescDocumentAndURL(
- IN Upnp_DescType descriptionType,
- IN char *description,
- IN unsigned int bufferLen,
- IN int config_baseURL,
- IN int AddressFamily,
- OUT IXML_Document ** xmlDoc,
- OUT char descURL[LINE_SIZE] );
+ /* [in] pointer to server address structure. */
+ Upnp_DescType descriptionType,
+ /* [in] . */
+ char *description,
+ /* [in] . */
+ unsigned int bufferLen,
+ /* [in] . */
+ int config_baseURL,
+ /* [in] . */
+ int AddressFamily,
+ /* [out] . */
+ IXML_Document **xmlDoc,
+ /* [out] . */
+ char *descURL);
int UpnpInit(const char *HostIP, unsigned short DestPort)
@@ -978,23 +987,16 @@ int UpnpUnRegisterClient(UpnpClient_Handle Hnd)
#ifdef INCLUDE_DEVICE_APIS
#ifdef INTERNAL_WEB_SERVER
-/**************************************************************************
- * Function: GetNameForAlias
+/*!
+ * \brief Determines alias for given name which is a file name or URL.
*
- * Parameters:
- * IN char *name: name of the file
- * OUT char** alias: pointer to alias string
- *
- * Description:
- * This function determines alias for given name which is a file name
- * or URL.
- *
- * Return Values:
- * UPNP_E_SUCCESS on success, nonzero on failure.
- ***************************************************************************/
-static int
-GetNameForAlias( IN char *name,
- OUT char **alias )
+ * \return UPNP_E_SUCCESS on success, nonzero on failure.
+ */
+static int GetNameForAlias(
+ /*! [in] Name of the file. */
+ char *name,
+ /*! [out] Pointer to alias string. */
+ char **alias)
{
char *ext;
char *al;
@@ -1014,21 +1016,12 @@ GetNameForAlias( IN char *name,
return UPNP_E_SUCCESS;
}
-/**************************************************************************
- * Function: get_server_addr
- *
- * Parameters:
- * OUT struct sockaddr* serverAddr: pointer to server address
- * structure
- *
- * Description:
- * This function fills the sockadr with IPv4 miniserver information.
- *
- * Return Values: VOID
- *
- ***************************************************************************/
-static void
-get_server_addr( OUT struct sockaddr *serverAddr )
+/*!
+ * \brief Fill the sockadr with IPv4 miniserver information.
+ */
+static void get_server_addr(
+ /*! [out] pointer to server address structure. */
+ struct sockaddr *serverAddr)
{
struct sockaddr_in* sa4 = (struct sockaddr_in*)serverAddr;
@@ -1039,21 +1032,12 @@ get_server_addr( OUT struct sockaddr *serverAddr )
sa4->sin_port = htons( LOCAL_PORT_V4 );
}
-/**************************************************************************
- * Function: get_server_addr6
- *
- * Parameters:
- * OUT struct sockaddr* serverAddr: pointer to server address
- * structure
- *
- * Description:
- * This function fills the sockadr with IPv6 miniserver information.
- *
- * Return Values: VOID
- *
- ***************************************************************************/
-static void
-get_server_addr6( OUT struct sockaddr *serverAddr )
+/*!
+ * \brief Fill the sockadr with IPv6 miniserver information.
+ */
+static void get_server_addr6(
+ /*! [out] pointer to server address structure. */
+ struct sockaddr *serverAddr)
{
struct sockaddr_in6* sa6 = (struct sockaddr_in6*)serverAddr;
@@ -1064,203 +1048,162 @@ get_server_addr6( OUT struct sockaddr *serverAddr )
sa6->sin6_port = htons( LOCAL_PORT_V6 );
}
-/**************************************************************************
- * Function: GetDescDocumentAndURL ( In the case of device)
- *
- * Parameters:
- * IN Upnp_DescType descriptionType: pointer to server address
- * structure
- * IN char* description:
- * IN unsigned int bufferLen:
- * IN int config_baseURL:
- * IN int AddressFamily:
- * OUT IXML_Document **xmlDoc:
- * OUT char descURL[LINE_SIZE]:
- *
- * Description:
- * This function fills the sockadr_in with miniserver information.
- *
- * Return Values: VOID
- *
- ***************************************************************************/
-static int
-GetDescDocumentAndURL( IN Upnp_DescType descriptionType,
- IN char *description,
- IN unsigned int bufferLen,
- IN int config_baseURL,
- IN int AddressFamily,
- OUT IXML_Document ** xmlDoc,
- OUT char descURL[LINE_SIZE] )
+
+static int GetDescDocumentAndURL(
+ Upnp_DescType descriptionType,
+ char *description,
+ unsigned int bufferLen,
+ int config_baseURL,
+ int AddressFamily,
+ IXML_Document **xmlDoc,
+ char *descURL)
{
- int retVal = 0;
- char *membuf = NULL;
- char aliasStr[LINE_SIZE];
- char *temp_str = NULL;
- FILE *fp = NULL;
- off_t fileLen;
- size_t num_read;
- time_t last_modified;
- struct stat file_info;
- struct sockaddr_storage serverAddr;
- int rc = UPNP_E_SUCCESS;
+ int retVal = 0;
+ char *membuf = NULL;
+ char aliasStr[LINE_SIZE];
+ char *temp_str = NULL;
+ FILE *fp = NULL;
+ off_t fileLen;
+ size_t num_read;
+ time_t last_modified;
+ struct stat file_info;
+ struct sockaddr_storage serverAddr;
+ int rc = UPNP_E_SUCCESS;
- if( description == NULL ) {
- return UPNP_E_INVALID_PARAM;
- }
- // non-URL description must have configuration specified
- if( descriptionType != UPNPREG_URL_DESC && ( !config_baseURL ) ) {
- return UPNP_E_INVALID_PARAM;
- }
- // get XML doc and last modified time
- if( descriptionType == UPNPREG_URL_DESC ) {
- if( ( retVal =
- UpnpDownloadXmlDoc( description,
- xmlDoc ) ) != UPNP_E_SUCCESS ) {
- return retVal;
- }
- last_modified = time( NULL );
- } else if( descriptionType == UPNPREG_FILENAME_DESC ) {
- retVal = stat( description, &file_info );
- if( retVal == -1 ) {
- return UPNP_E_FILE_NOT_FOUND;
- }
- fileLen = file_info.st_size;
- last_modified = file_info.st_mtime;
+ if (description == NULL) {
+ return UPNP_E_INVALID_PARAM;
+ }
+ /* non-URL description must have configuration specified */
+ if (descriptionType != UPNPREG_URL_DESC && !config_baseURL) {
+ return UPNP_E_INVALID_PARAM;
+ }
+ /* Get XML doc and last modified time */
+ if (descriptionType == UPNPREG_URL_DESC) {
+ retVal = UpnpDownloadXmlDoc(description, xmlDoc);
+ if (retVal != UPNP_E_SUCCESS) {
+ return retVal;
+ }
+ last_modified = time(NULL);
+ } else if (descriptionType == UPNPREG_FILENAME_DESC) {
+ retVal = stat( description, &file_info );
+ if (retVal == -1) {
+ return UPNP_E_FILE_NOT_FOUND;
+ }
+ fileLen = file_info.st_size;
+ last_modified = file_info.st_mtime;
+ fp = fopen(description, "rb");
+ if (fp == NULL) {
+ return UPNP_E_FILE_NOT_FOUND;
+ }
+ membuf = (char *)malloc(fileLen + 1);
+ if (membuf == NULL) {
+ fclose(fp);
+ return UPNP_E_OUTOF_MEMORY;
+ }
+ num_read = fread(membuf, 1, fileLen, fp);
+ if (num_read != fileLen) {
+ fclose(fp);
+ free(membuf);
+ return UPNP_E_FILE_READ_ERROR;
+ }
+ membuf[fileLen] = 0;
+ fclose(fp);
+ rc = ixmlParseBufferEx(membuf, xmlDoc);
+ free(membuf);
+ } else if (descriptionType == UPNPREG_BUF_DESC) {
+ last_modified = time(NULL);
+ rc = ixmlParseBufferEx(description, xmlDoc);
+ } else {
+ return UPNP_E_INVALID_PARAM;
+ }
- if( ( fp = fopen( description, "rb" ) ) == NULL ) {
- return UPNP_E_FILE_NOT_FOUND;
- }
+ if (rc != IXML_SUCCESS && descriptionType != UPNPREG_URL_DESC) {
+ if (rc == IXML_INSUFFICIENT_MEMORY) {
+ return UPNP_E_OUTOF_MEMORY;
+ } else {
+ return UPNP_E_INVALID_DESC;
+ }
+ }
+ /* Determine alias */
+ if (config_baseURL) {
+ if (descriptionType == UPNPREG_BUF_DESC) {
+ strcpy( aliasStr, "description.xml" );
+ } else {
+ /* URL or filename */
+ retVal = GetNameForAlias(description, &temp_str);
+ if (retVal != UPNP_E_SUCCESS) {
+ ixmlDocument_free(*xmlDoc);
+ return retVal;
+ }
+ if (strlen(temp_str) > (LINE_SIZE - 1)) {
+ ixmlDocument_free(*xmlDoc);
+ free(temp_str);
+ return UPNP_E_URL_TOO_BIG;
+ }
+ strcpy(aliasStr, temp_str);
+ }
+ if(AddressFamily == AF_INET) {
+ get_server_addr((struct sockaddr *)&serverAddr);
+ } else {
+ get_server_addr6((struct sockaddr *)&serverAddr);
+ }
- if( ( membuf = ( char * )malloc( fileLen + 1 ) ) == NULL ) {
- fclose( fp );
- return UPNP_E_OUTOF_MEMORY;
- }
+ /* config */
+ retVal = configure_urlbase(*xmlDoc, (struct sockaddr *)&serverAddr,
+ aliasStr, last_modified, descURL);
+ if (retVal != UPNP_E_SUCCESS) {
+ ixmlDocument_free(*xmlDoc);
+ return retVal;
+ }
+ } else {
+ /* Manual */
+ if (strlen(description) > (LINE_SIZE - 1)) {
+ ixmlDocument_free(*xmlDoc);
+ return UPNP_E_URL_TOO_BIG;
+ }
+ strcpy(descURL, description);
+ }
- num_read = fread( membuf, 1, fileLen, fp );
- if( num_read != fileLen ) {
- fclose( fp );
- free( membuf );
- return UPNP_E_FILE_READ_ERROR;
- }
+ assert(*xmlDoc != NULL);
- membuf[fileLen] = 0;
- fclose( fp );
- rc = ixmlParseBufferEx( membuf, xmlDoc );
- free( membuf );
- } else if( descriptionType == UPNPREG_BUF_DESC ) {
- last_modified = time( NULL );
- rc = ixmlParseBufferEx( description, xmlDoc );
- } else {
- return UPNP_E_INVALID_PARAM;
- }
-
- if( rc != IXML_SUCCESS && descriptionType != UPNPREG_URL_DESC ) {
- if( rc == IXML_INSUFFICIENT_MEMORY ) {
- return UPNP_E_OUTOF_MEMORY;
- } else {
- return UPNP_E_INVALID_DESC;
- }
- }
- // determine alias
- if( config_baseURL ) {
- if( descriptionType == UPNPREG_BUF_DESC ) {
- strcpy( aliasStr, "description.xml" );
- } else // URL or filename
- {
- retVal = GetNameForAlias( description, &temp_str );
- if( retVal != UPNP_E_SUCCESS ) {
- ixmlDocument_free( *xmlDoc );
- return retVal;
- }
- if( strlen( temp_str ) > ( LINE_SIZE - 1 ) ) {
- ixmlDocument_free( *xmlDoc );
- free( temp_str );
- return UPNP_E_URL_TOO_BIG;
- }
- strcpy( aliasStr, temp_str );
- }
-
- if(AddressFamily == AF_INET)
- get_server_addr( (struct sockaddr*)&serverAddr );
- else
- get_server_addr6( (struct sockaddr*)&serverAddr );
-
- // config
- retVal = configure_urlbase( *xmlDoc, (struct sockaddr*)&serverAddr,
- aliasStr, last_modified, descURL );
- if( retVal != UPNP_E_SUCCESS ) {
- ixmlDocument_free( *xmlDoc );
- return retVal;
- }
- } else // manual
- {
- if( strlen( description ) > ( LINE_SIZE - 1 ) ) {
- ixmlDocument_free( *xmlDoc );
- return UPNP_E_URL_TOO_BIG;
- }
- strcpy( descURL, description );
- }
-
- assert( *xmlDoc != NULL );
-
- return UPNP_E_SUCCESS;
+ return UPNP_E_SUCCESS;
}
-#else // no web server
-/**************************************************************************
- * Function: GetDescDocumentAndURL ( In the case of control point)
- *
- * Parameters:
- * IN Upnp_DescType descriptionType: pointer to server address
- * structure
- * IN char* description:
- * IN unsigned int bufferLen:
- * IN int config_baseURL:
- * IN int AddressFamily:
- * OUT IXML_Document **xmlDoc:
- * OUT char *descURL:
- *
- * Description:
- * This function fills the sockadr_in with miniserver information.
- *
- * Return Values: VOID
- *
- ***************************************************************************/
-static int
-GetDescDocumentAndURL( IN Upnp_DescType descriptionType,
- IN char *description,
- IN unsigned int bufferLen,
- IN int config_baseURL,
- IN int AddressFamily,
- OUT IXML_Document ** xmlDoc,
- OUT char *descURL )
+#else /* INTERNAL_WEB_SERVER */ /* no web server */
+static int GetDescDocumentAndURL(
+ Upnp_DescType descriptionType,
+ char *description,
+ unsigned int bufferLen,
+ int config_baseURL,
+ int AddressFamily,
+ IXML_Document **xmlDoc,
+ char *descURL)
{
- int retVal;
+ int retVal = 0;
- if( ( descriptionType != UPNPREG_URL_DESC ) || config_baseURL ) {
- return UPNP_E_NO_WEB_SERVER;
- }
+ if (descriptionType != UPNPREG_URL_DESC || config_baseURL) {
+ return UPNP_E_NO_WEB_SERVER;
+ }
- if( description == NULL ) {
- return UPNP_E_INVALID_PARAM;
- }
+ if (description == NULL) {
+ return UPNP_E_INVALID_PARAM;
+ }
- if( strlen( description ) > ( LINE_SIZE - 1 ) ) {
- return UPNP_E_URL_TOO_BIG;
- }
- strcpy( descURL, description );
+ if (strlen(description) > (LINE_SIZE - 1)) {
+ return UPNP_E_URL_TOO_BIG;
+ }
+ strcpy(descURL, description);
- if( ( retVal =
- UpnpDownloadXmlDoc( description, xmlDoc ) ) != UPNP_E_SUCCESS ) {
- return retVal;
- }
+ retVal = UpnpDownloadXmlDoc(description, xmlDoc);
+ if (retVal != UPNP_E_SUCCESS) {
+ return retVal;
+ }
- return UPNP_E_SUCCESS;
+ return UPNP_E_SUCCESS;
}
-
-#endif // INTERNAL_WEB_SERVER
-#endif // INCLUDE_DEVICE_APIS
+#endif /* INTERNAL_WEB_SERVER */
+#endif /* INCLUDE_DEVICE_APIS */
//-----------------------------------------------------------------------------
@@ -1269,26 +1212,10 @@ GetDescDocumentAndURL( IN Upnp_DescType descriptionType,
//
//-----------------------------------------------------------------------------
+
#ifdef INCLUDE_DEVICE_APIS
#if EXCLUDE_SSDP == 0
-
-/**************************************************************************
- * Function: UpnpSendAdvertisement
- *
- * Parameters:
- * IN UpnpDevice_Handle Hnd: handle of the device instance
- * IN int Exp : Timer for resending the advertisement
- *
- * Description:
- * This function sends the device advertisement. It also schedules a
- * job for the next advertisement after "Exp" time.
- *
- * Return Values: int
- * UPNP_E_SUCCESS if successful else sends appropriate error.
- ***************************************************************************/
-int
-UpnpSendAdvertisement( IN UpnpDevice_Handle Hnd,
- IN int Exp )
+int UpnpSendAdvertisement(UpnpDevice_Handle Hnd, int Exp)
{
struct Handle_Info *SInfo = NULL;
int retVal = 0,
@@ -1375,34 +1302,20 @@ UpnpSendAdvertisement( IN UpnpDevice_Handle Hnd,
return retVal;
-} /****************** End of UpnpSendAdvertisement *********************/
-#endif // INCLUDE_DEVICE_APIS
-#endif
+}
+#endif /* EXCLUDE_SSDP == 0 */
+#endif /* INCLUDE_DEVICE_APIS */
+
+
#if EXCLUDE_SSDP == 0
#ifdef INCLUDE_CLIENT_APIS
-/**************************************************************************
- * Function: UpnpSearchAsync
- *
- * Parameters:
- * IN UpnpClient_Handle Hnd: handle of the control point instance
- * IN int Mx : Maximum time to wait for the search reply
- * IN const char *Target_const:
- * IN const void *Cookie_const:
- *
- * Description:
- * This function searches for the devices for the provided maximum time.
- * It is a asynchronous function. It schedules a search job and returns.
- * client is notified about the search results after search timer.
- *
- * Return Values: int
- * UPNP_E_SUCCESS if successful else sends appropriate error.
- ***************************************************************************/
-int
-UpnpSearchAsync( IN UpnpClient_Handle Hnd,
- IN int Mx,
- IN const char *Target_const,
- IN const void *Cookie_const )
+
+int UpnpSearchAsync(
+ UpnpClient_Handle Hnd,
+ int Mx,
+ const char *Target_const,
+ const void *Cookie_const )
{
struct Handle_Info *SInfo = NULL;
char *Target = ( char * )Target_const;
@@ -1412,7 +1325,7 @@ UpnpSearchAsync( IN UpnpClient_Handle Hnd,
}
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
- "Inside UpnpSearchAsync \n" );
+ "Inside UpnpSearchAsync\n" );
HandleReadLock();
if( GetHandleInfo( Hnd, &SInfo ) != HND_CLIENT ) {
@@ -1437,35 +1350,23 @@ UpnpSearchAsync( IN UpnpClient_Handle Hnd,
return UPNP_E_SUCCESS;
-} /****************** End of UpnpSearchAsync *********************/
+}
#endif // INCLUDE_CLIENT_APIS
#endif
+
+
//-----------------------------------------------------------------------------
//
// GENA interface
//
//-----------------------------------------------------------------------------
+
#if EXCLUDE_GENA == 0
#ifdef INCLUDE_DEVICE_APIS
-
-/**************************************************************************
- * Function: UpnpSetMaxSubscriptions
- *
- * Parameters:
- * IN UpnpDevice_Handle Hnd: The handle of the device for which
- * the maximum subscriptions is being set.
- * IN int MaxSubscriptions: The maximum number of subscriptions to be
- * allowed per service.
- *
- * Description:
- * This function sets the maximum subscriptions of the control points
- * Return Values: int
- * UPNP_E_SUCCESS if successful else sends appropriate error.
- ***************************************************************************/
-int
-UpnpSetMaxSubscriptions( IN UpnpDevice_Handle Hnd,
- IN int MaxSubscriptions )
+int UpnpSetMaxSubscriptions(
+ UpnpDevice_Handle Hnd,
+ int MaxSubscriptions )
{
struct Handle_Info *SInfo = NULL;
@@ -1491,30 +1392,14 @@ UpnpSetMaxSubscriptions( IN UpnpDevice_Handle Hnd,
return UPNP_E_SUCCESS;
-} /***************** End of UpnpSetMaxSubscriptions ********************/
+}
#endif // INCLUDE_DEVICE_APIS
-#ifdef INCLUDE_DEVICE_APIS
-/**************************************************************************
- * Function: UpnpSetMaxSubscriptionTimeOut
- *
- * Parameters:
- * IN UpnpDevice_Handle Hnd: The handle of the device for which the
- * maximum subscription time-out is being set.
- * IN int MaxSubscriptionTimeOut:The maximum subscription time-out
- * to be accepted
- *
- * Description:
- * This function sets the maximum subscription timer. Control points
- * will require to send the subscription request before timeout.
- *
- * Return Values: int
- * UPNP_E_SUCCESS if successful else sends appropriate error.
- ***************************************************************************/
-int
-UpnpSetMaxSubscriptionTimeOut( IN UpnpDevice_Handle Hnd,
- IN int MaxSubscriptionTimeOut )
+#ifdef INCLUDE_DEVICE_APIS
+int UpnpSetMaxSubscriptionTimeOut(
+ UpnpDevice_Handle Hnd,
+ int MaxSubscriptionTimeOut)
{
struct Handle_Info *SInfo = NULL;
@@ -1522,8 +1407,8 @@ UpnpSetMaxSubscriptionTimeOut( IN UpnpDevice_Handle Hnd,
return UPNP_E_FINISH;
}
- UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
- "Inside UpnpSetMaxSubscriptionTimeOut \n" );
+ UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
+ "Inside UpnpSetMaxSubscriptionTimeOut\n" );
HandleLock();
@@ -1537,46 +1422,22 @@ UpnpSetMaxSubscriptionTimeOut( IN UpnpDevice_Handle Hnd,
SInfo->MaxSubscriptionTimeOut = MaxSubscriptionTimeOut;
HandleUnlock();
- UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
- "Exiting UpnpSetMaxSubscriptionTimeOut \n" );
+ UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
+ "Exiting UpnpSetMaxSubscriptionTimeOut\n");
return UPNP_E_SUCCESS;
-} /****************** End of UpnpSetMaxSubscriptionTimeOut ******************/
-#endif // INCLUDE_DEVICE_APIS
+}
+#endif /* INCLUDE_DEVICE_APIS */
+
#ifdef INCLUDE_CLIENT_APIS
-
-/**************************************************************************
- * Function: UpnpSubscribeAsync
- *
- * Parameters:
- * IN UpnpClient_Handle Hnd: The handle of the control point for which
- * the subscription request is to be sent.
- * IN const char * EvtUrl_const: URL that control point wants to
- * subscribe
- * IN int TimeOut: The requested subscription time. Upon
- * return, it contains the actual subscription time
- * returned from the service
- * IN Upnp_FunPtr Fun : callback function to tell result of the
- * subscription request
- * IN const void * Cookie_const: cookie passed by client to give back
- * in the callback function.
- *
- * Description:
- * This function performs the same operation as UpnpSubscribeAsync
- * but returns immediately and calls the registered callback function
- * when the operation is complete.
- *
- * Return Values: int
- * UPNP_E_SUCCESS if successful else sends appropriate error.
- ***************************************************************************/
-int
-UpnpSubscribeAsync( IN UpnpClient_Handle Hnd,
- IN const char *EvtUrl_const,
- IN int TimeOut,
- IN Upnp_FunPtr Fun,
- IN const void *Cookie_const )
+int UpnpSubscribeAsync(
+ UpnpClient_Handle Hnd,
+ const char *EvtUrl_const,
+ int TimeOut,
+ Upnp_FunPtr Fun,
+ const void *Cookie_const )
{
struct Handle_Info *SInfo = NULL;
struct UpnpNonblockParam *Param;
@@ -1587,8 +1448,8 @@ UpnpSubscribeAsync( IN UpnpClient_Handle Hnd,
return UPNP_E_FINISH;
}
- UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
- "Inside UpnpSubscribeAsync \n" );
+ UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
+ "Inside UpnpSubscribeAsync\n");
HandleReadLock();
if( GetHandleInfo( Hnd, &SInfo ) != HND_CLIENT ) {
@@ -1620,47 +1481,28 @@ UpnpSubscribeAsync( IN UpnpClient_Handle Hnd,
strcpy( Param->Url, EvtUrl );
Param->TimeOut = TimeOut;
Param->Fun = Fun;
- Param->Cookie = ( void * )Cookie_const;
+ Param->Cookie = (void *)Cookie_const;
- TPJobInit( &job, ( start_routine ) UpnpThreadDistribution, Param );
- TPJobSetFreeFunction( &job, ( free_routine ) free );
- TPJobSetPriority( &job, MED_PRIORITY );
- ThreadPoolAdd( &gSendThreadPool, &job, NULL );
+ TPJobInit(&job, (start_routine)UpnpThreadDistribution, Param);
+ TPJobSetFreeFunction(&job, (free_routine)free);
+ TPJobSetPriority(&job, MED_PRIORITY);
+ ThreadPoolAdd(&gSendThreadPool, &job, NULL);
- UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
- "Exiting UpnpSubscribeAsync \n" );
+ UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
+ "Exiting UpnpSubscribeAsync\n");
return UPNP_E_SUCCESS;
-} /****************** End of UpnpSubscribeAsync *********************/
-#endif // INCLUDE_CLIENT_APIS
+}
+#endif /* INCLUDE_CLIENT_APIS */
+
#ifdef INCLUDE_CLIENT_APIS
-
-/**************************************************************************
- * Function: UpnpSubscribe
- *
- * Parameters:
- * IN UpnpClient_Handle Hnd: The handle of the control point.
- * IN const char *PublisherUrl: The URL of the service to subscribe to.
- * INOUT int *TimeOut: Pointer to a variable containing the requested
- * subscription time. Upon return, it contains the
- * actual subscription time returned from the service.
- * OUT Upnp_SID SubsId: Pointer to a variable to receive the
- * subscription ID (SID).
- *
- * Description:
- * This function registers a control point to receive event
- * notifications from another device. This operation is synchronous
- *
- * Return Values: int
- * UPNP_E_SUCCESS if successful else sends appropriate error.
- ***************************************************************************/
int UpnpSubscribe(
- IN UpnpClient_Handle Hnd,
- IN const char *EvtUrl_const,
- INOUT int *TimeOut,
- OUT Upnp_SID SubsId)
+ UpnpClient_Handle Hnd,
+ const char *EvtUrl_const,
+ int *TimeOut,
+ Upnp_SID SubsId)
{
int retVal;
struct Handle_Info *SInfo = NULL;
@@ -1723,24 +1565,7 @@ exit_function:
#ifdef INCLUDE_CLIENT_APIS
-
-/**************************************************************************
- * Function: UpnpUnSubscribe
- *
- * Parameters:
- * IN UpnpClient_Handle Hnd: The handle of the control point.
- * IN const Upnp_SID SubsId: The ID returned when the control point
- * subscribed to the service.
- *
- * Description:
- * This function removes the subscription of a control point from a
- * service previously subscribed to using UpnpSubscribe or
- * UpnpSubscribeAsync. This is a synchronous call.
- *
- * Return Values: int
- * UPNP_E_SUCCESS if successful else sends appropriate error.
- ***************************************************************************/
-int UpnpUnSubscribe(IN UpnpClient_Handle Hnd, IN const Upnp_SID SubsId)
+int UpnpUnSubscribe(UpnpClient_Handle Hnd,const Upnp_SID SubsId)
{
struct Handle_Info *SInfo = NULL;
int retVal;
@@ -1785,32 +1610,11 @@ exit_function:
#ifdef INCLUDE_CLIENT_APIS
-
-/**************************************************************************
- * Function: UpnpUnSubscribeAsync
- *
- * Parameters:
- * IN UpnpClient_Handle Hnd: The handle of the subscribed control point.
- * IN Upnp_SID SubsId: The ID returned when the control point
- * subscribed to the service.
- * IN Upnp_FunPtr Fun: Pointer to a callback function to be called
- * when the operation is complete.
- * IN const void *Cookie:Pointer to user data to pass to the
- * callback function when invoked.
- *
- * Description:
- * This function removes a subscription of a control point
- * from a service previously subscribed to using UpnpSubscribe or
- * UpnpSubscribeAsync,generating a callback when the operation is complete.
- *
- * Return Values: int
- * UPNP_E_SUCCESS if successful else sends appropriate error.
- ***************************************************************************/
int UpnpUnSubscribeAsync(
- IN UpnpClient_Handle Hnd,
- IN Upnp_SID SubsId,
- IN Upnp_FunPtr Fun,
- IN const void *Cookie_const )
+ UpnpClient_Handle Hnd,
+ Upnp_SID SubsId,
+ Upnp_FunPtr Fun,
+ const void *Cookie_const)
{
int retVal;
ThreadPoolJob job;
@@ -1866,29 +1670,10 @@ exit_function:
#ifdef INCLUDE_CLIENT_APIS
-
-/**************************************************************************
- * Function: UpnpRenewSubscription
- *
- * Parameters:
- * IN UpnpClient_Handle Hnd: The handle of the control point that
- * is renewing the subscription.
- * INOUT int *TimeOut: Pointer to a variable containing the
- * requested subscription time. Upon return,
- * it contains the actual renewal time.
- * IN const Upnp_SID SubsId: The ID for the subscription to renew.
- *
- * Description:
- * This function renews a subscription that is about to
- * expire. This function is synchronous.
- *
- * Return Values: int
- * UPNP_E_SUCCESS if successful else sends appropriate error.
- ***************************************************************************/
int UpnpRenewSubscription(
- IN UpnpClient_Handle Hnd,
- INOUT int *TimeOut,
- IN const Upnp_SID SubsId )
+ UpnpClient_Handle Hnd,
+ int *TimeOut,
+ const Upnp_SID SubsId)
{
struct Handle_Info *SInfo = NULL;
int retVal;
@@ -1937,35 +1722,12 @@ exit_function:
#ifdef INCLUDE_CLIENT_APIS
-
-/**************************************************************************
- * Function: UpnpRenewSubscriptionAsync
- *
- * Parameters:
- * IN UpnpClient_Handle Hnd: The handle of the control point that
- * is renewing the subscription.
- * IN int TimeOut: The requested subscription time. The
- * actual timeout value is returned when
- * the callback function is called.
- * IN Upnp_SID SubsId: The ID for the subscription to renew.
- * IN Upnp_FunPtr Fun: Pointer to a callback function to be
- * invoked when the renewal is complete.
- * IN const void *Cookie : Pointer to user data passed
- * to the callback function when invoked.
- *
- * Description:
- * This function renews a subscription that is about
- * to expire, generating a callback when the operation is complete.
- *
- * Return Values: int
- * UPNP_E_SUCCESS if successful else sends appropriate error.
- ***************************************************************************/
-int
-UpnpRenewSubscriptionAsync( IN UpnpClient_Handle Hnd,
- INOUT int TimeOut,
- IN Upnp_SID SubsId,
- IN Upnp_FunPtr Fun,
- IN const void *Cookie_const )
+int UpnpRenewSubscriptionAsync(
+ UpnpClient_Handle Hnd,
+ int TimeOut,
+ Upnp_SID SubsId,
+ Upnp_FunPtr Fun,
+ const void *Cookie_const)
{
ThreadPoolJob job;
struct Handle_Info *SInfo = NULL;
@@ -1975,8 +1737,8 @@ UpnpRenewSubscriptionAsync( IN UpnpClient_Handle Hnd,
return UPNP_E_FINISH;
}
- UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
- "Inside UpnpRenewSubscriptionAsync \n" );
+ UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
+ "Inside UpnpRenewSubscriptionAsync\n");
HandleReadLock();
if( GetHandleInfo( Hnd, &SInfo ) != HND_CLIENT ) {
HandleUnlock();
@@ -2015,62 +1777,36 @@ UpnpRenewSubscriptionAsync( IN UpnpClient_Handle Hnd,
TPJobSetPriority( &job, MED_PRIORITY );
ThreadPoolAdd( &gSendThreadPool, &job, NULL );
- UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
- "Exiting UpnpRenewSubscriptionAsync \n" );
+ UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
+ "Exiting UpnpRenewSubscriptionAsync\n");
return UPNP_E_SUCCESS;
+}
+#endif /* INCLUDE_CLIENT_APIS */
-} /****************** End of UpnpRenewSubscriptionAsync *******************/
-#endif // INCLUDE_CLIENT_APIS
#ifdef INCLUDE_DEVICE_APIS
-
-/**************************************************************************
- * Function: UpnpNotify
- *
- * Parameters:
- * IN UpnpDevice_Handle: The handle to the device sending the event.
- * IN const char *DevID: The device ID of the subdevice of the
- * service generating the event.
- * IN const char *ServID: The unique identifier of the service
- * generating the event.
- * IN const char **VarName: Pointer to an array of variables that
- * have changed.
- * IN const char **NewVal: Pointer to an array of new values for
- * those variables.
- * IN int cVariables: The count of variables included in this
- * notification.
- *
- * Description:
- * This function sends out an event change notification to all
- * control points subscribed to a particular service. This function is
- * synchronous and generates no callbacks.
- *
- * Return Values: int
- * UPNP_E_SUCCESS if successful else sends appropriate error.
- ***************************************************************************/
-int
-UpnpNotify( IN UpnpDevice_Handle Hnd,
- IN const char *DevID_const,
- IN const char *ServName_const,
- IN const char **VarName_const,
- IN const char **NewVal_const,
- IN int cVariables )
+int UpnpNotify(
+ UpnpDevice_Handle Hnd,
+ const char *DevID_const,
+ const char *ServName_const,
+ const char **VarName_const,
+ const char **NewVal_const,
+ int cVariables)
{
-
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;
+ 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 UpnpNotify \n" );
+ UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
+ "Inside UpnpNotify\n");
HandleReadLock();
if( GetHandleInfo( Hnd, &SInfo ) != HND_DEVICE ) {
@@ -2094,47 +1830,24 @@ UpnpNotify( IN UpnpDevice_Handle Hnd,
retVal =
genaNotifyAll( Hnd, DevID, ServName, VarName, NewVal, cVariables );
- UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
- "Exiting UpnpNotify \n" );
+ UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
+ "Exiting UpnpNotify\n");
return retVal;
-} /****************** End of UpnpNotify *********************/
+}
-/**************************************************************************
- * Function: UpnpNotifyExt
- *
- * Parameters:
- * IN UpnpDevice_Handle: The handle to the device sending the
- * event.
- * IN const char *DevID: The device ID of the subdevice of the
- * service generating the event.
- * IN const char *ServID: The unique identifier of the service
- * generating the event.
- * IN IXML_Document *PropSet: The DOM document for the property set.
- * Property set documents must conform to the XML schema
- * defined in section 4.3 of the Universal Plug and Play
- * Device Architecture specification.
- *
- * Description:
- * This function is similar to UpnpNotify except that it takes
- * a DOM document for the event rather than an array of strings. This
- * function is synchronous and generates no callbacks.
- *
- * Return Values: int
- * UPNP_E_SUCCESS if successful else sends appropriate error.
- ***************************************************************************/
-int
-UpnpNotifyExt( IN UpnpDevice_Handle Hnd,
- IN const char *DevID_const,
- IN const char *ServName_const,
- IN IXML_Document * PropSet )
+
+int UpnpNotifyExt(
+ UpnpDevice_Handle Hnd,
+ const char *DevID_const,
+ const char *ServName_const,
+ IXML_Document *PropSet)
{
-
struct Handle_Info *SInfo = NULL;
int retVal;
- char *DevID = ( char * )DevID_const;
- char *ServName = ( char * )ServName_const;
+ char *DevID = (char *)DevID_const;
+ char *ServName = (char *)ServName_const;
if( UpnpSdkInit != 1 ) {
return UPNP_E_FINISH;
@@ -2165,46 +1878,19 @@ UpnpNotifyExt( IN UpnpDevice_Handle Hnd,
return retVal;
-} /****************** End of UpnpNotify *********************/
+}
+#endif /* INCLUDE_DEVICE_APIS */
-#endif // INCLUDE_DEVICE_APIS
#ifdef INCLUDE_DEVICE_APIS
-
-/**************************************************************************
- * Function: UpnpAcceptSubscription
- *
- * Parameters:
- * IN UpnpDevice_Handle Hnd: The handle of the device.
- * IN const char *DevID: The device ID of the subdevice of the
- * service generating the event.
- * IN const char *ServID: The unique service identifier of the
- * service generating the event.
- * IN const char **VarName: Pointer to an array of event variables.
- * IN const char **NewVal: Pointer to an array of values for
- * the event variables.
- * IN int cVariables: The number of event variables in VarName.
- * IN Upnp_SID SubsId: The subscription ID of the newly
- * registered control point.
- *
- * Description:
- * This function accepts a subscription request and sends
- * out the current state of the eventable variables for a service.
- * The device application should call this function when it receives a
- * UPNP_EVENT_SUBSCRIPTION_REQUEST callback. This function is sychronous
- * and generates no callbacks.
- *
- * Return Values: int
- * UPNP_E_SUCCESS if successful else sends appropriate error.
- ***************************************************************************/
int UpnpAcceptSubscription(
- IN UpnpDevice_Handle Hnd,
- IN const char *DevID_const,
- IN const char *ServName_const,
- IN const char **VarName_const,
- IN const char **NewVal_const,
+ UpnpDevice_Handle Hnd,
+ const char *DevID_const,
+ const char *ServName_const,
+ const char **VarName_const,
+ const char **NewVal_const,
int cVariables,
- IN const Upnp_SID SubsId)
+ const Upnp_SID SubsId)
{
int ret = 0;
int line = 0;
@@ -2273,36 +1959,12 @@ ExitFunction:
}
-/**************************************************************************
- * Function: UpnpAcceptSubscriptionExt
- *
- * Parameters:
- * IN UpnpDevice_Handle Hnd: The handle of the device.
- * IN const char *DevID: The device ID of the subdevice of the
- * service generating the event.
- * IN const char *ServID: The unique service identifier of the service
- * generating the event.
- * IN IXML_Document *PropSet: The DOM document for the property set.
- * Property set documents must conform to the XML schema
- * defined in section 4.3 of the Universal Plug and Play
- * Device Architecture specification.
- * IN Upnp_SID SubsId: The subscription ID of the newly
- * registered control point.
- *
- * Description:
- * This function is similar to UpnpAcceptSubscription except that it
- * takes a DOM document for the variables to event rather than an array
- * of strings. This function is sychronous and generates no callbacks.
- *
- * 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)
+ UpnpDevice_Handle Hnd,
+ const char *DevID_const,
+ const char *ServName_const,
+ IXML_Document *PropSet,
+ Upnp_SID SubsId)
{
int ret = 0;
int line = 0;
@@ -2366,56 +2028,31 @@ ExitFunction:
return ret;
}
+#endif /* INCLUDE_DEVICE_APIS */
+#endif /* EXCLUDE_GENA == 0 */
-#endif // INCLUDE_DEVICE_APIS
-#endif // EXCLUDE_GENA == 0
//---------------------------------------------------------------------------
//
// SOAP interface
//
//---------------------------------------------------------------------------
+
+
#if EXCLUDE_SOAP == 0
#ifdef INCLUDE_CLIENT_APIS
-
-/**************************************************************************
- * Function: UpnpSendAction
- *
- * Parameters:
- * IN UpnpClient_Handle Hnd: The handle of the control point
- * sending the action.
- * IN const char *ActionURL: The action URL of the service.
- * IN const char *ServiceType: The type of the service.
- * IN const char *DevUDN: This parameter is ignored.
- * IN IXML_Document *Action: The DOM document for the action.
- * OUT IXML_Document **RespNode: The DOM document for the response
- * to the action. The UPnP Library allocates this document
- * and the caller needs to free it.
- *
- * Description:
- * This function sends a message to change a state variable in a service.
- * This is a synchronous call that does not return until the action is
- * complete.
- *
- * Note that a positive return value indicates a SOAP-protocol error code.
- * In this case, the error description can be retrieved from RespNode.
- * A negative return value indicates a UPnP Library error.
- *
- * Return Values: int
- * UPNP_E_SUCCESS if successful else sends appropriate error.
- ***************************************************************************/
-int
-UpnpSendAction( IN UpnpClient_Handle Hnd,
- IN const char *ActionURL_const,
- IN const char *ServiceType_const,
- IN const char *DevUDN_const,
- IN IXML_Document * Action,
- OUT IXML_Document ** RespNodePtr )
+int UpnpSendAction(
+ UpnpClient_Handle Hnd,
+ const char *ActionURL_const,
+ const char *ServiceType_const,
+ const char *DevUDN_const,
+ IXML_Document *Action,
+ IXML_Document **RespNodePtr)
{
struct Handle_Info *SInfo = NULL;
int retVal = 0;
- char *ActionURL = ( char * )ActionURL_const;
- char *ServiceType = ( char * )ServiceType_const;
+ char *ActionURL = (char *)ActionURL_const;
+ char *ServiceType = (char *)ServiceType_const;
//char *DevUDN = (char *)DevUDN_const; // udn not used?
@@ -2423,10 +2060,11 @@ UpnpSendAction( IN UpnpClient_Handle Hnd,
return UPNP_E_FINISH;
}
- UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
- "Inside UpnpSendAction \n" );
- if(DevUDN_const !=NULL) {
- UpnpPrintf(UPNP_ALL,API,__FILE__,__LINE__,"non NULL DevUDN is ignored\n");
+ UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
+ "Inside UpnpSendAction\n");
+ if (DevUDN_const !=NULL) {
+ UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
+ "non NULL DevUDN is ignored\n");
}
DevUDN_const = NULL;
@@ -2449,55 +2087,27 @@ UpnpSendAction( IN UpnpClient_Handle Hnd,
retVal = SoapSendAction( ActionURL, ServiceType, Action, RespNodePtr );
- UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
- "Exiting UpnpSendAction \n" );
+ UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
+ "Exiting UpnpSendAction\n");
return retVal;
-} /****************** End of UpnpSendAction *********************/
+}
-/**************************************************************************
- * Function: UpnpSendActionEx
- *
- * Parameters:
- * IN UpnpClient_Handle Hnd: The handle of the control point sending
- * the action.
- * IN const char *ActionURL_const: The action URL of the service.
- * IN const char *ServiceType_const: The type of the service.
- * IN const char *DevUDN_const: This parameter is ignored.
- * IN IXML_Document *Header: The DOM document for the SOAP header.
- * This may be NULL if the header is not required.
- * IN IXML_Document *Action: The DOM document for the action.
- * OUT IXML_Document **RespNodePtr: The DOM document for the response to
- * the action. The UPnP library allocates this document and the
- * caller needs to free it.
- *
- * Description:
- * this function sends a message to change a state variable in a
- * service. This is a synchronous call that does not return until the
- * action is complete.
- *
- * Note that a positive return value indicates a SOAP-protocol error code.
- * In this case, the error description can be retrieved from {\bf RespNode}.
- * A negative return value indicates a UPnP Library error.
- *
- * Return Values: int
- * UPNP_E_SUCCESS if successful else sends appropriate error.
- ***************************************************************************/
-int
-UpnpSendActionEx( IN UpnpClient_Handle Hnd,
- IN const char *ActionURL_const,
- IN const char *ServiceType_const,
- IN const char *DevUDN_const,
- IN IXML_Document * Header,
- IN IXML_Document * Action,
- OUT IXML_Document ** RespNodePtr )
+
+int UpnpSendActionEx(
+ UpnpClient_Handle Hnd,
+ const char *ActionURL_const,
+ const char *ServiceType_const,
+ const char *DevUDN_const,
+ IXML_Document *Header,
+ IXML_Document *Action,
+ IXML_Document **RespNodePtr)
{
-
struct Handle_Info *SInfo = NULL;
int retVal = 0;
- char *ActionURL = ( char * )ActionURL_const;
- char *ServiceType = ( char * )ServiceType_const;
+ char *ActionURL = (char *)ActionURL_const;
+ char *ServiceType = (char *)ServiceType_const;
//char *DevUDN = (char *)DevUDN_const; // udn not used?
@@ -2505,8 +2115,8 @@ UpnpSendActionEx( IN UpnpClient_Handle Hnd,
return UPNP_E_FINISH;
}
- UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
- "Inside UpnpSendActionEx \n" );
+ UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
+ "Inside UpnpSendActionEx\n");
if( Header == NULL ) {
retVal = UpnpSendAction( Hnd, ActionURL_const, ServiceType_const,
@@ -2531,64 +2141,39 @@ UpnpSendActionEx( IN UpnpClient_Handle Hnd,
retVal = SoapSendActionEx( ActionURL, ServiceType, Header,
Action, RespNodePtr );
- UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
- "Exiting UpnpSendAction \n" );
+ UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
+ "Exiting UpnpSendAction \n");
return retVal;
-} /****************** End of UpnpSendActionEx *********************/
+}
-/**************************************************************************
- * Function: UpnpSendActionAsync
- *
- * Parameters:
- * IN UpnpClient_Handle Hnd: The handle of the control point
- * sending the action.
- * IN const char *ActionURL: The action URL of the service.
- * IN const char *ServiceType: The type of the service.
- * IN const char *DevUDN: This parameter is ignored.
- * IN IXML_Document *Action: The DOM document for the action to
- * perform on this device.
- * IN Upnp_FunPtr Fun: Pointer to a callback function to
- * be invoked when the operation completes
- * IN const void *Cookie: Pointer to user data that to be
- * passed to the callback when invoked.
- *
- * Description:
- * this function sends a message to change a state variable
- * in a service, generating a callback when the operation is complete.
- * See UpnpSendAction for comments on positive return values. These
- * positive return values are sent in the event struct associated with the
- * UPNP_CONTROL_ACTION_COMPLETE event.
- *
- * Return Values: int
- * UPNP_E_SUCCESS if successful else sends appropriate error.
- ***************************************************************************/
-int
-UpnpSendActionAsync( IN UpnpClient_Handle Hnd,
- IN const char *ActionURL_const,
- IN const char *ServiceType_const,
- IN const char *DevUDN_const,
- IN IXML_Document * Act,
- IN Upnp_FunPtr Fun,
- IN const void *Cookie_const )
+
+int UpnpSendActionAsync(
+ UpnpClient_Handle Hnd,
+ const char *ActionURL_const,
+ const char *ServiceType_const,
+ const char *DevUDN_const,
+ IXML_Document *Act,
+ Upnp_FunPtr Fun,
+ const void *Cookie_const)
{
ThreadPoolJob job;
struct Handle_Info *SInfo = NULL;
struct UpnpNonblockParam *Param;
DOMString tmpStr;
- char *ActionURL = ( char * )ActionURL_const;
- char *ServiceType = ( char * )ServiceType_const;
+ char *ActionURL = (char *)ActionURL_const;
+ char *ServiceType = (char *)ServiceType_const;
//char *DevUDN = (char *)DevUDN_const;
int rc;
- if( UpnpSdkInit != 1 ) {
+ if(UpnpSdkInit != 1) {
return UPNP_E_FINISH;
}
- UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
- "Inside UpnpSendActionAsync \n" );
+ UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
+ "Inside UpnpSendActionAsync\n");
HandleReadLock();
if( GetHandleInfo( Hnd, &SInfo ) != HND_CLIENT ) {
@@ -2647,45 +2232,18 @@ UpnpSendActionAsync( IN UpnpClient_Handle Hnd,
return UPNP_E_SUCCESS;
-} /****************** End of UpnpSendActionAsync *********************/
+}
-/*************************************************************************
- * Function: UpnpSendActionExAsync
- *
- * Parameters:
- * IN UpnpClient_Handle Hnd: The handle of the control point
- * sending the action.
- * IN const char *ActionURL_const: The action URL of the service.
- * IN const char *ServiceType_const: The type of the service.
- * IN const char *DevUDN_const: This parameter is ignored.
- * IN IXML_Document *Header: The DOM document for the SOAP header.
- * This may be NULL if the header is not required.
- * IN IXML_Document *Act: The DOM document for the action to
- * perform on this device.
- * IN Upnp_FunPtr Fun: Pointer to a callback function to be invoked
- * when the operation completes.
- * IN const void *Cookie_const: Pointer to user data that to be
- * passed to the callback when invoked.
- *
- * Description:
- * this function sends sends a message to change a state variable
- * in a service, generating a callback when the operation is complete.
- * See UpnpSendAction for comments on positive return values. These
- * positive return values are sent in the event struct associated with
- * the UPNP_CONTROL_ACTION_COMPLETE event.
- *
- * Return Values: int
- * UPNP_E_SUCCESS if successful else sends appropriate error.
- ***************************************************************************/
-int
-UpnpSendActionExAsync( IN UpnpClient_Handle Hnd,
- IN const char *ActionURL_const,
- IN const char *ServiceType_const,
- IN const char *DevUDN_const,
- IN IXML_Document * Header,
- IN IXML_Document * Act,
- IN Upnp_FunPtr Fun,
- IN const void *Cookie_const )
+
+int UpnpSendActionExAsync(
+ UpnpClient_Handle Hnd,
+ const char *ActionURL_const,
+ const char *ServiceType_const,
+ const char *DevUDN_const,
+ IXML_Document *Header,
+ IXML_Document *Act,
+ Upnp_FunPtr Fun,
+ const void *Cookie_const)
{
struct Handle_Info *SInfo = NULL;
struct UpnpNonblockParam *Param;
@@ -2700,8 +2258,8 @@ UpnpSendActionExAsync( IN UpnpClient_Handle Hnd,
return UPNP_E_FINISH;
}
- UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
- "Inside UpnpSendActionExAsync \n" );
+ UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
+ "Inside UpnpSendActionExAsync\n");
if( Header == NULL ) {
retVal = UpnpSendActionAsync( Hnd, ActionURL_const,
@@ -2778,51 +2336,33 @@ UpnpSendActionExAsync( IN UpnpClient_Handle Hnd,
TPJobSetPriority( &job, MED_PRIORITY );
ThreadPoolAdd( &gSendThreadPool, &job, NULL );
- UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
- "Exiting UpnpSendActionAsync \n" );
+ UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
+ "Exiting UpnpSendActionAsync\n");
return UPNP_E_SUCCESS;
-} /****************** End of UpnpSendActionExAsync *********************/
+}
-/*************************************************************************
- * Function: UpnpGetServiceVarStatusAsync
- *
- * Parameters:
- * IN UpnpClient_Handle Hnd: The handle of the control point.
- * IN const char *ActionURL: The URL of the service.
- * IN const char *VarName: The name of the variable to query.
- * IN Upnp_FunPtr Fun: Pointer to a callback function to
- * be invoked when the operation is complete.
- * IN const void *Cookie: Pointer to user data to pass to the
- * callback function when invoked.
- *
- * Description:
- * this function queries the state of a variable of a
- * service, generating a callback when the operation is complete.
- *
- * Return Values: int
- * UPNP_E_SUCCESS if successful else sends appropriate error.
- ***************************************************************************/
-int
-UpnpGetServiceVarStatusAsync( IN UpnpClient_Handle Hnd,
- IN const char *ActionURL_const,
- IN const char *VarName_const,
- IN Upnp_FunPtr Fun,
- IN const void *Cookie_const )
+
+int UpnpGetServiceVarStatusAsync(
+ UpnpClient_Handle Hnd,
+ const char *ActionURL_const,
+ const char *VarName_const,
+ Upnp_FunPtr Fun,
+ const void *Cookie_const)
{
ThreadPoolJob job;
struct Handle_Info *SInfo = NULL;
struct UpnpNonblockParam *Param;
- char *ActionURL = ( char * )ActionURL_const;
- char *VarName = ( char * )VarName_const;
+ char *ActionURL = (char *)ActionURL_const;
+ char *VarName = (char *)VarName_const;
if( UpnpSdkInit != 1 ) {
return UPNP_E_FINISH;
}
- UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
- "Inside UpnpGetServiceVarStatusAsync \n" );
+ UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
+ "Inside UpnpGetServiceVarStatusAsync\n");
HandleReadLock();
if( GetHandleInfo( Hnd, &SInfo ) != HND_CLIENT ) {
@@ -2858,51 +2398,31 @@ UpnpGetServiceVarStatusAsync( IN UpnpClient_Handle Hnd,
ThreadPoolAdd( &gSendThreadPool, &job, NULL );
- UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
- "Exiting UpnpGetServiceVarStatusAsync \n" );
+ UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
+ "Exiting UpnpGetServiceVarStatusAsync\n");
return UPNP_E_SUCCESS;
+}
-} /****************** End of UpnpGetServiceVarStatusAsync ****************/
-/**************************************************************************
- * Function: UpnpGetServiceVarStatus
- *
- * Parameters:
- * IN UpnpClient_Handle Hnd: The handle of the control point.
- * IN const char *ActionURL: The URL of the service.
- * IN const char *VarName: The name of the variable to query.
- * OUT DOMString *StVarVal: The pointer to store the value
- * for VarName. The UPnP Library allocates this string and
- * the caller needs to free it.
- *
- * Description:
- * this function queries the state of a state variable of a service on
- * another device. This is a synchronous call. A positive return value
- * indicates a SOAP error code, whereas a negative return code indicates
- * a UPnP SDK error code.
- *
- * Return Values: int
- * UPNP_E_SUCCESS if successful else sends appropriate error.
- ***************************************************************************/
-int
-UpnpGetServiceVarStatus( IN UpnpClient_Handle Hnd,
- IN const char *ActionURL_const,
- IN const char *VarName_const,
- OUT DOMString * StVar )
+int UpnpGetServiceVarStatus(
+ UpnpClient_Handle Hnd,
+ const char *ActionURL_const,
+ const char *VarName_const,
+ DOMString *StVar)
{
struct Handle_Info *SInfo = NULL;
int retVal = 0;
char *StVarPtr;
- char *ActionURL = ( char * )ActionURL_const;
- char *VarName = ( char * )VarName_const;
+ char *ActionURL = (char *)ActionURL_const;
+ char *VarName = (char *)VarName_const;
- if( UpnpSdkInit != 1 ) {
+ if(UpnpSdkInit != 1) {
return UPNP_E_FINISH;
}
- UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
- "Inside UpnpGetServiceVarStatus \n" );
+ UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
+ "Inside UpnpGetServiceVarStatus\n");
HandleReadLock();
if( GetHandleInfo( Hnd, &SInfo ) != HND_CLIENT ) {
@@ -2922,14 +2442,13 @@ UpnpGetServiceVarStatus( IN UpnpClient_Handle Hnd,
retVal = SoapGetServiceVarStatus( ActionURL, VarName, &StVarPtr );
*StVar = StVarPtr;
- UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,
- "Exiting UpnpGetServiceVarStatus \n" );
+ UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
+ "Exiting UpnpGetServiceVarStatus \n");
return retVal;
-
}
-#endif // INCLUDE_CLIENT_APIS
-#endif // EXCLUDE_SOAP
+#endif /* INCLUDE_CLIENT_APIS */
+#endif /* EXCLUDE_SOAP */
/******************************************************************************
@@ -2946,8 +2465,8 @@ int UpnpOpenHttpPost(
int contentLength,
int timeout)
{
- return http_OpenHttpPost( url, handle, contentType, contentLength,
- timeout );
+ return http_OpenHttpPost(
+ url, handle, contentType, contentLength, timeout);
}
@@ -2957,7 +2476,7 @@ int UpnpWriteHttpPost(
unsigned int *size,
int timeout)
{
- return http_WriteHttpPost( handle, buf, size, timeout );
+ return http_WriteHttpPost(handle, buf, size, timeout);
}
@@ -2966,7 +2485,7 @@ int UpnpCloseHttpPost(
int *httpStatus,
int timeout)
{
- return http_CloseHttpPost( handle, httpStatus, timeout );
+ return http_CloseHttpPost(handle, httpStatus, timeout);
}
@@ -2978,8 +2497,8 @@ int UpnpOpenHttpGet(
int *httpStatus,
int timeout)
{
- return http_OpenHttpGet( url_str, Handle, contentType, contentLength,
- httpStatus, timeout );
+ return http_OpenHttpGet(
+ url_str, Handle, contentType, contentLength, httpStatus, timeout);
}
@@ -2992,8 +2511,9 @@ int UpnpOpenHttpGetProxy(
int *httpStatus,
int timeout)
{
- return http_OpenHttpGetProxy( url_str, proxy_str, Handle, contentType, contentLength,
- httpStatus, timeout );
+ return http_OpenHttpGetProxy(
+ url_str, proxy_str, Handle, contentType, contentLength,
+ httpStatus, timeout);
}
@@ -3007,11 +2527,9 @@ int UpnpOpenHttpGetEx(
int highRange,
int timeout)
{
- return http_OpenHttpGetEx( url_str,
- Handle,
- contentType,
- contentLength,
- httpStatus, lowRange, highRange, timeout );
+ return http_OpenHttpGetEx(
+ url_str, Handle, contentType, contentLength, httpStatus,
+ lowRange, highRange, timeout);
}
@@ -3059,11 +2577,6 @@ int UpnpDownloadUrlItem(const char *url, char **outBuf, char *contentType)
}
-/*!
- * \brief UpnpDownloadXmlDoc
- *
- * \return UPNP_E_SUCCESS if successful otherwise the appropriate error code.
- */
int UpnpDownloadXmlDoc(const char *url, IXML_Document **xmlDoc)
{
int ret_code;
@@ -3124,12 +2637,14 @@ int UpnpDownloadXmlDoc(const char *url, IXML_Document **xmlDoc)
}
}
+
//----------------------------------------------------------------------------
//
// UPNP-API Internal function implementation
//
//----------------------------------------------------------------------------
+
#ifdef WIN32
int WinsockInit()
{
@@ -3915,7 +3430,10 @@ int PrintHandleInfo(UpnpClient_Handle Hnd)
}
-void printNodes(IXML_Node *tmpRoot, int depth)
+/*!
+ * \brief Print the node names and values of a XML tree.
+ */
+static void printNodes(IXML_Node *tmpRoot, int depth)
{
int i;
IXML_NodeList *NodeList1;
diff --git a/upnp/src/api/upnpdebug.c b/upnp/src/api/upnpdebug.c
index 70ed021..d40ae8e 100644
--- a/upnp/src/api/upnpdebug.c
+++ b/upnp/src/api/upnpdebug.c
@@ -44,138 +44,77 @@
-//Mutex to synchronize all the log file opeartions in the debug mode
+/*! Mutex to synchronize all the log file opeartions in the debug mode */
static ithread_mutex_t GlobalDebugMutex;
-// Global log level
+/*! Global log level */
static Upnp_LogLevel g_log_level = UPNP_DEFAULT_LOG_LEVEL;
-//File handle for the error log file
+/*! File handle for the error log file */
static FILE *ErrFileHnd = NULL;
-//File handle for the information log file
+/*! File handle for the information log file */
static FILE *InfoFileHnd = NULL;
-//Name of the error file
+/*! Name of the error file */
static const char *errFileName = "IUpnpErrFile.txt";
-//Name of the info file
+/*! Name of the info file */
static const char *infoFileName = "IUpnpInfoFile.txt";
#ifdef DEBUG
-/***************************************************************************
- * Function : UpnpSetLogFileNames
- *
- * Parameters:
- * IN const char* ErrFileName: name of the error file
- * IN const char *InfoFileName: name of the information file
- * IN int size: Size of the buffer
- * IN int starLength: This parameter provides the width of the banner
- *
- * Description:
- * This functions takes the buffer and writes the buffer in the file as
- * per the requested banner
- * Returns: void
- ***************************************************************************/
-void
-UpnpSetLogFileNames ( IN const char *ErrFileName,
- IN const char *InfoFileName )
+int UpnpInitLog()
{
- if( ErrFileName ) {
- errFileName = ErrFileName;
- }
- if( InfoFileName ) {
- infoFileName = InfoFileName;
- }
+ ithread_mutex_init(&GlobalDebugMutex, NULL);
+ if(DEBUG_TARGET == 1) {
+ if((ErrFileHnd = fopen( errFileName, "a")) == NULL) {
+ return -1;
+ }
+ if((InfoFileHnd = fopen( infoFileName, "a")) == NULL) {
+ return -1;
+ }
+ }
+ return UPNP_E_SUCCESS;
}
-/***************************************************************************
- * Function : UpnpInitLog
- *
- * Parameters: void
- *
- * Description:
- * This functions initializes the log files
- *
- * Returns: int
- * -1 : If fails
- * UPNP_E_SUCCESS : if success
- ***************************************************************************/
-int
-UpnpInitLog()
-{
- ithread_mutex_init( &GlobalDebugMutex, NULL );
-
- if( DEBUG_TARGET == 1 ) {
- if( ( ErrFileHnd = fopen( errFileName, "a" ) ) == NULL )
- return -1;
- if( ( InfoFileHnd = fopen( infoFileName, "a" ) ) == NULL )
- return -1;
- }
- return UPNP_E_SUCCESS;
-}
-
-
-/***************************************************************************
- * Function : UpnpSetLogLevel
- *
- * Parameters: Upnp_LogLevel log_level
- *
- * Description:
- * This functions set the log level (see {\tt Upnp_LogLevel}
- * Returns: void
- ***************************************************************************/
-void
-UpnpSetLogLevel (Upnp_LogLevel log_level)
+void UpnpSetLogLevel(Upnp_LogLevel log_level)
{
g_log_level = log_level;
}
-/***************************************************************************
- * Function : UpnpCloseLog
- *
- * Parameters: void
- *
- * Description:
- * This functions closes the log files
- * Returns: void
- ***************************************************************************/
-void
-UpnpCloseLog()
+void UpnpCloseLog()
{
- if( DEBUG_TARGET == 1 ) {
- fflush( ErrFileHnd );
- fflush( InfoFileHnd );
- fclose( ErrFileHnd );
- fclose( InfoFileHnd );
- }
- ithread_mutex_destroy( &GlobalDebugMutex );
-
+ if (DEBUG_TARGET == 1) {
+ fflush(ErrFileHnd);
+ fflush(InfoFileHnd);
+ fclose(ErrFileHnd);
+ fclose(InfoFileHnd);
+ }
+ ithread_mutex_destroy(&GlobalDebugMutex);
}
-#endif // DEBUG
-/***************************************************************************
- * Function : DebugAtThisLevel
- *
- * Parameters:
- * IN Upnp_LogLevel DLevel: The level of the debug logging. It will decide
- * whether debug statement will go to standard output,
- * or any of the log files.
- * IN Dbg_Module Module: debug will go in the name of this module
- *
- * Description:
- * This functions returns true if debug output should be done in this
- * module.
- *
- * Returns: int
- ***************************************************************************/
+
+void UpnpSetLogFileNames(
+ const char *ErrFileName,
+ const char *InfoFileName)
+{
+ if (ErrFileName) {
+ errFileName = ErrFileName;
+ }
+ if (InfoFileName) {
+ infoFileName = InfoFileName;
+ }
+}
+#endif /* DEBUG */
+
+
#ifdef DEBUG
int DebugAtThisLevel(
- IN Upnp_LogLevel DLevel,
- IN Dbg_Module Module)
+ Upnp_LogLevel DLevel,
+ Dbg_Module Module)
{
int ret = DLevel <= g_log_level;
ret &=
@@ -195,12 +134,12 @@ int DebugAtThisLevel(
#ifdef DEBUG
void UpnpPrintf(
- IN Upnp_LogLevel DLevel,
- IN Dbg_Module Module,
- IN const char *DbgFileName,
- IN int DbgLineNo,
- IN const char *FmtStr,
- ... )
+ Upnp_LogLevel DLevel,
+ Dbg_Module Module,
+ const char *DbgFileName,
+ int DbgLineNo,
+ const char *FmtStr,
+ ...)
{
va_list ArgList;
@@ -235,24 +174,8 @@ void UpnpPrintf(
#endif
-/***************************************************************************
- * Function : UpnpGetDebugFile
- *
- * Parameters:
- * IN Upnp_LogLevel DLevel: The level of the debug logging. It will decide
- * whether debug statement will go to standard output,
- * or any of the log files.
- * IN Dbg_Module Module: debug will go in the name of this module
- *
- * Description:
- * This function checks if the module is turned on for debug
- * and returns the file descriptor corresponding to the debug level
- * Returns: FILE *
- * NULL : if the module is turn off for debug
- * else returns the right file descriptor
- ***************************************************************************/
#ifdef DEBUG
-FILE *GetDebugFile( Upnp_LogLevel DLevel, Dbg_Module Module )
+FILE *GetDebugFile(Upnp_LogLevel DLevel, Dbg_Module Module)
{
FILE *ret;
@@ -273,25 +196,11 @@ FILE *GetDebugFile( Upnp_LogLevel DLevel, Dbg_Module Module )
#endif
-/***************************************************************************
- * Function : UpnpDisplayFileAndLine
- *
- * Parameters:
- * IN FILE *fd: File descriptor where line number and file name will be
- * written
- * IN char *DbgFileName: Name of the file
- * IN int DbgLineNo : Line number of the file
- *
- * Description:
- * This function writes the file name and file number from where
- * debug statement is coming to the log file
- * Returns: void
- ***************************************************************************/
#ifdef DEBUG
void UpnpDisplayFileAndLine(
- IN FILE * fd,
- IN const char *DbgFileName,
- IN int DbgLineNo)
+ FILE *fd,
+ const char *DbgFileName,
+ int DbgLineNo)
{
#define NLINES 2
#define MAX_LINE_SIZE 512
@@ -329,10 +238,10 @@ void UpnpDisplayFileAndLine(
#ifdef DEBUG
void UpnpDisplayBanner(
- IN FILE * fd,
- IN const char **lines,
- IN size_t size,
- IN int starLength)
+ FILE * fd,
+ const char **lines,
+ size_t size,
+ int starLength)
{
int leftMarginLength = starLength / 2 + 1;
int rightMarginLength = starLength / 2 + 1;
@@ -373,12 +282,12 @@ void UpnpDisplayBanner(
rightMargin[rightMarginLength] = 0;
fprintf( fd, "*%s%s%s*\n", leftMargin, line, rightMargin );
}
- fprintf( fd, "%s\n\n", stars );
+ fprintf(fd, "%s\n\n", stars);
- free( currentLine );
- free( stars );
- free( rightMargin );
- free( leftMargin );
+ free(currentLine);
+ free(stars);
+ free(rightMargin);
+ free(leftMargin);
}
#endif
diff --git a/upnp/src/gena/gena_ctrlpt.c b/upnp/src/gena/gena_ctrlpt.c
index 4ab6265..69ff144 100644
--- a/upnp/src/gena/gena_ctrlpt.c
+++ b/upnp/src/gena/gena_ctrlpt.c
@@ -383,7 +383,7 @@ static int gena_subscribe(
}
-int genaUnregisterClient(IN UpnpClient_Handle client_handle)
+int genaUnregisterClient(UpnpClient_Handle client_handle)
{
ClientSubscription *sub_copy = UpnpClientSubscription_new();
int return_code = UPNP_E_SUCCESS;
@@ -430,8 +430,8 @@ exit_function:
#ifdef INCLUDE_CLIENT_APIS
int genaUnSubscribe(
- IN UpnpClient_Handle client_handle,
- IN const UpnpString *in_sid)
+ UpnpClient_Handle client_handle,
+ const UpnpString *in_sid)
{
ClientSubscription *sub = NULL;
int return_code = GENA_SUCCESS;
@@ -482,10 +482,10 @@ exit_function:
#ifdef INCLUDE_CLIENT_APIS
int genaSubscribe(
- IN UpnpClient_Handle client_handle,
- IN const UpnpString *PublisherURL,
- INOUT int *TimeOut,
- OUT UpnpString *out_sid)
+ UpnpClient_Handle client_handle,
+ const UpnpString *PublisherURL,
+ int *TimeOut,
+ UpnpString *out_sid)
{
int return_code = GENA_SUCCESS;
ClientSubscription *newSubscription = UpnpClientSubscription_new();
@@ -564,9 +564,9 @@ error_handler:
int genaRenewSubscription(
- IN UpnpClient_Handle client_handle,
- IN const UpnpString *in_sid,
- INOUT int *TimeOut)
+ UpnpClient_Handle client_handle,
+ const UpnpString *in_sid,
+ int *TimeOut)
{
int return_code = GENA_SUCCESS;
ClientSubscription *sub = NULL;
@@ -662,8 +662,8 @@ exit_function:
void gena_process_notification_event(
- IN SOCKINFO *info,
- IN http_message_t *event)
+ SOCKINFO *info,
+ http_message_t *event)
{
UpnpEvent *event_struct = UpnpEvent_new();
IXML_Document *ChangedVars = NULL;
diff --git a/upnp/src/gena/gena_device.c b/upnp/src/gena/gena_device.c
index 9ba2a66..66afb0b 100644
--- a/upnp/src/gena/gena_device.c
+++ b/upnp/src/gena/gena_device.c
@@ -61,7 +61,7 @@
*/
int genaUnregisterDevice(
/*! [in] Device handle. */
- IN UpnpDevice_Handle device_handle)
+ UpnpDevice_Handle device_handle)
{
int ret = 0;
struct Handle_Info *handle_info;
@@ -92,13 +92,13 @@ int genaUnregisterDevice(
*/
static int GeneratePropertySet(
/*! [in] Array of variable names (go in the event notify). */
- IN char **names,
+ char **names,
/*! [in] Array of variable values (go in the event notify). */
- IN char **values,
+ char **values,
/*! [in] number of variables. */
- IN int count,
+ int count,
/*! [out] PropertySet node in the string format. */
- OUT DOMString *out)
+ DOMString *out)
{
char *buffer;
int counter = 0;
@@ -147,7 +147,7 @@ static int GeneratePropertySet(
*/
static void free_notify_struct(
/*! [in] Notify structure. */
- IN notify_thread_struct *input)
+ notify_thread_struct *input)
{
( *input->reference_count )--;
if( ( *input->reference_count ) == 0 ) {
@@ -170,13 +170,13 @@ static void free_notify_struct(
*/
static UPNP_INLINE int notify_send_and_recv(
/*! [in] subscription callback URL (URL of the control point). */
- IN uri_type *destination_url,
+ uri_type *destination_url,
/*! [in] Common HTTP headers. */
- IN membuffer *mid_msg,
+ membuffer *mid_msg,
/*! [in] The evented XML. */
- IN char *propertySet,
+ char *propertySet,
/*! [out] The response from the control point. */
- OUT http_parser_t *response)
+ http_parser_t *response)
{
uri_type url;
int conn_fd;
@@ -258,11 +258,11 @@ static UPNP_INLINE int notify_send_and_recv(
*/
static int genaNotify(
/*! [in] Null terminated, includes all headers (including \\r\\n) except SID and SEQ. */
- IN char *headers,
+ char *headers,
/*! [in] The evented XML. */
- IN char *propertySet,
+ char *propertySet,
/*! [in] subscription to be Notified, assumes this is valid for life of function. */
- IN subscription *sub)
+ subscription *sub)
{
int i;
membuffer mid_msg;
@@ -326,7 +326,7 @@ static int genaNotify(
*/
static void genaNotifyThread(
/*! [in] notify thread structure containing all the headers and property set info. */
- IN void *input)
+ void *input)
{
subscription *sub;
service_info *service;
@@ -406,13 +406,13 @@ static void genaNotifyThread(
int genaInitNotify(
- IN UpnpDevice_Handle device_handle,
- IN char *UDN,
- IN char *servId,
- IN char **VarNames,
- IN char **VarValues,
- IN int var_count,
- IN const Upnp_SID sid)
+ UpnpDevice_Handle device_handle,
+ char *UDN,
+ char *servId,
+ char **VarNames,
+ char **VarValues,
+ int var_count,
+ const Upnp_SID sid)
{
int ret = GENA_SUCCESS;
int line = 0;
@@ -574,11 +574,11 @@ ExitFunction:
int genaInitNotifyExt(
- IN UpnpDevice_Handle device_handle,
- IN char *UDN,
- IN char *servId,
- IN IXML_Document *PropSet,
- IN const Upnp_SID sid)
+ UpnpDevice_Handle device_handle,
+ char *UDN,
+ char *servId,
+ IXML_Document *PropSet,
+ const Upnp_SID sid)
{
int ret = GENA_SUCCESS;
int line = 0;
@@ -669,10 +669,10 @@ int genaInitNotifyExt(
propertySet);
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;
+ 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__;
@@ -741,10 +741,10 @@ ExitFunction:
int genaNotifyAllExt(
- IN UpnpDevice_Handle device_handle,
- IN char *UDN,
- IN char *servId,
- IN IXML_Document *PropSet)
+ UpnpDevice_Handle device_handle,
+ char *UDN,
+ char *servId,
+ IXML_Document *PropSet)
{
int ret = GENA_SUCCESS;
int line = 0;
@@ -891,12 +891,12 @@ ExitFunction:
int genaNotifyAll(
- IN UpnpDevice_Handle device_handle,
- IN char *UDN,
- IN char *servId,
- IN char **VarNames,
- IN char **VarValues,
- IN int var_count )
+ UpnpDevice_Handle device_handle,
+ char *UDN,
+ char *servId,
+ char **VarNames,
+ char **VarValues,
+ int var_count )
{
int ret = GENA_SUCCESS;
int line = 0;
@@ -1049,13 +1049,13 @@ ExitFunction:
*/
static int respond_ok(
/*! [in] Socket connection of request. */
- IN SOCKINFO *info,
+ SOCKINFO *info,
/*! [in] Accepted duration. */
- IN int time_out,
+ int time_out,
/*! [in] Accepted subscription. */
- IN subscription *sub,
+ subscription *sub,
/*! [in] Http request. */
- IN http_message_t *request)
+ http_message_t *request)
{
int major;
int minor;
@@ -1109,9 +1109,9 @@ static int respond_ok(
*/
static int create_url_list(
/*! [in] . */
- IN memptr *url_list,
+ memptr *url_list,
/*! [out] . */
- OUT URL_list *out)
+ URL_list *out)
{
int URLcount = 0;
int i;
@@ -1185,8 +1185,8 @@ static int create_url_list(
void gena_process_subscription_request(
- IN SOCKINFO *info,
- IN http_message_t *request)
+ SOCKINFO *info,
+ http_message_t *request)
{
UpnpSubscriptionRequest *request_struct = UpnpSubscriptionRequest_new();
Upnp_SID temp_sid;
@@ -1368,8 +1368,8 @@ exit_function:
void gena_process_subscription_renewal_request(
- IN SOCKINFO *info,
- IN http_message_t *request)
+ SOCKINFO *info,
+ http_message_t *request)
{
Upnp_SID sid;
subscription *sub;
@@ -1480,8 +1480,8 @@ void gena_process_subscription_renewal_request(
void gena_process_unsubscribe_request(
- IN SOCKINFO *info,
- IN http_message_t *request)
+ SOCKINFO *info,
+ http_message_t *request)
{
Upnp_SID sid;
service_info *service;
diff --git a/upnp/src/genlib/miniserver/miniserver.c b/upnp/src/genlib/miniserver/miniserver.c
index abce442..46fb1cd 100644
--- a/upnp/src/genlib/miniserver/miniserver.c
+++ b/upnp/src/genlib/miniserver/miniserver.c
@@ -29,18 +29,27 @@
*
**************************************************************************/
-/************************************************************************
- * Purpose: This file implements the functionality and utility functions
+
+#include "config.h"
+
+
+/*!
+ * \file
+ *
+ * \brief This file implements the functionality and utility functions
* used by the Miniserver module.
*
* The miniserver is a central point for processing all network requests.
* It is made of:
* - The SSDP sockets for discovery.
* - The HTTP listeners for description / control / eventing.
- ************************************************************************/
+ *
+ */
+
-#include "config.h"
#include "miniserver.h"
+
+
#include "httpreadwrite.h"
#include "ithread.h"
#include "ssdplib.h"
@@ -49,6 +58,8 @@
#include "unixutil.h" /* for socklen_t, EAFNOSUPPORT */
#include "upnpapi.h"
#include "util.h"
+
+
#include
#include
#include
@@ -59,15 +70,24 @@
#define APPLICATION_LISTENING_PORT 49152
+
struct mserv_request_t {
- int connfd; // connection handle
- struct sockaddr_storage foreign_sockaddr;
+ /*! Connection handle. */
+ int connfd;
+ struct sockaddr_storage foreign_sockaddr;
};
-typedef enum { MSERV_IDLE, MSERV_RUNNING, MSERV_STOPPING } MiniServerState;
+
+typedef enum {
+ MSERV_IDLE,
+ MSERV_RUNNING,
+ MSERV_STOPPING
+} MiniServerState;
+
unsigned short miniStopSockPort;
+
////////////////////////////////////////////////////////////////////////////
// module vars
static MiniServerCallback gGetCallback = NULL;
@@ -75,1035 +95,925 @@ static MiniServerCallback gSoapCallback = NULL;
static MiniServerCallback gGenaCallback = NULL;
static MiniServerState gMServState = MSERV_IDLE;
-/************************************************************************
- * Function: SetHTTPGetCallback
- *
- * Parameters :
- * MiniServerCallback callback - HTTP Callback to be invoked
- *
- * Description:
- * Set HTTP Get Callback
- *
- * Return: void
- ************************************************************************/
-void
-SetHTTPGetCallback( MiniServerCallback callback )
+
+void SetHTTPGetCallback(MiniServerCallback callback)
{
- gGetCallback = callback;
+ gGetCallback = callback;
}
-/************************************************************************
- * Function: SetSoapCallback
- *
- * Parameters:
- * MiniServerCallback callback - SOAP Callback to be invoked
- *
- * Description:
- * Set SOAP Callback
- *
- * Return: void
- ************************************************************************/
+
#ifdef INCLUDE_DEVICE_APIS
-void
-SetSoapCallback( MiniServerCallback callback )
+void SetSoapCallback(MiniServerCallback callback)
{
- gSoapCallback = callback;
+ gSoapCallback = callback;
}
#endif /* INCLUDE_DEVICE_APIS */
-/************************************************************************
- * Function: SetGenaCallback
- *
- * Parameters:
- * MiniServerCallback callback - GENA Callback to be invoked
- *
- * Description:
- * Set GENA Callback
- *
- * Return: void
- ************************************************************************/
-void
-SetGenaCallback( MiniServerCallback callback )
+void SetGenaCallback(MiniServerCallback callback)
{
- gGenaCallback = callback;
+ gGenaCallback = callback;
}
+
#ifdef INTERNAL_WEB_SERVER
-/************************************************************************
- * Function : dispatch_request
+/*!
+ * \brief Based on the type pf message, appropriate callback is issued.
*
- * Parameters :
- * IN SOCKINFO *info - Socket Information object.
- * http_parser_t* hparser - HTTP parser object.
- *
- * Description :
- * Based on the type pf message, appropriate callback is issued
- *
- * Return: int
- * 0 - On Success
- * HTTP_INTERNAL_SERVER_ERROR - Callback is NULL
- ************************************************************************/
-static int
-dispatch_request( IN SOCKINFO * info,
- http_parser_t * hparser )
+ * \return 0 on Success or HTTP_INTERNAL_SERVER_ERROR if Callback is NULL.
+ */
+static int dispatch_request(
+ /*! [in] Socket Information object. */
+ IN SOCKINFO *info,
+ /*! [in] HTTP parser object. */
+ http_parser_t *hparser)
{
- MiniServerCallback callback;
+ MiniServerCallback callback;
- switch ( hparser->msg.method ) {
- //Soap Call
- case SOAPMETHOD_POST:
- case HTTPMETHOD_MPOST:
- callback = gSoapCallback;
- break;
+ switch (hparser->msg.method) {
+ /* Soap Call */
+ case SOAPMETHOD_POST:
+ case HTTPMETHOD_MPOST:
+ callback = gSoapCallback;
+ break;
- //Gena Call
- case HTTPMETHOD_NOTIFY:
- case HTTPMETHOD_SUBSCRIBE:
- case HTTPMETHOD_UNSUBSCRIBE:
- UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
- "miniserver %d: got GENA msg\n", info->socket );
- callback = gGenaCallback;
- break;
+ /* Gena Call */
+ case HTTPMETHOD_NOTIFY:
+ case HTTPMETHOD_SUBSCRIBE:
+ case HTTPMETHOD_UNSUBSCRIBE:
+ UpnpPrintf(UPNP_INFO, MSERV, __FILE__, __LINE__,
+ "miniserver %d: got GENA msg\n", info->socket);
+ callback = gGenaCallback;
+ break;
- //HTTP server call
- case HTTPMETHOD_GET:
- case HTTPMETHOD_POST:
- case HTTPMETHOD_HEAD:
- case HTTPMETHOD_SIMPLEGET:
- callback = gGetCallback;
- break;
+ /* HTTP server call */
+ case HTTPMETHOD_GET:
+ case HTTPMETHOD_POST:
+ case HTTPMETHOD_HEAD:
+ case HTTPMETHOD_SIMPLEGET:
+ callback = gGetCallback;
+ break;
- default:
- callback = NULL;
- }
+ default:
+ callback = NULL;
+ }
- if( callback == NULL ) {
- return HTTP_INTERNAL_SERVER_ERROR;
- }
+ if (callback == NULL) {
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
- callback( hparser, &hparser->msg, info );
- return 0;
+ callback(hparser, &hparser->msg, info);
+
+ return 0;
}
-/************************************************************************
- * Function: handle_error
- *
- * Parameters:
- * IN SOCKINFO *info - Socket Inforamtion Object
- * int http_error_code - HTTP Error Code
- * int major - Major Version Number
- * int minor - Minor Version Number
- *
- * Description:
- * Send Error Message
- *
- * Return: void
- ************************************************************************/
-static UPNP_INLINE void
-handle_error( IN SOCKINFO * info,
- int http_error_code,
- int major,
- int minor )
+
+/*!
+ * \brief Send Error Message.
+ */
+static UPNP_INLINE void handle_error(
+ /*! [in] Socket Information object. */
+ SOCKINFO *info,
+ /*! [in] HTTP Error Code. */
+ int http_error_code,
+ /*! [in] Major Version Number. */
+ int major,
+ /*! [in] Minor Version Number. */
+ int minor)
{
- http_SendStatusResponse( info, http_error_code, major, minor );
+ http_SendStatusResponse(info, http_error_code, major, minor);
}
-/************************************************************************
- * Function: free_handle_request_arg
- *
- * Parameters:
- * void *args ; Request Message to be freed
- *
- * Description:
- * Free memory assigned for handling request and unitialize socket
- * functionality
- *
- * Return: void
- ************************************************************************/
-static void
-free_handle_request_arg( void *args )
-{
- struct mserv_request_t *request = ( struct mserv_request_t * )args;
- shutdown( request->connfd, SD_BOTH );
- UpnpCloseSocket( request->connfd );
- free( request );
+/*!
+ * \brief Free memory assigned for handling request and unitialize socket
+ * functionality.
+ */
+static void free_handle_request_arg(
+ /*! [in] Request Message to be freed. */
+ void *args)
+{
+ struct mserv_request_t *request = (struct mserv_request_t *)args;
+
+ shutdown(request->connfd, SD_BOTH);
+ UpnpCloseSocket(request->connfd);
+ free(request);
}
-/************************************************************************
- * Function: handle_request
- *
- * Parameters:
- * void *args - Request Message to be handled
- *
- * Description:
- * Receive the request and dispatch it for handling
- *
- * Return: void
- ************************************************************************/
-static void
-handle_request( void *args )
+
+/*!
+ * \brief Receive the request and dispatch it for handling.
+ */
+static void handle_request(
+ /*! [in] Request Message to be handled. */
+ void *args)
{
- SOCKINFO info;
- int http_error_code;
- int ret_code;
- int major = 1;
- int minor = 1;
- http_parser_t parser;
- http_message_t *hmsg = NULL;
- int timeout = HTTP_DEFAULT_TIMEOUT;
- struct mserv_request_t *request = ( struct mserv_request_t * )args;
- int connfd = request->connfd;
+ SOCKINFO info;
+ int http_error_code;
+ int ret_code;
+ int major = 1;
+ int minor = 1;
+ http_parser_t parser;
+ http_message_t *hmsg = NULL;
+ int timeout = HTTP_DEFAULT_TIMEOUT;
+ struct mserv_request_t *request = (struct mserv_request_t *)args;
+ int connfd = request->connfd;
- UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
- "miniserver %d: READING\n", connfd );
- //parser_request_init( &parser ); ////LEAK_FIX_MK
- hmsg = &parser.msg;
+ UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
+ "miniserver %d: READING\n", connfd );
+ //parser_request_init( &parser ); ////LEAK_FIX_MK
+ hmsg = &parser.msg;
- if( sock_init_with_ip( &info, connfd, (struct sockaddr*)&request->foreign_sockaddr )
- != UPNP_E_SUCCESS ) {
- free( request );
- httpmsg_destroy( hmsg );
- return;
- }
- // read
- ret_code = http_RecvMessage( &info, &parser, HTTPMETHOD_UNKNOWN,
- &timeout, &http_error_code );
- if( ret_code != 0 ) {
- goto error_handler;
- }
+ ret_code = sock_init_with_ip(
+ &info, connfd, (struct sockaddr *)&request->foreign_sockaddr);
+ if (ret_code != UPNP_E_SUCCESS) {
+ free(request);
+ httpmsg_destroy(hmsg);
+ return;
+ }
- UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
- "miniserver %d: PROCESSING...\n", connfd );
- // dispatch
- http_error_code = dispatch_request( &info, &parser );
- if( http_error_code != 0 ) {
- goto error_handler;
- }
+ // read
+ ret_code = http_RecvMessage(
+ &info, &parser, HTTPMETHOD_UNKNOWN, &timeout, &http_error_code);
+ if (ret_code != 0) {
+ goto error_handler;
+ }
- http_error_code = 0;
+ UpnpPrintf(UPNP_INFO, MSERV, __FILE__, __LINE__,
+ "miniserver %d: PROCESSING...\n", connfd);
- error_handler:
- if( http_error_code > 0 ) {
- if( hmsg ) {
- major = hmsg->major_version;
- minor = hmsg->minor_version;
- }
- handle_error( &info, http_error_code, major, minor );
- }
+ // dispatch
+ http_error_code = dispatch_request( &info, &parser );
+ if (http_error_code != 0) {
+ goto error_handler;
+ }
- UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
- "miniserver %d: COMPLETE\n", connfd );
- sock_destroy( &info, SD_BOTH ); //should shutdown completely
+ http_error_code = 0;
- httpmsg_destroy( hmsg );
- free( request );
+error_handler:
+ if (http_error_code > 0) {
+ if (hmsg) {
+ major = hmsg->major_version;
+ minor = hmsg->minor_version;
+ }
+ handle_error(&info, http_error_code, major, minor);
+ }
+
+ UpnpPrintf(UPNP_INFO, MSERV, __FILE__, __LINE__,
+ "miniserver %d: COMPLETE\n", connfd);
+ sock_destroy(&info, SD_BOTH); // should shutdown completely
+
+ httpmsg_destroy(hmsg);
+ free(request);
}
-/************************************************************************
- * Function: schedule_request_job
- *
- * Parameters:
- * IN int connfd - Socket Descriptor on which connection is accepted
- * IN struct sockaddr* clientAddr - Clients Address information
- *
- * Description:
- * Initilize the thread pool to handle a request.
- * Sets priority for the job and adds the job to the thread pool
- *
- * Return: void
- ************************************************************************/
-static UPNP_INLINE void
-schedule_request_job( IN int connfd,
- IN struct sockaddr *clientAddr )
+
+/*!
+ * \brief Initilize the thread pool to handle a request, sets priority for the
+ * job and adds the job to the thread pool.
+ */
+static UPNP_INLINE void schedule_request_job(
+ /*! [in] Socket Descriptor on which connection is accepted. */
+ int connfd,
+ /*! [in] Clients Address information. */
+ struct sockaddr *clientAddr)
{
- struct mserv_request_t *request;
- ThreadPoolJob job;
+ struct mserv_request_t *request;
+ ThreadPoolJob job;
- request =
- ( struct mserv_request_t * )
- malloc( sizeof( struct mserv_request_t ) );
- if( request == NULL ) {
- UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
- "mserv %d: out of memory\n", connfd );
- shutdown( connfd, SD_BOTH );
- UpnpCloseSocket( connfd );
- return;
- }
+ request = (struct mserv_request_t *)malloc(sizeof (struct mserv_request_t));
+ if (request == NULL) {
+ UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
+ "mserv %d: out of memory\n", connfd );
+ shutdown( connfd, SD_BOTH );
+ UpnpCloseSocket( connfd );
+ return;
+ }
- request->connfd = connfd;
- memcpy( &request->foreign_sockaddr, clientAddr, sizeof(request->foreign_sockaddr) );
+ request->connfd = connfd;
+ memcpy(&request->foreign_sockaddr, clientAddr,
+ sizeof(request->foreign_sockaddr));
- TPJobInit( &job, ( start_routine ) handle_request, ( void * )request );
- TPJobSetFreeFunction( &job, free_handle_request_arg );
- TPJobSetPriority( &job, MED_PRIORITY );
-
- if( ThreadPoolAdd( &gMiniServerThreadPool, &job, NULL ) != 0 ) {
- UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
- "mserv %d: cannot schedule request\n", connfd );
- free( request );
- shutdown( connfd, SD_BOTH );
- UpnpCloseSocket( connfd );
- return;
- }
+ TPJobInit(&job, (start_routine)handle_request, (void *)request);
+ TPJobSetFreeFunction(&job, free_handle_request_arg);
+ TPJobSetPriority(&job, MED_PRIORITY);
+ if (ThreadPoolAdd(&gMiniServerThreadPool, &job, NULL) != 0) {
+ UpnpPrintf(UPNP_INFO, MSERV, __FILE__, __LINE__,
+ "mserv %d: cannot schedule request\n", connfd);
+ free(request);
+ shutdown(connfd, SD_BOTH);
+ UpnpCloseSocket(connfd);
+ return;
+ }
}
#endif
-/************************************************************************
- * Function: RunMiniServer
+
+/*!
+ * \brief Run the miniserver.
*
- * Parameters:
- * MiniServerSockArray *miniSock - Socket Array
- *
- * Description:
- * Function runs the miniserver. The MiniServer accepts a
- * new request and schedules a thread to handle the new request.
- * Checks for socket state and invokes appropriate read and shutdown
- * actions for the Miniserver and SSDP sockets
- *
- * Return: void
- ************************************************************************/
-static void
-RunMiniServer( MiniServerSockArray *miniSock )
+ * The MiniServer accepts a new request and schedules a thread to handle the
+ * new request. Checks for socket state and invokes appropriate read and
+ * shutdown actions for the Miniserver and SSDP sockets.
+ */
+static void RunMiniServer(
+ /*! [in] Socket Array. */
+ MiniServerSockArray *miniSock)
{
- char errorBuffer[ERROR_BUFFER_LEN];
- struct sockaddr_storage clientAddr;
- socklen_t clientLen;
- SOCKET connectHnd;
- SOCKET miniServStopSock = miniSock->miniServerStopSock;
- SOCKET ssdpSock4 = miniSock->ssdpSock4;
- SOCKET ssdpSock6 = miniSock->ssdpSock6;
+ char errorBuffer[ERROR_BUFFER_LEN];
+ struct sockaddr_storage clientAddr;
+ socklen_t clientLen;
+ SOCKET connectHnd;
+ SOCKET miniServStopSock = miniSock->miniServerStopSock;
+ SOCKET ssdpSock4 = miniSock->ssdpSock4;
+ SOCKET ssdpSock6 = miniSock->ssdpSock6;
#ifdef INTERNAL_WEB_SERVER
- SOCKET miniServSock4 = miniSock->miniServerSock4;
- SOCKET miniServSock6 = miniSock->miniServerSock6;
-#endif
+ SOCKET miniServSock4 = miniSock->miniServerSock4;
+ SOCKET miniServSock6 = miniSock->miniServerSock6;
+#endif /* INTERNAL_WEB_SERVER */
#ifdef INCLUDE_CLIENT_APIS
- SOCKET ssdpReqSock4 = miniSock->ssdpReqSock4;
- SOCKET ssdpReqSock6 = miniSock->ssdpReqSock6;
-#endif
- char buf_ntop[64];
- fd_set expSet;
- fd_set rdSet;
- unsigned int maxMiniSock = 0;
- int byteReceived;
- char requestBuf[256];
- int ret = 0;
+ SOCKET ssdpReqSock4 = miniSock->ssdpReqSock4;
+ SOCKET ssdpReqSock6 = miniSock->ssdpReqSock6;
+#endif /* INCLUDE_CLIENT_APIS */
+ char buf_ntop[64];
+ fd_set expSet;
+ fd_set rdSet;
+ unsigned int maxMiniSock = 0;
+ int byteReceived;
+ char requestBuf[256];
+ int ret = 0;
#ifdef INTERNAL_WEB_SERVER
- if( miniServSock4 != INVALID_SOCKET )
- maxMiniSock = max( maxMiniSock, miniServSock4 );
- if( miniServSock6 != INVALID_SOCKET )
- maxMiniSock = max( maxMiniSock, miniServSock6 );
-#endif
- if( ssdpSock4 != INVALID_SOCKET )
- maxMiniSock = max( maxMiniSock, ssdpSock4 );
- if( ssdpSock6 != INVALID_SOCKET )
- maxMiniSock = max( maxMiniSock, ssdpSock6 );
+ if (miniServSock4 != INVALID_SOCKET) {
+ maxMiniSock = max(maxMiniSock, miniServSock4);
+ }
+ if (miniServSock6 != INVALID_SOCKET) {
+ maxMiniSock = max(maxMiniSock, miniServSock6);
+ }
+#endif /* INTERNAL_WEB_SERVER */
+ if (ssdpSock4 != INVALID_SOCKET) {
+ maxMiniSock = max(maxMiniSock, ssdpSock4);
+ }
+ if (ssdpSock6 != INVALID_SOCKET) {
+ maxMiniSock = max(maxMiniSock, ssdpSock6);
+ }
#ifdef INCLUDE_CLIENT_APIS
- if( ssdpReqSock4 != INVALID_SOCKET )
- maxMiniSock = max( maxMiniSock, ssdpReqSock4 );
- if( ssdpReqSock6 != INVALID_SOCKET )
- maxMiniSock = max( maxMiniSock, ssdpReqSock6 );
-#endif
- maxMiniSock = max( maxMiniSock, miniServStopSock) ;
- ++maxMiniSock;
+ if (ssdpReqSock4 != INVALID_SOCKET) {
+ maxMiniSock = max(maxMiniSock, ssdpReqSock4);
+ }
+ if (ssdpReqSock6 != INVALID_SOCKET) {
+ maxMiniSock = max(maxMiniSock, ssdpReqSock6);
+ }
+#endif /* INCLUDE_CLIENT_APIS */
+ maxMiniSock = max(maxMiniSock, miniServStopSock);
+ ++maxMiniSock;
- gMServState = MSERV_RUNNING;
- while( TRUE ) {
- FD_ZERO( &rdSet );
- FD_ZERO( &expSet );
+ gMServState = MSERV_RUNNING;
+ while(TRUE) {
+ FD_ZERO(&rdSet);
+ FD_ZERO(&expSet);
- FD_SET( miniServStopSock, &expSet );
- FD_SET( miniServStopSock, &rdSet );
+ FD_SET(miniServStopSock, &expSet);
+ FD_SET(miniServStopSock, &rdSet);
#ifdef INTERNAL_WEB_SERVER
- if( miniServSock4 != INVALID_SOCKET )
- FD_SET( miniServSock4, &rdSet );
- if( miniServSock6 != INVALID_SOCKET )
- FD_SET( miniServSock6, &rdSet );
-#endif
- if( ssdpSock4 != INVALID_SOCKET )
- FD_SET( ssdpSock4, &rdSet );
- if( ssdpSock6 != INVALID_SOCKET )
- FD_SET( ssdpSock6, &rdSet );
+ if(miniServSock4 != INVALID_SOCKET) {
+ FD_SET(miniServSock4, &rdSet);
+ }
+ if(miniServSock6 != INVALID_SOCKET) {
+ FD_SET(miniServSock6, &rdSet);
+ }
+#endif /* INTERNAL_WEB_SERVER */
+ if(ssdpSock4 != INVALID_SOCKET) {
+ FD_SET(ssdpSock4, &rdSet);
+ }
+ if(ssdpSock6 != INVALID_SOCKET) {
+ FD_SET(ssdpSock6, &rdSet);
+ }
#ifdef INCLUDE_CLIENT_APIS
- if( ssdpReqSock4 != INVALID_SOCKET )
- FD_SET( ssdpReqSock4, &rdSet );
- if( ssdpReqSock6 != INVALID_SOCKET )
- FD_SET( ssdpReqSock6, &rdSet );
-#endif
+ if(ssdpReqSock4 != INVALID_SOCKET) {
+ FD_SET(ssdpReqSock4, &rdSet);
+ }
+ if(ssdpReqSock6 != INVALID_SOCKET) {
+ FD_SET(ssdpReqSock6, &rdSet);
+ }
+#endif /* INCLUDE_CLIENT_APIS */
- ret = select( maxMiniSock, &rdSet, NULL, &expSet, NULL );
- if ( ret == -1 ) {
- strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
- UpnpPrintf( UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
- "Error in select(): %s\n", errorBuffer );
- /* Avoid 100% CPU in case of repeated error in select() */
- isleep( 1 );
- continue;
- } else {
+ ret = select(maxMiniSock, &rdSet, NULL, &expSet, NULL);
+ if (ret == -1) {
+ strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
+ UpnpPrintf(UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
+ "Error in select(): %s\n", errorBuffer);
+ /* Avoid 100% CPU in case of repeated error in select() */
+ isleep(1);
+ continue;
+ } else {
#ifdef INTERNAL_WEB_SERVER
- if( miniServSock6 != INVALID_SOCKET &&
- FD_ISSET( miniServSock6, &rdSet ) ) {
- clientLen = sizeof( clientAddr );
- connectHnd = accept( miniServSock6,
- ( struct sockaddr * )&clientAddr, &clientLen );
- if( connectHnd == -1 ) {
- strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
- UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
- "miniserver: Error in accept(): %s\n", errorBuffer );
- continue;
- }
- schedule_request_job( connectHnd, (struct sockaddr*)&clientAddr );
- }
- if( miniServSock4 != INVALID_SOCKET &&
- FD_ISSET( miniServSock4, &rdSet ) ) {
- clientLen = sizeof( clientAddr );
- connectHnd = accept( miniServSock4,
- ( struct sockaddr * )&clientAddr, &clientLen );
- if( connectHnd == -1 ) {
- strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
- UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
- "miniserver: Error in accept(): %s\n", errorBuffer );
- continue;
- }
- schedule_request_job( connectHnd, (struct sockaddr*)&clientAddr );
- }
-#endif
+ if (miniServSock6 != INVALID_SOCKET &&
+ FD_ISSET(miniServSock6, &rdSet)) {
+ clientLen = sizeof( clientAddr );
+ connectHnd = accept(miniServSock6,
+ (struct sockaddr *)&clientAddr, &clientLen);
+ if (connectHnd == -1) {
+ strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
+ UpnpPrintf(UPNP_INFO, MSERV, __FILE__, __LINE__,
+ "miniserver: Error in accept(): %s\n",
+ errorBuffer);
+ continue;
+ }
+ schedule_request_job(
+ connectHnd, (struct sockaddr *)&clientAddr);
+ }
+ if (miniServSock4 != INVALID_SOCKET &&
+ FD_ISSET(miniServSock4, &rdSet)) {
+ clientLen = sizeof(clientAddr);
+ connectHnd = accept(miniServSock4,
+ (struct sockaddr *)&clientAddr, &clientLen);
+ if (connectHnd == -1) {
+ strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
+ UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
+ "miniserver: Error in accept(): %s\n",
+ errorBuffer);
+ continue;
+ }
+ schedule_request_job(
+ connectHnd, (struct sockaddr *)&clientAddr);
+ }
+#endif /* INTERNAL_WEB_SERVER */
#ifdef INCLUDE_CLIENT_APIS
- // ssdp
- if( ssdpReqSock6 != INVALID_SOCKET &&
- FD_ISSET( ssdpReqSock6, &rdSet ) ) {
- readFromSSDPSocket( ssdpReqSock6 );
- }
- if( ssdpReqSock4 != INVALID_SOCKET &&
- FD_ISSET( ssdpReqSock4, &rdSet ) ) {
- readFromSSDPSocket( ssdpReqSock4 );
- }
-#endif
- if( ssdpSock6 != INVALID_SOCKET &&
- FD_ISSET( ssdpSock6, &rdSet ) ) {
- readFromSSDPSocket( ssdpSock6 );
- }
- if( ssdpSock4 != INVALID_SOCKET &&
- FD_ISSET( ssdpSock4, &rdSet ) ) {
- readFromSSDPSocket( ssdpSock4 );
- }
- if( FD_ISSET( miniServStopSock, &rdSet ) ) {
- clientLen = sizeof( clientAddr );
- memset( (char *)&clientAddr, 0, sizeof(clientAddr) );
- byteReceived =
- recvfrom( miniServStopSock, requestBuf, 25, 0,
- ( struct sockaddr * )&clientAddr,
- &clientLen );
- if( byteReceived > 0 ) {
- requestBuf[byteReceived] = '\0';
- inet_ntop(AF_INET,
- &((struct sockaddr_in*)&clientAddr)->sin_addr,
- buf_ntop, sizeof(buf_ntop) );
- UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
- "Received response: %s From host %s \n",
- requestBuf, buf_ntop );
- UpnpPrintf( UPNP_PACKET, MSERV, __FILE__, __LINE__,
- "Received multicast packet: \n %s\n",
- requestBuf );
- if( NULL != strstr( requestBuf, "ShutDown" ) ) {
- break;
- }
- }
- }
- }
- }
+ // ssdp
+ if (ssdpReqSock6 != INVALID_SOCKET &&
+ FD_ISSET(ssdpReqSock6, &rdSet)) {
+ readFromSSDPSocket(ssdpReqSock6);
+ }
+ if (ssdpReqSock4 != INVALID_SOCKET &&
+ FD_ISSET( ssdpReqSock4, &rdSet)) {
+ readFromSSDPSocket(ssdpReqSock4);
+ }
+#endif /* INCLUDE_CLIENT_APIS */
+ if (ssdpSock6 != INVALID_SOCKET &&
+ FD_ISSET(ssdpSock6, &rdSet)) {
+ readFromSSDPSocket(ssdpSock6);
+ }
+ if (ssdpSock4 != INVALID_SOCKET &&
+ FD_ISSET(ssdpSock4, &rdSet)) {
+ readFromSSDPSocket(ssdpSock4);
+ }
+ if (FD_ISSET( miniServStopSock, &rdSet)) {
+ clientLen = sizeof(clientAddr);
+ memset((char *)&clientAddr, 0, sizeof(clientAddr));
+ byteReceived = recvfrom(miniServStopSock, requestBuf,
+ 25, 0, (struct sockaddr *)&clientAddr, &clientLen);
+ if (byteReceived > 0) {
+ requestBuf[byteReceived] = '\0';
+ inet_ntop(AF_INET,
+ &((struct sockaddr_in*)&clientAddr)->sin_addr,
+ buf_ntop, sizeof(buf_ntop));
+ UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
+ "Received response: %s From host %s \n",
+ requestBuf, buf_ntop );
+ UpnpPrintf( UPNP_PACKET, MSERV, __FILE__, __LINE__,
+ "Received multicast packet: \n %s\n",
+ requestBuf);
+ if (NULL != strstr(requestBuf, "ShutDown")) {
+ break;
+ }
+ }
+ }
+ }
+ }
#ifdef INTERNAL_WEB_SERVER
- shutdown( miniServSock4, SD_BOTH );
- UpnpCloseSocket( miniServSock4 );
- shutdown( miniServSock6, SD_BOTH );
- UpnpCloseSocket( miniServSock6 );
-#endif
- shutdown( miniServStopSock, SD_BOTH );
- UpnpCloseSocket( miniServStopSock );
- shutdown( ssdpSock4, SD_BOTH );
- UpnpCloseSocket( ssdpSock4 );
- shutdown( ssdpSock6, SD_BOTH );
- UpnpCloseSocket( ssdpSock6 );
+ shutdown(miniServSock4, SD_BOTH);
+ UpnpCloseSocket(miniServSock4);
+ shutdown(miniServSock6, SD_BOTH);
+ UpnpCloseSocket(miniServSock6);
+#endif /* INTERNAL_WEB_SERVER */
+ shutdown(miniServStopSock, SD_BOTH);
+ UpnpCloseSocket(miniServStopSock);
+ shutdown(ssdpSock4, SD_BOTH);
+ UpnpCloseSocket(ssdpSock4);
+ shutdown(ssdpSock6, SD_BOTH);
+ UpnpCloseSocket(ssdpSock6);
#ifdef INCLUDE_CLIENT_APIS
- shutdown( ssdpReqSock4, SD_BOTH );
- UpnpCloseSocket( ssdpReqSock4 );
- shutdown( ssdpReqSock6, SD_BOTH );
- UpnpCloseSocket( ssdpReqSock6 );
-#endif
+ shutdown(ssdpReqSock4, SD_BOTH);
+ UpnpCloseSocket(ssdpReqSock4);
+ shutdown(ssdpReqSock6, SD_BOTH);
+ UpnpCloseSocket(ssdpReqSock6);
+#endif /* INCLUDE_CLIENT_APIS */
- free( miniSock );
- gMServState = MSERV_IDLE;
+ free(miniSock);
+ gMServState = MSERV_IDLE;
- return;
+ return;
}
-/************************************************************************
- * Function: get_port
+
+/*!
+ * \brief Returns port to which socket, sockfd, is bound.
*
- * Parameters:
- * int sockfd - Socket Descriptor
- *
- * Description:
- * Returns port to which socket, sockfd, is bound.
- *
- * Return: int
- * -1 on error; check errno
- * > 0 means port number
- ************************************************************************/
-static int
-get_port( int sockfd )
+ * \return -1 on error; check errno, otherwise > 0 means port number.
+ */
+static int get_port(
+ /*! [in] Socket descriptor. */
+ int sockfd)
{
- struct sockaddr_storage sockinfo;
- socklen_t len;
- int code;
- int port = 0;
+ struct sockaddr_storage sockinfo;
+ socklen_t len;
+ int code;
+ int port = 0;
- len = sizeof( sockinfo );
- code = getsockname( sockfd, ( struct sockaddr * )&sockinfo, &len );
- if( code == -1 ) {
- return -1;
- }
+ len = sizeof(sockinfo);
+ code = getsockname(sockfd, (struct sockaddr *)&sockinfo, &len);
+ if (code == -1) {
+ return -1;
+ }
- if( sockinfo.ss_family == AF_INET ) {
- port = ntohs( ((struct sockaddr_in*)&sockinfo)->sin_port );
- } else if( sockinfo.ss_family == AF_INET6 ) {
- port = ntohs( ((struct sockaddr_in6*)&sockinfo)->sin6_port );
- }
- UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
- "sockfd = %d, .... port = %d\n", sockfd, port );
+ if (sockinfo.ss_family == AF_INET) {
+ port = ntohs(((struct sockaddr_in*)&sockinfo)->sin_port);
+ } else if(sockinfo.ss_family == AF_INET6) {
+ port = ntohs(((struct sockaddr_in6*)&sockinfo)->sin6_port);
+ }
+ UpnpPrintf(UPNP_INFO, MSERV, __FILE__, __LINE__,
+ "sockfd = %d, .... port = %d\n", sockfd, port);
- return port;
+ return port;
}
+
#ifdef INTERNAL_WEB_SERVER
-/************************************************************************
- * Function: get_miniserver_sockets
+/*!
+ * \brief Creates a STREAM socket, binds to INADDR_ANY and listens for
+ * incoming connecttions. Returns the actual port which the sockets
+ * sub-system returned.
*
- * Parameters:
- * MiniServerSockArray *out - Socket Array
- * unsigned short listen_port4 - port on which the server is
- * listening for incoming IPv4 connections
- * unsigned short listen_port6 - port on which the server is
- * listening for incoming IPv6 connections
+ * Also creates a DGRAM socket, binds to the loop back address and
+ * returns the port allocated by the socket sub-system.
*
- * Description:
- * Creates a STREAM socket, binds to INADDR_ANY and listens for
- * incoming connecttions. Returns the actual port which the sockets
- * sub-system returned.
- *
- * Also creates a DGRAM socket, binds to the loop back address and
- * returns the port allocated by the socket sub-system.
- *
- * Return: int
- * UPNP_E_OUTOF_SOCKET - Failed to create a socket
- * UPNP_E_SOCKET_BIND - Bind() failed
- * UPNP_E_LISTEN - Listen() failed
- * UPNP_E_INTERNAL_ERROR - Port returned by the socket layer is < 0
- * UPNP_E_SUCCESS - Success
- ************************************************************************/
-int
-get_miniserver_sockets( MiniServerSockArray * out,
- unsigned short listen_port4,
- unsigned short listen_port6 )
+ * \return
+ * \li UPNP_E_OUTOF_SOCKET: Failed to create a socket.
+ * \li UPNP_E_SOCKET_BIND: Bind() failed.
+ * \li UPNP_E_LISTEN: Listen() failed.
+ * \li UPNP_E_INTERNAL_ERROR: Port returned by the socket layer is < 0.
+ * \li UPNP_E_SUCCESS: Success.
+ */
+static int get_miniserver_sockets(
+ /*! [in] Socket Array. */
+ MiniServerSockArray *out,
+ /*! [in] port on which the server is listening for incoming IPv4 connections. */
+ unsigned short listen_port4,
+ /*! [in] port on which the server is listening for incoming IPv6 connections. */
+ unsigned short listen_port6)
{
- char errorBuffer[ERROR_BUFFER_LEN];
- struct sockaddr_storage __ss_v4;
- struct sockaddr_storage __ss_v6;
- struct sockaddr_in* serverAddr4 = (struct sockaddr_in*)&__ss_v4;
- struct sockaddr_in6* serverAddr6 = (struct sockaddr_in6*)&__ss_v6;
- SOCKET listenfd4, listenfd6;
- int ret_code;
- unsigned short actual_port4, actual_port6;
- int reuseaddr_on = 0;
- int sockError = UPNP_E_SUCCESS;
- int errCode = 0;
- int ret = 0;
+ char errorBuffer[ERROR_BUFFER_LEN];
+ struct sockaddr_storage __ss_v4;
+ struct sockaddr_storage __ss_v6;
+ struct sockaddr_in* serverAddr4 = (struct sockaddr_in*)&__ss_v4;
+ struct sockaddr_in6* serverAddr6 = (struct sockaddr_in6*)&__ss_v6;
+ SOCKET listenfd4, listenfd6;
+ int ret_code;
+ unsigned short actual_port4, actual_port6;
+ int reuseaddr_on = 0;
+ int sockError = UPNP_E_SUCCESS;
+ int errCode = 0;
- // Create listen socket for IPv4/IPv6. An error here may indicate
- // that we don't have an IPv4/IPv6 stack.
- listenfd4 = socket( AF_INET, SOCK_STREAM, 0 );
- listenfd6 = socket( AF_INET6, SOCK_STREAM, 0 );
- if (listenfd4 == INVALID_SOCKET && listenfd6 == INVALID_SOCKET) {
- return UPNP_E_OUTOF_SOCKET;
- }
+ // Create listen socket for IPv4/IPv6. An error here may indicate
+ // that we don't have an IPv4/IPv6 stack.
+ listenfd4 = socket(AF_INET, SOCK_STREAM, 0);
+ listenfd6 = socket(AF_INET6, SOCK_STREAM, 0);
+ if (listenfd4 == INVALID_SOCKET && listenfd6 == INVALID_SOCKET) {
+ return UPNP_E_OUTOF_SOCKET;
+ }
- // As per the IANA specifications for the use of ports by applications
- // override the listen port passed in with the first available
- if (listen_port4 < APPLICATION_LISTENING_PORT) {
- listen_port4 = APPLICATION_LISTENING_PORT;
- }
- if (listen_port6 < APPLICATION_LISTENING_PORT) {
- listen_port6 = APPLICATION_LISTENING_PORT;
- }
+ // As per the IANA specifications for the use of ports by applications
+ // override the listen port passed in with the first available
+ if (listen_port4 < APPLICATION_LISTENING_PORT) {
+ listen_port4 = APPLICATION_LISTENING_PORT;
+ }
+ if (listen_port6 < APPLICATION_LISTENING_PORT) {
+ listen_port6 = APPLICATION_LISTENING_PORT;
+ }
- memset( &__ss_v4, 0, sizeof( __ss_v4 ) );
- serverAddr4->sin_family = AF_INET;
- serverAddr4->sin_addr.s_addr = htonl( INADDR_ANY );
+ memset(&__ss_v4, 0, sizeof (__ss_v4));
+ serverAddr4->sin_family = AF_INET;
+ serverAddr4->sin_addr.s_addr = htonl(INADDR_ANY);
- memset( &__ss_v6, 0, sizeof( __ss_v6 ) );
- serverAddr6->sin6_family = AF_INET6;
- serverAddr6->sin6_addr = in6addr_any;
+ memset(&__ss_v6, 0, sizeof (__ss_v6));
+ serverAddr6->sin6_family = AF_INET6;
+ serverAddr6->sin6_addr = in6addr_any;
- // Getting away with implementation of re-using address:port and instead
- // choosing to increment port numbers.
- // Keeping the re-use address code as an optional behaviour that can be
- // turned on if necessary.
- // TURN ON the reuseaddr_on option to use the option.
- if ( reuseaddr_on ) {
- // THIS IS ALLOWS US TO BIND AGAIN IMMEDIATELY
- // AFTER OUR SERVER HAS BEEN CLOSED
- // THIS MAY CAUSE TCP TO BECOME LESS RELIABLE
- // HOWEVER IT HAS BEEN SUGESTED FOR TCP SERVERS
- UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
- "get_miniserver_sockets: resuseaddr set\n" );
+ // Getting away with implementation of re-using address:port and instead
+ // choosing to increment port numbers.
+ // Keeping the re-use address code as an optional behaviour that can be
+ // turned on if necessary.
+ // TURN ON the reuseaddr_on option to use the option.
+ if (reuseaddr_on) {
+ // THIS IS ALLOWS US TO BIND AGAIN IMMEDIATELY
+ // AFTER OUR SERVER HAS BEEN CLOSED
+ // THIS MAY CAUSE TCP TO BECOME LESS RELIABLE
+ // HOWEVER IT HAS BEEN SUGESTED FOR TCP SERVERS
+ UpnpPrintf(UPNP_INFO, MSERV, __FILE__, __LINE__,
+ "get_miniserver_sockets: resuseaddr set\n");
- if( listenfd4 != INVALID_SOCKET ) {
- sockError = setsockopt( listenfd4, SOL_SOCKET, SO_REUSEADDR,
- (const char *)&reuseaddr_on, sizeof (int) );
- if ( sockError == -1 ) {
- shutdown( listenfd4, SD_BOTH );
- UpnpCloseSocket( listenfd4 );
- shutdown( listenfd6, SD_BOTH );
- UpnpCloseSocket( listenfd6 );
+ if (listenfd4 != INVALID_SOCKET) {
+ sockError = setsockopt(listenfd4, SOL_SOCKET, SO_REUSEADDR,
+ (const char *)&reuseaddr_on, sizeof (int));
+ if (sockError == -1) {
+ shutdown(listenfd4, SD_BOTH);
+ UpnpCloseSocket(listenfd4);
+ shutdown(listenfd6, SD_BOTH);
+ UpnpCloseSocket(listenfd6);
+ return UPNP_E_SOCKET_BIND;
+ }
- return UPNP_E_SOCKET_BIND;
- }
+ sockError = bind(listenfd4, (struct sockaddr *)&__ss_v4,
+ sizeof (__ss_v4));
+ if (sockError == -1) {
+ strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
+ UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
+ "get_miniserver_sockets: Error in IPv4 bind(): %s\n",
+ errorBuffer);
+ shutdown(listenfd4, SD_BOTH);
+ UpnpCloseSocket(listenfd4);
+ shutdown(listenfd6, SD_BOTH);
+ UpnpCloseSocket(listenfd6);
+ /* Bind failed */
+ return UPNP_E_SOCKET_BIND;
+ }
+ }
- sockError = bind( listenfd4, (struct sockaddr *)&__ss_v4,
- sizeof(__ss_v4) );
- if ( sockError == -1 ) {
- strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
- UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
- "get_miniserver_sockets: Error in IPv4 bind(): %s\n",
- errorBuffer );
- shutdown( listenfd4, SD_BOTH );
- UpnpCloseSocket( listenfd4 );
- shutdown( listenfd6, SD_BOTH );
- UpnpCloseSocket( listenfd6 );
+ if(listenfd6 != INVALID_SOCKET) {
+ sockError = setsockopt(listenfd6, SOL_SOCKET, SO_REUSEADDR,
+ (const char *)&reuseaddr_on, sizeof (int));
+ if (sockError == -1) {
+ shutdown(listenfd4, SD_BOTH);
+ UpnpCloseSocket(listenfd4);
+ shutdown(listenfd6, SD_BOTH);
+ UpnpCloseSocket(listenfd6);
+ return UPNP_E_SOCKET_BIND;
+ }
- return UPNP_E_SOCKET_BIND; // bind failed
- }
- }
-
- if( listenfd6 != INVALID_SOCKET ) {
- sockError = setsockopt( listenfd6, SOL_SOCKET, SO_REUSEADDR,
- (const char *)&reuseaddr_on, sizeof (int) );
- if ( sockError == -1 ) {
- shutdown( listenfd4, SD_BOTH );
- UpnpCloseSocket( listenfd4 );
- shutdown( listenfd6, SD_BOTH );
- UpnpCloseSocket( listenfd6 );
-
- return UPNP_E_SOCKET_BIND;
- }
-
- sockError = bind( listenfd6, (struct sockaddr *)&__ss_v6,
- sizeof(__ss_v6) );
- if ( sockError == -1 ) {
- strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
- UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
- "get_miniserver_sockets: Error in IPv6 bind(): %s\n",
- errorBuffer );
- shutdown( listenfd4, SD_BOTH );
- UpnpCloseSocket( listenfd4 );
- shutdown( listenfd6, SD_BOTH );
- UpnpCloseSocket( listenfd6 );
-
- return UPNP_E_SOCKET_BIND; // bind failed
- }
- }
- } else {
- if( listenfd4 != INVALID_SOCKET ) {
- do {
- serverAddr4->sin_port = htons( listen_port4++ );
- sockError = bind( listenfd4, (struct sockaddr *)&__ss_v4,
- sizeof(__ss_v4) );
- if ( sockError == -1 ) {
+ sockError = bind(listenfd6, (struct sockaddr *)&__ss_v6, sizeof (__ss_v6));
+ if (sockError == -1) {
+ strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
+ UpnpPrintf(UPNP_INFO, MSERV, __FILE__, __LINE__,
+ "get_miniserver_sockets: Error in IPv6 bind(): %s\n",
+ errorBuffer);
+ shutdown(listenfd4, SD_BOTH);
+ UpnpCloseSocket(listenfd4);
+ shutdown(listenfd6, SD_BOTH);
+ UpnpCloseSocket(listenfd6);
+ /* Bind failed */
+ return UPNP_E_SOCKET_BIND;
+ }
+ }
+ } else {
+ if (listenfd4 != INVALID_SOCKET) {
+ do {
+ serverAddr4->sin_port = htons(listen_port4++ );
+ sockError = bind(listenfd4, (struct sockaddr *)&__ss_v4,
+ sizeof(__ss_v4));
+ if (sockError == -1) {
#ifdef WIN32
- errCode = WSAGetLastError();
+ errCode = WSAGetLastError();
#else
- errCode = errno;
+ errCode = errno;
#endif
- if( errno == EADDRINUSE ) {
- errCode = 1;
- }
- } else
- errCode = 0;
- } while ( errCode != 0 );
- if ( sockError == -1 ) {
- strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
- UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
- "get_miniserver_sockets: Error in IPv4 bind(): %s\n",
- errorBuffer );
- shutdown( listenfd4, SD_BOTH );
- UpnpCloseSocket( listenfd4 );
- shutdown( listenfd6, SD_BOTH );
- UpnpCloseSocket( listenfd6 );
+ if (errno == EADDRINUSE) {
+ errCode = 1;
+ }
+ } else {
+ errCode = 0;
+ }
+ } while ( errCode != 0 );
- return UPNP_E_SOCKET_BIND; // bind failed
- }
- }
+ if (sockError == -1) {
+ strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
+ UpnpPrintf(UPNP_INFO, MSERV, __FILE__, __LINE__,
+ "get_miniserver_sockets: Error in IPv4 bind(): %s\n",
+ errorBuffer);
+ shutdown(listenfd4, SD_BOTH);
+ UpnpCloseSocket(listenfd4);
+ shutdown(listenfd6, SD_BOTH);
+ UpnpCloseSocket(listenfd6);
+ return UPNP_E_SOCKET_BIND; // bind failed
+ }
+ }
- if( listenfd6 != INVALID_SOCKET ) {
- do {
- serverAddr4->sin_port = htons( listen_port6++ );
- sockError = bind( listenfd6, (struct sockaddr *)&__ss_v4,
- sizeof(__ss_v4) );
- if ( sockError == -1 ) {
+ if (listenfd6 != INVALID_SOCKET) {
+ do {
+ serverAddr4->sin_port = htons(listen_port6++);
+ sockError = bind(listenfd6, (struct sockaddr *)&__ss_v4,
+ sizeof(__ss_v4));
+ if (sockError == -1) {
#ifdef WIN32
- errCode = WSAGetLastError();
+ errCode = WSAGetLastError();
#else
- errCode = errno;
+ errCode = errno;
#endif
- if( errno == EADDRINUSE ) {
- errCode = 1;
- }
- } else
- errCode = 0;
- } while ( errCode != 0 );
- if ( sockError == -1 ) {
- strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
- UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
- "get_miniserver_sockets: Error in IPv6 bind(): %s\n",
- errorBuffer );
- shutdown( listenfd4, SD_BOTH );
- UpnpCloseSocket( listenfd4 );
- shutdown( listenfd6, SD_BOTH );
- UpnpCloseSocket( listenfd6 );
+ if (errno == EADDRINUSE) {
+ errCode = 1;
+ }
+ } else {
+ errCode = 0;
+ }
+ } while (errCode != 0);
- return UPNP_E_SOCKET_BIND; // bind failed
- }
- }
- }
+ if (sockError == -1) {
+ strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
+ UpnpPrintf(UPNP_INFO, MSERV, __FILE__, __LINE__,
+ "get_miniserver_sockets: Error in IPv6 bind(): %s\n",
+ errorBuffer);
+ shutdown(listenfd4, SD_BOTH);
+ UpnpCloseSocket(listenfd4);
+ shutdown(listenfd6, SD_BOTH);
+ UpnpCloseSocket(listenfd6);
+ /* Bind failied */
+ return UPNP_E_SOCKET_BIND;
+ }
+ }
+ }
- UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
- "get_miniserver_sockets: bind successful\n" );
+ UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
+ "get_miniserver_sockets: bind successful\n" );
- if( listenfd4 != INVALID_SOCKET ) {
- ret_code = listen( listenfd4, SOMAXCONN );
- if ( ret_code == -1 ) {
- strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
- UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
- "mserv start: Error in IPv4 listen(): %s\n", errorBuffer );
- shutdown( listenfd4, SD_BOTH );
- UpnpCloseSocket( listenfd4 );
- shutdown( listenfd6, SD_BOTH );
- UpnpCloseSocket( listenfd6 );
+ if (listenfd4 != INVALID_SOCKET) {
+ ret_code = listen(listenfd4, SOMAXCONN);
+ if (ret_code == -1) {
+ strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
+ UpnpPrintf(UPNP_INFO, MSERV, __FILE__, __LINE__,
+ "mserv start: Error in IPv4 listen(): %s\n",
+ errorBuffer);
+ shutdown(listenfd4, SD_BOTH);
+ UpnpCloseSocket(listenfd4);
+ shutdown(listenfd6, SD_BOTH);
+ UpnpCloseSocket(listenfd6);
+ return UPNP_E_LISTEN;
+ }
- return UPNP_E_LISTEN;
- }
+ actual_port4 = get_port(listenfd4);
+ if (actual_port4 <= 0) {
+ shutdown(listenfd4, SD_BOTH);
+ UpnpCloseSocket(listenfd4);
+ shutdown(listenfd6, SD_BOTH);
+ UpnpCloseSocket(listenfd6);
+ return UPNP_E_INTERNAL_ERROR;
+ }
- actual_port4 = get_port( listenfd4 );
- if( actual_port4 <= 0 ) {
- shutdown( listenfd4, SD_BOTH );
- UpnpCloseSocket( listenfd4 );
- shutdown( listenfd6, SD_BOTH );
- UpnpCloseSocket( listenfd6 );
+ out->miniServerPort4 = actual_port4;
+ }
- return UPNP_E_INTERNAL_ERROR;
- }
+ if (listenfd6 != INVALID_SOCKET) {
+ ret_code = listen(listenfd6, SOMAXCONN);
+ if (ret_code == -1) {
+ strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
+ UpnpPrintf(UPNP_INFO, MSERV, __FILE__, __LINE__,
+ "mserv start: Error in IPv6 listen(): %s\n",
+ errorBuffer);
+ shutdown(listenfd4, SD_BOTH);
+ UpnpCloseSocket(listenfd4);
+ shutdown(listenfd6, SD_BOTH);
+ UpnpCloseSocket(listenfd6);
+ return UPNP_E_LISTEN;
+ }
- out->miniServerPort4 = actual_port4;
- }
+ actual_port6 = get_port(listenfd6);
+ if (actual_port6 <= 0) {
+ shutdown(listenfd4, SD_BOTH);
+ UpnpCloseSocket(listenfd4);
+ shutdown(listenfd6, SD_BOTH);
+ UpnpCloseSocket(listenfd6);
+ return UPNP_E_INTERNAL_ERROR;
+ }
- if( listenfd6 != INVALID_SOCKET ) {
- ret_code = listen( listenfd6, SOMAXCONN );
- if ( ret_code == -1 ) {
- strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
- UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
- "mserv start: Error in IPv6 listen(): %s\n", errorBuffer );
- shutdown( listenfd4, SD_BOTH );
- UpnpCloseSocket( listenfd4 );
- shutdown( listenfd6, SD_BOTH );
- UpnpCloseSocket( listenfd6 );
+ out->miniServerPort6 = actual_port6;
+ }
- return UPNP_E_LISTEN;
- }
+ out->miniServerSock4 = listenfd4;
+ out->miniServerSock6 = listenfd6;
- actual_port6 = get_port( listenfd6 );
- if( actual_port6 <= 0 ) {
- shutdown( listenfd4, SD_BOTH );
- UpnpCloseSocket( listenfd4 );
- shutdown( listenfd6, SD_BOTH );
- UpnpCloseSocket( listenfd6 );
-
- return UPNP_E_INTERNAL_ERROR;
- }
-
- out->miniServerPort6 = actual_port6;
- }
-
- out->miniServerSock4 = listenfd4;
- out->miniServerSock6 = listenfd6;
-
- return UPNP_E_SUCCESS;
+ return UPNP_E_SUCCESS;
}
-#endif
+#endif /* INTERNAL_WEB_SERVER */
-/************************************************************************
- * Function: get_miniserver_stopsock
- *
- * Parameters:
- * MiniServerSockArray *out - Miniserver Socket Array
- *
- * Description:
- * Creates the miniserver STOP socket. This socket is created and
+/*!
+ * \brief Creates the miniserver STOP socket. This socket is created and
* listened on to know when it is time to stop the Miniserver.
*
- * Return: int
- * UPNP_E_OUTOF_SOCKET - Failed to create a socket
- * UPNP_E_SOCKET_BIND - Bind() failed
- * UPNP_E_INTERNAL_ERROR - Port returned by the socket layer is < 0
- * UPNP_E_SUCCESS - Success
- ************************************************************************/
-int get_miniserver_stopsock( MiniServerSockArray * out )
+ * \return
+ * \li UPNP_E_OUTOF_SOCKET: Failed to create a socket.
+ * \li UPNP_E_SOCKET_BIND: Bind() failed.
+ * \li UPNP_E_INTERNAL_ERROR: Port returned by the socket layer is < 0.
+ * \li UPNP_E_SUCCESS: Success.
+ */
+static int get_miniserver_stopsock(
+ /*! [in] Miniserver Socket Array. */
+ MiniServerSockArray *out)
{
- char errorBuffer[ERROR_BUFFER_LEN];
- struct sockaddr_in stop_sockaddr;
- int miniServerStopSock;
- int ret;
+ char errorBuffer[ERROR_BUFFER_LEN];
+ struct sockaddr_in stop_sockaddr;
+ int miniServerStopSock = 0;
+ int ret = 0;
- miniServerStopSock = socket( AF_INET, SOCK_DGRAM, 0 );
- if ( miniServerStopSock == -1 ) {
- strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
- UpnpPrintf( UPNP_CRITICAL, MSERV, __FILE__, __LINE__,
- "Error in socket(): %s\n", errorBuffer );
-
- return UPNP_E_OUTOF_SOCKET;
- }
-
- // bind to local socket
- memset( &stop_sockaddr, 0, sizeof( stop_sockaddr ) );
- stop_sockaddr.sin_family = AF_INET;
- stop_sockaddr.sin_addr.s_addr = inet_addr( "127.0.0.1" );
- ret = bind( miniServerStopSock, (struct sockaddr *)&stop_sockaddr,
- sizeof(stop_sockaddr) );
- if ( ret == -1 ) {
- UpnpPrintf( UPNP_CRITICAL,
- MSERV, __FILE__, __LINE__,
- "Error in binding localhost!!!\n" );
- shutdown( miniServerStopSock, SD_BOTH );
- UpnpCloseSocket( miniServerStopSock );
-
- return UPNP_E_SOCKET_BIND;
- }
-
- miniStopSockPort = get_port( miniServerStopSock );
- if ( miniStopSockPort <= 0 ) {
- shutdown( miniServerStopSock, SD_BOTH );
- UpnpCloseSocket( miniServerStopSock );
-
- return UPNP_E_INTERNAL_ERROR;
- }
-
- out->miniServerStopSock = miniServerStopSock;
- out->stopPort = miniStopSockPort;
-
- return UPNP_E_SUCCESS;
-}
-
-
-/************************************************************************
- * Function: StartMiniServer
- *
- * Parameters:
- * IN OUT unsigned short *listen_port4 ; Port on which the server
- * listens for incoming IPv4 connections.
- * IN OUT unsigned short *listen_port6 ; Port on which the server
- * listens for incoming IPv6 connections.
- *
- * Description: Initialize the sockets functionality for the
- * Miniserver. Initialize a thread pool job to run the MiniServer
- * and the job to the thread pool. If listen port is 0, port is
- * dynamically picked
- *
- * Use timer mechanism to start the MiniServer, failure to meet the
- * allowed delay aborts the attempt to launch the MiniServer.
- *
- * Return: int;
- * On success: UPNP_E_SUCCESS
- * On error: PNP_E_XXX
- ************************************************************************/
-int
-StartMiniServer( unsigned short* listen_port4,
- unsigned short* listen_port6 )
-{
- int ret_code;
- int count;
- int max_count = 10000;
-
- MiniServerSockArray *miniSocket;
- ThreadPoolJob job;
-
- if( gMServState != MSERV_IDLE ) {
- return UPNP_E_INTERNAL_ERROR; // miniserver running
- }
-
- miniSocket = (MiniServerSockArray *) malloc( sizeof (MiniServerSockArray) );
- if( miniSocket == NULL ) {
- return UPNP_E_OUTOF_MEMORY;
- }
- memset( miniSocket, 0, sizeof(*miniSocket) );
-
-#ifdef INTERNAL_WEB_SERVER
- // V4 and V6 http listeners.
- ret_code = get_miniserver_sockets( miniSocket, *listen_port4, *listen_port6 );
- if( ret_code != UPNP_E_SUCCESS ) {
- free( miniSocket );
- return ret_code;
- }
-#endif
-
- // Stop socket (To end miniserver processing).
- ret_code = get_miniserver_stopsock( miniSocket );
- if( ret_code != UPNP_E_SUCCESS ) {
-#ifdef INTERNAL_WEB_SERVER
- shutdown( miniSocket->miniServerSock4, SD_BOTH );
- UpnpCloseSocket( miniSocket->miniServerSock4 );
- shutdown( miniSocket->miniServerSock6, SD_BOTH );
- UpnpCloseSocket( miniSocket->miniServerSock6 );
-#endif
- free( miniSocket );
-
- return ret_code;
- }
-
- // SSDP socket for discovery / advertising.
- ret_code = get_ssdp_sockets( miniSocket );
- if( ret_code != UPNP_E_SUCCESS ) {
-#ifdef INTERNAL_WEB_SERVER
- shutdown( miniSocket->miniServerSock4, SD_BOTH );
- UpnpCloseSocket( miniSocket->miniServerSock4 );
- shutdown( miniSocket->miniServerSock6, SD_BOTH );
- UpnpCloseSocket( miniSocket->miniServerSock6 );
-#endif
- shutdown( miniSocket->miniServerStopSock, SD_BOTH );
- UpnpCloseSocket( miniSocket->miniServerStopSock );
- free( miniSocket );
-
- return ret_code;
- }
-
- TPJobInit( &job, (start_routine)RunMiniServer, (void *)miniSocket );
- TPJobSetPriority( &job, MED_PRIORITY );
- TPJobSetFreeFunction( &job, ( free_routine ) free );
-
- ret_code = ThreadPoolAddPersistent( &gMiniServerThreadPool, &job, NULL );
- if ( ret_code < 0 ) {
-#ifdef INTERNAL_WEB_SERVER
- shutdown( miniSocket->miniServerSock4, SD_BOTH );
- UpnpCloseSocket( miniSocket->miniServerSock4 );
- shutdown( miniSocket->miniServerSock6, SD_BOTH );
- UpnpCloseSocket( miniSocket->miniServerSock6 );
-#endif
- shutdown( miniSocket->miniServerStopSock, SD_BOTH );
- UpnpCloseSocket( miniSocket->miniServerStopSock );
- shutdown( miniSocket->ssdpSock4, SD_BOTH );
- UpnpCloseSocket( miniSocket->ssdpSock4 );
- shutdown( miniSocket->ssdpSock6, SD_BOTH );
- UpnpCloseSocket( miniSocket->ssdpSock6 );
-#ifdef INCLUDE_CLIENT_APIS
- shutdown( miniSocket->ssdpReqSock4, SD_BOTH );
- UpnpCloseSocket( miniSocket->ssdpReqSock4 );
- shutdown( miniSocket->ssdpReqSock6, SD_BOTH );
- UpnpCloseSocket( miniSocket->ssdpReqSock6 );
-#endif
-
- return UPNP_E_OUTOF_MEMORY;
- }
- // wait for miniserver to start
- count = 0;
- while ( gMServState != MSERV_RUNNING && count < max_count ) {
- usleep( 50 * 1000 ); // 0.05s
- count++;
- }
-
- // taking too long to start that thread
- if ( count >= max_count ) {
-#ifdef INTERNAL_WEB_SERVER
- shutdown( miniSocket->miniServerSock4, SD_BOTH );
- UpnpCloseSocket( miniSocket->miniServerSock4 );
- shutdown( miniSocket->miniServerSock6, SD_BOTH );
- UpnpCloseSocket( miniSocket->miniServerSock6 );
-#endif
- shutdown( miniSocket->miniServerStopSock, SD_BOTH );
- UpnpCloseSocket( miniSocket->miniServerStopSock );
- shutdown( miniSocket->ssdpSock4, SD_BOTH );
- UpnpCloseSocket( miniSocket->ssdpSock4 );
- shutdown( miniSocket->ssdpSock6, SD_BOTH );
- UpnpCloseSocket( miniSocket->ssdpSock6 );
-#ifdef INCLUDE_CLIENT_APIS
- shutdown( miniSocket->ssdpReqSock4, SD_BOTH );
- UpnpCloseSocket( miniSocket->ssdpReqSock4 );
- shutdown( miniSocket->ssdpReqSock6, SD_BOTH );
- UpnpCloseSocket( miniSocket->ssdpReqSock6 );
-#endif
-
- return UPNP_E_INTERNAL_ERROR;
- }
-#ifdef INTERNAL_WEB_SERVER
- *listen_port4 = miniSocket->miniServerPort4;
- *listen_port6 = miniSocket->miniServerPort6;
-#endif
-
- return UPNP_E_SUCCESS;
-}
-
-/************************************************************************
- * Function: StopMiniServer
- *
- * Parameters:
- * void
- *
- * Description:
- * Stop and Shutdown the MiniServer and free socket
- * resources.
- *
- * Return: int
- * Always returns 0
- ************************************************************************/
-int
-StopMiniServer()
-{
- char errorBuffer[ERROR_BUFFER_LEN];
- int socklen = sizeof( struct sockaddr_in );
- SOCKET sock;
- struct sockaddr_in ssdpAddr;
- char buf[256] = "ShutDown";
- int bufLen = strlen( buf );
-
- if( gMServState == MSERV_RUNNING ) {
- gMServState = MSERV_STOPPING;
- } else {
- return 0;
- }
-
- sock = socket( AF_INET, SOCK_DGRAM, 0 );
- if ( sock == -1 ) {
- strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
- UpnpPrintf( UPNP_INFO, SSDP, __FILE__, __LINE__,
- "SSDP_SERVER: StopSSDPServer: Error in socket() %s\n", errorBuffer );
- return 0;
- }
-
- while( gMServState != MSERV_IDLE ) {
- ssdpAddr.sin_family = AF_INET;
- ssdpAddr.sin_addr.s_addr = inet_addr( "127.0.0.1" );
- ssdpAddr.sin_port = htons( miniStopSockPort );
- sendto( sock, buf, bufLen, 0, (struct sockaddr *)&ssdpAddr, socklen );
- usleep( 1000 );
- if( gMServState == MSERV_IDLE ) {
- break;
+ miniServerStopSock = socket(AF_INET, SOCK_DGRAM, 0);
+ if (miniServerStopSock == -1) {
+ strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
+ UpnpPrintf(UPNP_CRITICAL, MSERV, __FILE__, __LINE__,
+ "Error in socket(): %s\n", errorBuffer);
+ return UPNP_E_OUTOF_SOCKET;
}
- isleep( 1 );
- }
- shutdown( sock, SD_BOTH );
- UpnpCloseSocket( sock );
- return 0;
+ // bind to local socket
+ memset(&stop_sockaddr, 0, sizeof (stop_sockaddr));
+ stop_sockaddr.sin_family = AF_INET;
+ stop_sockaddr.sin_addr.s_addr = inet_addr("127.0.0.1");
+ ret = bind(miniServerStopSock, (struct sockaddr *)&stop_sockaddr,
+ sizeof(stop_sockaddr));
+ if (ret == -1) {
+ UpnpPrintf(UPNP_CRITICAL,
+ MSERV, __FILE__, __LINE__,
+ "Error in binding localhost!!!\n");
+ shutdown(miniServerStopSock, SD_BOTH);
+ UpnpCloseSocket(miniServerStopSock);
+ return UPNP_E_SOCKET_BIND;
+ }
+
+ miniStopSockPort = get_port( miniServerStopSock );
+ if (miniStopSockPort <= 0) {
+ shutdown(miniServerStopSock, SD_BOTH);
+ UpnpCloseSocket(miniServerStopSock);
+ return UPNP_E_INTERNAL_ERROR;
+ }
+
+ out->miniServerStopSock = miniServerStopSock;
+ out->stopPort = miniStopSockPort;
+
+ return UPNP_E_SUCCESS;
+}
+
+
+int StartMiniServer(
+ /*! [in,out] Port on which the server listens for incoming IPv4 connections. */
+ unsigned short *listen_port4,
+ /*! [in,out] Port on which the server listens for incoming IPv6 connections. */
+ unsigned short *listen_port6)
+{
+ int ret_code;
+ int count;
+ int max_count = 10000;
+
+ MiniServerSockArray *miniSocket;
+ ThreadPoolJob job;
+
+ if (gMServState != MSERV_IDLE) {
+ return UPNP_E_INTERNAL_ERROR; // miniserver running
+ }
+
+ miniSocket = (MiniServerSockArray *)malloc(sizeof (MiniServerSockArray));
+ if (miniSocket == NULL) {
+ return UPNP_E_OUTOF_MEMORY;
+ }
+ memset(miniSocket, 0, sizeof (*miniSocket));
+
+#ifdef INTERNAL_WEB_SERVER
+ // V4 and V6 http listeners.
+ ret_code = get_miniserver_sockets(miniSocket, *listen_port4, *listen_port6);
+ if (ret_code != UPNP_E_SUCCESS) {
+ free(miniSocket);
+ return ret_code;
+ }
+#endif
+
+ // Stop socket (To end miniserver processing).
+ ret_code = get_miniserver_stopsock(miniSocket);
+ if (ret_code != UPNP_E_SUCCESS) {
+#ifdef INTERNAL_WEB_SERVER
+ shutdown(miniSocket->miniServerSock4, SD_BOTH);
+ UpnpCloseSocket(miniSocket->miniServerSock4);
+ shutdown(miniSocket->miniServerSock6, SD_BOTH);
+ UpnpCloseSocket(miniSocket->miniServerSock6);
+#endif
+ free(miniSocket);
+ return ret_code;
+ }
+
+ // SSDP socket for discovery / advertising.
+ ret_code = get_ssdp_sockets(miniSocket);
+ if (ret_code != UPNP_E_SUCCESS) {
+#ifdef INTERNAL_WEB_SERVER
+ shutdown(miniSocket->miniServerSock4, SD_BOTH);
+ UpnpCloseSocket(miniSocket->miniServerSock4);
+ shutdown(miniSocket->miniServerSock6, SD_BOTH);
+ UpnpCloseSocket(miniSocket->miniServerSock6);
+#endif
+ shutdown(miniSocket->miniServerStopSock, SD_BOTH);
+ UpnpCloseSocket(miniSocket->miniServerStopSock);
+ free(miniSocket);
+ return ret_code;
+ }
+
+ TPJobInit(&job, (start_routine)RunMiniServer, (void *)miniSocket);
+ TPJobSetPriority(&job, MED_PRIORITY);
+ TPJobSetFreeFunction(&job, (free_routine)free);
+ ret_code = ThreadPoolAddPersistent(&gMiniServerThreadPool, &job, NULL);
+ if (ret_code < 0) {
+#ifdef INTERNAL_WEB_SERVER
+ shutdown(miniSocket->miniServerSock4, SD_BOTH);
+ UpnpCloseSocket(miniSocket->miniServerSock4);
+ shutdown(miniSocket->miniServerSock6, SD_BOTH);
+ UpnpCloseSocket(miniSocket->miniServerSock6);
+#endif
+ shutdown(miniSocket->miniServerStopSock, SD_BOTH);
+ UpnpCloseSocket(miniSocket->miniServerStopSock);
+ shutdown(miniSocket->ssdpSock4, SD_BOTH);
+ UpnpCloseSocket(miniSocket->ssdpSock4);
+ shutdown(miniSocket->ssdpSock6, SD_BOTH);
+ UpnpCloseSocket(miniSocket->ssdpSock6);
+#ifdef INCLUDE_CLIENT_APIS
+ shutdown(miniSocket->ssdpReqSock4, SD_BOTH );
+ UpnpCloseSocket(miniSocket->ssdpReqSock4 );
+ shutdown(miniSocket->ssdpReqSock6, SD_BOTH );
+ UpnpCloseSocket(miniSocket->ssdpReqSock6 );
+#endif
+ return UPNP_E_OUTOF_MEMORY;
+ }
+ // wait for miniserver to start
+ count = 0;
+ while (gMServState != MSERV_RUNNING && count < max_count) {
+ usleep(50 * 1000); // 0.05s
+ count++;
+ }
+
+ // taking too long to start that thread
+ if (count >= max_count) {
+#ifdef INTERNAL_WEB_SERVER
+ shutdown(miniSocket->miniServerSock4, SD_BOTH);
+ UpnpCloseSocket(miniSocket->miniServerSock4);
+ shutdown(miniSocket->miniServerSock6, SD_BOTH);
+ UpnpCloseSocket(miniSocket->miniServerSock6);
+#endif
+ shutdown(miniSocket->miniServerStopSock, SD_BOTH);
+ UpnpCloseSocket(miniSocket->miniServerStopSock);
+ shutdown(miniSocket->ssdpSock4, SD_BOTH);
+ UpnpCloseSocket(miniSocket->ssdpSock4);
+ shutdown(miniSocket->ssdpSock6, SD_BOTH);
+ UpnpCloseSocket(miniSocket->ssdpSock6);
+#ifdef INCLUDE_CLIENT_APIS
+ shutdown(miniSocket->ssdpReqSock4, SD_BOTH);
+ UpnpCloseSocket(miniSocket->ssdpReqSock4);
+ shutdown(miniSocket->ssdpReqSock6, SD_BOTH);
+ UpnpCloseSocket(miniSocket->ssdpReqSock6);
+#endif
+ return UPNP_E_INTERNAL_ERROR;
+ }
+#ifdef INTERNAL_WEB_SERVER
+ *listen_port4 = miniSocket->miniServerPort4;
+ *listen_port6 = miniSocket->miniServerPort6;
+#endif
+
+ return UPNP_E_SUCCESS;
+}
+
+
+int StopMiniServer()
+{
+ char errorBuffer[ERROR_BUFFER_LEN];
+ int socklen = sizeof (struct sockaddr_in);
+ SOCKET sock;
+ struct sockaddr_in ssdpAddr;
+ char buf[256] = "ShutDown";
+ int bufLen = strlen(buf);
+
+ if(gMServState == MSERV_RUNNING) {
+ gMServState = MSERV_STOPPING;
+ } else {
+ return 0;
+ }
+
+ sock = socket(AF_INET, SOCK_DGRAM, 0);
+ if (sock == -1) {
+ strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
+ UpnpPrintf(UPNP_INFO, SSDP, __FILE__, __LINE__,
+ "SSDP_SERVER: StopSSDPServer: Error in socket() %s\n",
+ errorBuffer);
+ return 0;
+ }
+
+ while(gMServState != MSERV_IDLE) {
+ ssdpAddr.sin_family = AF_INET;
+ ssdpAddr.sin_addr.s_addr = inet_addr("127.0.0.1");
+ ssdpAddr.sin_port = htons(miniStopSockPort);
+ sendto(sock, buf, bufLen, 0, (struct sockaddr *)&ssdpAddr,
+ socklen);
+ usleep(1000);
+ if (gMServState == MSERV_IDLE) {
+ break;
+ }
+ isleep(1);
+ }
+ shutdown(sock, SD_BOTH);
+ UpnpCloseSocket(sock);
+
+ return 0;
}
diff --git a/upnp/src/inc/gena.h b/upnp/src/inc/gena.h
index a188141..80ff93d 100644
--- a/upnp/src/inc/gena.h
+++ b/upnp/src/inc/gena.h
@@ -161,11 +161,11 @@ typedef struct NOTIFY_THREAD_STRUCT {
*/
EXTERN_C void genaCallback(
/*! [in] represents the parse state of the request */
- IN http_parser_t *parser,
+ http_parser_t *parser,
/*! [in] HTTP message containing GENA request */
- IN http_message_t* request,
+ http_message_t* request,
/*! [in,out] Structure containing information about the socket */
- IN SOCKINFO *info);
+ SOCKINFO *info);
/*!
@@ -181,16 +181,16 @@ EXTERN_C void genaCallback(
#ifdef INCLUDE_CLIENT_APIS
EXTERN_C int genaSubscribe(
/*! [in] The client handle. */
- IN UpnpClient_Handle client_handle,
+ UpnpClient_Handle client_handle,
/*! [in] Of the form: "http://134.134.156.80:4000/RedBulb/Event */
- IN const UpnpString *PublisherURL,
+ 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,
+ int *TimeOut,
/*! [out] sid of subscription, memory passed in by caller. */
- OUT UpnpString *out_sid);
+ UpnpString *out_sid);
#endif /* INCLUDE_CLIENT_APIS */
@@ -207,9 +207,9 @@ EXTERN_C int genaSubscribe(
#ifdef INCLUDE_CLIENT_APIS
EXTERN_C int genaUnSubscribe(
/*! [in] UPnP client handle. */
- IN UpnpClient_Handle client_handle,
+ UpnpClient_Handle client_handle,
/*! [in] The subscription ID. */
- IN const UpnpString *in_sid);
+ const UpnpString *in_sid);
#endif /* INCLUDE_CLIENT_APIS */
@@ -259,12 +259,12 @@ EXTERN_C int genaUnregisterDevice(
#ifdef INCLUDE_CLIENT_APIS
EXTERN_C int genaRenewSubscription(
/*! [in] Client handle. */
- IN UpnpClient_Handle client_handle,
+ UpnpClient_Handle client_handle,
/*! [in] Subscription ID. */
- IN const UpnpString *in_sid,
- /*! [out] requested Duration, if -1, then "infinite". In the OUT case:
+ const UpnpString *in_sid,
+ /*! [in,out] requested Duration, if -1, then "infinite". In the OUT case:
* actual Duration granted by Service, -1 for infinite. */
- OUT int * TimeOut);
+ int *TimeOut);
#endif /* INCLUDE_CLIENT_APIS */
@@ -310,7 +310,7 @@ EXTERN_C int genaNotifyAllExt(
/*! [in] Service ID. */
char *servId,
/*! [in] XML document Event varible property set. */
- IN IXML_Document *PropSet);
+ IXML_Document *PropSet);
#endif /* INCLUDE_DEVICE_APIS */
@@ -325,19 +325,19 @@ EXTERN_C int genaNotifyAllExt(
#ifdef INCLUDE_DEVICE_APIS
EXTERN_C int genaInitNotify(
/*! [in] Device handle. */
- IN UpnpDevice_Handle device_handle,
+ UpnpDevice_Handle device_handle,
/*! [in] Device udn. */
- IN char *UDN,
+ char *UDN,
/*! [in] Service ID. */
- IN char *servId,
+ char *servId,
/*! [in] Array of variable names. */
- IN char **VarNames,
+ char **VarNames,
/*! [in] Array of variable values. */
- IN char **VarValues,
+ char **VarValues,
/*! [in] Array size. */
- IN int var_count,
+ int var_count,
/*! [in] Subscription ID. */
- IN const Upnp_SID sid);
+ const Upnp_SID sid);
#endif /* INCLUDE_DEVICE_APIS */
@@ -354,15 +354,15 @@ EXTERN_C int genaInitNotify(
#ifdef INCLUDE_DEVICE_APIS
EXTERN_C int genaInitNotifyExt(
/*! [in] Device handle. */
- IN UpnpDevice_Handle device_handle,
+ UpnpDevice_Handle device_handle,
/*! [in] Device udn. */
- IN char *UDN,
+ char *UDN,
/*! [in] Service ID. */
- IN char *servId,
+ char *servId,
/*! [in] Document of the state table. */
- IN IXML_Document *PropSet,
+ IXML_Document *PropSet,
/*! [in] subscription ID. */
- IN const Upnp_SID sid);
+ const Upnp_SID sid);
#endif /* INCLUDE_DEVICE_APIS */
@@ -374,11 +374,11 @@ EXTERN_C int genaInitNotifyExt(
*/
void error_respond(
/*! [in] Structure containing information about the socket. */
- IN SOCKINFO *info,
+ SOCKINFO *info,
/*! [in] error code that will be in the GENA response. */
- IN int error_code,
+ int error_code,
/*! [in] GENA request Packet. */
- IN http_message_t* hmsg);
+ http_message_t* hmsg);
#endif /* GENA_H */
diff --git a/upnp/src/inc/gena_ctrlpt.h b/upnp/src/inc/gena_ctrlpt.h
index dc20400..ea2d630 100644
--- a/upnp/src/inc/gena_ctrlpt.h
+++ b/upnp/src/inc/gena_ctrlpt.h
@@ -55,9 +55,9 @@
*/
void gena_process_notification_event(
/*! [in] Socket info of the device. */
- IN SOCKINFO *info,
+ SOCKINFO *info,
/*! [in] The http message contains the GENA notification. */
- IN http_message_t *event);
+ 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 5ac7a30..4ffdb31 100644
--- a/upnp/src/inc/gena_device.h
+++ b/upnp/src/inc/gena_device.h
@@ -48,9 +48,9 @@
*/
void gena_process_subscription_request(
/*! [in] Socket info of the device. */
- IN SOCKINFO *info,
+ SOCKINFO *info,
/*! [in] Subscription request from the control point. */
- IN http_message_t *request);
+ http_message_t *request);
/*!
@@ -59,9 +59,9 @@ void gena_process_subscription_request(
*/
void gena_process_subscription_renewal_request(
/*! [in] Socket info of the device. */
- IN SOCKINFO *info,
+ SOCKINFO *info,
/*! [in] Subscription renewal request from the control point. */
- IN http_message_t *request);
+ http_message_t *request);
/*!
@@ -70,9 +70,9 @@ void gena_process_subscription_renewal_request(
*/
void gena_process_unsubscribe_request(
/*! [in] Socket info of the device. */
- IN SOCKINFO *info,
+ SOCKINFO *info,
/*! [in] UNSUBSCRIBE request from the control point. */
- IN http_message_t *request);
+ http_message_t *request);
#endif /* GENA_DEVICE_H */
diff --git a/upnp/src/inc/miniserver.h b/upnp/src/inc/miniserver.h
index 2b82ba3..47ae4c5 100644
--- a/upnp/src/inc/miniserver.h
+++ b/upnp/src/inc/miniserver.h
@@ -70,81 +70,62 @@ typedef void (*MiniServerCallback)(
extern "C" {
#endif
-/************************************************************************
- * Function: SetHTTPGetCallback
- *
- * Parameters:
- * MiniServerCallback callback; - HTTP Callback to be invoked
- *
- * Description: Set HTTP Get Callback
- *
- * Return: void
- ************************************************************************/
-void SetHTTPGetCallback( MiniServerCallback callback );
-/************************************************************************
- * Function: SetSoapCallback
- *
- * Parameters:
- * MiniServerCallback callback; - SOAP Callback to be invoked
- *
- * Description: Set SOAP Callback
- *
- * Return: void
- ************************************************************************/
+/*!
+ * \brief Set HTTP Get Callback.
+ */
+void SetHTTPGetCallback(
+ /*! [in] HTTP Callback to be invoked . */
+ MiniServerCallback callback);
+
+
+/*!
+ * \brief Set SOAP Callback.
+ */
#ifdef INCLUDE_DEVICE_APIS
-void SetSoapCallback( MiniServerCallback callback );
+void SetSoapCallback(
+ /*! [in] SOAP Callback to be invoked . */
+ MiniServerCallback callback);
#else /* INCLUDE_DEVICE_APIS */
-static inline void SetSoapCallback( MiniServerCallback callback ) {}
+static inline void SetSoapCallback(MiniServerCallback callback) {}
#endif /* INCLUDE_DEVICE_APIS */
-/************************************************************************
- * Function: SetGenaCallback
- *
- * Parameters:
- * MiniServerCallback callback; - GENA Callback to be invoked
- *
- * D6escription: Set GENA Callback
- *
- * Return: void
- ************************************************************************/
-void SetGenaCallback( MiniServerCallback callback );
-/************************************************************************
- * Function: StartMiniServer
- *
- * Parameters:
- * IN OUT unsigned short *listen_port4 ; Port on which the server
- * listens for incoming IPv4 connections.
- * IN OUT unsigned short *listen_port6 ; Port on which the server
- * listens for incoming IPv6 connections.
- *
- * Description: Initialize the sockets functionality for the
- * Miniserver. Initialize a thread pool job to run the MiniServer
- * and the job to the thread pool. If listen port is 0, port is
- * dynamically picked
- *
- * Use timer mechanism to start the MiniServer, failure to meet the
- * allowed delay aborts the attempt to launch the MiniServer.
- *
- * Return: int;
- * On success: UPNP_E_SUCCESS
- * On error: UPNP_E_XXX
- ************************************************************************/
-int StartMiniServer( IN OUT unsigned short* listen_port4,
- IN OUT unsigned short* listen_port6 );
+/*!
+ * \brief Set GENA Callback.
+ */
+void SetGenaCallback(
+ /*! [in] GENA Callback to be invoked. */
+ MiniServerCallback callback);
-/************************************************************************
- * Function: StopMiniServer
+
+/*!
+ * \brief Initialize the sockets functionality for the Miniserver.
*
- * Parameters:
- * void;
+ * Initialize a thread pool job to run the MiniServer and the job to the
+ * thread pool.
*
- * Description: Stop and Shutdown the MiniServer and free socket resources.
+ * If listen port is 0, port is dynamically picked.
*
- * Return : int;
- * Always returns 0
- ************************************************************************/
+ * Use timer mechanism to start the MiniServer, failure to meet the
+ * allowed delay aborts the attempt to launch the MiniServer.
+ *
+ * \return
+ * \li On success: UPNP_E_SUCCESS.
+ * \li On error: UPNP_E_XXX.
+ */
+int StartMiniServer(
+ /*! [in,out] Port on which the server listens for incoming IPv4 connections. */
+ unsigned short *listen_port4,
+ /*! [in,out] Port on which the server listens for incoming IPv6 connections. */
+ unsigned short *listen_port6);
+
+
+/*!
+ * \brief Stop and Shutdown the MiniServer and free socket resources.
+ *
+ * \return Always returns 0.
+ */
int StopMiniServer();
diff --git a/upnp/src/inc/upnpapi.h b/upnp/src/inc/upnpapi.h
index 6fc7e7a..28e884f 100644
--- a/upnp/src/inc/upnpapi.h
+++ b/upnp/src/inc/upnpapi.h
@@ -352,7 +352,7 @@ void UpnpThreadDistribution(struct UpnpNonblockParam * Param);
/*!
* \brief This function is a timer thread scheduled by UpnpSendAdvertisement
- * to the send advetisement again.
+ * to the send advetisement again.
*/
void AutoAdvertise(
/*! [in] Information provided to the thread. */