libUPnP
1.8.0
|
#include "config.h"
#include "gena.h"
#include "httpparser.h"
#include "httpreadwrite.h"
#include "parsetools.h"
#include "ssdplib.h"
#include "statcodes.h"
#include "sysdep.h"
#include "unixutil.h"
#include "upnpapi.h"
#include "uuid.h"
Functions | |
int | genaUnregisterDevice (UpnpDevice_Handle device_handle) |
Unregisters a device. More... | |
static int | GeneratePropertySet (char **names, char **values, int count, DOMString *out) |
Generates XML property set for notifications. More... | |
static void | free_notify_struct (notify_thread_struct *input) |
Frees memory used in notify_threads if the reference count is 0, otherwise decrements the refrence count. More... | |
static UPNP_INLINE int | notify_send_and_recv (uri_type *destination_url, membuffer *mid_msg, char *propertySet, http_parser_t *response) |
Sends the notify message and returns a reply. More... | |
static int | genaNotify (char *headers, char *propertySet, subscription *sub) |
Function to Notify a particular subscription of a particular event. More... | |
static void | genaNotifyThread (void *input) |
Thread job to Notify a control point. More... | |
static char * | AllocGenaHeaders (const DOMString propertySet) |
Allocates the GENA header. More... | |
int | genaInitNotify (UpnpDevice_Handle device_handle, char *UDN, char *servId, char **VarNames, char **VarValues, int var_count, const Upnp_SID sid) |
Sends the intial state table dump to newly subscribed control point. More... | |
int | genaInitNotifyExt (UpnpDevice_Handle device_handle, char *UDN, char *servId, IXML_Document *PropSet, const Upnp_SID sid) |
Similar to the genaInitNofity. The only difference is that it takes the xml document for the state table and sends the intial state table dump to newly subscribed control point. More... | |
int | genaNotifyAllExt (UpnpDevice_Handle device_handle, char *UDN, char *servId, IXML_Document *PropSet) |
Sends a notification to all the subscribed control points. More... | |
int | genaNotifyAll (UpnpDevice_Handle device_handle, char *UDN, char *servId, char **VarNames, char **VarValues, int var_count) |
Sends a notification to all the subscribed control points. More... | |
static int | respond_ok (SOCKINFO *info, int time_out, subscription *sub, http_message_t *request) |
Returns OK message in the case of a subscription request. More... | |
static int | create_url_list (memptr *url_list, URL_list *out) |
Function to parse the Callback header value in subscription requests. More... | |
void | gena_process_subscription_request (SOCKINFO *info, http_message_t *request) |
Handles a subscription request from a ctrl point. The socket is not closed on return. More... | |
void | gena_process_subscription_renewal_request (SOCKINFO *info, http_message_t *request) |
Handles a subscription renewal request from a ctrl point. The connection is not destroyed on return. More... | |
void | gena_process_unsubscribe_request (SOCKINFO *info, http_message_t *request) |
Handles a subscription cancellation request from a ctrl point. The connection is not destroyed on return. More... | |
|
static |
Allocates the GENA header.
[in] | propertySet | The property set string. |
References PRIzu, and UpnpPrintf().
Referenced by genaInitNotify(), genaInitNotifyExt(), genaNotifyAll(), and genaNotifyAllExt().
Function to parse the Callback header value in subscription requests.
Takes in a buffer containing URLS delimited by '<' and '>'. The entire buffer is copied into dynamic memory and stored in the URL_list. Pointers to the individual urls within this buffer are allocated and stored in the URL_list. Only URLs with network addresses are considered (i.e. host:port or domain name).
[in] | url_list | . |
[out] | out | . |
References parse_uri(), HOSTPORT::text, UPNP_E_OUTOF_MEMORY, and URL_LIST::URLs.
Referenced by gena_process_subscription_request().
|
static |
Frees memory used in notify_threads if the reference count is 0, otherwise decrements the refrence count.
[in] | input | Notify structure. |
References ixmlFreeDOMString().
Referenced by genaInitNotify(), genaInitNotifyExt(), genaNotifyAll(), genaNotifyAllExt(), and genaNotifyThread().
void gena_process_subscription_renewal_request | ( | SOCKINFO * | info, |
http_message_t * | request | ||
) |
Handles a subscription renewal request from a ctrl point. The connection is not destroyed on return.
[in] | info | Socket info of the device. |
[in] | request | Subscription renewal request from the control point. |
References error_respond(), GetDeviceHandleInfo(), Handle_Info::MaxSubscriptions, Handle_Info::MaxSubscriptionTimeOut, respond_ok(), Handle_Info::ServiceTable, UPNP_E_SUCCESS, and UpnpPrintf().
void gena_process_subscription_request | ( | SOCKINFO * | info, |
http_message_t * | request | ||
) |
Handles a subscription request from a ctrl point. The socket is not closed on return.
[in] | info | Socket info of the device. |
[in] | request | Subscription request from the control point. |
References Handle_Info::Callback, Handle_Info::Cookie, create_url_list(), error_respond(), GetDeviceHandleInfo(), Handle_Info::MaxSubscriptions, Handle_Info::MaxSubscriptionTimeOut, respond_ok(), Handle_Info::ServiceTable, UPNP_E_OUTOF_MEMORY, UPNP_E_SUCCESS, UPNP_EVENT_SUBSCRIPTION_REQUEST, UpnpPrintf(), UpnpSubscriptionRequest_delete(), UpnpSubscriptionRequest_new(), and URL_LIST::URLs.
void gena_process_unsubscribe_request | ( | SOCKINFO * | info, |
http_message_t * | request | ||
) |
Handles a subscription cancellation request from a ctrl point. The connection is not destroyed on return.
[in] | info | Socket info of the device. |
[in] | request | UNSUBSCRIBE request from the control point. |
References error_respond(), GetDeviceHandleInfo(), and Handle_Info::ServiceTable.
int genaInitNotify | ( | UpnpDevice_Handle | device_handle, |
char * | UDN, | ||
char * | servId, | ||
char ** | VarNames, | ||
char ** | VarValues, | ||
int | var_count, | ||
const Upnp_SID | sid | ||
) |
Sends the intial state table dump to newly subscribed control point.
[in] | device_handle | Device handle. |
[in] | UDN | Device udn. |
[in] | servId | Service ID. |
[in] | VarNames | Array of variable names. |
[in] | VarValues | Array of variable values. |
[in] | var_count | Array size. |
[in] | sid | Subscription ID. |
References AllocGenaHeaders(), DOMString, free_notify_struct(), genaNotifyThread(), GeneratePropertySet(), GetHandleInfo(), gSendThreadPool, ixmlFreeDOMString(), Handle_Info::ServiceTable, UPNP_E_OUTOF_MEMORY, and UpnpPrintf().
Referenced by UpnpAcceptSubscription().
int genaInitNotifyExt | ( | UpnpDevice_Handle | device_handle, |
char * | UDN, | ||
char * | servId, | ||
IXML_Document * | PropSet, | ||
const Upnp_SID | sid | ||
) |
Similar to the genaInitNofity. The only difference is that it takes the xml document for the state table and sends the intial state table dump to newly subscribed control point.
[in] | device_handle | Device handle. |
[in] | UDN | Device udn. |
[in] | servId | Service ID. |
[in] | PropSet | Document of the state table. |
[in] | sid | subscription ID. |
References AllocGenaHeaders(), DOMString, free_notify_struct(), genaNotifyThread(), GetHandleInfo(), gSendThreadPool, ixmlFreeDOMString(), ixmlPrintNode(), Handle_Info::ServiceTable, UPNP_E_INVALID_PARAM, UPNP_E_OUTOF_MEMORY, and UpnpPrintf().
Referenced by UpnpAcceptSubscriptionExt().
|
static |
Function to Notify a particular subscription of a particular event.
In general the service should NOT be blocked around this call (this may cause deadlock with a client).
NOTIFY http request is sent and the reply is processed.
[in] | headers | Null terminated, includes all headers (including \r\n) except SID and SEQ. |
[in] | propertySet | The evented XML. |
[in] | sub | subscription to be Notified, assumes this is valid for life of function. |
References notify_send_and_recv(), UPNP_E_OUTOF_MEMORY, and UPNP_E_SUCCESS.
Referenced by genaNotifyThread().
int genaNotifyAll | ( | UpnpDevice_Handle | device_handle, |
char * | UDN, | ||
char * | servId, | ||
char ** | VarNames, | ||
char ** | VarValues, | ||
int | var_count | ||
) |
Sends a notification to all the subscribed control points.
[in] | device_handle | Device handle. |
[in] | UDN | Device udn. |
[in] | servId | Service ID. |
[in] | VarNames | Array of varible names. |
[in] | VarValues | Array of variable values. |
[in] | var_count | Number of variables. |
References AllocGenaHeaders(), DOMString, free_notify_struct(), genaNotifyThread(), GeneratePropertySet(), GetHandleInfo(), gSendThreadPool, ixmlFreeDOMString(), Handle_Info::ServiceTable, UPNP_E_OUTOF_MEMORY, and UpnpPrintf().
Referenced by UpnpNotify().
int genaNotifyAllExt | ( | UpnpDevice_Handle | device_handle, |
char * | UDN, | ||
char * | servId, | ||
IXML_Document * | PropSet | ||
) |
Sends a notification to all the subscribed control points.
[in] | device_handle | Device handle. |
[in] | UDN | Device udn. |
[in] | servId | Service ID. |
[in] | PropSet | XML document Event varible property set. |
References AllocGenaHeaders(), DOMString, free_notify_struct(), genaNotifyThread(), GetHandleInfo(), gSendThreadPool, ixmlFreeDOMString(), ixmlPrintNode(), Handle_Info::ServiceTable, UPNP_E_INVALID_PARAM, UPNP_E_OUTOF_MEMORY, and UpnpPrintf().
Referenced by UpnpNotifyExt().
|
static |
Thread job to Notify a control point.
It validates the subscription and copies the subscription. Also make sure that events are sent in order.
[in] | input | notify thread structure containing all the headers and property set info. |
References free_notify_struct(), genaNotify(), GetHandleInfo(), gSendThreadPool, and Handle_Info::ServiceTable.
Referenced by genaInitNotify(), genaInitNotifyExt(), genaNotifyAll(), and genaNotifyAllExt().
int genaUnregisterDevice | ( | UpnpDevice_Handle | device_handle | ) |
Unregisters a device.
Cleans the service table of the device.
[in] | device_handle | Device handle. |
References GetHandleInfo(), Handle_Info::ServiceTable, UPNP_E_SUCCESS, and UpnpPrintf().
Referenced by UpnpUnRegisterRootDevice().
|
static |
Generates XML property set for notifications.
[in] | names | Array of variable names (go in the event notify). |
[in] | values | Array of variable values (go in the event notify). |
[in] | count | number of variables. |
[out] | out | PropertySet node in the string format. |
References ixmlCloneDOMString(), and UPNP_E_OUTOF_MEMORY.
Referenced by genaInitNotify(), and genaNotifyAll().
|
static |
Sends the notify message and returns a reply.
[in] | destination_url | subscription callback URL (URL of the control point). |
[in] | mid_msg | Common HTTP headers. |
[in] | propertySet | The evented XML. |
[out] | response | The response from the control point. |
References HOSTPORT::text, UPNP_E_OUTOF_MEMORY, UPNP_E_SUCCESS, and UpnpPrintf().
Referenced by genaNotify().
|
static |
Returns OK message in the case of a subscription request.
[in] | info | Socket connection of request. |
[in] | time_out | Accepted duration. |
[in] | sub | Accepted subscription. |
[in] | request | Http request. |
References error_respond(), and UPNP_E_OUTOF_MEMORY.
Referenced by gena_process_subscription_renewal_request(), and gena_process_subscription_request().