UPnPsdk 0.1
Universal Plug and Play +, Software Development Kit
 
Loading...
Searching...
No Matches
gena_device.cpp File Reference

Manage GENA Devices. More...

#include <assert.h>
#include <gena.hpp>
#include <httpreadwrite.hpp>
#include <parsetools.hpp>
#include <ssdp_common.hpp>
#include <statcodes.hpp>
#include <unixutil.hpp>
#include <upnpapi.hpp>
#include <uuid.hpp>
#include <UpnpSubscriptionRequest.hpp>
#include <webserver.hpp>
+ Include dependency graph for gena_device.cpp:

Go to the source code of this file.

Macros

#define STALE_JOBID   (INVALID_JOB_ID - 1)
 Invalid job id.
 

Functions

int anonymous_namespace{gena_device.cpp}::GeneratePropertySet (char **names, char **values, int count, DOMString *out)
 Generates XML property set for notifications.
 
void anonymous_namespace{gena_device.cpp}::free_notify_struct (notify_thread_struct *input)
 Frees memory used in notify_threads if the reference count is 0, otherwise decrements the refrence count.
 
int anonymous_namespace{gena_device.cpp}::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.
 
int anonymous_namespace{gena_device.cpp}::genaNotify (char *headers, char *propertySet, subscription *sub)
 Function to Notify a particular subscription of a particular event.
 
void anonymous_namespace{gena_device.cpp}::genaNotifyThread (void *input)
 Thread job to Notify a control point.
 
char * anonymous_namespace{gena_device.cpp}::AllocGenaHeaders (const DOMString propertySet)
 Allocates the GENA header.
 
int anonymous_namespace{gena_device.cpp}::genaInitNotifyCommon (UpnpDevice_Handle device_handle, char *UDN, char *servId, DOMString propertySet, const Upnp_SID sid)
 We take ownership of propertySet and will free it.
 
void anonymous_namespace{gena_device.cpp}::maybeDiscardEvents (LinkedList *listp)
 This gets called before queuing a new event.
 
int anonymous_namespace{gena_device.cpp}::genaNotifyAllCommon (UpnpDevice_Handle device_handle, char *UDN, char *servId, DOMString propertySet)
 We take ownership of propertySet and will free it.
 
int anonymous_namespace{gena_device.cpp}::respond_ok (SOCKINFO *info, int time_out, subscription *sub, http_message_t *request)
 Returns OK message in the case of a subscription request.
 
int anonymous_namespace{gena_device.cpp}::create_url_list (memptr *url_list, URL_list *out)
 Function to parse the Callback header value in subscription requests.
 
int genaUnregisterDevice (UpnpDevice_Handle device_handle)
 Cleans the service table of the device.
 
void freeSubscriptionQueuedEvents (subscription *sub)
 ???
 
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.
 
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.
 
int genaNotifyAllExt (UpnpDevice_Handle device_handle, char *UDN, char *servId, IXML_Document *PropSet)
 Sends a notification to all the subscribed control points.
 
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.
 
int gena_validate_delivery_urls (SOCKINFO *info, URL_list *url_list)
 Validate that the URLs passed by the user are on the same network segment than the device.
 
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.
 
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.
 
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.
 

Detailed Description

Manage GENA Devices.

Definition in file gena_device.cpp.

Macro Definition Documentation

◆ STALE_JOBID

#define STALE_JOBID   (INVALID_JOB_ID - 1)

Invalid job id.

Definition at line 53 of file gena_device.cpp.

Function Documentation

◆ genaUnregisterDevice()

int genaUnregisterDevice ( UpnpDevice_Handle  device_handle)

Cleans the service table of the device.

Returns
UPNP_E_SUCCESS if successful, otherwise returns GENA_E_BAD_HANDLE
Parameters
[in]device_handleHandle of the root device

Definition at line 887 of file gena_device.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ freeSubscriptionQueuedEvents()

void freeSubscriptionQueuedEvents ( subscription sub)

???

Definition at line 905 of file gena_device.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ genaInitNotify()

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.

Returns
GENA_E_SUCCESS if successful, otherwise the appropriate error code.
Note
No other event will be sent to this control point before the intial state table dump.
Parameters
[in]device_handleDevice handle.
[in]UDNDevice udn.
[in]servIdService ID.
[in]VarNamesArray of variable names.
[in]VarValuesArray of variable values.
[in]var_countArray size.
[in]sidSubscription ID.

Definition at line 928 of file gena_device.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ genaInitNotifyExt()

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.

Returns
GENA_E_SUCCESS if successful, otherwise the appropriate error code.
Note
No other event will be sent to this control point before the intial state table dump.
Parameters
[in]device_handleDevice handle.
[in]UDNDevice udn.
[in]servIdService ID.
[in]PropSetDocument of the state table.
[in]sidsubscription ID.

Definition at line 962 of file gena_device.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ genaNotifyAllExt()

int genaNotifyAllExt ( UpnpDevice_Handle  device_handle,
char *  UDN,
char *  servId,
IXML_Document PropSet 
)

Sends a notification to all the subscribed control points.

Returns
int
Note
This function is similar to the genaNotifyAll. the only difference is it takes the document instead of event variable array.
Parameters
[in]device_handleDevice handle.
[in]UDNDevice udn.
[in]servIdService ID.
[in]PropSetXML document Event varible property set.

Definition at line 997 of file gena_device.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ genaNotifyAll()

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.

Returns
int
Note
This function is similar to the genaNotifyAllExt. The only difference is it takes event variable array instead of xml document.
Parameters
[in]device_handleDevice handle.
[in]UDNDevice udn.
[in]servIdService ID.
[in]VarNamesArray of varible names.
[in]VarValuesArray of variable values.
[in]var_countNumber of variables.

Definition at line 1026 of file gena_device.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gena_validate_delivery_urls()

int gena_validate_delivery_urls ( SOCKINFO info,
URL_list url_list 
)

Validate that the URLs passed by the user are on the same network segment than the device.

Note: This is a fix for CallStanger a.k.a. CVE-2020-12695

Returns
0 if all URLs are on the same segment or -1 otherwise.
Parameters
[in]info.
[in]url_list.

Definition at line 1061 of file gena_device.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gena_process_subscription_request()

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.

Parameters
[in]infoSocket info of the device.
[in]requestSubscription request from the control point.

Definition at line 1148 of file gena_device.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gena_process_subscription_renewal_request()

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.

Parameters
[in]infoSocket info of the device.
[in]requestSubscription renewal request from the control point.

Definition at line 1340 of file gena_device.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gena_process_unsubscribe_request()

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.

Parameters
[in]infoSocket info of the device.
[in]requestUNSUBSCRIBE request from the control point.

Definition at line 1443 of file gena_device.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function: