libUPnP  1.6.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 "config.h"
45 #include "uri.h"
46 #include "ixml.h"
47 #include "upnp.h"
48 #include "upnpdebug.h"
49 
50 #include <stdio.h>
51 #include <time.h>
52 
53 #define SID_SIZE (size_t)41
54 
55 #ifdef INCLUDE_DEVICE_APIS
56 
57 typedef struct SUBSCRIPTION {
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;
69 } subscription;
70 
71 extern void freeSubscriptionQueuedEvents(subscription *sub);
72 
73 typedef struct SERVICE_INFO {
74  DOMString serviceType;
75  DOMString serviceId;
76  char *SCPDURL ;
77  char *controlURL;
78  char *eventURL;
79  DOMString UDN;
80  int active;
81  int TotalSubscriptions;
82  subscription *subscriptionList;
83  struct SERVICE_INFO *next;
84 } service_info;
85 
86 typedef struct SERVICE_TABLE {
87  DOMString URLBase;
88  service_info *serviceList;
89  service_info *endServiceList;
91 
92 /* Functions for Subscriptions */
93 
101  subscription *in,
103  subscription *out);
104 
105 /*
106  * \brief Remove the subscription represented by the const Upnp_SID sid parameter
107  * from the service table and update the service table.
108  */
111  Upnp_SID sid,
113  service_info *service);
114 
123  const Upnp_SID sid,
125  service_info *service);
126 
134  service_info *service);
135 
143  service_info *service,
145  subscription *current);
146 
150 void freeSubscription(
152  subscription *sub);
153 
159  subscription * head);
160 
169  service_table *table,
172  const char *serviceId,
175  const char *UDN);
176 
186  service_table *table,
188  char *eventURLPath);
189 
199  service_table *table,
201  const char *controlURLPath);
202 
207 #ifdef DEBUG
208 void printService(
210  service_info *service,
212  Upnp_LogLevel level,
214  Dbg_Module module);
215 #else
216 static UPNP_INLINE void printService(
217  service_info *service,
218  Upnp_LogLevel level,
219  Dbg_Module module)
220 {
221  return;
222  service = service;
223  level = level;
224  module = module;
225 }
226 #endif
227 
232 #ifdef DEBUG
233 void printServiceList(
235  service_info *service,
237  Upnp_LogLevel level,
239  Dbg_Module module);
240 #else
241 static UPNP_INLINE void printServiceList(
242  service_info *service,
243  Upnp_LogLevel level,
244  Dbg_Module module)
245 {
246  return;
247  service = service;
248  level = level;
249  module = module;
250 }
251 #endif
252 
257 #ifdef DEBUG
258 void printServiceTable(
260  service_table *table,
262  Upnp_LogLevel level,
264  Dbg_Module module);
265 #else
266 static UPNP_INLINE void printServiceTable(
267  service_table *table,
268  Upnp_LogLevel level,
269  Dbg_Module module)
270 {
271  return;
272  table = table;
273  level = level;
274  module = module;
275 }
276 #endif
277 
282 void freeService(
284  service_info *in);
285 
290 void freeServiceList(
292  service_info *head);
293 
298 void freeServiceTable(
300  service_table *table);
301 
312  IXML_Node *node,
314  service_table *in);
315 
319 int addServiceTable(
321  IXML_Node *node,
323  service_table *in,
326  const char *DefaultURLBase);
327 
333 int getServiceTable(
335  IXML_Node *node,
337  service_table *out,
339  const char *DefaultURLBase);
340 
341 /* Misc helper functions */
342 
352  IXML_Node *node);
353 
362 int getSubElement(
364  const char *element_name,
366  IXML_Node *node,
368  IXML_Node **out);
369 
370 #endif /* INCLUDE_DEVICE_APIS */
371 
372 #ifdef __cplusplus
373 }
374 #endif
375 
376 #endif /* SERVICE_TABLE */
377 
Definition: service_table.h:57
Definition: service_table.h:73
int copy_subscription(subscription *in, subscription *out)
Makes a copy of the subscription.
Definition: service_table.c:62
subscription * GetFirstSubscription(service_info *service)
Gets pointer to the first subscription node in the service table.
Definition: service_table.c:192
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&#39;s memory allocated for all the subscriptions in the service table.
Definition: service_table.c:228
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
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
Represents a list of URLs as in the "callback" header of SUBSCRIBE message in GENA. "char *" URLs holds dynamic memory.
Definition: uri.h:149
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
DOMString getElementValue(IXML_Node *node)
Returns the clone of the element value.
Definition: service_table.c:645
void freeSubscription(subscription *sub)
Free&#39;s the memory allocated for storing the URL of the subscription.
Definition: service_table.c:206
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 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
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
Definition: service_table.h:86
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
Data structure common to all types of nodes.
Definition: ixml.h:165
int addServiceTable(IXML_Node *node, service_table *in, const char *DefaultURLBase)
Add Service to the table.
Definition: service_table.c:992
subscription * GetNextSubscription(service_info *service, subscription *current)
Get current and valid subscription from the service table.
Definition: service_table.c:159
void RemoveSubscriptionSID(Upnp_SID sid, service_info *service)
Definition: service_table.c:98
#define DOMString
The type of DOM strings.
Definition: ixml.h:59
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
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
int getServiceTable(IXML_Node *node, service_table *out, const char *DefaultURLBase)
Retrieve service from the table.
Definition: service_table.c:1045
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
char Upnp_SID[44]
Holds the subscription identifier for a subscription between a client and a device.
Definition: upnp.h:534
#define UPNP_INLINE
Declares an inline function.
Definition: UpnpGlobal.h:93
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
Definition: LinkedList.h:83