libUPnP 1.14.19
|
#include "config.h"
#include "UpnpActionRequest.h"
#include "httpparser.h"
#include "httpreadwrite.h"
#include "parsetools.h"
#include "soaplib.h"
#include "ssdplib.h"
#include "statcodes.h"
#include "unixutil.h"
#include "upnpapi.h"
#include <assert.h>
#include <string.h>
Data Structures | |
struct | soap_devserv_t |
Macros | |
#define | SOAP_TIMEOUT UPNP_TIMEOUT |
#define | SREQ_HDR_NOT_FOUND -1 |
#define | SREQ_BAD_HDR_FORMAT -2 |
#define | SREQ_NOT_EXTENDED -3 |
#define | SOAP_INVALID_ACTION 401 |
#define | SOAP_INVALID_ARGS 402 |
#define | SOAP_OUT_OF_SYNC 403 |
#define | SOAP_INVALID_VAR 404 |
#define | SOAP_ACTION_FAILED 501 |
#define | SOAP_MEMORY_OUT 603 |
Typedefs | |
typedef struct soap_devserv_t | soap_devserv_t |
Functions | |
static void | send_error_response (SOCKINFO *info, int error_code, const char *err_msg, http_message_t *hmsg) |
Sends SOAP error response. | |
static UPNP_INLINE void | send_var_query_response (SOCKINFO *info, const char *var_value, http_message_t *hmsg) |
Sends response of get var status. | |
static UPNP_INLINE void | send_action_response (SOCKINFO *info, IXML_Document *action_resp, http_message_t *request) |
Sends the SOAP action response. | |
static UPNP_INLINE void | handle_query_variable (SOCKINFO *info, http_message_t *request, soap_devserv_t *soap_info, IXML_Node *req_node) |
Handles the SOAP requests to querry the state variables. This functionality has been deprecated in the UPnP V1.0 architecture. | |
static void | handle_invoke_action (SOCKINFO *info, http_message_t *request, soap_devserv_t *soap_info, IXML_Node *req_node) |
Handles the SOAP action request. | |
static int | get_dev_service (http_message_t *request, int AddressFamily, soap_devserv_t *soap_info) |
Retrieve SOAP device/service information associated with request-URI, which includes the callback function to hand-over the request to the device application. | |
static int | get_mpost_acton_hdrval (http_message_t *request, memptr *val) |
Get the SOAPACTION header value for M-POST request. | |
static int | check_soapaction_hdr (http_message_t *request, soap_devserv_t *soap_info) |
Check the header validity, and get the action name and the version of the service that the CP wants to use. | |
static int | check_soap_request (soap_devserv_t *soap_info, IXML_Document *xml_doc, IXML_Node **req_node) |
Check validity of the SOAP request per UPnP specification. | |
void | soap_device_callback (http_parser_t *parser, http_message_t *request, SOCKINFO *info) |
This is a callback called by minisever after receiving the request from the control point. After HTTP processing, it calls handle_soap_request to start SOAP processing. | |
Variables | |
static const char * | SOAP_BODY = "Body" |
static const char * | SOAP_URN |
static const char * | QUERY_STATE_VAR_URN = "urn:schemas-upnp-org:control-1-0" |
static const char * | Soap_Invalid_Action = "Invalid Action" |
static const char * | Soap_Action_Failed = "Action Failed" |
static const char * | Soap_Invalid_Var = "Invalid Var" |
static const char * | Soap_Memory_out = "Out of Memory" |
#define SOAP_TIMEOUT UPNP_TIMEOUT |
timeout duration in secs for transmission/reception
|
static |
Check validity of the SOAP request per UPnP specification.
[in] | soap_info | SOAP device/service information. |
[in] | xml_doc | Document containing the SOAP action request. |
[out] | req_node | Node containing the SOAP action request/variable name. |
References memptr::buf, DOMString, ixmlNode_getFirstChild(), ixmlNode_getLocalName(), ixmlNode_getNamespaceURI(), and ixmlNode_getNodeType().
Referenced by soap_device_callback().
|
static |
Check the header validity, and get the action name and the version of the service that the CP wants to use.
[in] | request | HTTP request. |
[in,out] | soap_info | SOAP device/service information. |
References memptr::buf, get_mpost_acton_hdrval(), memptr::length, http_message_t::method, namecopy(), PARSE_OK, and UPNP_E_SUCCESS.
Referenced by soap_device_callback().
|
static |
Retrieve SOAP device/service information associated with request-URI, which includes the callback function to hand-over the request to the device application.
[in] | request | HTTP request. |
[in] | AddressFamily | Address family: AF_INET or AF_INET6. |
[out] | soap_info | SOAP device/service information. |
References Handle_Info::Callback, Handle_Info::Cookie, GetDeviceHandleInfoForPath(), namecopy(), and http_message_t::uri.
Referenced by soap_device_callback().
|
static |
Get the SOAPACTION header value for M-POST request.
[in] | request | HTTP request. |
[out] | val | Buffer to get the header value |
References memptr::buf, membuffer::buf, memptr::length, membuffer::length, http_message_t::method, PARSE_OK, UPNP_E_OUTOF_MEMORY, UPNP_E_SUCCESS, and http_header_t::value.
Referenced by check_soapaction_hdr().
|
static |
Handles the SOAP action request.
[in] | info | Socket info. |
[in] | request | HTTP Request. |
[in] | soap_info | SOAP device/service information. |
[in] | req_node | Node containing the SOAP action request. |
References memptr::buf, DOMString, SOCKINFO::foreign_sockaddr, ixmlDocument_free(), ixmlFreeDOMString(), ixmlParseBufferEx(), ixmlPrintNode(), memptr::length, send_action_response(), send_error_response(), UPNP_CONTROL_ACTION_REQUEST, UPNP_E_SUCCESS, UpnpActionRequest_delete(), UpnpActionRequest_get_ActionResult(), UpnpActionRequest_get_ErrCode(), UpnpActionRequest_get_ErrStr_cstr(), UpnpActionRequest_new(), UpnpActionRequest_set_ActionRequest(), UpnpActionRequest_set_ActionResult(), UpnpActionRequest_set_CtrlPtIPAddr(), UpnpActionRequest_set_ErrCode(), UpnpActionRequest_strcpy_ActionName(), UpnpActionRequest_strcpy_DevUDN(), UpnpActionRequest_strcpy_ServiceID(), UpnpActionRequest_strncpy_Os(), and UpnpPrintf().
Referenced by soap_device_callback().
|
static |
Handles the SOAP requests to querry the state variables. This functionality has been deprecated in the UPnP V1.0 architecture.
[in] | info | Socket info. |
[in] | request | HTTP Request. |
[in] | soap_info | SOAP device/service information. |
[in] | req_node | Node containing variable name. |
References DOMString, SOCKINFO::foreign_sockaddr, ixmlNode_getNodeValue(), send_error_response(), send_var_query_response(), UPNP_CONTROL_GET_VAR_REQUEST, UPNP_E_SUCCESS, UpnpPrintf(), UpnpStateVarRequest_delete(), UpnpStateVarRequest_get_CurrentVal(), UpnpStateVarRequest_get_ErrCode(), UpnpStateVarRequest_get_ErrStr(), UpnpStateVarRequest_get_ErrStr_cstr(), UpnpStateVarRequest_new(), UpnpStateVarRequest_set_CtrlPtIPAddr(), UpnpStateVarRequest_set_ErrCode(), UpnpStateVarRequest_strcpy_DevUDN(), UpnpStateVarRequest_strcpy_ServiceID(), UpnpStateVarRequest_strcpy_StateVarName(), and UpnpString_get_Length().
Referenced by soap_device_callback().
|
static |
Sends the SOAP action response.
[in] | info | Socket info. |
[in] | action_resp | The response document. |
[in] | request | Action request document. |
References membuffer::buf, http_MakeMessage(), http_SendMessage(), ixmlFreeDOMString(), ixmlPrintNode(), membuffer::length, send_error_response(), SOAP_TIMEOUT, UPNP_E_OUTOF_MEMORY, and UpnpPrintf().
Referenced by handle_invoke_action().
|
static |
Sends SOAP error response.
[in] | info | Socket info. |
[in] | error_code | Error code. |
[in] | err_msg | Error message. |
[in] | hmsg | HTTP request. |
References membuffer::buf, http_MakeMessage(), http_SendMessage(), membuffer::length, and SOAP_TIMEOUT.
Referenced by handle_invoke_action(), handle_query_variable(), and send_action_response().
|
static |
Sends response of get var status.
[in] | info | Socket info. |
[in] | var_value | Value of the state variable. |
[in] | hmsg | HTTP request. |
References membuffer::buf, http_MakeMessage(), http_SendMessage(), membuffer::length, and SOAP_TIMEOUT.
Referenced by handle_query_variable().
void soap_device_callback | ( | http_parser_t * | parser, |
http_message_t * | request, | ||
SOCKINFO * | info | ||
) |
This is a callback called by minisever after receiving the request from the control point. After HTTP processing, it calls handle_soap_request to start SOAP processing.
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.
[in] | parser | Parsed request received by the device. |
[in] | request | HTTP request. |
[in,out] | info | Socket info. |
References memptr::buf, check_soap_request(), check_soapaction_hdr(), http_message_t::entity, SOCKINFO::foreign_sockaddr, get_dev_service(), handle_invoke_action(), handle_query_variable(), has_xml_content_type(), ixmlDocument_free(), ixmlParseBufferEx(), UPNP_E_OUTOF_MEMORY, and UPNP_E_SUCCESS.
Referenced by UpnpInitPreamble().
|
static |