libUPnP  1.8.4
Data Structures | Macros | Typedefs | Functions
service_table.h File Reference
#include "config.h"
#include "uri.h"
#include "ixml.h"
#include "upnp.h"
#include "upnpdebug.h"
#include "LinkedList.h"
#include <stdio.h>
#include <time.h>
Include dependency graph for service_table.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SUBSCRIPTION
 
struct  SERVICE_INFO
 
struct  SERVICE_TABLE
 

Macros

#define SID_SIZE   (size_t)41
 

Typedefs

typedef struct SUBSCRIPTION subscription
 
typedef struct SERVICE_INFO service_info
 
typedef struct SERVICE_TABLE service_table
 

Functions

void freeSubscriptionQueuedEvents (subscription *sub)
 
int copy_subscription (subscription *in, subscription *out)
 Makes a copy of the subscription. More...
 
void RemoveSubscriptionSID (Upnp_SID sid, service_info *service)
 
subscription * GetSubscriptionSID (const Upnp_SID sid, service_info *service)
 Return the subscription from the service table that matches const Upnp_SID sid value. More...
 
subscription * GetFirstSubscription (service_info *service)
 Gets pointer to the first subscription node in the service table. More...
 
subscription * GetNextSubscription (service_info *service, subscription *current)
 Get current and valid subscription from the service table. More...
 
void freeSubscription (subscription *sub)
 Free's the memory allocated for storing the URL of the subscription. More...
 
void freeSubscriptionList (subscription *head)
 Free's memory allocated for all the subscriptions in the service table. More...
 
service_info * FindServiceId (service_table *table, const char *serviceId, const char *UDN)
 Traverses through the service table and returns a pointer to the service node that matches a known service id and a known UDN. More...
 
service_info * FindServiceEventURLPath (service_table *table, const char *eventURLPath)
 Traverses the service table and finds the node whose event URL Path matches a know value. More...
 
service_info * FindServiceControlURLPath (service_table *table, const char *controlURLPath)
 Traverses the service table and finds the node whose control URL Path matches a know value. More...
 
void printService (service_info *service, Upnp_LogLevel level, Dbg_Module module)
 For debugging purposes prints information from the service passed into the function. More...
 
void printServiceList (service_info *service, Upnp_LogLevel level, Dbg_Module module)
 For debugging purposes prints information of each service from the service table passed into the function. More...
 
void printServiceTable (service_table *table, Upnp_LogLevel level, Dbg_Module module)
 For debugging purposes prints the URL base of the table and information of each service from the service table passed into the function. More...
 
void freeService (service_info *in)
 Free's memory allocated for the various components of the service entry in the service table. More...
 
void freeServiceList (service_info *head)
 Free's memory allocated for the various components of each service entry in the service table. More...
 
void freeServiceTable (service_table *table)
 Free's dynamic memory in table (does not free table, only memory within the structure). More...
 
int removeServiceTable (IXML_Node *node, service_table *in)
 This function assumes that services for a particular root device are placed linearly in the service table, and in the order in which they are found in the description document all services for this root device are removed from the list. More...
 
int addServiceTable (IXML_Node *node, service_table *in, const char *DefaultURLBase)
 Add Service to the table. More...
 
int getServiceTable (IXML_Node *node, service_table *out, const char *DefaultURLBase)
 Retrieve service from the table. More...
 
DOMString getElementValue (IXML_Node *node)
 Returns the clone of the element value. More...
 
int getSubElement (const char *element_name, IXML_Node *node, IXML_Node **out)
 Traverses through a list of XML nodes to find the node with the known element name. More...
 

Function Documentation

◆ addServiceTable()

int addServiceTable ( IXML_Node *  node,
service_table *  in,
const char *  DefaultURLBase 
)

Add Service to the table.

Parameters
[in]node[in] XML node information.
[in]in[in] Service table that will be initialized with services.
[in]DefaultURLBase[in] Default base URL on which the URL will be returned to the service list.

References getElementValue(), getSubElement(), and ixmlCloneDOMString().

◆ copy_subscription()

int copy_subscription ( subscription *  in,
subscription *  out 
)

Makes a copy of the subscription.

Returns
HTTP_SUCCESS on success.
Parameters
[in]in[in] Source subscription.
[in]out[in] Destination subscription.

◆ FindServiceControlURLPath()

service_info* FindServiceControlURLPath ( service_table *  table,
const char *  controlURLPath 
)

Traverses the service table and finds the node whose control URL Path matches a know value.

Returns
Pointer to the service list node from the service table whose control URL Path matches a known value.
Parameters
[in]table[in] Service table.
[in]controlURLPath[in] Control URL path used to find a service from the table.

References parse_uri().

◆ FindServiceEventURLPath()

service_info* FindServiceEventURLPath ( service_table *  table,
const char *  eventURLPath 
)

Traverses the service table and finds the node whose event URL Path matches a know value.

Returns
Pointer to the service list node from the service table whose event URL matches a known event URL.
Parameters
[in]table[in] Service table.
[in]eventURLPath[in] Event URL path used to find a service from the table.

References parse_uri().

◆ FindServiceId()

service_info* FindServiceId ( service_table *  table,
const char *  serviceId,
const char *  UDN 
)

Traverses through the service table and returns a pointer to the service node that matches a known service id and a known UDN.

Returns
Pointer to the matching service_info node.
Parameters
[in]table[in] Service table.
[in]serviceId[in] String representing the service id to be found among those in the table.
[in]UDN[in] String representing the UDN to be found among those in the table.

◆ freeService()

void freeService ( service_info *  in)

Free's memory allocated for the various components of the service entry in the service table.

Parameters
[in]in[in] Service information that is to be freed.

References freeSubscriptionList(), and ixmlFreeDOMString().

Referenced by removeServiceTable().

◆ freeServiceList()

void freeServiceList ( service_info *  head)

Free's memory allocated for the various components of each service entry in the service table.

Parameters
[in]head[in] Head of the service list to be freed.

References freeSubscriptionList(), and ixmlFreeDOMString().

Referenced by freeServiceTable().

◆ freeServiceTable()

void freeServiceTable ( service_table *  table)

Free's dynamic memory in table (does not free table, only memory within the structure).

Parameters
[in]table[in] Service table whose internal memory needs to be freed.

References freeServiceList(), and ixmlFreeDOMString().

◆ freeSubscription()

void freeSubscription ( subscription *  sub)

Free's the memory allocated for storing the URL of the subscription.

Parameters
[in]sub[in] Subscription object to be freed.

References free_URL_list().

Referenced by freeSubscriptionList().

◆ freeSubscriptionList()

void freeSubscriptionList ( subscription *  head)

Free's memory allocated for all the subscriptions in the service table.

Parameters
[in]head[in] Head of the subscription list.

References freeSubscription().

Referenced by freeService(), freeServiceList(), GetNextSubscription(), GetSubscriptionSID(), and RemoveSubscriptionSID().

◆ getElementValue()

DOMString getElementValue ( IXML_Node *  node)

Returns the clone of the element value.

Note
Value must be freed with DOMString_free.
Returns
DOMString
Parameters
[in]node[in] Input node which provides the list of child nodes.

References DOMString, ixmlNode_getFirstChild(), and ixmlNode_getNodeType().

Referenced by addServiceTable(), getServiceTable(), and removeServiceTable().

◆ GetFirstSubscription()

subscription* GetFirstSubscription ( service_info *  service)

Gets pointer to the first subscription node in the service table.

Returns
Pointer to the first subscription node.
Parameters
[in]service[in] Service object providing the list of subscriptions.

References GetNextSubscription().

◆ GetNextSubscription()

subscription* GetNextSubscription ( service_info *  service,
subscription *  current 
)

Get current and valid subscription from the service table.

Returns
Pointer to the next subscription node.
Parameters
[in]service[in] Service object providing the list of subscriptions.
[in]current[in] Current subscription object.

References freeSubscriptionList().

Referenced by GetFirstSubscription().

◆ getServiceTable()

int getServiceTable ( IXML_Node *  node,
service_table *  out,
const char *  DefaultURLBase 
)

Retrieve service from the table.

Returns
An integer
Parameters
[in]node[in] XML node information.
[in]out[in] Output parameter which will contain the service list and URL.
[in]DefaultURLBase[in] Default base URL on which the URL will be returned.

References getElementValue(), getSubElement(), and ixmlCloneDOMString().

◆ getSubElement()

int getSubElement ( const char *  element_name,
IXML_Node *  node,
IXML_Node **  out 
)

Traverses through a list of XML nodes to find the node with the known element name.

Returns
  • 1 - On Success
  • 0 - On Failure
Parameters
[in]element_name[in] Sub element name to be searched for.
[in]node[in] Input node which provides the list of child nodes.
[out]out[out] Ouput node to which the matched child node is returned.

References DOMString, ixmlNode_getFirstChild(), and ixmlNode_getNodeType().

Referenced by addServiceTable(), getServiceTable(), and removeServiceTable().

◆ GetSubscriptionSID()

subscription* GetSubscriptionSID ( const Upnp_SID  sid,
service_info *  service 
)

Return the subscription from the service table that matches const Upnp_SID sid value.

Returns
Pointer to the matching subscription node.
Parameters
[in]sid[in] Subscription ID.
[in]service[in] Service object providing the list of subscriptions.

References freeSubscriptionList().

◆ printService()

void printService ( service_info *  service,
Upnp_LogLevel  level,
Dbg_Module  module 
)

For debugging purposes prints information from the service passed into the function.

Parameters
[in]service[in] Service whose information is to be printed.
[in]level[in] Debug level specified to the print function.
[in]module[in] Debug module specified to the print function.

References UpnpPrintf().

◆ printServiceList()

void printServiceList ( service_info *  service,
Upnp_LogLevel  level,
Dbg_Module  module 
)

For debugging purposes prints information of each service from the service table passed into the function.

Parameters
[in]service[in] Service whose information is to be printed.
[in]level[in] Debug level specified to the print function.
[in]module[in] Debug module specified to the print function.

References UpnpPrintf().

Referenced by printServiceTable().

◆ printServiceTable()

void printServiceTable ( service_table *  table,
Upnp_LogLevel  level,
Dbg_Module  module 
)

For debugging purposes prints the URL base of the table and information of each service from the service table passed into the function.

Parameters
[in]table[in] Service table to be printed.
[in]level[in] Debug level specified to the print function.
[in]module[in] Debug module specified to the print function.

References printServiceList(), and UpnpPrintf().

◆ removeServiceTable()

int removeServiceTable ( IXML_Node *  node,
service_table *  in 
)

This function assumes that services for a particular root device are placed linearly in the service table, and in the order in which they are found in the description document all services for this root device are removed from the list.

Returns
An integer.
Parameters
[in]node[in] XML node information.
[in]in[in] Service table from which services will be removed.

References DOMString, freeService(), getElementValue(), getSubElement(), ixmlElement_getElementsByTagName(), ixmlFreeDOMString(), ixmlNodeList_free(), and ixmlNodeList_length().

◆ RemoveSubscriptionSID()

void RemoveSubscriptionSID ( Upnp_SID  sid,
service_info *  service 
)
Parameters
[in]sid[in] Subscription ID.
[in]service[in] Service object providing the list of subscriptions.

References freeSubscriptionList().