libUPnP
1.6.17
|
#include "config.h"
#include "gena.h"
#include "httpparser.h"
#include "httpreadwrite.h"
#include "parsetools.h"
#include "statcodes.h"
#include "sysdep.h"
#include "uuid.h"
#include "upnpapi.h"
Functions | |
static void | GenaAutoRenewSubscription (IN void *input) |
This is a thread function to send the renewal just before the subscription times out. | |
static int | ScheduleGenaAutoRenew (IN int client_handle, IN int TimeOut, IN ClientSubscription *sub) |
Schedules a job to renew the subscription just before time out. | |
static int | gena_unsubscribe (IN const UpnpString *url, IN const UpnpString *sid, OUT http_parser_t *response) |
Sends the UNSUBCRIBE gena request and recieves the response from the device and returns it as a parameter. | |
static int | gena_subscribe (IN const UpnpString *url, INOUT int *timeout, IN const UpnpString *renewal_sid, OUT UpnpString *sid) |
Subscribes or renew subscription. | |
int | genaUnregisterClient (UpnpClient_Handle client_handle) |
Unsubcribes all the outstanding subscriptions and cleans the subscription list. | |
int | genaUnSubscribe (UpnpClient_Handle client_handle, const UpnpString *in_sid) |
Unsubscribes a SID. | |
int | genaSubscribe (UpnpClient_Handle client_handle, const UpnpString *PublisherURL, int *TimeOut, UpnpString *out_sid) |
This function subscribes to a PublisherURL (also mentioned as EventURL in some places). | |
int | genaRenewSubscription (UpnpClient_Handle client_handle, const UpnpString *in_sid, int *TimeOut) |
Renews a SID. | |
void | gena_process_notification_event (SOCKINFO *info, http_message_t *event) |
This function processes NOTIFY events that are sent by devices. | |
Variables | |
ithread_mutex_t | GlobalClientSubscribeMutex |
void gena_process_notification_event | ( | SOCKINFO * | info, |
http_message_t * | event | ||
) |
This function processes NOTIFY events that are sent by devices.
Parameters: IN SOCKINFO *info: Socket structure containing the device socket information IN http_message_t *event: The http message contains the GENA notification
[in] | info | Socket info of the device. |
[in] | event | The http message contains the GENA notification. |
References memptr::buf, Handle_Info::Callback, Upnp_Event::ChangedVariables, Handle_Info::ClientSubList, Handle_Info::Cookie, http_message_t::entity, error_respond(), Upnp_Event::EventKey, GetClientHandleInfo(), has_xml_content_type(), ixmlDocument_free(), ixmlParseBufferEx(), memptr::length, membuffer::length, http_message_t::msg, PARSE_OK, Upnp_Event::Sid, SubscribeLock, SubscribeUnlock, UPNP_EVENT_RECEIVED, and UpnpString_get_String().
static int gena_subscribe | ( | IN const UpnpString * | url, |
INOUT int * | timeout, | ||
IN const UpnpString * | renewal_sid, | ||
OUT UpnpString * | sid | ||
) | [static] |
Subscribes or renew subscription.
[in] | url | URL of service to subscribe. |
[in,out] | timeout | Subscription time desired (in secs). |
[in] | renewal_sid | for renewal, this contains a currently held subscription SID. For first time subscription, this must be NULL. |
[out] | sid | SID returned by the subscription or renew msg. |
References memptr::buf, membuffer::buf, gIF_IPV4, gIF_IPV6, gIF_IPV6_ULA_GUA, http_MakeMessage(), memptr::length, membuffer::length, LOCAL_PORT_V4, LOCAL_PORT_V6, PARSE_OK, membuffer::size_inc, http_message_t::status_code, UPNP_E_BAD_RESPONSE, UPNP_E_OUTOF_MEMORY, UPNP_E_SUBSCRIBE_UNACCEPTED, UPNP_E_SUCCESS, UpnpString_clear(), UpnpString_get_Length(), UpnpString_get_String(), and UpnpString_set_StringN().
Referenced by genaRenewSubscription(), and genaSubscribe().
static int gena_unsubscribe | ( | IN const UpnpString * | url, |
IN const UpnpString * | sid, | ||
OUT http_parser_t * | response | ||
) | [static] |
Sends the UNSUBCRIBE gena request and recieves the response from the device and returns it as a parameter.
[in] | url | Event URL of the service. |
[in] | sid | The subcription ID. |
[out] | response | The UNSUBCRIBE response from the device. |
References membuffer::buf, http_MakeMessage(), membuffer::length, membuffer::size_inc, UPNP_E_UNSUBSCRIBE_UNACCEPTED, UpnpString_get_Length(), and UpnpString_get_String().
Referenced by genaUnregisterClient(), and genaUnSubscribe().
static void GenaAutoRenewSubscription | ( | IN void * | input | ) | [static] |
This is a thread function to send the renewal just before the subscription times out.
[in] | input | Thread data(upnp_timeout *) needed to send the renewal. |
References Upnp_Event_Subscribe::ErrCode, free_upnp_timeout(), genaRenewSubscription(), GetHandleInfo(), Upnp_Event_Subscribe::Sid, Upnp_Event_Subscribe::TimeOut, UPNP_E_SUCCESS, UPNP_EVENT_AUTORENEWAL_FAILED, UPNP_EVENT_SUBSCRIPTION_EXPIRED, UpnpPrintf(), UpnpString_delete(), UpnpString_new(), and UpnpString_set_String().
Referenced by ScheduleGenaAutoRenew().
int genaRenewSubscription | ( | UpnpClient_Handle | client_handle, |
const UpnpString * | in_sid, | ||
int * | TimeOut | ||
) |
Renews a SID.
It first validates the SID and client_handle and copies the subscription. It sends RENEW (modified SUBSCRIBE) http request to service and processes the response.
[in] | client_handle | Client handle. |
[in] | in_sid | Subscription ID. |
[in,out] | TimeOut | requested Duration, if -1, then "infinite". In the OUT case: actual Duration granted by Service, -1 for infinite. |
References Handle_Info::ClientSubList, free_upnp_timeout(), gena_subscribe(), GetHandleInfo(), gTimerThread, ScheduleGenaAutoRenew(), TimerThreadRemove(), UPNP_E_SUCCESS, UpnpPrintf(), UpnpString_delete(), and UpnpString_new().
Referenced by GenaAutoRenewSubscription(), UpnpRenewSubscription(), and UpnpThreadDistribution().
int genaSubscribe | ( | UpnpClient_Handle | client_handle, |
const UpnpString * | PublisherURL, | ||
int * | TimeOut, | ||
UpnpString * | out_sid | ||
) |
This function subscribes to a PublisherURL (also mentioned as EventURL in some places).
It sends SUBSCRIBE http request to service processes request. Finally adds a Subscription to the clients subscription list, if service responds with OK.
[in] | client_handle | The client handle. |
[in] | PublisherURL | Of the form: "http://134.134.156.80:4000/RedBulb/Event @param[in,out] TimeOut requested Duration:
\li if -1, then "infinite".
|
[out] | out_sid | sid of subscription, memory passed in by caller. |
References Handle_Info::ClientSubList, gena_subscribe(), GetHandleInfo(), ScheduleGenaAutoRenew(), SubscribeLock, SubscribeUnlock, UPNP_E_OUTOF_MEMORY, UPNP_E_SUCCESS, UpnpPrintf(), UpnpString_assign(), UpnpString_clear(), UpnpString_delete(), UpnpString_new(), UpnpString_set_String(), uuid_create(), and uuid_unpack().
Referenced by UpnpSubscribe(), and UpnpThreadDistribution().
int genaUnregisterClient | ( | UpnpClient_Handle | client_handle | ) |
Unsubcribes all the outstanding subscriptions and cleans the subscription list.
This function is called when control point unregisters.
[in] | client_handle | Handle containing all the control point related information. |
References Handle_Info::ClientSubList, gena_unsubscribe(), GetHandleInfo(), and UPNP_E_SUCCESS.
Referenced by UpnpUnRegisterClient().
int genaUnSubscribe | ( | UpnpClient_Handle | client_handle, |
const UpnpString * | in_sid | ||
) |
Unsubscribes a SID.
It first validates the SID and client_handle,copies the subscription, sends UNSUBSCRIBE http request to service processes request and finally removes the subscription.
[in] | client_handle | UPnP client handle. |
[in] | in_sid | The subscription ID. |
References Handle_Info::ClientSubList, gena_unsubscribe(), and GetHandleInfo().
Referenced by UpnpThreadDistribution(), and UpnpUnSubscribe().
static int ScheduleGenaAutoRenew | ( | IN int | client_handle, |
IN int | TimeOut, | ||
IN ClientSubscription * | sub | ||
) | [static] |
Schedules a job to renew the subscription just before time out.
[in] | client_handle | Handle that also contains the subscription list. |
[in] | TimeOut | The time out value of the subscription. |
[in] | sub | Subscription being renewed. |
References Upnp_Event_Subscribe::ErrCode, free_upnp_timeout(), GenaAutoRenewSubscription(), gTimerThread, Upnp_Event_Subscribe::PublisherUrl, REL_SEC, Upnp_Event_Subscribe::Sid, Upnp_Event_Subscribe::TimeOut, TimerThreadSchedule(), TPJobInit(), TPJobSetFreeFunction(), TPJobSetPriority(), UPNP_E_OUTOF_MEMORY, UPNP_E_SUCCESS, UpnpString_assign(), UpnpString_get_String(), and UpnpString_new().
Referenced by genaRenewSubscription(), and genaSubscribe().