Code convergence for client_table (ClientSubscription).
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/branches/branch-1.6.x@539 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
@@ -1739,7 +1739,8 @@ int UpnpSubscribe(
|
|||||||
{
|
{
|
||||||
int retVal;
|
int retVal;
|
||||||
struct Handle_Info *SInfo = NULL;
|
struct Handle_Info *SInfo = NULL;
|
||||||
char *EvtUrl = (char *)EvtUrl_const;
|
UpnpString *EvtUrl = UpnpString_new();
|
||||||
|
UpnpString *SubsIdTmp = UpnpString_new();
|
||||||
|
|
||||||
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__, "Inside UpnpSubscribe\n");
|
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__, "Inside UpnpSubscribe\n");
|
||||||
|
|
||||||
@@ -1756,11 +1757,17 @@ int UpnpSubscribe(
|
|||||||
retVal = UPNP_E_INVALID_PARAM;
|
retVal = UPNP_E_INVALID_PARAM;
|
||||||
goto exit_function;
|
goto exit_function;
|
||||||
}
|
}
|
||||||
|
UpnpString_set_String(EvtUrl, EvtUrl_const);
|
||||||
|
|
||||||
|
if (SubsIdTmp == NULL) {
|
||||||
|
retVal = UPNP_E_OUTOF_MEMORY;
|
||||||
|
goto exit_function;
|
||||||
|
}
|
||||||
if (SubsId == NULL) {
|
if (SubsId == NULL) {
|
||||||
retVal = UPNP_E_INVALID_PARAM;
|
retVal = UPNP_E_INVALID_PARAM;
|
||||||
goto exit_function;
|
goto exit_function;
|
||||||
}
|
}
|
||||||
|
UpnpString_set_String(SubsIdTmp, SubsId);
|
||||||
|
|
||||||
if (TimeOut == NULL) {
|
if (TimeOut == NULL) {
|
||||||
retVal = UPNP_E_INVALID_PARAM;
|
retVal = UPNP_E_INVALID_PARAM;
|
||||||
@@ -1775,12 +1782,16 @@ int UpnpSubscribe(
|
|||||||
}
|
}
|
||||||
HandleUnlock();
|
HandleUnlock();
|
||||||
|
|
||||||
retVal = genaSubscribe(Hnd, EvtUrl, TimeOut, SubsId);
|
retVal = genaSubscribe(Hnd, EvtUrl, TimeOut, SubsIdTmp);
|
||||||
|
strcpy(SubsId, UpnpString_get_String(SubsIdTmp));
|
||||||
|
|
||||||
exit_function:
|
exit_function:
|
||||||
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
|
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
|
||||||
"Exiting UpnpSubscribe, retVal=%d\n", retVal);
|
"Exiting UpnpSubscribe, retVal=%d\n", retVal);
|
||||||
|
|
||||||
|
UpnpString_delete(SubsIdTmp);
|
||||||
|
UpnpString_delete(EvtUrl);
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
#endif /* INCLUDE_CLIENT_APIS */
|
#endif /* INCLUDE_CLIENT_APIS */
|
||||||
@@ -1791,6 +1802,7 @@ int UpnpUnSubscribe(UpnpClient_Handle Hnd, const Upnp_SID SubsId)
|
|||||||
{
|
{
|
||||||
struct Handle_Info *SInfo = NULL;
|
struct Handle_Info *SInfo = NULL;
|
||||||
int retVal;
|
int retVal;
|
||||||
|
UpnpString *SubsIdTmp = UpnpString_new();
|
||||||
|
|
||||||
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, "Inside UpnpUnSubscribe\n");
|
UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__, "Inside UpnpUnSubscribe\n");
|
||||||
|
|
||||||
@@ -1799,10 +1811,16 @@ int UpnpUnSubscribe(UpnpClient_Handle Hnd, const Upnp_SID SubsId)
|
|||||||
goto exit_function;
|
goto exit_function;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SubsIdTmp == NULL) {
|
||||||
|
retVal = UPNP_E_OUTOF_MEMORY;
|
||||||
|
goto exit_function;
|
||||||
|
}
|
||||||
if (SubsId == NULL) {
|
if (SubsId == NULL) {
|
||||||
HandleUnlock();
|
HandleUnlock();
|
||||||
return UPNP_E_INVALID_PARAM;
|
return UPNP_E_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
UpnpString_set_String(SubsIdTmp, SubsId);
|
||||||
|
|
||||||
HandleReadLock();
|
HandleReadLock();
|
||||||
if (GetHandleInfo(Hnd, &SInfo) != HND_CLIENT) {
|
if (GetHandleInfo(Hnd, &SInfo) != HND_CLIENT) {
|
||||||
HandleUnlock();
|
HandleUnlock();
|
||||||
@@ -1811,12 +1829,14 @@ int UpnpUnSubscribe(UpnpClient_Handle Hnd, const Upnp_SID SubsId)
|
|||||||
}
|
}
|
||||||
HandleUnlock();
|
HandleUnlock();
|
||||||
|
|
||||||
retVal = genaUnSubscribe(Hnd, SubsId);
|
retVal = genaUnSubscribe(Hnd, SubsIdTmp);
|
||||||
|
|
||||||
exit_function:
|
exit_function:
|
||||||
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
|
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
|
||||||
"Exiting UpnpUnSubscribe, retVal=%d\n", retVal);
|
"Exiting UpnpUnSubscribe, retVal=%d\n", retVal);
|
||||||
|
|
||||||
|
UpnpString_delete(SubsIdTmp);
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
#endif /* INCLUDE_CLIENT_APIS */
|
#endif /* INCLUDE_CLIENT_APIS */
|
||||||
@@ -1890,6 +1910,7 @@ int UpnpRenewSubscription(
|
|||||||
{
|
{
|
||||||
struct Handle_Info *SInfo = NULL;
|
struct Handle_Info *SInfo = NULL;
|
||||||
int retVal;
|
int retVal;
|
||||||
|
UpnpString *SubsIdTmp = UpnpString_new();
|
||||||
|
|
||||||
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__, "Inside UpnpRenewSubscription\n");
|
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__, "Inside UpnpRenewSubscription\n");
|
||||||
|
|
||||||
@@ -1897,10 +1918,15 @@ int UpnpRenewSubscription(
|
|||||||
return UPNP_E_FINISH;
|
return UPNP_E_FINISH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SubsIdTmp == NULL) {
|
||||||
|
retVal = UPNP_E_OUTOF_MEMORY;
|
||||||
|
goto exit_function;
|
||||||
|
}
|
||||||
if (SubsId == NULL) {
|
if (SubsId == NULL) {
|
||||||
retVal = UPNP_E_INVALID_PARAM;
|
retVal = UPNP_E_INVALID_PARAM;
|
||||||
goto exit_function;
|
goto exit_function;
|
||||||
}
|
}
|
||||||
|
UpnpString_set_String(SubsIdTmp, SubsId);
|
||||||
|
|
||||||
if (TimeOut == NULL) {
|
if (TimeOut == NULL) {
|
||||||
retVal = UPNP_E_INVALID_PARAM;
|
retVal = UPNP_E_INVALID_PARAM;
|
||||||
@@ -1915,12 +1941,14 @@ int UpnpRenewSubscription(
|
|||||||
}
|
}
|
||||||
HandleUnlock();
|
HandleUnlock();
|
||||||
|
|
||||||
retVal = genaRenewSubscription(Hnd, SubsId, TimeOut);
|
retVal = genaRenewSubscription(Hnd, SubsIdTmp, TimeOut);
|
||||||
|
|
||||||
exit_function:
|
exit_function:
|
||||||
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
|
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
|
||||||
"Exiting UpnpRenewSubscription, retVal=%d\n", retVal);
|
"Exiting UpnpRenewSubscription, retVal=%d\n", retVal);
|
||||||
|
|
||||||
|
UpnpString_delete(SubsIdTmp);
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
#endif /* INCLUDE_CLIENT_APIS */
|
#endif /* INCLUDE_CLIENT_APIS */
|
||||||
@@ -3171,6 +3199,8 @@ int UpnpGetIfInfo(const char *IfName)
|
|||||||
#ifdef INCLUDE_CLIENT_APIS
|
#ifdef INCLUDE_CLIENT_APIS
|
||||||
void UpnpThreadDistribution(struct UpnpNonblockParam *Param)
|
void UpnpThreadDistribution(struct UpnpNonblockParam *Param)
|
||||||
{
|
{
|
||||||
|
/*int errCode = 0;*/
|
||||||
|
|
||||||
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
|
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
|
||||||
"Inside UpnpThreadDistribution \n");
|
"Inside UpnpThreadDistribution \n");
|
||||||
|
|
||||||
@@ -3178,39 +3208,50 @@ void UpnpThreadDistribution(struct UpnpNonblockParam *Param)
|
|||||||
#if EXCLUDE_GENA == 0
|
#if EXCLUDE_GENA == 0
|
||||||
case SUBSCRIBE: {
|
case SUBSCRIBE: {
|
||||||
struct Upnp_Event_Subscribe Evt;
|
struct Upnp_Event_Subscribe Evt;
|
||||||
|
UpnpString *Sid = UpnpString_new();
|
||||||
|
UpnpString *Url = UpnpString_new();
|
||||||
|
UpnpString_set_String(Url, Param->Url);
|
||||||
|
UpnpString_set_String(Sid, (char *)Evt.Sid);
|
||||||
Evt.ErrCode = genaSubscribe(
|
Evt.ErrCode = genaSubscribe(
|
||||||
Param->Handle,
|
Param->Handle,
|
||||||
Param->Url,
|
Url,
|
||||||
(int *)&Param->TimeOut,
|
(int *)&Param->TimeOut,
|
||||||
(char *)Evt.Sid);
|
Sid);
|
||||||
strcpy(Evt.PublisherUrl, Param->Url);
|
strcpy(Evt.PublisherUrl, Param->Url);
|
||||||
Evt.TimeOut = Param->TimeOut;
|
Evt.TimeOut = Param->TimeOut;
|
||||||
Param->Fun(UPNP_EVENT_SUBSCRIBE_COMPLETE, &Evt, Param->Cookie);
|
Param->Fun(UPNP_EVENT_SUBSCRIBE_COMPLETE, &Evt, Param->Cookie);
|
||||||
|
UpnpString_delete(Sid);
|
||||||
|
UpnpString_delete(Url);
|
||||||
free(Param);
|
free(Param);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case UNSUBSCRIBE: {
|
case UNSUBSCRIBE: {
|
||||||
struct Upnp_Event_Subscribe Evt;
|
struct Upnp_Event_Subscribe Evt;
|
||||||
|
UpnpString *Sid = UpnpString_new();
|
||||||
|
UpnpString_set_String(Sid, Param->SubsId);
|
||||||
Evt.ErrCode = genaUnSubscribe(
|
Evt.ErrCode = genaUnSubscribe(
|
||||||
Param->Handle,
|
Param->Handle,
|
||||||
Param->SubsId);
|
Sid);
|
||||||
strcpy((char *)Evt.Sid, Param->SubsId);
|
strcpy((char *)Evt.Sid, UpnpString_get_String(Sid));
|
||||||
strcpy(Evt.PublisherUrl, "");
|
strcpy(Evt.PublisherUrl, "");
|
||||||
Evt.TimeOut = 0;
|
Evt.TimeOut = 0;
|
||||||
Param->Fun(UPNP_EVENT_UNSUBSCRIBE_COMPLETE, &Evt, Param->Cookie);
|
Param->Fun(UPNP_EVENT_UNSUBSCRIBE_COMPLETE, &Evt, Param->Cookie);
|
||||||
|
UpnpString_delete(Sid);
|
||||||
free(Param);
|
free(Param);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case RENEW: {
|
case RENEW: {
|
||||||
struct Upnp_Event_Subscribe Evt;
|
struct Upnp_Event_Subscribe Evt;
|
||||||
|
UpnpString *Sid = UpnpString_new();
|
||||||
|
UpnpString_set_String(Sid, Param->SubsId);
|
||||||
Evt.ErrCode = genaRenewSubscription(
|
Evt.ErrCode = genaRenewSubscription(
|
||||||
Param->Handle,
|
Param->Handle,
|
||||||
Param->SubsId,
|
Sid,
|
||||||
&Param->TimeOut);
|
&Param->TimeOut);
|
||||||
Evt.TimeOut = Param->TimeOut;
|
Evt.TimeOut = Param->TimeOut;
|
||||||
strcpy((char *)Evt.Sid, Param->SubsId);
|
strcpy((char *)Evt.Sid, UpnpString_get_String(Sid));
|
||||||
Param->Fun(UPNP_EVENT_RENEWAL_COMPLETE, &Evt, Param->Cookie);
|
Param->Fun(UPNP_EVENT_RENEWAL_COMPLETE, &Evt, Param->Cookie);
|
||||||
|
UpnpString_delete(Sid);
|
||||||
free(Param);
|
free(Param);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -72,6 +72,7 @@ static void GenaAutoRenewSubscription(
|
|||||||
int eventType = 0;
|
int eventType = 0;
|
||||||
int timeout = 0;
|
int timeout = 0;
|
||||||
int errCode = 0;
|
int errCode = 0;
|
||||||
|
UpnpString *tmpSID = UpnpString_new();
|
||||||
|
|
||||||
if (AUTO_RENEW_TIME == 0) {
|
if (AUTO_RENEW_TIME == 0) {
|
||||||
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, "GENA SUB EXPIRED");
|
UpnpPrintf( UPNP_INFO, GENA, __FILE__, __LINE__, "GENA SUB EXPIRED");
|
||||||
@@ -81,9 +82,10 @@ static void GenaAutoRenewSubscription(
|
|||||||
} else {
|
} else {
|
||||||
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, "GENA AUTO RENEW");
|
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, "GENA AUTO RENEW");
|
||||||
timeout = sub_struct->TimeOut;
|
timeout = sub_struct->TimeOut;
|
||||||
|
UpnpString_set_String(tmpSID, sub_struct->Sid);
|
||||||
errCode = genaRenewSubscription(
|
errCode = genaRenewSubscription(
|
||||||
event->handle,
|
event->handle,
|
||||||
sub_struct->Sid,
|
tmpSID,
|
||||||
&timeout);
|
&timeout);
|
||||||
sub_struct->ErrCode = errCode;
|
sub_struct->ErrCode = errCode;
|
||||||
sub_struct->TimeOut = timeout;
|
sub_struct->TimeOut = timeout;
|
||||||
@@ -100,8 +102,7 @@ static void GenaAutoRenewSubscription(
|
|||||||
if( GetHandleInfo( event->handle, &handle_info ) != HND_CLIENT ) {
|
if( GetHandleInfo( event->handle, &handle_info ) != HND_CLIENT ) {
|
||||||
HandleUnlock();
|
HandleUnlock();
|
||||||
free_upnp_timeout(event);
|
free_upnp_timeout(event);
|
||||||
|
goto end_function;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, "HANDLE IS VALID");
|
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, "HANDLE IS VALID");
|
||||||
|
|
||||||
@@ -113,6 +114,10 @@ static void GenaAutoRenewSubscription(
|
|||||||
}
|
}
|
||||||
|
|
||||||
free_upnp_timeout(event);
|
free_upnp_timeout(event);
|
||||||
|
|
||||||
|
end_function:
|
||||||
|
UpnpString_delete(tmpSID);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -134,27 +139,33 @@ static int ScheduleGenaAutoRenew(
|
|||||||
upnp_timeout *RenewEvent = NULL;
|
upnp_timeout *RenewEvent = NULL;
|
||||||
int return_code = GENA_SUCCESS;
|
int return_code = GENA_SUCCESS;
|
||||||
ThreadPoolJob job;
|
ThreadPoolJob job;
|
||||||
|
const UpnpString *tmpSID = UpnpClientSubscription_get_SID(sub);
|
||||||
|
const UpnpString *tmpEventURL = UpnpClientSubscription_get_EventURL(sub);
|
||||||
|
|
||||||
if( TimeOut == UPNP_INFINITE ) {
|
if (TimeOut == UPNP_INFINITE) {
|
||||||
return GENA_SUCCESS;
|
return_code = GENA_SUCCESS;
|
||||||
|
goto end_function;
|
||||||
}
|
}
|
||||||
|
|
||||||
RenewEventStruct = (struct Upnp_Event_Subscribe *)malloc(sizeof (struct Upnp_Event_Subscribe));
|
RenewEventStruct = (struct Upnp_Event_Subscribe *)malloc(sizeof (struct Upnp_Event_Subscribe));
|
||||||
if( RenewEventStruct == NULL ) {
|
if (RenewEventStruct == NULL) {
|
||||||
return UPNP_E_OUTOF_MEMORY;
|
return_code = UPNP_E_OUTOF_MEMORY;
|
||||||
|
goto end_function;
|
||||||
}
|
}
|
||||||
|
|
||||||
RenewEvent = (upnp_timeout *) malloc(sizeof(upnp_timeout));
|
RenewEvent = (upnp_timeout *) malloc(sizeof(upnp_timeout));
|
||||||
if( RenewEvent == NULL ) {
|
if (RenewEvent == NULL) {
|
||||||
free( RenewEventStruct );
|
free(RenewEventStruct);
|
||||||
return UPNP_E_OUTOF_MEMORY;
|
return_code = UPNP_E_OUTOF_MEMORY;
|
||||||
|
goto end_function;
|
||||||
}
|
}
|
||||||
|
|
||||||
// schedule expire event
|
// schedule expire event
|
||||||
strcpy( RenewEventStruct->Sid, sub->sid );
|
|
||||||
RenewEventStruct->ErrCode = UPNP_E_SUCCESS;
|
RenewEventStruct->ErrCode = UPNP_E_SUCCESS;
|
||||||
strncpy( RenewEventStruct->PublisherUrl, sub->EventURL, NAME_SIZE - 1 );
|
|
||||||
RenewEventStruct->TimeOut = TimeOut;
|
RenewEventStruct->TimeOut = TimeOut;
|
||||||
|
strcpy(RenewEventStruct->Sid, UpnpString_get_String(tmpSID));
|
||||||
|
strncpy(RenewEventStruct->PublisherUrl,
|
||||||
|
UpnpString_get_String(tmpEventURL), NAME_SIZE - 1);
|
||||||
|
|
||||||
// RenewEvent->EventType=UPNP_EVENT_SUBSCRIPTION_EXPIRE;
|
// RenewEvent->EventType=UPNP_EVENT_SUBSCRIPTION_EXPIRE;
|
||||||
RenewEvent->handle = client_handle;
|
RenewEvent->handle = client_handle;
|
||||||
@@ -174,13 +185,15 @@ static int ScheduleGenaAutoRenew(
|
|||||||
if (return_code != UPNP_E_SUCCESS) {
|
if (return_code != UPNP_E_SUCCESS) {
|
||||||
free(RenewEvent);
|
free(RenewEvent);
|
||||||
free(RenewEventStruct);
|
free(RenewEventStruct);
|
||||||
|
goto end_function;
|
||||||
return return_code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub->RenewEventId = RenewEvent->eventId;
|
UpnpClientSubscription_set_RenewEventId(sub, RenewEvent->eventId);
|
||||||
|
|
||||||
return GENA_SUCCESS;
|
return_code = GENA_SUCCESS;
|
||||||
|
|
||||||
|
end_function:
|
||||||
|
return return_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -192,9 +205,9 @@ static int ScheduleGenaAutoRenew(
|
|||||||
*/
|
*/
|
||||||
static int gena_unsubscribe(
|
static int gena_unsubscribe(
|
||||||
/*! [in] Event URL of the service. */
|
/*! [in] Event URL of the service. */
|
||||||
IN const char *url,
|
IN const UpnpString *url,
|
||||||
/*! [in] The subcription ID. */
|
/*! [in] The subcription ID. */
|
||||||
IN const char *sid,
|
IN const UpnpString *sid,
|
||||||
/*! [out] The UNSUBCRIBE response from the device. */
|
/*! [out] The UNSUBCRIBE response from the device. */
|
||||||
OUT http_parser_t *response )
|
OUT http_parser_t *response )
|
||||||
{
|
{
|
||||||
@@ -203,7 +216,10 @@ static int gena_unsubscribe(
|
|||||||
membuffer request;
|
membuffer request;
|
||||||
|
|
||||||
// parse url
|
// parse url
|
||||||
return_code = http_FixStrUrl(url, strlen(url), &dest_url);
|
return_code = http_FixStrUrl(
|
||||||
|
UpnpString_get_String(url),
|
||||||
|
UpnpString_get_Length(url),
|
||||||
|
&dest_url);
|
||||||
if (return_code != 0) {
|
if (return_code != 0) {
|
||||||
return return_code;
|
return return_code;
|
||||||
}
|
}
|
||||||
@@ -215,7 +231,7 @@ static int gena_unsubscribe(
|
|||||||
&request, 1, 1,
|
&request, 1, 1,
|
||||||
"q" "ssc" "Uc",
|
"q" "ssc" "Uc",
|
||||||
HTTPMETHOD_UNSUBSCRIBE, &dest_url,
|
HTTPMETHOD_UNSUBSCRIBE, &dest_url,
|
||||||
"SID: ", sid);
|
"SID: ", UpnpString_get_String(sid));
|
||||||
|
|
||||||
// Not able to make the message so destroy the existing buffer
|
// Not able to make the message so destroy the existing buffer
|
||||||
if (return_code != 0) {
|
if (return_code != 0) {
|
||||||
@@ -249,14 +265,14 @@ static int gena_unsubscribe(
|
|||||||
*/
|
*/
|
||||||
static int gena_subscribe(
|
static int gena_subscribe(
|
||||||
/*! [in] URL of service to subscribe. */
|
/*! [in] URL of service to subscribe. */
|
||||||
IN const char *url,
|
IN const UpnpString *url,
|
||||||
/*! [in,out] Subscription time desired (in secs). */
|
/*! [in,out] Subscription time desired (in secs). */
|
||||||
INOUT int *timeout,
|
INOUT int *timeout,
|
||||||
/*! [in] for renewal, this contains a currently held subscription SID.
|
/*! [in] for renewal, this contains a currently held subscription SID.
|
||||||
* For first time subscription, this must be NULL. */
|
* For first time subscription, this must be NULL. */
|
||||||
IN const char *renewal_sid,
|
IN const UpnpString *renewal_sid,
|
||||||
/*! [out] SID returned by the subscription or renew msg. */
|
/*! [out] SID returned by the subscription or renew msg. */
|
||||||
OUT char **sid)
|
OUT UpnpString *sid)
|
||||||
{
|
{
|
||||||
int return_code;
|
int return_code;
|
||||||
int parse_ret = 0;
|
int parse_ret = 0;
|
||||||
@@ -268,7 +284,7 @@ static int gena_subscribe(
|
|||||||
uri_type dest_url;
|
uri_type dest_url;
|
||||||
http_parser_t response;
|
http_parser_t response;
|
||||||
|
|
||||||
*sid = NULL; // init
|
UpnpString_clear(sid);
|
||||||
|
|
||||||
// request timeout to string
|
// request timeout to string
|
||||||
if (timeout == NULL) {
|
if (timeout == NULL) {
|
||||||
@@ -283,7 +299,10 @@ static int gena_subscribe(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// parse url
|
// parse url
|
||||||
return_code = http_FixStrUrl( url, strlen( url ), &dest_url );
|
return_code = http_FixStrUrl(
|
||||||
|
UpnpString_get_String(url),
|
||||||
|
UpnpString_get_Length(url),
|
||||||
|
&dest_url);
|
||||||
if (return_code != 0) {
|
if (return_code != 0) {
|
||||||
return return_code;
|
return return_code;
|
||||||
}
|
}
|
||||||
@@ -297,7 +316,7 @@ static int gena_subscribe(
|
|||||||
&request, 1, 1,
|
&request, 1, 1,
|
||||||
"q" "ssc" "sscc",
|
"q" "ssc" "sscc",
|
||||||
HTTPMETHOD_SUBSCRIBE, &dest_url,
|
HTTPMETHOD_SUBSCRIBE, &dest_url,
|
||||||
"SID: ", renewal_sid,
|
"SID: ", UpnpString_get_String(renewal_sid),
|
||||||
"TIMEOUT: Second-", timeout_str );
|
"TIMEOUT: Second-", timeout_str );
|
||||||
} else {
|
} else {
|
||||||
// subscribe
|
// subscribe
|
||||||
@@ -365,8 +384,8 @@ static int gena_subscribe(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// save SID
|
// save SID
|
||||||
*sid = str_alloc( sid_hdr.buf, sid_hdr.length );
|
UpnpString_set_StringN(sid, sid_hdr.buf, sid_hdr.length);
|
||||||
if( *sid == NULL ) {
|
if (UpnpString_get_String(sid) == NULL) {
|
||||||
httpmsg_destroy(&response.msg);
|
httpmsg_destroy(&response.msg);
|
||||||
|
|
||||||
return UPNP_E_OUTOF_MEMORY;
|
return UPNP_E_OUTOF_MEMORY;
|
||||||
@@ -379,7 +398,7 @@ static int gena_subscribe(
|
|||||||
|
|
||||||
int genaUnregisterClient(UpnpClient_Handle client_handle)
|
int genaUnregisterClient(UpnpClient_Handle client_handle)
|
||||||
{
|
{
|
||||||
ClientSubscription sub_copy;
|
ClientSubscription *sub_copy = UpnpClientSubscription_new();
|
||||||
int return_code = UPNP_E_SUCCESS;
|
int return_code = UPNP_E_SUCCESS;
|
||||||
struct Handle_Info *handle_info = NULL;
|
struct Handle_Info *handle_info = NULL;
|
||||||
http_parser_t response;
|
http_parser_t response;
|
||||||
@@ -396,25 +415,28 @@ int genaUnregisterClient(UpnpClient_Handle client_handle)
|
|||||||
return_code = UPNP_E_SUCCESS;
|
return_code = UPNP_E_SUCCESS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return_code = copy_client_subscription( handle_info->ClientSubList, &sub_copy);
|
UpnpClientSubscription_assign(sub_copy, handle_info->ClientSubList);
|
||||||
RemoveClientSubClientSID(&handle_info->ClientSubList, sub_copy.sid);
|
RemoveClientSubClientSID(
|
||||||
|
&handle_info->ClientSubList,
|
||||||
|
UpnpClientSubscription_get_SID(sub_copy));
|
||||||
|
|
||||||
HandleUnlock();
|
HandleUnlock();
|
||||||
|
|
||||||
return_code = gena_unsubscribe(
|
return_code = gena_unsubscribe(
|
||||||
sub_copy.EventURL,
|
UpnpClientSubscription_get_EventURL(sub_copy),
|
||||||
sub_copy.ActualSID,
|
UpnpClientSubscription_get_ActualSID(sub_copy),
|
||||||
&response);
|
&response);
|
||||||
if (return_code == 0) {
|
if (return_code == 0) {
|
||||||
httpmsg_destroy(&response.msg);
|
httpmsg_destroy(&response.msg);
|
||||||
}
|
}
|
||||||
free_client_subscription(&sub_copy);
|
free_client_subscription(sub_copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
freeClientSubList(handle_info->ClientSubList);
|
freeClientSubList(handle_info->ClientSubList);
|
||||||
HandleUnlock();
|
HandleUnlock();
|
||||||
|
|
||||||
exit_function:
|
exit_function:
|
||||||
|
UpnpClientSubscription_delete(sub_copy);
|
||||||
return return_code;
|
return return_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -422,12 +444,12 @@ exit_function:
|
|||||||
#ifdef INCLUDE_CLIENT_APIS
|
#ifdef INCLUDE_CLIENT_APIS
|
||||||
int genaUnSubscribe(
|
int genaUnSubscribe(
|
||||||
UpnpClient_Handle client_handle,
|
UpnpClient_Handle client_handle,
|
||||||
const Upnp_SID in_sid)
|
const UpnpString *in_sid)
|
||||||
{
|
{
|
||||||
ClientSubscription *sub = NULL;
|
ClientSubscription *sub = NULL;
|
||||||
int return_code = GENA_SUCCESS;
|
int return_code = GENA_SUCCESS;
|
||||||
struct Handle_Info *handle_info;
|
struct Handle_Info *handle_info;
|
||||||
ClientSubscription sub_copy;
|
ClientSubscription *sub_copy = UpnpClientSubscription_new();
|
||||||
http_parser_t response;
|
http_parser_t response;
|
||||||
|
|
||||||
// validate handle and sid
|
// validate handle and sid
|
||||||
@@ -443,17 +465,17 @@ int genaUnSubscribe(
|
|||||||
return_code = GENA_E_BAD_SID;
|
return_code = GENA_E_BAD_SID;
|
||||||
goto exit_function;
|
goto exit_function;
|
||||||
}
|
}
|
||||||
return_code = copy_client_subscription( sub, &sub_copy );
|
UpnpClientSubscription_assign(sub_copy, sub);
|
||||||
HandleUnlock();
|
HandleUnlock();
|
||||||
|
|
||||||
return_code = gena_unsubscribe(
|
return_code = gena_unsubscribe(
|
||||||
sub_copy.EventURL,
|
UpnpClientSubscription_get_EventURL(sub_copy),
|
||||||
sub_copy.ActualSID,
|
UpnpClientSubscription_get_ActualSID(sub_copy),
|
||||||
&response);
|
&response);
|
||||||
if (return_code == 0) {
|
if (return_code == 0) {
|
||||||
httpmsg_destroy(&response.msg);
|
httpmsg_destroy(&response.msg);
|
||||||
}
|
}
|
||||||
free_client_subscription(&sub_copy);
|
free_client_subscription(sub_copy);
|
||||||
|
|
||||||
HandleLock();
|
HandleLock();
|
||||||
if (GetHandleInfo(client_handle, &handle_info) != HND_CLIENT) {
|
if (GetHandleInfo(client_handle, &handle_info) != HND_CLIENT) {
|
||||||
@@ -465,6 +487,7 @@ int genaUnSubscribe(
|
|||||||
HandleUnlock();
|
HandleUnlock();
|
||||||
|
|
||||||
exit_function:
|
exit_function:
|
||||||
|
UpnpClientSubscription_delete(sub_copy);
|
||||||
return return_code;
|
return return_code;
|
||||||
}
|
}
|
||||||
#endif /* INCLUDE_CLIENT_APIS */
|
#endif /* INCLUDE_CLIENT_APIS */
|
||||||
@@ -473,21 +496,22 @@ exit_function:
|
|||||||
#ifdef INCLUDE_CLIENT_APIS
|
#ifdef INCLUDE_CLIENT_APIS
|
||||||
int genaSubscribe(
|
int genaSubscribe(
|
||||||
UpnpClient_Handle client_handle,
|
UpnpClient_Handle client_handle,
|
||||||
const char *PublisherURL,
|
const UpnpString *PublisherURL,
|
||||||
int *TimeOut,
|
int *TimeOut,
|
||||||
Upnp_SID out_sid)
|
UpnpString *out_sid)
|
||||||
{
|
{
|
||||||
int return_code = GENA_SUCCESS;
|
int return_code = GENA_SUCCESS;
|
||||||
ClientSubscription *newSubscription = NULL;
|
ClientSubscription *newSubscription = UpnpClientSubscription_new();
|
||||||
uuid_upnp uid;
|
uuid_upnp uid;
|
||||||
Upnp_SID temp_sid;
|
Upnp_SID temp_sid;
|
||||||
char *ActualSID = NULL;
|
Upnp_SID temp_sid2;
|
||||||
|
UpnpString *ActualSID = UpnpString_new();
|
||||||
|
UpnpString *EventURL = UpnpString_new();
|
||||||
struct Handle_Info *handle_info;
|
struct Handle_Info *handle_info;
|
||||||
char *EventURL = NULL;
|
|
||||||
|
|
||||||
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, "GENA SUBSCRIBE BEGIN");
|
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, "GENA SUBSCRIBE BEGIN");
|
||||||
|
|
||||||
memset( out_sid, 0, sizeof( Upnp_SID ) );
|
UpnpString_clear(out_sid);
|
||||||
|
|
||||||
HandleReadLock();
|
HandleReadLock();
|
||||||
// validate handle
|
// validate handle
|
||||||
@@ -500,7 +524,7 @@ int genaSubscribe(
|
|||||||
|
|
||||||
// subscribe
|
// subscribe
|
||||||
SubscribeLock();
|
SubscribeLock();
|
||||||
return_code = gena_subscribe(PublisherURL, TimeOut, NULL, &ActualSID);
|
return_code = gena_subscribe(PublisherURL, TimeOut, NULL, ActualSID);
|
||||||
HandleLock();
|
HandleLock();
|
||||||
if (return_code != UPNP_E_SUCCESS) {
|
if (return_code != UPNP_E_SUCCESS) {
|
||||||
UpnpPrintf( UPNP_CRITICAL, GENA, __FILE__, __LINE__,
|
UpnpPrintf( UPNP_CRITICAL, GENA, __FILE__, __LINE__,
|
||||||
@@ -517,27 +541,22 @@ int genaSubscribe(
|
|||||||
// generate client SID
|
// generate client SID
|
||||||
uuid_create(&uid );
|
uuid_create(&uid );
|
||||||
uuid_unpack(&uid, temp_sid);
|
uuid_unpack(&uid, temp_sid);
|
||||||
sprintf( out_sid, "uuid:%s", temp_sid );
|
sprintf(temp_sid2, "uuid:%s", temp_sid);
|
||||||
|
UpnpString_set_String(out_sid, temp_sid2);
|
||||||
|
|
||||||
// create event url
|
// create event url
|
||||||
EventURL = ( char * )malloc( strlen( PublisherURL ) + 1 );
|
UpnpString_assign(EventURL, PublisherURL);
|
||||||
if( EventURL == NULL ) {
|
|
||||||
return_code = UPNP_E_OUTOF_MEMORY;
|
|
||||||
goto error_handler;
|
|
||||||
}
|
|
||||||
strcpy( EventURL, PublisherURL );
|
|
||||||
|
|
||||||
// fill subscription
|
// fill subscription
|
||||||
newSubscription = (ClientSubscription *)malloc(sizeof (ClientSubscription));
|
|
||||||
if (newSubscription == NULL) {
|
if (newSubscription == NULL) {
|
||||||
return_code = UPNP_E_OUTOF_MEMORY;
|
return_code = UPNP_E_OUTOF_MEMORY;
|
||||||
goto error_handler;
|
goto error_handler;
|
||||||
}
|
}
|
||||||
newSubscription->EventURL = EventURL;
|
UpnpClientSubscription_set_RenewEventId(newSubscription, -1);
|
||||||
newSubscription->ActualSID = ActualSID;
|
UpnpClientSubscription_set_SID(newSubscription, out_sid);
|
||||||
strcpy(newSubscription->sid, out_sid);
|
UpnpClientSubscription_set_ActualSID(newSubscription, ActualSID);
|
||||||
newSubscription->RenewEventId = -1;
|
UpnpClientSubscription_set_EventURL(newSubscription, EventURL);
|
||||||
newSubscription->next = handle_info->ClientSubList;
|
UpnpClientSubscription_set_Next(newSubscription, handle_info->ClientSubList);
|
||||||
handle_info->ClientSubList = newSubscription;
|
handle_info->ClientSubList = newSubscription;
|
||||||
|
|
||||||
// schedule expiration event
|
// schedule expiration event
|
||||||
@@ -545,9 +564,9 @@ int genaSubscribe(
|
|||||||
|
|
||||||
error_handler:
|
error_handler:
|
||||||
if (return_code != UPNP_E_SUCCESS) {
|
if (return_code != UPNP_E_SUCCESS) {
|
||||||
free(ActualSID);
|
UpnpString_delete(ActualSID);
|
||||||
free(EventURL);
|
UpnpString_delete(EventURL);
|
||||||
free(newSubscription);
|
UpnpClientSubscription_delete(newSubscription);
|
||||||
}
|
}
|
||||||
HandleUnlock();
|
HandleUnlock();
|
||||||
SubscribeUnlock();
|
SubscribeUnlock();
|
||||||
@@ -559,14 +578,14 @@ error_handler:
|
|||||||
|
|
||||||
int genaRenewSubscription(
|
int genaRenewSubscription(
|
||||||
UpnpClient_Handle client_handle,
|
UpnpClient_Handle client_handle,
|
||||||
const char *in_sid,
|
const UpnpString *in_sid,
|
||||||
int *TimeOut)
|
int *TimeOut)
|
||||||
{
|
{
|
||||||
int return_code = GENA_SUCCESS;
|
int return_code = GENA_SUCCESS;
|
||||||
ClientSubscription *sub = NULL;
|
ClientSubscription *sub = NULL;
|
||||||
ClientSubscription sub_copy;
|
ClientSubscription *sub_copy = UpnpClientSubscription_new();
|
||||||
struct Handle_Info *handle_info;
|
struct Handle_Info *handle_info;
|
||||||
char *ActualSID;
|
UpnpString *ActualSID = UpnpString_new();
|
||||||
ThreadPoolJob tempJob;
|
ThreadPoolJob tempJob;
|
||||||
|
|
||||||
HandleLock();
|
HandleLock();
|
||||||
@@ -590,27 +609,23 @@ int genaRenewSubscription(
|
|||||||
// remove old events
|
// remove old events
|
||||||
if (TimerThreadRemove(
|
if (TimerThreadRemove(
|
||||||
&gTimerThread,
|
&gTimerThread,
|
||||||
sub->RenewEventId,
|
UpnpClientSubscription_get_RenewEventId(sub),
|
||||||
&tempJob) == 0 ) {
|
&tempJob) == 0 ) {
|
||||||
free_upnp_timeout((upnp_timeout *)tempJob.arg);
|
free_upnp_timeout((upnp_timeout *)tempJob.arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, "REMOVED AUTO RENEW EVENT");
|
UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, "REMOVED AUTO RENEW EVENT");
|
||||||
|
|
||||||
sub->RenewEventId = -1;
|
UpnpClientSubscription_set_RenewEventId(sub, -1);
|
||||||
return_code = copy_client_subscription(sub, &sub_copy);
|
UpnpClientSubscription_assign(sub_copy, sub);
|
||||||
|
|
||||||
HandleUnlock();
|
HandleUnlock();
|
||||||
|
|
||||||
if( return_code != HTTP_SUCCESS ) {
|
|
||||||
return return_code;
|
|
||||||
}
|
|
||||||
|
|
||||||
return_code = gena_subscribe(
|
return_code = gena_subscribe(
|
||||||
sub_copy.EventURL,
|
UpnpClientSubscription_get_EventURL(sub_copy),
|
||||||
TimeOut,
|
TimeOut,
|
||||||
sub_copy.ActualSID,
|
UpnpClientSubscription_get_ActualSID(sub_copy),
|
||||||
&ActualSID);
|
ActualSID);
|
||||||
|
|
||||||
HandleLock();
|
HandleLock();
|
||||||
|
|
||||||
@@ -625,7 +640,7 @@ int genaRenewSubscription(
|
|||||||
if (return_code != UPNP_E_SUCCESS) {
|
if (return_code != UPNP_E_SUCCESS) {
|
||||||
// network failure (remove client sub)
|
// network failure (remove client sub)
|
||||||
RemoveClientSubClientSID(&handle_info->ClientSubList, in_sid);
|
RemoveClientSubClientSID(&handle_info->ClientSubList, in_sid);
|
||||||
free_client_subscription(&sub_copy);
|
free_client_subscription(sub_copy);
|
||||||
HandleUnlock();
|
HandleUnlock();
|
||||||
goto exit_function;
|
goto exit_function;
|
||||||
}
|
}
|
||||||
@@ -633,29 +648,28 @@ int genaRenewSubscription(
|
|||||||
// get subscription
|
// get subscription
|
||||||
sub = GetClientSubClientSID(handle_info->ClientSubList, in_sid);
|
sub = GetClientSubClientSID(handle_info->ClientSubList, in_sid);
|
||||||
if (sub == NULL) {
|
if (sub == NULL) {
|
||||||
free_client_subscription(&sub_copy);
|
free_client_subscription(sub_copy);
|
||||||
HandleUnlock();
|
HandleUnlock();
|
||||||
return_code = GENA_E_BAD_SID;
|
return_code = GENA_E_BAD_SID;
|
||||||
goto exit_function;
|
goto exit_function;
|
||||||
}
|
}
|
||||||
|
|
||||||
// store actual sid
|
// store actual sid
|
||||||
free( sub->ActualSID );
|
UpnpClientSubscription_set_ActualSID(sub, ActualSID);
|
||||||
sub->ActualSID = ActualSID;
|
|
||||||
|
|
||||||
// start renew subscription timer
|
// start renew subscription timer
|
||||||
return_code = ScheduleGenaAutoRenew(client_handle, *TimeOut, sub);
|
return_code = ScheduleGenaAutoRenew(client_handle, *TimeOut, sub);
|
||||||
if (return_code != GENA_SUCCESS) {
|
if (return_code != GENA_SUCCESS) {
|
||||||
RemoveClientSubClientSID(
|
RemoveClientSubClientSID(
|
||||||
&handle_info->ClientSubList,
|
&handle_info->ClientSubList,
|
||||||
sub->sid);
|
UpnpClientSubscription_get_SID(sub));
|
||||||
}
|
}
|
||||||
free_client_subscription(&sub_copy);
|
free_client_subscription(sub_copy);
|
||||||
HandleUnlock();
|
HandleUnlock();
|
||||||
|
|
||||||
exit_function:
|
exit_function:
|
||||||
free(ActualSID);
|
UpnpString_delete(ActualSID);
|
||||||
|
UpnpClientSubscription_delete(sub_copy);
|
||||||
return return_code;
|
return return_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -673,6 +687,7 @@ void gena_process_notification_event(
|
|||||||
void *cookie;
|
void *cookie;
|
||||||
Upnp_FunPtr callback;
|
Upnp_FunPtr callback;
|
||||||
UpnpClient_Handle client_handle;
|
UpnpClient_Handle client_handle;
|
||||||
|
const UpnpString *tmpSID = NULL;
|
||||||
|
|
||||||
memptr sid_hdr;
|
memptr sid_hdr;
|
||||||
memptr nt_hdr,
|
memptr nt_hdr,
|
||||||
@@ -769,7 +784,8 @@ void gena_process_notification_event(
|
|||||||
error_respond(info, HTTP_OK, event);
|
error_respond(info, HTTP_OK, event);
|
||||||
|
|
||||||
// fill event struct
|
// fill event struct
|
||||||
strcpy(event_struct.Sid, subscription->sid);
|
tmpSID = UpnpClientSubscription_get_SID(subscription);
|
||||||
|
strcpy(event_struct.Sid, UpnpString_get_String(tmpSID));
|
||||||
event_struct.EventKey = eventKey;
|
event_struct.EventKey = eventKey;
|
||||||
event_struct.ChangedVariables = ChangedVars;
|
event_struct.ChangedVariables = ChangedVars;
|
||||||
|
|
||||||
|
@@ -1,209 +1,329 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
/*******************************************************************************
|
||||||
//
|
*
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
* Copyright (c) 2000-2003 Intel Corporation
|
||||||
// All rights reserved.
|
* All rights reserved.
|
||||||
//
|
*
|
||||||
// Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
//
|
*
|
||||||
// * Redistributions of source code must retain the above copyright notice,
|
* - Redistributions of source code must retain the above copyright notice,
|
||||||
// this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
// * Neither name of Intel Corporation nor the names of its contributors
|
* - Neither name of Intel Corporation nor the names of its contributors
|
||||||
// may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
* without specific prior written permission.
|
||||||
//
|
*
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
*
|
||||||
///////////////////////////////////////////////////////////////////////////
|
******************************************************************************/
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Purpose: This file defines the functions for clients. It defines
|
* Purpose: This file defines the functions for clients. It defines
|
||||||
* functions for adding and removing clients to and from the client table,
|
* functions for adding and removing clients to and from the client table,
|
||||||
* adding and accessing subscription and other attributes pertaining to the
|
* adding and accessing subscription and other attributes pertaining to the
|
||||||
* client
|
* client
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
#include "client_table.h"
|
#include "client_table.h"
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : copy_client_subscription
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* ClientSubscription * in ; - source client subscription
|
|
||||||
* ClientSubscription * out ; - destination client subscription
|
|
||||||
*
|
|
||||||
* Description : Make a copy of the client subscription data
|
|
||||||
*
|
|
||||||
* Return : int ;
|
|
||||||
* UPNP_E_OUTOF_MEMORY - On Failure to allocate memory
|
|
||||||
* HTTP_SUCCESS - On Success
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
CLIENTONLY( int copy_client_subscription( ClientSubscription * in,
|
|
||||||
ClientSubscription * out ) {
|
|
||||||
int len = strlen( in->ActualSID ) + 1;
|
|
||||||
int len1 = strlen( in->EventURL ) + 1;
|
|
||||||
memcpy( out->sid, in->sid, SID_SIZE );
|
|
||||||
out->sid[SID_SIZE] = 0;
|
|
||||||
out->ActualSID = ( char * )malloc( len );
|
|
||||||
if( out->ActualSID == NULL )
|
|
||||||
return UPNP_E_OUTOF_MEMORY;
|
|
||||||
out->EventURL = ( char * )malloc( len1 );
|
|
||||||
if( out->EventURL == NULL ) {
|
|
||||||
free(out->ActualSID);
|
|
||||||
return UPNP_E_OUTOF_MEMORY;
|
|
||||||
}
|
|
||||||
memcpy( out->ActualSID, in->ActualSID, len );
|
|
||||||
memcpy( out->EventURL, in->EventURL, len1 );
|
|
||||||
//copies do not get RenewEvent Ids or next
|
|
||||||
out->RenewEventId = -1; out->next = NULL; return HTTP_SUCCESS;}
|
|
||||||
|
|
||||||
/************************************************************************
|
#ifdef INCLUDE_CLIENT_APIS
|
||||||
* Function : free_client_subscription
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* ClientSubscription * sub ; - Client subscription to be freed
|
|
||||||
*
|
|
||||||
* Description : Free memory allocated for client subscription data.
|
|
||||||
* Remove timer thread associated with this subscription event.
|
|
||||||
*
|
|
||||||
* Return : void ;
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
void free_client_subscription( ClientSubscription * sub ) {
|
|
||||||
upnp_timeout * event; ThreadPoolJob tempJob; if( sub ) {
|
|
||||||
if( sub->ActualSID )
|
|
||||||
free( sub->ActualSID ); if( sub->EventURL )
|
|
||||||
free( sub->EventURL ); if( sub->RenewEventId != -1 ) //do not remove timer event of copy
|
|
||||||
//invalid timer event id
|
|
||||||
{
|
|
||||||
if( TimerThreadRemove
|
|
||||||
( &gTimerThread, sub->RenewEventId, &tempJob ) == 0 ) {
|
|
||||||
event = ( upnp_timeout * ) tempJob.arg;
|
|
||||||
free_upnp_timeout( event );}
|
|
||||||
}
|
|
||||||
|
|
||||||
sub->RenewEventId = -1;}
|
|
||||||
}
|
|
||||||
|
|
||||||
/************************************************************************
|
#include <stdlib.h> // for calloc(), free()
|
||||||
* Function : freeClientSubList
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* ClientSubscription * list ; Client subscription
|
|
||||||
*
|
|
||||||
* Description : Free the client subscription table.
|
|
||||||
*
|
|
||||||
* Return : void ;
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
void freeClientSubList( ClientSubscription * list ) {
|
|
||||||
ClientSubscription * next; while( list ) {
|
|
||||||
free_client_subscription( list );
|
|
||||||
next = list->next; free( list ); list = next;}
|
|
||||||
}
|
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : RemoveClientSubClientSID
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* ClientSubscription **head ; Head of the subscription list
|
|
||||||
* const Upnp_SID sid ; Subscription ID to be mactched
|
|
||||||
*
|
|
||||||
* Description : Remove the client subscription matching the
|
|
||||||
* subscritpion id represented by the const Upnp_SID sid parameter
|
|
||||||
* from the table and update the table.
|
|
||||||
*
|
|
||||||
* Return : void ;
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
void RemoveClientSubClientSID( ClientSubscription ** head,
|
|
||||||
const Upnp_SID sid ) {
|
|
||||||
ClientSubscription * finger = ( *head );
|
|
||||||
ClientSubscription * previous = NULL; while( finger ) {
|
|
||||||
if( !( strcmp( sid, finger->sid ) ) ) {
|
|
||||||
if( previous )
|
|
||||||
previous->next = finger->next;
|
|
||||||
else
|
|
||||||
( *head ) = finger->next;
|
|
||||||
finger->next = NULL;
|
|
||||||
freeClientSubList( finger ); finger = NULL;}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
previous = finger; finger = finger->next;}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/************************************************************************
|
struct SClientSubscription {
|
||||||
* Function : GetClientSubClientSID
|
int m_renewEventId;
|
||||||
*
|
UpnpString *m_SID;
|
||||||
* Parameters :
|
UpnpString *m_actualSID;
|
||||||
* ClientSubscription *head ; Head of the subscription list
|
UpnpString *m_eventURL;
|
||||||
* const Upnp_SID sid ; Subscription ID to be matched
|
struct SClientSubscription *m_next;
|
||||||
*
|
};
|
||||||
* Description : Return the client subscription from the client table
|
|
||||||
* that matches const Upnp_SID sid subscrition id value.
|
|
||||||
*
|
|
||||||
* Return : ClientSubscription * ; The matching subscription
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
ClientSubscription *
|
|
||||||
GetClientSubClientSID( ClientSubscription * head,
|
|
||||||
const Upnp_SID sid ) {
|
|
||||||
ClientSubscription * next = head; while( next ) {
|
|
||||||
if( !strcmp( next->sid, sid ) )
|
|
||||||
break;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
next = next->next;}
|
|
||||||
}
|
|
||||||
return next;}
|
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : GetClientSubActualSID
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* ClientSubscription *head ; Head of the subscription list
|
|
||||||
* token * sid ; Subscription ID to be matched
|
|
||||||
*
|
|
||||||
* Description : Returns the client subscription from the client
|
|
||||||
* subscription table that has the matching token * sid buffer
|
|
||||||
* value.
|
|
||||||
*
|
|
||||||
* Return : ClientSubscription * ; The matching subscription
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
ClientSubscription *
|
|
||||||
GetClientSubActualSID( ClientSubscription * head,
|
|
||||||
token * sid ) {
|
|
||||||
ClientSubscription * next = head; while( next ) {
|
|
||||||
|
|
||||||
if( !memcmp( next->ActualSID, sid->buff, sid->size ) )
|
/** Constructor */
|
||||||
break;
|
ClientSubscription *UpnpClientSubscription_new()
|
||||||
else
|
{
|
||||||
{
|
struct SClientSubscription *p = calloc(1, sizeof (struct SClientSubscription));
|
||||||
next = next->next;}
|
#if 0
|
||||||
}
|
p->renewEventId = 0;
|
||||||
return next;}
|
#endif
|
||||||
|
p->m_SID = UpnpString_new();
|
||||||
|
p->m_actualSID = UpnpString_new();
|
||||||
|
p->m_eventURL = UpnpString_new();
|
||||||
|
p->m_next = NULL;
|
||||||
|
|
||||||
|
return (ClientSubscription *)p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Destructor */
|
||||||
|
void UpnpClientSubscription_delete(ClientSubscription *p)
|
||||||
|
{
|
||||||
|
struct SClientSubscription *q = (struct SClientSubscription *)p;
|
||||||
|
|
||||||
|
if (!q) return;
|
||||||
|
|
||||||
|
q->m_renewEventId = 0;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_SID);
|
||||||
|
q->m_SID = NULL;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_actualSID);
|
||||||
|
q->m_actualSID = NULL;
|
||||||
|
|
||||||
|
UpnpString_delete(q->m_eventURL);
|
||||||
|
q->m_eventURL = NULL;
|
||||||
|
|
||||||
|
q->m_next = NULL;
|
||||||
|
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Copy Constructor */
|
||||||
|
ClientSubscription *UpnpClientSubscription_dup(const ClientSubscription *p)
|
||||||
|
{
|
||||||
|
ClientSubscription *q = UpnpClientSubscription_new();
|
||||||
|
|
||||||
|
UpnpClientSubscription_assign(q, p);
|
||||||
|
|
||||||
|
return q;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Assignment operator */
|
||||||
|
void UpnpClientSubscription_assign(ClientSubscription *q, const ClientSubscription *p)
|
||||||
|
{
|
||||||
|
if (q != p) {
|
||||||
|
// Do not copy RenewEventId
|
||||||
|
((struct SClientSubscription *)q)->m_renewEventId = -1;
|
||||||
|
UpnpClientSubscription_set_SID(q, UpnpClientSubscription_get_SID(p));
|
||||||
|
UpnpClientSubscription_set_ActualSID(q, UpnpClientSubscription_get_ActualSID(p));
|
||||||
|
UpnpClientSubscription_set_EventURL(q, UpnpClientSubscription_get_EventURL(p));
|
||||||
|
// Do not copy m_next
|
||||||
|
((struct SClientSubscription *)q)->m_next = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int UpnpClientSubscription_get_RenewEventId(const ClientSubscription *p)
|
||||||
|
{
|
||||||
|
return ((struct SClientSubscription *)p)->m_renewEventId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpClientSubscription_set_RenewEventId(ClientSubscription *p, int n)
|
||||||
|
{
|
||||||
|
((struct SClientSubscription *)p)->m_renewEventId = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpClientSubscription_get_SID(const ClientSubscription *p)
|
||||||
|
{
|
||||||
|
return ((struct SClientSubscription *)p)->m_SID;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpnpClientSubscription_get_SID_cstr(const ClientSubscription *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpClientSubscription_get_SID(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpClientSubscription_set_SID(ClientSubscription *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SClientSubscription *)p)->m_SID);
|
||||||
|
((struct SClientSubscription *)p)->m_SID = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpClientSubscription_strcpy_SID(ClientSubscription *p, const char *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SClientSubscription *)p)->m_SID);
|
||||||
|
((struct SClientSubscription *)p)->m_SID = UpnpString_new();
|
||||||
|
UpnpString_set_String(((struct SClientSubscription *)p)->m_SID, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpClientSubscription_get_ActualSID(const ClientSubscription *p)
|
||||||
|
{
|
||||||
|
return ((struct SClientSubscription *)p)->m_actualSID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char *UpnpClientSubscription_get_ActualSID_cstr(const ClientSubscription *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpClientSubscription_get_ActualSID(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpClientSubscription_set_ActualSID(ClientSubscription *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SClientSubscription *)p)->m_actualSID);
|
||||||
|
((struct SClientSubscription *)p)->m_actualSID = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpClientSubscription_strcpy_ActualSID(ClientSubscription *p, const char *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SClientSubscription *)p)->m_actualSID);
|
||||||
|
((struct SClientSubscription *)p)->m_actualSID = UpnpString_new();
|
||||||
|
UpnpString_set_String(((struct SClientSubscription *)p)->m_actualSID, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const UpnpString *UpnpClientSubscription_get_EventURL(const ClientSubscription *p)
|
||||||
|
{
|
||||||
|
return ((struct SClientSubscription *)p)->m_eventURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char *UpnpClientSubscription_get_EventURL_cstr(const ClientSubscription *p)
|
||||||
|
{
|
||||||
|
return UpnpString_get_String(UpnpClientSubscription_get_EventURL(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpClientSubscription_set_EventURL(ClientSubscription *p, const UpnpString *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SClientSubscription *)p)->m_eventURL);
|
||||||
|
((struct SClientSubscription *)p)->m_eventURL = UpnpString_dup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpClientSubscription_strcpy_EventURL(ClientSubscription *p, const char *s)
|
||||||
|
{
|
||||||
|
UpnpString_delete(((struct SClientSubscription *)p)->m_eventURL);
|
||||||
|
((struct SClientSubscription *)p)->m_eventURL = UpnpString_new();
|
||||||
|
UpnpString_set_String(((struct SClientSubscription *)p)->m_eventURL, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ClientSubscription *UpnpClientSubscription_get_Next(const ClientSubscription *p)
|
||||||
|
{
|
||||||
|
return (ClientSubscription *)(((struct SClientSubscription *)p)->m_next);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpnpClientSubscription_set_Next(ClientSubscription *p, ClientSubscription *q)
|
||||||
|
{
|
||||||
|
((struct SClientSubscription *)p)->m_next = (struct SClientSubscription *)q;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void free_client_subscription(ClientSubscription *sub)
|
||||||
|
{
|
||||||
|
upnp_timeout *event;
|
||||||
|
ThreadPoolJob tempJob;
|
||||||
|
if (sub) {
|
||||||
|
int renewEventId = UpnpClientSubscription_get_RenewEventId(sub);
|
||||||
|
UpnpClientSubscription_strcpy_ActualSID(sub, "");
|
||||||
|
UpnpClientSubscription_strcpy_EventURL(sub, "");
|
||||||
|
if (renewEventId != -1) {
|
||||||
|
// do not remove timer event of copy
|
||||||
|
// invalid timer event id
|
||||||
|
if (TimerThreadRemove(&gTimerThread, renewEventId, &tempJob) == 0) {
|
||||||
|
event = (upnp_timeout *)tempJob.arg;
|
||||||
|
free_upnp_timeout(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UpnpClientSubscription_set_RenewEventId(sub, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void freeClientSubList(ClientSubscription *list)
|
||||||
|
{
|
||||||
|
ClientSubscription *next;
|
||||||
|
while (list) {
|
||||||
|
free_client_subscription(list);
|
||||||
|
next = UpnpClientSubscription_get_Next(list);
|
||||||
|
UpnpClientSubscription_delete(list);
|
||||||
|
list = next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RemoveClientSubClientSID(ClientSubscription **head, const UpnpString *sid)
|
||||||
|
{
|
||||||
|
ClientSubscription *finger = *head;
|
||||||
|
ClientSubscription *previous = NULL;
|
||||||
|
int found = 0;
|
||||||
|
while (finger) {
|
||||||
|
found = !strcmp(
|
||||||
|
UpnpString_get_String(sid),
|
||||||
|
UpnpClientSubscription_get_SID_cstr(finger));
|
||||||
|
if (found) {
|
||||||
|
if (previous) {
|
||||||
|
UpnpClientSubscription_set_Next(previous,
|
||||||
|
UpnpClientSubscription_get_Next(finger));
|
||||||
|
} else {
|
||||||
|
*head = UpnpClientSubscription_get_Next(finger);
|
||||||
|
}
|
||||||
|
UpnpClientSubscription_set_Next(finger, NULL);
|
||||||
|
freeClientSubList(finger);
|
||||||
|
finger = NULL;
|
||||||
|
} else {
|
||||||
|
previous = finger;
|
||||||
|
finger = UpnpClientSubscription_get_Next(finger);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ClientSubscription *GetClientSubClientSID(ClientSubscription *head, const UpnpString *sid)
|
||||||
|
{
|
||||||
|
ClientSubscription *next = head;
|
||||||
|
int found = 0;
|
||||||
|
while (next) {
|
||||||
|
found = !strcmp(
|
||||||
|
UpnpClientSubscription_get_SID_cstr(next),
|
||||||
|
UpnpString_get_String(sid));
|
||||||
|
if(found) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
next = UpnpClientSubscription_get_Next(next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ClientSubscription *GetClientSubActualSID(ClientSubscription *head, token *sid)
|
||||||
|
{
|
||||||
|
ClientSubscription *next = head;
|
||||||
|
while (next) {
|
||||||
|
if (!memcmp(
|
||||||
|
UpnpClientSubscription_get_ActualSID_cstr(next),
|
||||||
|
sid->buff, sid->size)) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
next = UpnpClientSubscription_get_Next(next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* INCLUDE_CLIENT_APIS */
|
||||||
|
|
||||||
)
|
|
||||||
|
@@ -1,166 +1,248 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Copyright (c) 2000-2003 Intel Corporation
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
|
||||||
// and/or other materials provided with the distribution.
|
|
||||||
// * Neither name of Intel Corporation nor the names of its contributors
|
|
||||||
// may be used to endorse or promote products derived from this software
|
|
||||||
// without specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
|
||||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
//
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef _CLIENT_TABLE
|
#ifndef CLIENT_TABLE_H
|
||||||
#define _CLIENT_TABLE
|
#define CLIENT_TABLE_H
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include "service_table.h"
|
||||||
#include "upnp.h"
|
#include "upnp.h"
|
||||||
|
#include "UpnpString.h"
|
||||||
|
#include "upnp_timeout.h"
|
||||||
|
#include "uri.h"
|
||||||
|
#include "TimerThread.h"
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
//#include <malloc.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "uri.h"
|
|
||||||
#include "service_table.h"
|
|
||||||
|
|
||||||
#include "TimerThread.h"
|
|
||||||
#include "upnp_timeout.h"
|
|
||||||
|
|
||||||
extern TimerThread gTimerThread;
|
extern TimerThread gTimerThread;
|
||||||
|
|
||||||
CLIENTONLY(
|
|
||||||
typedef struct CLIENT_SUBSCRIPTION {
|
|
||||||
Upnp_SID sid;
|
|
||||||
char * ActualSID;
|
|
||||||
char * EventURL;
|
|
||||||
int RenewEventId;
|
|
||||||
struct CLIENT_SUBSCRIPTION *next;
|
|
||||||
} ClientSubscription;
|
|
||||||
|
|
||||||
/************************************************************************
|
#ifdef INCLUDE_CLIENT_APIS
|
||||||
* Function : copy_client_subscription
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* ClientSubscription * in ; - source client subscription
|
|
||||||
* ClientSubscription * out ; - destination client subscription
|
|
||||||
*
|
|
||||||
* Description : Make a copy of the client subscription data
|
|
||||||
*
|
|
||||||
* Return : int ;
|
|
||||||
* UPNP_E_OUTOF_MEMORY - On Failure to allocate memory
|
|
||||||
* HTTP_SUCCESS - On Success
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
int copy_client_subscription(ClientSubscription * in, ClientSubscription * out);
|
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : free_client_subscription
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* ClientSubscription * sub ; - Client subscription to be freed
|
|
||||||
*
|
|
||||||
* Description : Free memory allocated for client subscription data.
|
|
||||||
* Remove timer thread associated with this subscription event.
|
|
||||||
*
|
|
||||||
* Return : void ;
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
void free_client_subscription(ClientSubscription * sub);
|
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
typedef struct s_ClientSubscription ClientSubscription;
|
||||||
* Function : freeClientSubList
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* ClientSubscription * list ; Client subscription
|
|
||||||
*
|
|
||||||
* Description : Free the client subscription table.
|
|
||||||
*
|
|
||||||
* Return : void ;
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
void freeClientSubList(ClientSubscription * list);
|
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : RemoveClientSubClientSID
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* ClientSubscription **head ; Head of the subscription list
|
|
||||||
* const Upnp_SID sid ; Subscription ID to be mactched
|
|
||||||
*
|
|
||||||
* Description : Remove the client subscription matching the
|
|
||||||
* subscritpion id represented by the const Upnp_SID sid parameter
|
|
||||||
* from the table and update the table.
|
|
||||||
*
|
|
||||||
* Return : void ;
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
void RemoveClientSubClientSID(ClientSubscription **head,
|
|
||||||
const Upnp_SID sid);
|
|
||||||
|
|
||||||
/************************************************************************
|
/*!
|
||||||
* Function : GetClientSubClientSID
|
* \brief Constructor.
|
||||||
*
|
*/
|
||||||
* Parameters :
|
ClientSubscription *UpnpClientSubscription_new();
|
||||||
* ClientSubscription *head ; Head of the subscription list
|
|
||||||
* const Upnp_SID sid ; Subscription ID to be matched
|
|
||||||
*
|
/*!
|
||||||
* Description : Return the client subscription from the client table
|
* \brief Destructor.
|
||||||
* that matches const Upnp_SID sid subscrition id value.
|
*/
|
||||||
*
|
void UpnpClientSubscription_delete(
|
||||||
* Return : ClientSubscription * ; The matching subscription
|
/*! [in] The \b this pointer. */
|
||||||
*
|
ClientSubscription *p);
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
ClientSubscription * GetClientSubClientSID(ClientSubscription *head
|
/*!
|
||||||
, const Upnp_SID sid);
|
* \brief Copy Constructor.
|
||||||
|
*/
|
||||||
|
ClientSubscription *UpnpClientSubscription_dup(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
const ClientSubscription *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Assignment operator.
|
||||||
|
*/
|
||||||
|
void UpnpClientSubscription_assign(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *q,
|
||||||
|
const ClientSubscription *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
int UpnpClientSubscription_get_RenewEventId(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
const ClientSubscription *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
void UpnpClientSubscription_set_RenewEventId(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *p,
|
||||||
|
/*! [in] . */
|
||||||
|
int n);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
const UpnpString *UpnpClientSubscription_get_SID(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
const ClientSubscription *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
void UpnpClientSubscription_set_SID(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *p,
|
||||||
|
const UpnpString *s);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
void UpnpClientSubscription_strcpy_SID(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *p,
|
||||||
|
const char *s);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
const UpnpString *UpnpClientSubscription_get_ActualSID(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
const ClientSubscription *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
void UpnpClientSubscription_set_ActualSID(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *p,
|
||||||
|
const UpnpString *s);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
void UpnpClientSubscription_strcpy_ActualSID(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *p,
|
||||||
|
const char *s);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
const UpnpString *UpnpClientSubscription_get_EventURL(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
const ClientSubscription *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
void UpnpClientSubscription_set_EventURL(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *p,
|
||||||
|
const UpnpString *s);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
void UpnpClientSubscription_strcpy_EventURL(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *p,
|
||||||
|
const char *s);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
ClientSubscription *UpnpClientSubscription_get_Next(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
const ClientSubscription *p);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
void UpnpClientSubscription_set_Next(
|
||||||
|
/*! [in] The \b this pointer. */
|
||||||
|
ClientSubscription *p,
|
||||||
|
ClientSubscription *q);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Free memory allocated for client subscription data.
|
||||||
|
*
|
||||||
|
* Remove timer thread associated with this subscription event.
|
||||||
|
*/
|
||||||
|
void free_client_subscription(
|
||||||
|
/*! [in] Client subscription to be freed. */
|
||||||
|
ClientSubscription *sub);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Free the client subscription table.
|
||||||
|
*/
|
||||||
|
void freeClientSubList(
|
||||||
|
/*! [in] Client subscription list to be freed. */
|
||||||
|
ClientSubscription *list);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Remove the client subscription matching the subscritpion id
|
||||||
|
* represented by the const Upnp_SID sid parameter from the table and
|
||||||
|
* update the table.
|
||||||
|
*/
|
||||||
|
void RemoveClientSubClientSID(
|
||||||
|
/*! [in] Head of the subscription list. */
|
||||||
|
ClientSubscription **head,
|
||||||
|
/*! [in] Subscription ID to be mactched. */
|
||||||
|
const UpnpString *sid);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Return the client subscription from the client table that matches
|
||||||
|
* const Upnp_SID sid subscrition id value.
|
||||||
|
*
|
||||||
|
* \return The matching subscription.
|
||||||
|
*/
|
||||||
|
ClientSubscription *GetClientSubClientSID(
|
||||||
|
/*! [in] Head of the subscription list. */
|
||||||
|
ClientSubscription *head,
|
||||||
|
/*! [in] Subscription ID to be mactched. */
|
||||||
|
const UpnpString *sid);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Returns the client subscription from the client subscription table
|
||||||
|
* that has the matching token *sid buffer value.
|
||||||
|
*
|
||||||
|
* \return The matching subscription.
|
||||||
|
*/
|
||||||
|
ClientSubscription *GetClientSubActualSID(
|
||||||
|
/*! [in] Head of the subscription list. */
|
||||||
|
ClientSubscription *head,
|
||||||
|
/*! [in] Subscription ID to be mactched. */
|
||||||
|
token *sid);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* INCLUDE_CLIENT_APIS */
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* Function : GetClientSubActualSID
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* ClientSubscription *head ; Head of the subscription list
|
|
||||||
* token * sid ; Subscription ID to be matched
|
|
||||||
*
|
|
||||||
* Description : Returns the client subscription from the client
|
|
||||||
* subscription table that has the matching token * sid buffer
|
|
||||||
* value.
|
|
||||||
*
|
|
||||||
* Return : ClientSubscription * ; The matching subscription
|
|
||||||
*
|
|
||||||
* Note :
|
|
||||||
************************************************************************/
|
|
||||||
ClientSubscription * GetClientSubActualSID(ClientSubscription *head, token * sid);
|
|
||||||
)
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* CLIENT_TABLE_H */
|
||||||
|
|
||||||
#endif /* _CLIENT_TABLE */
|
|
||||||
|
@@ -53,6 +53,7 @@
|
|||||||
#include "sock.h"
|
#include "sock.h"
|
||||||
#include "ThreadPool.h"
|
#include "ThreadPool.h"
|
||||||
#include "upnp.h"
|
#include "upnp.h"
|
||||||
|
#include "UpnpString.h"
|
||||||
#include "uri.h"
|
#include "uri.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -182,14 +183,14 @@ EXTERN_C int genaSubscribe(
|
|||||||
/*! [in] The client handle. */
|
/*! [in] The client handle. */
|
||||||
UpnpClient_Handle client_handle,
|
UpnpClient_Handle client_handle,
|
||||||
/*! [in] Of the form: "http://134.134.156.80:4000/RedBulb/Event */
|
/*! [in] Of the form: "http://134.134.156.80:4000/RedBulb/Event */
|
||||||
const char *PublisherURL,
|
const UpnpString *PublisherURL,
|
||||||
/*! [in,out] requested Duration:
|
/*! [in,out] requested Duration:
|
||||||
* \li if -1, then "infinite".
|
* \li if -1, then "infinite".
|
||||||
* \li in the OUT case: actual Duration granted by Service,
|
* \li in the OUT case: actual Duration granted by Service,
|
||||||
* -1 for infinite. */
|
* -1 for infinite. */
|
||||||
int *TimeOut,
|
int *TimeOut,
|
||||||
/*! [out] sid of subscription, memory passed in by caller. */
|
/*! [out] sid of subscription, memory passed in by caller. */
|
||||||
Upnp_SID out_sid);
|
UpnpString *out_sid);
|
||||||
#endif /* INCLUDE_CLIENT_APIS */
|
#endif /* INCLUDE_CLIENT_APIS */
|
||||||
|
|
||||||
|
|
||||||
@@ -208,7 +209,7 @@ EXTERN_C int genaUnSubscribe(
|
|||||||
/*! [in] UPnP client handle. */
|
/*! [in] UPnP client handle. */
|
||||||
UpnpClient_Handle client_handle,
|
UpnpClient_Handle client_handle,
|
||||||
/*! [in] The subscription ID. */
|
/*! [in] The subscription ID. */
|
||||||
const Upnp_SID in_sid);
|
const UpnpString *in_sid);
|
||||||
#endif /* INCLUDE_CLIENT_APIS */
|
#endif /* INCLUDE_CLIENT_APIS */
|
||||||
|
|
||||||
|
|
||||||
@@ -260,7 +261,7 @@ EXTERN_C int genaRenewSubscription(
|
|||||||
/*! [in] Client handle. */
|
/*! [in] Client handle. */
|
||||||
UpnpClient_Handle client_handle,
|
UpnpClient_Handle client_handle,
|
||||||
/*! [in] Subscription ID. */
|
/*! [in] Subscription ID. */
|
||||||
const Upnp_SID in_sid,
|
const UpnpString *in_sid,
|
||||||
/*! [in,out] requested Duration, if -1, then "infinite". In the OUT case:
|
/*! [in,out] requested Duration, if -1, then "infinite". In the OUT case:
|
||||||
* actual Duration granted by Service, -1 for infinite. */
|
* actual Duration granted by Service, -1 for infinite. */
|
||||||
int *TimeOut);
|
int *TimeOut);
|
||||||
|
Reference in New Issue
Block a user