service_table.h
Go to the documentation of this file.
/*******************************************************************************
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
* Copyright (c) 2012 France Telecom 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 SERVICE_TABLE_H
#define SERVICE_TABLE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "LinkedList.h"
#include "config.h"
#include "ixml.h"
#include "upnp.h"
#include "upnpdebug.h"
#include "uri.h"
#include <time.h>
#define SID_SIZE (size_t)41
typedef struct SUBSCRIPTION
{
Upnp_SID sid;
int ToSendEventKey;
time_t expireTime;
int active;
URL_list DeliveryURLs;
/* List of queued events for this subscription. Only one event job
at a time goes into the thread pool. The first element in the
list is a copy of the active job. Others are activated on job
completion. */
LinkedList outgoing;
struct SUBSCRIPTION *next;
} subscription;
typedef struct SERVICE_INFO
{
DOMString serviceType;
DOMString serviceId;
char *SCPDURL;
char *controlURL;
char *eventURL;
DOMString UDN;
int active;
int TotalSubscriptions;
subscription *subscriptionList;
struct SERVICE_INFO *next;
} service_info;
#ifdef INCLUDE_DEVICE_APIS
extern void freeSubscriptionQueuedEvents(subscription *sub);
typedef struct SERVICE_TABLE
{
DOMString URLBase;
service_info *serviceList;
service_info *endServiceList;
} service_table;
/* Functions for Subscriptions */
int copy_subscription(
subscription *in,
subscription *out);
/*
* \brief Remove the subscription represented by the const Upnp_SID sid
* parameter from the service table and update the service table.
*/
void RemoveSubscriptionSID(
Upnp_SID sid,
service_info *service);
subscription *GetSubscriptionSID(
const Upnp_SID sid,
service_info *service);
subscription *GetFirstSubscription(
service_info *service);
subscription *GetNextSubscription(
service_info *service,
subscription *current);
void freeSubscription(
subscription *sub);
void freeSubscriptionList(
subscription *head);
service_info *FindServiceId(
service_table *table,
const char *serviceId,
const char *UDN);
service_info *FindServiceEventURLPath(
service_table *table,
const char *eventURLPath);
service_info *FindServiceControlURLPath(
service_table *table,
const char *controlURLPath);
#ifdef DEBUG
void printService(
service_info *service,
Upnp_LogLevel level,
Dbg_Module module);
#else
#define printService(service, level, module) \
do { \
} while (0)
#endif
#ifdef DEBUG
void printServiceList(
service_info *service,
Upnp_LogLevel level,
Dbg_Module module);
#else
#define printServiceList(service, level, module) \
do { \
} while (0)
#endif
#ifdef DEBUG
void printServiceTable(
service_table *table,
Upnp_LogLevel level,
Dbg_Module module);
#else
#define printServiceTable(table, level, module) \
do { \
} while (0)
#endif
void freeService(
service_info *in);
void freeServiceList(
service_info *head);
void freeServiceTable(
service_table *table);
int removeServiceTable(
IXML_Node *node,
service_table *in);
int addServiceTable(
IXML_Node *node,
service_table *in,
const char *DefaultURLBase);
int getServiceTable(
IXML_Node *node,
service_table *out,
const char *DefaultURLBase);
/* Misc helper functions */
DOMString getElementValue(
IXML_Node *node);
int getSubElement(
const char *element_name,
IXML_Node *node,
IXML_Node **out);
#endif /* INCLUDE_DEVICE_APIS */
#ifdef __cplusplus
}
#endif
#endif /* SERVICE_TABLE */
LinkedList.h
Upnp_SID
char Upnp_SID[44]
Holds the subscription identifier for a subscription between a client and a device.
Definition upnp.h:448
DOMString
#define DOMString
The type of DOM strings.
Definition ixml.h:48
ixml.h
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.
Definition service_table.c:325
printService
void printService(service_info *service, Upnp_LogLevel level, Dbg_Module module)
For debugging purposes prints information from the service passed into the function.
Definition service_table.c:371
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 serv...
Definition service_table.c:538
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.
Definition service_table.c:699
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 func...
Definition service_table.c:453
GetFirstSubscription
subscription * GetFirstSubscription(service_info *service)
Gets pointer to the first subscription node in the service table.
Definition service_table.c:181
GetSubscriptionSID
subscription * GetSubscriptionSID(const Upnp_SID sid, service_info *service)
Return the subscription from the service table that matches const Upnp_SID sid value.
Definition service_table.c:117
freeService
void freeService(service_info *in)
Free's memory allocated for the various components of the service entry in the service table.
Definition service_table.c:566
copy_subscription
int copy_subscription(subscription *in, subscription *out)
Makes a copy of the subscription.
Definition service_table.c:60
freeServiceTable
void freeServiceTable(service_table *table)
Free's dynamic memory in table (does not free table, only memory within the structure).
Definition service_table.c:649
addServiceTable
int addServiceTable(IXML_Node *node, service_table *in, const char *DefaultURLBase)
Add Service to the table.
Definition service_table.c:1030
freeServiceList
void freeServiceList(service_info *head)
Free's memory allocated for the various components of each service entry in the service table.
Definition service_table.c:608
freeSubscription
void freeSubscription(subscription *sub)
Free's the memory allocated for storing the URL of the subscription.
Definition service_table.c:194
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 t...
Definition service_table.c:944
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.
Definition service_table.c:278
RemoveSubscriptionSID
void RemoveSubscriptionSID(Upnp_SID sid, service_info *service)
Definition service_table.c:94
getServiceTable
int getServiceTable(IXML_Node *node, service_table *out, const char *DefaultURLBase)
Retrieve service from the table.
Definition service_table.c:1078
freeSubscriptionList
void freeSubscriptionList(subscription *head)
Free's memory allocated for all the subscriptions in the service table.
Definition service_table.c:215
GetNextSubscription
subscription * GetNextSubscription(service_info *service, subscription *current)
Get current and valid subscription from the service table.
Definition service_table.c:150
getElementValue
DOMString getElementValue(IXML_Node *node)
Returns the clone of the element value.
Definition service_table.c:669
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 se...
Definition service_table.c:243
LINKEDLIST
Definition LinkedList.h:84
SERVICE_INFO
Definition service_table.h:71
SERVICE_TABLE
Definition service_table.h:89
SUBSCRIPTION
Definition service_table.h:56
URL_LIST
Represents a list of URLs as in the "callback" header of SUBSCRIBE message in GENA....
Definition uri.h:148
_IXML_Node
Data structure common to all types of nodes.
Definition ixml.h:136
upnp.h
upnpdebug.h
uri.h