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 "config.h"
#include "uri.h"
#include "ixml.h"
#include "upnp.h"
#include "upnpdebug.h"
#include <stdio.h>
#include <time.h>
#define SID_SIZE (size_t)41
#ifdef INCLUDE_DEVICE_APIS
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;
extern void freeSubscriptionQueuedEvents(subscription *sub);
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;
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,
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
static UPNP_INLINE void printService(
service_info *service,
Upnp_LogLevel level,
Dbg_Module module)
{
return;
service = service;
level = level;
module = module;
}
#endif
#ifdef DEBUG
void printServiceList(
service_info *service,
Upnp_LogLevel level,
Dbg_Module module);
#else
static UPNP_INLINE void printServiceList(
service_info *service,
Upnp_LogLevel level,
Dbg_Module module)
{
return;
service = service;
level = level;
module = module;
}
#endif
#ifdef DEBUG
void printServiceTable(
service_table *table,
Upnp_LogLevel level,
Dbg_Module module);
#else
static UPNP_INLINE void printServiceTable(
service_table *table,
Upnp_LogLevel level,
Dbg_Module module)
{
return;
table = table;
level = level;
module = module;
}
#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 */
upnpdebug.h
upnp.h
SUBSCRIPTION
Definition: service_table.h:57
SERVICE_INFO
Definition: service_table.h:73
copy_subscription
int copy_subscription(subscription *in, subscription *out)
Makes a copy of the subscription.
Definition: service_table.c:62
GetFirstSubscription
subscription * GetFirstSubscription(service_info *service)
Gets pointer to the first subscription node in the service table.
Definition: service_table.c:192
ixml.h
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
freeSubscriptionList
void freeSubscriptionList(subscription *head)
Free&#39;s memory allocated for all the subscriptions in the service table.
Definition: service_table.c:228
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:396
uri.h
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:123
URL_LIST
Represents a list of URLs as in the "callback" header of SUBSCRIBE message in GENA. "char *" URLs holds dynamic memory.
Definition: uri.h:149
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:512
getElementValue
DOMString getElementValue(IXML_Node *node)
Returns the clone of the element value.
Definition: service_table.c:645
freeSubscription
void freeSubscription(subscription *sub)
Free&#39;s the memory allocated for storing the URL of the subscription.
Definition: service_table.c:206
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:348
freeServiceList
void freeServiceList(service_info *head)
Free&#39;s memory allocated for the various components of each service entry in the service table...
Definition: service_table.c:581
freeServiceTable
void freeServiceTable(service_table *table)
Free&#39;s dynamic memory in table (does not free table, only memory within the structure).
Definition: service_table.c:623
SERVICE_TABLE
Definition: service_table.h:86
freeService
void freeService(service_info *in)
Free&#39;s memory allocated for the various components of the service entry in the service table...
Definition: service_table.c:538
_IXML_Node
Data structure common to all types of nodes.
Definition: ixml.h:172
addServiceTable
int addServiceTable(IXML_Node *node, service_table *in, const char *DefaultURLBase)
Add Service to the table.
Definition: service_table.c:992
GetNextSubscription
subscription * GetNextSubscription(service_info *service, subscription *current)
Get current and valid subscription from the service table.
Definition: service_table.c:159
RemoveSubscriptionSID
void RemoveSubscriptionSID(Upnp_SID sid, service_info *service)
Definition: service_table.c:98
DOMString
#define DOMString
The type of DOM strings.
Definition: ixml.h:59
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:917
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:678
getServiceTable
int getServiceTable(IXML_Node *node, service_table *out, const char *DefaultURLBase)
Retrieve service from the table.
Definition: service_table.c:1045
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:259
Upnp_SID
char Upnp_SID[44]
Holds the subscription identifier for a subscription between a client and a device.
Definition: upnp.h:445
UPNP_INLINE
#define UPNP_INLINE
Declares an inline function.
Definition: UpnpGlobal.h:99
FindServiceEventURLPath
service_info * FindServiceEventURLPath(service_table *table, char *eventURLPath)
Traverses the service table and finds the node whose event URL Path matches a know value...
Definition: service_table.c:296
LINKEDLIST
Definition: LinkedList.h:83