libUPnP 1.14.19
gena.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#ifndef GENA_H
33#define GENA_H
34
39#include "config.h"
40
41#include <string.h>
42#include <time.h>
43
44#include "ThreadPool.h"
45#include "UpnpString.h"
46#include "client_table.h"
47#include "httpparser.h"
48#include "miniserver.h"
49#include "service_table.h"
50#include "sock.h"
51#include "upnp.h"
52#include "uri.h"
53
54#ifdef __cplusplus
55 #define EXTERN_C extern "C"
56#else /* __cplusplus */
57 #ifndef EXTERN_C
58 #define EXTERN_C
59 #endif /* EXTERN_C */
60#endif /* __cplusplus */
61
66#define XML_VERSION "<?xml version='1.0' encoding='ISO-8859-1' ?>\n"
67#define XML_PROPERTYSET_HEADER \
68 "<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">\n"
69
70#define UNABLE_MEMORY "HTTP/1.1 500 Internal Server Error\r\n\r\n"
71#define UNABLE_SERVICE_UNKNOWN "HTTP/1.1 404 Not Found\r\n\r\n"
72#define UNABLE_SERVICE_NOT_ACCEPT "HTTP/1.1 503 Service Not Available\r\n\r\n"
73
74#define NOT_IMPLEMENTED "HTTP/1.1 501 Not Implemented\r\n\r\n"
75#define BAD_REQUEST "HTTP/1.1 400 Bad Request\r\n\r\n"
76#define INVALID_NT BAD_CALLBACK
77#define BAD_CALLBACK "HTTP/1.1 412 Precondition Failed\r\n\r\n"
78#define HTTP_OK_CRLF "HTTP/1.1 200 OK\r\n\r\n"
79#define HTTP_OK_STR "HTTP/1.1 200 OK\r\n"
80#define INVALID_SID BAD_CALLBACK
81#define MISSING_SID BAD_CALLBACK
82#define MAX_CONTENT_LENGTH 20
83#define MAX_SECONDS 10
84#define MAX_EVENTS 20
85#define MAX_PORT_SIZE 10
86
87#define GENA_E_BAD_RESPONSE UPNP_E_BAD_RESPONSE
88#define GENA_E_BAD_SERVICE UPNP_E_INVALID_SERVICE
89#define GENA_E_SUBSCRIPTION_UNACCEPTED UPNP_E_SUBSCRIBE_UNACCEPTED
90#define GENA_E_BAD_SID UPNP_E_INVALID_SID
91#define GENA_E_UNSUBSCRIBE_UNACCEPTED UPNP_E_UNSUBSCRIBE_UNACCEPTED
92#define GENA_E_NOTIFY_UNACCEPTED UPNP_E_NOTIFY_UNACCEPTED
93#define GENA_E_NOTIFY_UNACCEPTED_REMOVE_SUB -9
94#define GENA_E_BAD_HANDLE UPNP_E_INVALID_HANDLE
95
96#define XML_ERROR -5
97#define XML_SUCCESS UPNP_E_SUCCESS
98#define GENA_SUCCESS UPNP_E_SUCCESS
99
100#define CALLBACK_SUCCESS 0
101#define DEFAULT_TIMEOUT 1801
102
103extern ithread_mutex_t GlobalClientSubscribeMutex;
104
108#define SubscribeLock() \
109 UpnpPrintf( \
110 UPNP_INFO, GENA, __FILE__, __LINE__, "Trying Subscribe Lock"); \
111 ithread_mutex_lock(&GlobalClientSubscribeMutex); \
112 UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, "Subscribe Lock");
113
117#define SubscribeUnlock() \
118 UpnpPrintf(UPNP_INFO, \
119 GENA, \
120 __FILE__, \
121 __LINE__, \
122 "Trying Subscribe UnLock"); \
123 ithread_mutex_unlock(&GlobalClientSubscribeMutex); \
124 UpnpPrintf(UPNP_INFO, GENA, __FILE__, __LINE__, "Subscribe UnLock");
125
130{
131 char *headers;
132 DOMString propertySet;
133 char *servId;
134 char *UDN;
135 Upnp_SID sid;
136 time_t ctime;
137 int *reference_count;
138 UpnpDevice_Handle device_handle;
140
147EXTERN_C void genaCallback(
149 http_parser_t *parser,
151 http_message_t *request,
153 SOCKINFO *info);
154
165#ifdef INCLUDE_CLIENT_APIS
166EXTERN_C int genaSubscribe(
168 UpnpClient_Handle client_handle,
170 const UpnpString *PublisherURL,
175 int *TimeOut,
177 UpnpString *out_sid);
178#endif /* INCLUDE_CLIENT_APIS */
179
190#ifdef INCLUDE_CLIENT_APIS
191EXTERN_C int genaUnSubscribe(
193 UpnpClient_Handle client_handle,
195 const UpnpString *in_sid);
196#endif /* INCLUDE_CLIENT_APIS */
197
207#ifdef INCLUDE_CLIENT_APIS
208EXTERN_C int genaUnregisterClient(
210 UpnpClient_Handle client_handle);
211#endif /* INCLUDE_CLIENT_APIS */
212
213/*
214 * DEVICE
215 */
216
222#ifdef INCLUDE_DEVICE_APIS
223EXTERN_C int genaUnregisterDevice(
226#endif /* INCLUDE_CLIENT_APIS */
227
238#ifdef INCLUDE_CLIENT_APIS
239EXTERN_C int genaRenewSubscription(
241 UpnpClient_Handle client_handle,
243 const UpnpString *in_sid,
246 int *TimeOut);
247#endif /* INCLUDE_CLIENT_APIS */
248
257#ifdef INCLUDE_DEVICE_APIS
258EXTERN_C int genaNotifyAll(
262 char *UDN,
264 char *servId,
266 char **VarNames,
268 char **VarValues,
270 int var_count);
271#endif /* INCLUDE_DEVICE_APIS */
272
281#ifdef INCLUDE_DEVICE_APIS
282EXTERN_C int genaNotifyAllExt(
286 char *UDN,
288 char *servId,
290 IXML_Document *PropSet);
291#endif /* INCLUDE_DEVICE_APIS */
292
301#ifdef INCLUDE_DEVICE_APIS
302EXTERN_C int genaInitNotify(
306 char *UDN,
308 char *servId,
310 char **VarNames,
312 char **VarValues,
314 int var_count,
316 const Upnp_SID sid);
317#endif /* INCLUDE_DEVICE_APIS */
318
329#ifdef INCLUDE_DEVICE_APIS
330EXTERN_C int genaInitNotifyExt(
334 char *UDN,
336 char *servId,
338 IXML_Document *PropSet,
340 const Upnp_SID sid);
341#endif /* INCLUDE_DEVICE_APIS */
342
349void error_respond(
351 SOCKINFO *info,
353 int error_code,
355 http_message_t *hmsg);
356
357#endif /* GENA_H */
UpnpString object declaration.
struct NOTIFY_THREAD_STRUCT notify_thread_struct
int genaUnregisterClient(UpnpClient_Handle client_handle)
Unsubcribes all the outstanding subscriptions and cleans the subscription list.
Definition gena_ctrlpt.c:466
int genaNotifyAll(UpnpDevice_Handle device_handle, char *UDN, char *servId, char **VarNames, char **VarValues, int var_count)
Sends a notification to all the subscribed control points.
Definition gena_device.c:1004
int genaUnregisterDevice(UpnpDevice_Handle device_handle)
Cleans the service table of the device.
Definition gena_device.c:64
int genaUnSubscribe(UpnpClient_Handle client_handle, const UpnpString *in_sid)
Unsubscribes a SID.
Definition gena_ctrlpt.c:511
void genaCallback(http_parser_t *parser, http_message_t *request, SOCKINFO *info)
This is the callback function called by the miniserver to handle incoming GENA requests.
Definition gena_callback2.c:84
int genaNotifyAllExt(UpnpDevice_Handle device_handle, char *UDN, char *servId, IXML_Document *PropSet)
Sends a notification to all the subscribed control points.
Definition gena_device.c:961
int genaSubscribe(UpnpClient_Handle client_handle, const UpnpString *PublisherURL, int *TimeOut, UpnpString *out_sid)
This function subscribes to a PublisherURL (also mentioned as EventURL in some places).
Definition gena_ctrlpt.c:560
int genaInitNotifyExt(UpnpDevice_Handle device_handle, char *UDN, char *servId, IXML_Document *PropSet, const Upnp_SID sid)
Similar to the genaInitNofity. The only difference is that it takes the xml document for the state ta...
Definition gena_device.c:711
void error_respond(SOCKINFO *info, int error_code, http_message_t *hmsg)
Sends an error message to the control point in the case of incorrect GENA requests.
Definition gena_callback2.c:58
int genaRenewSubscription(UpnpClient_Handle client_handle, const UpnpString *in_sid, int *TimeOut)
Renews a SID.
Definition gena_ctrlpt.c:654
int genaInitNotify(UpnpDevice_Handle device_handle, char *UDN, char *servId, char **VarNames, char **VarValues, int var_count, const Upnp_SID sid)
Sends the intial state table dump to newly subscribed control point.
Definition gena_device.c:660
char Upnp_SID[44]
Holds the subscription identifier for a subscription between a client and a device.
Definition upnp.h:448
int UpnpClient_Handle
Returned when a control point application registers with UpnpRegisterClient.
Definition upnp.h:429
ithread_mutex_t GlobalClientSubscribeMutex
Definition upnpapi.c:116
int UpnpDevice_Handle
Returned when a device application registers with UpnpRegisterRootDevice, UpnpRegisterRootDevice2,...
Definition upnp.h:439
UpnpDevice_Handle device_handle
Definition tv_device.c:78
struct s_UpnpString UpnpString
Type of the string objects inside libupnp.
Definition UpnpString.h:33
#define DOMString
The type of DOM strings.
Definition ixml.h:48
Definition gena.h:130
Definition sock.h:60
Data structure representing the DOM Document.
Definition ixml.h:160
Definition httpparser.h:182
Definition httpparser.h:217