libUPnP 1.14.19
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 <stdio.h>
52#include <time.h>
53
54#define SID_SIZE (size_t)41
55
56typedef struct SUBSCRIPTION
57{
58 Upnp_SID sid;
59 int ToSendEventKey;
60 time_t expireTime;
61 int active;
62 URL_list DeliveryURLs;
63 /* List of queued events for this subscription. Only one event job
64 at a time goes into the thread pool. The first element in the
65 list is a copy of the active job. Others are activated on job
66 completion. */
67 LinkedList outgoing;
68 struct SUBSCRIPTION *next;
70
71typedef struct SERVICE_INFO
72{
73 DOMString serviceType;
74 DOMString serviceId;
75 char *SCPDURL;
76 char *controlURL;
77 char *eventURL;
78 DOMString UDN;
79 int active;
80 int TotalSubscriptions;
81 subscription *subscriptionList;
82 struct SERVICE_INFO *next;
84
85#ifdef INCLUDE_DEVICE_APIS
86
87extern void freeSubscriptionQueuedEvents(subscription *sub);
88
89typedef struct SERVICE_TABLE
90{
91 DOMString URLBase;
92 service_info *serviceList;
93 service_info *endServiceList;
95
96/* Functions for Subscriptions */
97
105 subscription *in,
107 subscription *out);
108
109/*
110 * \brief Remove the subscription represented by the const Upnp_SID sid
111 * parameter from the service table and update the service table.
112 */
115 Upnp_SID sid,
117 service_info *service);
118
127 const Upnp_SID sid,
129 service_info *service);
130
138 service_info *service);
139
147 service_info *service,
149 subscription *current);
150
156 subscription *sub);
157
164 subscription *head);
165
174 service_table *table,
177 const char *serviceId,
180 const char *UDN);
181
191 service_table *table,
193 const char *eventURLPath);
194
204 service_table *table,
206 const char *controlURLPath);
207
212 #ifdef DEBUG
213void printService(
215 service_info *service,
217 Upnp_LogLevel level,
219 Dbg_Module module);
220 #else
221 #define printService(service, level, module) \
222 do { \
223 } while (0)
224 #endif
225
230 #ifdef DEBUG
233 service_info *service,
235 Upnp_LogLevel level,
237 Dbg_Module module);
238 #else
239 #define printServiceList(service, level, module) \
240 do { \
241 } while (0)
242 #endif
243
249 #ifdef DEBUG
252 service_table *table,
254 Upnp_LogLevel level,
256 Dbg_Module module);
257 #else
258 #define printServiceTable(table, level, module) \
259 do { \
260 } while (0)
261 #endif
262
267void freeService(
269 service_info *in);
270
275void freeServiceList(
277 service_info *head);
278
285 service_table *table);
286
297 IXML_Node *node,
299 service_table *in);
300
306 IXML_Node *node,
308 service_table *in,
311 const char *DefaultURLBase);
312
320 IXML_Node *node,
323 service_table *out,
325 const char *DefaultURLBase);
326
327/* Misc helper functions */
328
338 IXML_Node *node);
339
348int getSubElement(
350 const char *element_name,
352 IXML_Node *node,
354 IXML_Node **out);
355
356#endif /* INCLUDE_DEVICE_APIS */
357
358#ifdef __cplusplus
359}
360#endif
361
362#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:72
Definition service_table.h:90
Definition service_table.h:57
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