libUPnP 1.14.23
service_table.h
Go to the documentation of this file.
1/*******************************************************************************
2 *
3 * Copyright (c) 2000-2003 Intel Corporation
4 * All rights reserved.
5 * Copyright (c) 2012 France Telecom All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * - Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
15 * - Neither name of Intel Corporation nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 *
31 ******************************************************************************/
32
33#ifndef SERVICE_TABLE_H
34#define SERVICE_TABLE_H
35
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44#include "LinkedList.h"
45#include "config.h"
46#include "ixml.h"
47#include "upnp.h"
48#include "upnpdebug.h"
49#include "uri.h"
50
51#include <time.h>
52
53#define SID_SIZE (size_t)41
54
55typedef struct SUBSCRIPTION
56{
57 Upnp_SID sid;
58 int ToSendEventKey;
59 time_t expireTime;
60 int active;
61 URL_list DeliveryURLs;
62 /* List of queued events for this subscription. Only one event job
63 at a time goes into the thread pool. The first element in the
64 list is a copy of the active job. Others are activated on job
65 completion. */
66 LinkedList outgoing;
67 struct SUBSCRIPTION *next;
69
70typedef struct SERVICE_INFO
71{
72 DOMString serviceType;
73 DOMString serviceId;
74 char *SCPDURL;
75 char *controlURL;
76 char *eventURL;
77 DOMString UDN;
78 int active;
79 int TotalSubscriptions;
80 subscription *subscriptionList;
81 struct SERVICE_INFO *next;
83
84#ifdef INCLUDE_DEVICE_APIS
85
86extern void freeSubscriptionQueuedEvents(subscription *sub);
87
88typedef struct SERVICE_TABLE
89{
90 DOMString URLBase;
91 service_info *serviceList;
92 service_info *endServiceList;
94
95/* Functions for Subscriptions */
96
104 subscription *in,
106 subscription *out);
107
108/*
109 * \brief Remove the subscription represented by the const Upnp_SID sid
110 * parameter from the service table and update the service table.
111 */
114 Upnp_SID sid,
116 service_info *service);
117
126 const Upnp_SID sid,
128 service_info *service);
129
137 service_info *service);
138
146 service_info *service,
148 subscription *current);
149
155 subscription *sub);
156
163 subscription *head);
164
173 service_table *table,
176 const char *serviceId,
179 const char *UDN);
180
190 service_table *table,
192 const char *eventURLPath);
193
203 service_table *table,
205 const char *controlURLPath);
206
211 #ifdef DEBUG
212void printService(
214 service_info *service,
216 Upnp_LogLevel level,
218 Dbg_Module module);
219 #else
220 #define printService(service, level, module) \
221 do { \
222 } while (0)
223 #endif
224
229 #ifdef DEBUG
232 service_info *service,
234 Upnp_LogLevel level,
236 Dbg_Module module);
237 #else
238 #define printServiceList(service, level, module) \
239 do { \
240 } while (0)
241 #endif
242
248 #ifdef DEBUG
251 service_table *table,
253 Upnp_LogLevel level,
255 Dbg_Module module);
256 #else
257 #define printServiceTable(table, level, module) \
258 do { \
259 } while (0)
260 #endif
261
266void freeService(
268 service_info *in);
269
274void freeServiceList(
276 service_info *head);
277
284 service_table *table);
285
296 IXML_Node *node,
298 service_table *in);
299
305 IXML_Node *node,
307 service_table *in,
310 const char *DefaultURLBase);
311
319 IXML_Node *node,
322 service_table *out,
324 const char *DefaultURLBase);
325
326/* Misc helper functions */
327
337 IXML_Node *node);
338
347int getSubElement(
349 const char *element_name,
351 IXML_Node *node,
353 IXML_Node **out);
354
355#endif /* INCLUDE_DEVICE_APIS */
356
357#ifdef __cplusplus
358}
359#endif
360
361#endif /* SERVICE_TABLE */
char Upnp_SID[44]
Holds the subscription identifier for a subscription between a client and a device.
Definition upnp.h:448
#define DOMString
The type of DOM strings.
Definition ixml.h:48
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
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
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
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
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
subscription * GetFirstSubscription(service_info *service)
Gets pointer to the first subscription node in the service table.
Definition service_table.c:181
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
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
int copy_subscription(subscription *in, subscription *out)
Makes a copy of the subscription.
Definition service_table.c:60
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
int addServiceTable(IXML_Node *node, service_table *in, const char *DefaultURLBase)
Add Service to the table.
Definition service_table.c:1030
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
void freeSubscription(subscription *sub)
Free's the memory allocated for storing the URL of the subscription.
Definition service_table.c:194
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
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
void RemoveSubscriptionSID(Upnp_SID sid, service_info *service)
Definition service_table.c:94
int getServiceTable(IXML_Node *node, service_table *out, const char *DefaultURLBase)
Retrieve service from the table.
Definition service_table.c:1078
void freeSubscriptionList(subscription *head)
Free's memory allocated for all the subscriptions in the service table.
Definition service_table.c:215
subscription * GetNextSubscription(service_info *service, subscription *current)
Get current and valid subscription from the service table.
Definition service_table.c:150
DOMString getElementValue(IXML_Node *node)
Returns the clone of the element value.
Definition service_table.c:669
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
Definition LinkedList.h:84
Definition service_table.h:71
Definition service_table.h:89
Definition service_table.h:56
Represents a list of URLs as in the "callback" header of SUBSCRIBE message in GENA....
Definition uri.h:148
Data structure common to all types of nodes.
Definition ixml.h:136