libUPnP  1.8.0
service_table.h
Go to the documentation of this file.
1 /*******************************************************************************
2  *
3  * Copyright (c) 2000-2003 Intel Corporation
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * - Redistributions of source code must retain the above copyright notice,
10  * this list of conditions and the following disclaimer.
11  * - Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  * - Neither name of Intel Corporation nor the names of its contributors
15  * may be used to endorse or promote products derived from this software
16  * without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
22  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  *
30  ******************************************************************************/
31 
32 
33 #ifndef SERVICE_TABLE_H
34 #define SERVICE_TABLE_H
35 
36 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 
47 #include "config.h"
48 #include "uri.h"
49 #include "ixml.h"
50 #include "upnp.h"
51 #include "upnpdebug.h"
52 
53 
54 #include <stdio.h>
55 #include <time.h>
56 
57 
58 #define SID_SIZE 41
59 
60 
61 #ifdef INCLUDE_DEVICE_APIS
62 
63 
64 typedef struct SUBSCRIPTION {
65  Upnp_SID sid;
66  int eventKey;
67  int ToSendEventKey;
68  time_t expireTime;
69  int active;
70  URL_list DeliveryURLs;
71  struct SUBSCRIPTION *next;
72 } subscription;
73 
74 
75 typedef struct SERVICE_INFO {
76  DOMString serviceType;
77  DOMString serviceId;
78  char *SCPDURL ;
79  char *controlURL;
80  char *eventURL;
81  DOMString UDN;
82  int active;
83  int TotalSubscriptions;
84  subscription *subscriptionList;
85  struct SERVICE_INFO *next;
86 } service_info;
87 
88 
89 typedef struct SERVICE_TABLE {
90  DOMString URLBase;
91  service_info *serviceList;
92  service_info *endServiceList;
94 
95 
96 /* Functions for Subscriptions */
97 
98 
106  subscription *in,
108  subscription *out);
109 
110 
111 /*
112  * \brief Remove the subscription represented by the const Upnp_SID sid parameter
113  * from the service table and update the service table.
114  */
117  Upnp_SID sid,
119  service_info *service);
120 
121 
130  const Upnp_SID sid,
132  service_info *service);
133 
134 
142  service_info *service);
143 
144 
152  service_info *service,
154  subscription *current);
155 
156 
160 void freeSubscription(
162  subscription *sub);
163 
164 
170  subscription * head);
171 
172 
181  service_table *table,
184  const char *serviceId,
187  const char *UDN);
188 
189 
199  service_table *table,
201  char *eventURLPath);
202 
203 
213  service_table *table,
215  const char *controlURLPath);
216 
217 
222 #ifdef DEBUG
223 void printService(
225  service_info *service,
227  Upnp_LogLevel level,
229  Dbg_Module module);
230 #else
231 static UPNP_INLINE void printService(
232  service_info *service,
233  Upnp_LogLevel level,
234  Dbg_Module module) {}
235 #endif
236 
237 
242 #ifdef DEBUG
243 void printServiceList(
245  service_info *service,
247  Upnp_LogLevel level,
249  Dbg_Module module);
250 #else
251 static UPNP_INLINE void printServiceList(
252  service_info *service,
253  Upnp_LogLevel level,
254  Dbg_Module module) {}
255 #endif
256 
257 
262 #ifdef DEBUG
263 void printServiceTable(
265  service_table *table,
267  Upnp_LogLevel level,
269  Dbg_Module module);
270 #else
271 static UPNP_INLINE void printServiceTable(
272  service_table *table,
273  Upnp_LogLevel level,
274  Dbg_Module module) {}
275 #endif
276 
277 
282 void freeService(
284  service_info *in);
285 
286 
291 void freeServiceList(
293  service_info *head);
294 
295 
300 void freeServiceTable(
302  service_table *table);
303 
304 
315  IXML_Node *node,
317  service_table *in);
318 
319 
323 int addServiceTable(
325  IXML_Node *node,
327  service_table *in,
330  const char *DefaultURLBase);
331 
332 
338 int getServiceTable(
340  IXML_Node *node,
342  service_table *out,
344  const char *DefaultURLBase);
345 
346 
347 /* Misc helper functions */
348 
349 
359  IXML_Node *node);
360 
361 
370 int getSubElement(
372  const char *element_name,
374  IXML_Node *node,
376  IXML_Node **out);
377 
378 
379 #endif /* INCLUDE_DEVICE_APIS */
380 
381 #ifdef __cplusplus
382 }
383 #endif
384 
385 #endif /* SERVICE_TABLE */
386 
Definition: service_table.h:64
Definition: service_table.h:75
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:190
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:446
void freeSubscriptionList(subscription *head)
Free's memory allocated for all the subscriptions in the service table.
Definition: service_table.c:225
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:389
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:121
Represents a list of URLs as in the "callback" header of SUBSCRIBE message in GENA. "char *" URLs holds dynamic memory.
Definition: uri.h:162
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:505
DOMString getElementValue(IXML_Node *node)
Returns the clone of the element value.
Definition: service_table.c:637
void freeSubscription(subscription *sub)
Free's the memory allocated for storing the URL of the subscription.
Definition: service_table.c:204
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:342
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:573
void freeServiceTable(service_table *table)
Free's dynamic memory in table (does not free table, only memory within the structure).
Definition: service_table.c:615
Definition: service_table.h:89
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:530
Data structure common to all types of nodes.
Definition: ixml.h:161
int addServiceTable(IXML_Node *node, service_table *in, const char *DefaultURLBase)
Add Service to the table.
Definition: service_table.c:1027
subscription * GetNextSubscription(service_info *service, subscription *current)
Get current and valid subscription from the service table.
Definition: service_table.c:157
void RemoveSubscriptionSID(Upnp_SID sid, service_info *service)
Definition: service_table.c:96
#define DOMString
The type of DOM strings.
Definition: ixml.h:55
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:952
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:670
int getServiceTable(IXML_Node *node, service_table *out, const char *DefaultURLBase)
Retrieve service from the table.
Definition: service_table.c:1080
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:256
char Upnp_SID[44]
Holds the subscription identifier for a subscription between a client and a device.
Definition: upnp.h:590
#define UPNP_INLINE
Declares an inline function.
Definition: UpnpGlobal.h:91
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:293