1
///////////////////////////////////////////////////////////////////////////
3
// Copyright (c) 2000-2003 Intel Corporation
4
// All rights reserved.
6
// Redistribution and use in source and binary forms, with or without
7
// modification, are permitted provided that the following conditions are met:
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.
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.
30
///////////////////////////////////////////////////////////////////////////
35
#include "gena_device.h"
36
#include "gena_ctrlpt.h"
38
#include "httpparser.h"
39
#include "httpreadwrite.h"
40
#include "statcodes.h"
43
/************************************************************************
44
* Function : error_respond
47
* IN SOCKINFO *info: Structure containing information about the socket
48
* IN int error_code: error code that will be in the GENA response
49
* IN http_message_t* hmsg: GENA request Packet
52
* This function send an error message to the control point in the case
53
* incorrect GENA requests.
56
* UPNP_E_SUCCESS if successful else appropriate error
57
***************************************************************************/
59
error_respond( IN SOCKINFO * info,
61
IN http_message_t * hmsg )
66
// retrieve the minor and major version from the GENA request
67
http_CalcResponseVersion( hmsg->major_version,
68
hmsg->minor_version, &major, &minor );
70
http_SendStatusResponse( info, error_code, major, minor );
73
/************************************************************************
74
* Function : genaCallback
77
* IN http_parser_t *parser: represents the parse state of the request
78
* IN http_message_t* request: HTTP message containing GENA request
79
* INOUT SOCKINFO *info: Structure containing information about the socket
82
* This is the callback function called by the miniserver to handle
83
* incoming GENA requests.
86
* UPNP_E_SUCCESS if successful else appropriate error
87
***************************************************************************/
89
genaCallback( IN http_parser_t * parser,
90
IN http_message_t * request,
91
INOUT SOCKINFO * info )
93
xboolean found_function = FALSE;
95
if( request->method == HTTPMETHOD_SUBSCRIBE ) {
96
DEVICEONLY( found_function = TRUE;
97
if( httpmsg_find_hdr( request, HDR_NT, NULL ) == NULL )
100
gena_process_subscription_renewal_request
105
gena_process_subscription_request( info, request );}
108
( UPNP_ALL, GENA, __FILE__, __LINE__,
109
"got subscription request\n" ); )
113
if( request->method == HTTPMETHOD_UNSUBSCRIBE ) {
114
DEVICEONLY( found_function = TRUE;
116
gena_process_unsubscribe_request( info,
118
} else if( request->method == HTTPMETHOD_NOTIFY ) {
119
CLIENTONLY( found_function = TRUE;
121
gena_process_notification_event( info, request ); )
124
if( !found_function ) {
125
// handle missing functions of device or ctrl pt
126
error_respond( info, HTTP_NOT_IMPLEMENTED, request );
129
#endif // EXCLUDE_GENA