UPnPsdk 0.1
Universal Plug and Play +, Software Development Kit
 
Loading...
Searching...
No Matches
gena.hpp
Go to the documentation of this file.
1#ifndef COMPA_GENA_HPP
2#define COMPA_GENA_HPP
3/*******************************************************************************
4 *
5 * Copyright (c) 2000-2003 Intel Corporation
6 * All rights reserved.
7 * Copyright (C) 2022+ GPL 3 and higher by Ingo Höft, <Ingo@Hoeft-online.de>
8 * Redistribution only with this Copyright remark. Last modified: 2025-06-12
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 *
13 * - Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * - Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * - Neither name of Intel Corporation nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
26 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
30 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 ******************************************************************************/
41#include <time.h>
42
43#include <client_table.hpp>
44#include <httpparser.hpp>
45#include <sock.hpp>
46
49#define XML_VERSION "<?xml version='1.0' encoding='ISO-8859-1' ?>\n"
52#define XML_PROPERTYSET_HEADER \
53 "<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">\n"
54
55#define UNABLE_MEMORY "HTTP/1.1 500 Internal Server Error\r\n\r\n"
56#define UNABLE_SERVICE_UNKNOWN "HTTP/1.1 404 Not Found\r\n\r\n"
57#define UNABLE_SERVICE_NOT_ACCEPT "HTTP/1.1 503 Service Not Available\r\n\r\n"
58
59#define NOT_IMPLEMENTED "HTTP/1.1 501 Not Implemented\r\n\r\n"
60#define BAD_REQUEST "HTTP/1.1 400 Bad Request\r\n\r\n"
61#define INVALID_NT BAD_CALLBACK
62#define BAD_CALLBACK "HTTP/1.1 412 Precondition Failed\r\n\r\n"
63#define HTTP_OK_CRLF "HTTP/1.1 200 OK\r\n\r\n"
64#define HTTP_OK_STR "HTTP/1.1 200 OK\r\n"
65#define INVALID_SID BAD_CALLBACK
66#define MISSING_SID BAD_CALLBACK
67#define MAX_CONTENT_LENGTH 20
68#define MAX_SECONDS 10
69#define MAX_EVENTS 20
70#define MAX_PORT_SIZE 10
71
72#define GENA_E_BAD_RESPONSE UPNP_E_BAD_RESPONSE
73#define GENA_E_BAD_SERVICE UPNP_E_INVALID_SERVICE
74#define GENA_E_SUBSCRIPTION_UNACCEPTED UPNP_E_SUBSCRIBE_UNACCEPTED
75#define GENA_E_BAD_SID UPNP_E_INVALID_SID
76#define GENA_E_UNSUBSCRIBE_UNACCEPTED UPNP_E_UNSUBSCRIBE_UNACCEPTED
77#define GENA_E_NOTIFY_UNACCEPTED UPNP_E_NOTIFY_UNACCEPTED
78#define GENA_E_NOTIFY_UNACCEPTED_REMOVE_SUB -9
79#define GENA_E_BAD_HANDLE UPNP_E_INVALID_HANDLE
80
81#define XML_ERROR -5
82#define XML_SUCCESS UPNP_E_SUCCESS
83#define GENA_SUCCESS UPNP_E_SUCCESS
84
85#define CALLBACK_SUCCESS 0
86#define DEFAULT_TIMEOUT 1801
88
105
108
111
118void genaCallback(
120 http_parser_t* parser,
122 http_message_t* request,
124 SOCKINFO* info);
125
136#ifdef COMPA_HAVE_CTRLPT_SSDP
137int genaSubscribe(
139 UpnpClient_Handle client_handle,
141 const UpnpString* PublisherURL,
146 int* TimeOut,
148 UpnpString* out_sid);
149#endif
150
161#ifdef COMPA_HAVE_CTRLPT_SSDP
164 UpnpClient_Handle client_handle,
166 const UpnpString* in_sid);
167#endif
168
178#ifdef COMPA_HAVE_CTRLPT_SSDP
181 UpnpClient_Handle client_handle);
182#endif
183
184/*
185 * DEVICE
186 */
187
193#ifdef COMPA_HAVE_DEVICE_SSDP
196 UpnpDevice_Handle device_handle);
197#endif
198
209#ifdef COMPA_HAVE_CTRLPT_SSDP
212 UpnpClient_Handle client_handle,
214 const UpnpString* in_sid,
217 int* TimeOut);
218#endif
219
228#ifdef COMPA_HAVE_DEVICE_SSDP
229int genaNotifyAll(
231 UpnpDevice_Handle device_handle,
233 char* UDN,
235 char* servId,
237 char** VarNames,
239 char** VarValues,
241 int var_count);
242#endif
243
252#ifdef COMPA_HAVE_DEVICE_SSDP
255 UpnpDevice_Handle device_handle,
257 char* UDN,
259 char* servId,
261 IXML_Document* PropSet);
262#endif
263
272#ifdef COMPA_HAVE_DEVICE_SSDP
275 UpnpDevice_Handle device_handle,
277 char* UDN,
279 char* servId,
281 char** VarNames,
283 char** VarValues,
285 int var_count,
287 const Upnp_SID sid);
288#endif
289
300#ifdef COMPA_HAVE_DEVICE_SSDP
303 UpnpDevice_Handle device_handle,
305 char* UDN,
307 char* servId,
309 IXML_Document* PropSet,
311 const Upnp_SID sid);
312#endif
313
320void error_respond(
321 SOCKINFO* info,
322 int error_code,
323 http_message_t* hmsg
324);
325
326#endif /* COMPA_GENA_HPP */
char Upnp_SID[44]
Holds the subscription identifier for a subscription between a client and a device.
Definition API.hpp:434
int UpnpClient_Handle
Returned when a control point application registers with UpnpRegisterClient().
Definition API.hpp:415
int UpnpDevice_Handle
Returned when a device application registers with UpnpRegisterRootDevice(),UpnpRegisterRootDevice2(),...
Definition API.hpp:425
Structure of an HTTP parser object.
Structure of an HTTP message.
Functions to parse UPnP messages like requests and responses.
struct NOTIFY_THREAD_STRUCT notify_thread_struct
UpnpDevice_Handle device_handle
Definition gena.hpp:102
int clientSubscribeMutexInit()
Initialize the client subsribe mutex.
int genaUnregisterClient(UpnpClient_Handle client_handle)
Unsubcribes all the outstanding subscriptions and cleans the subscription list.
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.
int genaUnregisterDevice(UpnpDevice_Handle device_handle)
Cleans the service table of the device.
int genaUnSubscribe(UpnpClient_Handle client_handle, const UpnpString *in_sid)
Unsubscribes a SID.
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.
int genaNotifyAllExt(UpnpDevice_Handle device_handle, char *UDN, char *servId, IXML_Document *PropSet)
Sends a notification to all the subscribed control points.
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).
int clientSubscribeMutexDestroy()
Destroy the client subsribe mutex.
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...
DOMString propertySet
Definition gena.hpp:96
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.
int genaRenewSubscription(UpnpClient_Handle client_handle, const UpnpString *in_sid, int *TimeOut)
Renews a SID.
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.
Internal implementation of the class UpnpString.
Data structure representing the DOM Document.
Definition ixml.hpp:155
#define DOMString
The type of DOM strings.
Definition ixml.hpp:47
Manage network sockets and connections.
Additional socket information for connections and ssl.
Definition sock.hpp:65