libUPnP  1.14.24
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
41 extern "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 
55 typedef 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;
68 } subscription;
69 
70 typedef 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;
82 } service_info;
83 
84 #ifdef INCLUDE_DEVICE_APIS
85 
86 extern void freeSubscriptionQueuedEvents(subscription *sub);
87 
88 typedef 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 
153 void freeSubscription(
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
212 void 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
230 void printServiceList(
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
249 void printServiceTable(
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 
266 void freeService(
268  service_info *in);
269 
274 void freeServiceList(
276  service_info *head);
277 
282 void freeServiceTable(
284  service_table *table);
285 
296  IXML_Node *node,
298  service_table *in);
299 
303 int addServiceTable(
305  IXML_Node *node,
307  service_table *in,
310  const char *DefaultURLBase);
311 
317 int getServiceTable(
319  IXML_Node *node,
322  service_table *out,
324  const char *DefaultURLBase);
325 
326 /* Misc helper functions */
327 
337  IXML_Node *node);
338 
347 int 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 */
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
Definition: service_table.h:55
Definition: service_table.h:70
int copy_subscription(subscription *in, subscription *out)
Makes a copy of the subscription.
Definition: service_table.c:60
subscription * GetFirstSubscription(service_info *service)
Gets pointer to the first subscription node in the service table.
Definition: service_table.c:181
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
void freeSubscriptionList(subscription *head)
Free's memory allocated for all the subscriptions in the service table.
Definition: service_table.c:215
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
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
Represents a list of URLs as in the "callback" header of SUBSCRIBE message in GENA. "char *" URLs holds dynamic memory.
Definition: uri.h:147
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
DOMString getElementValue(IXML_Node *node)
Returns the clone of the element value.
Definition: service_table.c:669
void freeSubscription(subscription *sub)
Free's the memory allocated for storing the URL of the subscription.
Definition: service_table.c:194
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 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 freeServiceTable(service_table *table)
Free's dynamic memory in table (does not free table, only memory within the structure).
Definition: service_table.c:649
Definition: service_table.h:88
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
Data structure common to all types of nodes.
Definition: ixml.h:135
int addServiceTable(IXML_Node *node, service_table *in, const char *DefaultURLBase)
Add Service to the table.
Definition: service_table.c:1030
subscription * GetNextSubscription(service_info *service, subscription *current)
Get current and valid subscription from the service table.
Definition: service_table.c:150
void RemoveSubscriptionSID(Upnp_SID sid, service_info *service)
Definition: service_table.c:94
#define DOMString
The type of DOM strings.
Definition: ixml.h:48
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
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
int getServiceTable(IXML_Node *node, service_table *out, const char *DefaultURLBase)
Retrieve service from the table.
Definition: service_table.c:1078
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
char Upnp_SID[44]
Holds the subscription identifier for a subscription between a client and a device.
Definition: upnp.h:448
Definition: LinkedList.h:83