Ejemplo n.º 1
0
/****************************************************************************
*	Function :	soap_device_callback
*
*	Parameters :
*		  IN http_parser_t *parser : Parsed request received by the device
*		  IN http_message_t* request :	HTTP request
*		  INOUT SOCKINFO *info :	socket info
*
*	Description :	This is a callback called by minisever after receiving
*		the request from the control point. This function will start
*		processing the request. It calls handle_invoke_action to handle the
*		SOAP action
*
*	Return :	void
*
*	Note :
****************************************************************************/
void
soap_device_callback( IN http_parser_t * parser,
                      IN http_message_t * request,
                      INOUT SOCKINFO * info )
{
    int err_code;
    const char *err_str;
    memptr action_name;
    IXML_Document *xml_doc = NULL;

    // set default error
    err_code = SOAP_INVALID_ACTION;
    err_str = Soap_Invalid_Action;

    // validate: content-type == text/xml
    if( !has_xml_content_type( request ) ) {
        goto error_handler;
    }
    // type of request
    if( get_request_type( request, &action_name ) != 0 ) {
        goto error_handler;
    }
    // parse XML
    err_code = ixmlParseBufferEx( request->entity.buf, &xml_doc );
    if( err_code != IXML_SUCCESS ) {
        if( err_code == IXML_INSUFFICIENT_MEMORY ) {
            err_code = UPNP_E_OUTOF_MEMORY;
        } else {
            err_code = SOAP_ACTION_FAILED;
        }

        err_str = "XML error";
        goto error_handler;
    }

    if( action_name.length == 0 ) {
        // query var
        handle_query_variable( info, request, xml_doc );
    } else {
        // invoke action
        handle_invoke_action( info, request, action_name, xml_doc );
    }

    err_code = 0;               // no error

error_handler:
    ixmlDocument_free( xml_doc );
    if( err_code != 0 ) {
        send_error_response( info, err_code, err_str, request );
    }
}
Ejemplo n.º 2
0
/*!
 * \brief This is a callback called by minisever after receiving the request
 * from the control point. This function will start processing the request.
 * It calls handle_invoke_action to handle the SOAP action.
 */
void soap_device_callback(
    int iface,
	/*! [in] Parsed request received by the device. */
	http_parser_t *parser,
	/*! [in] HTTP request. */
	http_message_t *request,
	/*! [in,out] Socket info. */
	SOCKINFO *info)
{
	int err_code;
	const char *err_str;
	memptr action_name;
	IXML_Document *xml_doc = NULL;

	/* set default error */
	err_code = SOAP_INVALID_ACTION;
	err_str = Soap_Invalid_Action;

	/* validate: content-type == text/xml */
	if (!has_xml_content_type(request))
		goto error_handler;
	/* type of request */
	if (get_request_type(request, &action_name) != 0)
		goto error_handler;
	/* parse XML */
	err_code = ixmlParseBufferEx(request->entity.buf, &xml_doc);
	if (err_code != IXML_SUCCESS) {
		if (err_code == IXML_INSUFFICIENT_MEMORY)
			err_code = UPNP_E_OUTOF_MEMORY;
		else
			err_code = SOAP_ACTION_FAILED;
		err_str = "XML error";
		goto error_handler;
	}
	if (action_name.length == 0)
		/* query var */
		handle_query_variable(iface, info, request, xml_doc);
	else
		/* invoke action */
		handle_invoke_action(iface, info, request, action_name, xml_doc);
	/* no error */
	err_code = 0;

 error_handler:
	ixmlDocument_free(xml_doc);
	if (err_code != 0)
		send_error_response(info, err_code, err_str, request);
	return;
	parser = parser;
}