UPnPsdk 0.1
Universal Plug and Play +, Software Development Kit
 
Loading...
Searching...
No Matches
gena_callback2.cpp
Go to the documentation of this file.
1/*******************************************************************************
2 *
3 * Copyright (c) 2000-2003 Intel Corporation
4 * All rights reserved.
5 * Copyright (C) 2022+ GPL 3 and higher by Ingo Höft, <Ingo@Hoeft-online.de>
6 * Redistribution only with this Copyright remark. Last modified: 2024-03-01
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * - Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the following disclaimer.
13 * - Redistributions in binary form must reproduce the above copyright notice,
14 * this list of conditions and the following disclaimer in the documentation
15 * and/or other materials provided with the distribution.
16 * - Neither name of Intel Corporation nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
28 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 ******************************************************************************/
38#include <gena.hpp>
39#include <gena_ctrlpt.hpp>
40#include <gena_device.hpp>
41
42#include <httpreadwrite.hpp>
43#include <statcodes.hpp>
44#include <unixutil.hpp>
45
46
47void error_respond(SOCKINFO* info, int error_code, http_message_t* hmsg) {
48 int major, minor;
49
50 /* retrieve the minor and major version from the GENA request */
52 &minor);
53
54 http_SendStatusResponse(info, error_code, major, minor);
55}
56
57
59 SOCKINFO* info) {
60 int found_function = 0;
61 (void)parser;
62
63 if (request->method == HTTPMETHOD_SUBSCRIBE) {
64#ifdef COMPA_HAVE_DEVICE_SSDP
65 found_function = 1;
66 if (httpmsg_find_hdr(request, HDR_NT, NULL) == NULL) {
67 /* renew subscription */
69 } else {
70 /* subscribe */
72 }
73 UpnpPrintf(UPNP_ALL, GENA, __FILE__, __LINE__,
74 "got subscription request\n");
75 } else if (request->method == HTTPMETHOD_UNSUBSCRIBE) {
76 found_function = 1;
77 /* unsubscribe */
79#endif
80 } else if (request->method == HTTPMETHOD_NOTIFY) {
81#ifdef COMPA_HAVE_CTRLPT_SSDP
82 found_function = 1;
83 /* notify */
85#endif
86 }
87
88 if (!found_function) {
89 /* handle missing functions of device or ctrl pt */
90 error_respond(info, HTTP_NOT_IMPLEMENTED, request);
91 }
92 return;
93}
void http_CalcResponseVersion(int request_major_vers, int request_minor_vers, int *response_major_vers, int *response_minor_vers)
Calculate HTTP response versions based on the request versions.
int http_SendStatusResponse(SOCKINFO *info, int http_status_code, int request_major_version, int request_minor_version)
Generate a response message for the status query and send the status response.
http_method_t method
Http method of an outgoing request.
int major_version
Http major version.
#define HDR_NT
Type of a HTTP header.
int minor_version
Http minor version.
Structure of an HTTP parser object.
Structure of an HTTP message.
Manage Eventing with GENA, the General Event Notification Architecture.
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.
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.
void gena_process_notification_event(SOCKINFO *info, http_message_t *event)
This function processes NOTIFY events that are sent by devices.
Processes NOTIFY events that are sent by devices.
void gena_process_subscription_request(SOCKINFO *info, http_message_t *request)
Handles a subscription request from a ctrl point. The socket is not closed on return.
void gena_process_unsubscribe_request(SOCKINFO *info, http_message_t *request)
Handles a subscription cancellation request from a ctrl point. The connection is not destroyed on ret...
void gena_process_subscription_renewal_request(SOCKINFO *info, http_message_t *request)
Handles a subscription renewal request from a ctrl point. The connection is not destroyed on return.
Handles subscriptions from a control point.
http_header_t * httpmsg_find_hdr(http_message_t *msg, int header_name_id, memptr *value)
Finds header from a list, with the given 'name_id'.
Additional socket information for connections and ssl.
Definition sock.hpp:65
HTTP status codes.
Unix-specific network utilities.
UPnPsdk_VIS void UpnpPrintf(Upnp_LogLevel DLevel, Dbg_Module Module, const char *DbgFileName, int DbgLineNo, const char *FmtStr,...)
Prints the debug statement.