libUPnP 1.8.4
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 "config.h"
45#include "uri.h"
46#include "ixml.h"
47#include "upnp.h"
48#include "upnpdebug.h"
49#include "LinkedList.h"
50
51#include <stdio.h>
52#include <time.h>
53
54#define SID_SIZE (size_t)41
55
56#ifdef INCLUDE_DEVICE_APIS
57
58typedef struct SUBSCRIPTION {
59 Upnp_SID sid;
60 int ToSendEventKey;
61 time_t expireTime;
62 int active;
63 URL_list DeliveryURLs;
64 /* List of queued events for this subscription. Only one event job
65 at a time goes into the thread pool. The first element in the
66 list is a copy of the active job. Others are activated on job
67 completion. */
68 LinkedList outgoing;
69 struct SUBSCRIPTION *next;
71
72extern void freeSubscriptionQueuedEvents(subscription *sub);
73
74typedef struct SERVICE_INFO {
75 DOMString serviceType;
76 DOMString serviceId;
77 char *SCPDURL ;
78 char *controlURL;
79 char *eventURL;
80 DOMString UDN;
81 int active;
82 int TotalSubscriptions;
83 subscription *subscriptionList;
84 struct SERVICE_INFO *next;
86
87typedef struct SERVICE_TABLE {
88 DOMString URLBase;
89 service_info *serviceList;
90 service_info *endServiceList;
92
93/* Functions for Subscriptions */
94
102 subscription *in,
104 subscription *out);
105
106/*
107 * \brief Remove the subscription represented by the const Upnp_SID sid parameter
108 * from the service table and update the service table.
109 */
112 Upnp_SID sid,
114 service_info *service);
115
124 const Upnp_SID sid,
126 service_info *service);
127
135 service_info *service);
136
144 service_info *service,
146 subscription *current);
147
153 subscription *sub);
154
160 subscription * head);
161
170 service_table *table,
173 const char *serviceId,
176 const char *UDN);
177
187 service_table *table,
189 const char *eventURLPath);
190
200 service_table *table,
202 const char *controlURLPath);
203
208#ifdef DEBUG
209void printService(
211 service_info *service,
213 Upnp_LogLevel level,
215 Dbg_Module module);
216#else
217static UPNP_INLINE void printService(
218 service_info *service,
219 Upnp_LogLevel level,
220 Dbg_Module module)
221{
222 return;
223 service = service;
224 level = level;
225 module = module;
226}
227#endif
228
233#ifdef DEBUG
236 service_info *service,
238 Upnp_LogLevel level,
240 Dbg_Module module);
241#else
242static UPNP_INLINE void printServiceList(
243 service_info *service,
244 Upnp_LogLevel level,
245 Dbg_Module module)
246{
247 return;
248 service = service;
249 level = level;
250 module = module;
251}
252#endif
253
258#ifdef DEBUG
261 service_table *table,
263 Upnp_LogLevel level,
265 Dbg_Module module);
266#else
268 service_table *table,
269 Upnp_LogLevel level,
270 Dbg_Module module)
271{
272 return;
273 table = table;
274 level = level;
275 module = module;
276}
277#endif
278
283void freeService(
285 service_info *in);
286
291void freeServiceList(
293 service_info *head);
294
301 service_table *table);
302
313 IXML_Node *node,
315 service_table *in);
316
322 IXML_Node *node,
324 service_table *in,
327 const char *DefaultURLBase);
328
336 IXML_Node *node,
338 service_table *out,
340 const char *DefaultURLBase);
341
342/* Misc helper functions */
343
353 IXML_Node *node);
354
363int getSubElement(
365 const char *element_name,
367 IXML_Node *node,
369 IXML_Node **out);
370
371#endif /* INCLUDE_DEVICE_APIS */
372
373#ifdef __cplusplus
374}
375#endif
376
377#endif /* SERVICE_TABLE */
378
#define UPNP_INLINE
Declares an inline function.
Definition UpnpGlobal.h:99
char Upnp_SID[44]
Holds the subscription identifier for a subscription between a client and a device.
Definition upnp.h:445
#define DOMString
The type of DOM strings.
Definition ixml.h:59
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
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
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
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
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:192
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
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:538
int copy_subscription(subscription *in, subscription *out)
Makes a copy of the subscription.
Definition service_table.c:62
void freeServiceTable(service_table *table)
Free's dynamic memory in table (does not free table, only memory within the structure).
Definition service_table.c:623
int addServiceTable(IXML_Node *node, service_table *in, const char *DefaultURLBase)
Add Service to the table.
Definition service_table.c:992
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:581
void freeSubscription(subscription *sub)
Free's the memory allocated for storing the URL of the subscription.
Definition service_table.c:206
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
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:296
void RemoveSubscriptionSID(Upnp_SID sid, service_info *service)
Definition service_table.c:98
int getServiceTable(IXML_Node *node, service_table *out, const char *DefaultURLBase)
Retrieve service from the table.
Definition service_table.c:1045
void freeSubscriptionList(subscription *head)
Free's memory allocated for all the subscriptions in the service table.
Definition service_table.c:228
subscription * GetNextSubscription(service_info *service, subscription *current)
Get current and valid subscription from the service table.
Definition service_table.c:159
DOMString getElementValue(IXML_Node *node)
Returns the clone of the element value.
Definition service_table.c:645
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
Definition LinkedList.h:84
Definition service_table.h:74
Definition service_table.h:87
Definition service_table.h:58
Represents a list of URLs as in the "callback" header of SUBSCRIBE message in GENA....
Definition uri.h:149
Data structure common to all types of nodes.
Definition ixml.h:173