libUPnP
1.6.17
|
#include "config.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"
Defines | |
#define | SOAP_TIMEOUT UPNP_TIMEOUT |
#define | SREQ_HDR_NOT_FOUND -1 |
#define | SREQ_BAD_HDR_FORMAT -2 |
#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 |
Functions | |
static UPNP_INLINE int | get_request_type (http_message_t *request, memptr *action_name) |
This function retrives the name of the SOAP action. | |
static void | send_error_response (IN SOCKINFO *info, IN int error_code, IN const char *err_msg, IN 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 int | get_action_node (IXML_Document *TempDoc, char *NodeName, IXML_Document **RespNode) |
Separates the action node from the root DOM node. | |
static int | check_soap_body (IN IXML_Document *doc, IN const char *urn, IN const char *actionName) |
Checks the soap body xml came in the SOAP request. | |
static int | check_soap_action_header (http_message_t *request, const char *urn, char **actionName) |
Checks the HTTP header of the SOAP request coming from the control point. | |
static int | get_device_info (http_message_t *request, int isQuery, IXML_Document *actionDoc, int AddressFamily, OUT char device_udn[LINE_SIZE], char service_id[LINE_SIZE], Upnp_FunPtr *callback, void **cookie) |
Retrives all the information needed to process the incoming SOAP request. It finds the device and service info and also the callback function to hand-over the request to the device application. | |
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 int | get_var_name (IXML_Document *TempDoc, char *VarName) |
Finds the name of the state variable asked in the SOAP request. | |
static UPNP_INLINE void | handle_query_variable (SOCKINFO *info, http_message_t *request, IXML_Document *xml_doc) |
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 (IN SOCKINFO *info, IN http_message_t *request, IN memptr action_name, IN IXML_Document *xml_doc) |
Handles the SOAP action request. It checks the integrity of the SOAP action request and gives the call back to the device application. | |
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. This function will start processing the request. It calls handle_invoke_action to handle the SOAP action. | |
Variables | |
static const char * | SOAP_BODY = "Body" |
static const char * | SOAP_URN = "/schemas.xmlsoap.org/soap/envelope/" |
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" |
#define SOAP_TIMEOUT UPNP_TIMEOUT |
timeout duration in secs for transmission/reception
Referenced by send_action_response(), send_error_response(), and send_var_query_response().
static int check_soap_action_header | ( | http_message_t * | request, |
const char * | urn, | ||
char ** | actionName | ||
) | [static] |
Checks the HTTP header of the SOAP request coming from the control point.
[in] | request | HTTP request. |
[in] | urn | URN. |
[out] | actionName | Name of the SOAP action. |
References membuffer::buf, membuffer::length, UPNP_E_INVALID_ACTION, UPNP_E_OUTOF_MEMORY, UPNP_E_SUCCESS, and http_header_t::value.
Referenced by get_device_info().
static int check_soap_body | ( | IN IXML_Document * | doc, |
IN const char * | urn, | ||
IN const char * | actionName | ||
) | [static] |
Checks the soap body xml came in the SOAP request.
References DOMString, ixmlDocument_getElementsByTagNameNS(), ixmlNode_getFirstChild(), ixmlNode_getLocalName(), ixmlNode_getNamespaceURI(), ixmlNodeList_free(), ixmlNodeList_item(), UPNP_E_INVALID_ACTION, and UPNP_E_SUCCESS.
Referenced by get_device_info().
static UPNP_INLINE int get_action_node | ( | IXML_Document * | TempDoc, |
char * | NodeName, | ||
IXML_Document ** | RespNode | ||
) | [static] |
Separates the action node from the root DOM node.
[in] | TempDoc | The root DOM node. |
[in] | NodeName | IXML_Node name to be searched. |
[out] | RespNode | Response/Output node. |
References DOMString, ixmlElement_getElementsByTagNameNS(), ixmlFreeDOMString(), ixmlNode_getFirstChild(), ixmlNode_getNodeName(), ixmlNodeList_free(), ixmlNodeList_item(), ixmlParseBufferEx(), ixmlPrintNode(), and UpnpPrintf().
Referenced by handle_invoke_action().
static int get_device_info | ( | http_message_t * | request, |
int | isQuery, | ||
IXML_Document * | actionDoc, | ||
int | AddressFamily, | ||
OUT char | device_udn[LINE_SIZE], | ||
char | service_id[LINE_SIZE], | ||
Upnp_FunPtr * | callback, | ||
void ** | cookie | ||
) | [static] |
Retrives all the information needed to process the incoming SOAP request. It finds the device and service info and also the callback function to hand-over the request to the device application.
[in] | request | HTTP request. |
[in] | isQuery | flag for a querry. |
[in] | actionDoc | Action request document. |
[in] | AddressFamily | . |
[out] | device_udn | Device UDN string. |
[out] | service_id | Service ID string. |
[out] | callback | callback function of the device application. |
[out] | cookie | cookie stored by device application. |
References Handle_Info::Callback, check_soap_action_header(), check_soap_body(), Handle_Info::Cookie, GetDeviceHandleInfo(), namecopy(), Handle_Info::ServiceTable, UPNP_E_INVALID_ACTION, UPNP_E_INVALID_SERVICE, UPNP_E_OUTOF_MEMORY, UPNP_E_SUCCESS, and http_message_t::uri.
Referenced by handle_invoke_action(), and handle_query_variable().
static UPNP_INLINE int get_request_type | ( | http_message_t * | request, |
memptr * | action_name | ||
) | [static] |
This function retrives the name of the SOAP action.
[in] | request | HTTP request. |
[out] | action_name | SOAP action name. |
References memptr::buf, membuffer::buf, memptr::length, membuffer::length, http_message_t::method, PARSE_OK, UPNP_E_OUTOF_MEMORY, and http_header_t::value.
Referenced by soap_device_callback().
static UPNP_INLINE int get_var_name | ( | IXML_Document * | TempDoc, |
char * | VarName | ||
) | [static] |
Finds the name of the state variable asked in the SOAP request.
[in] | TempDoc | Document containing variable request. |
[out] | VarName | Name of the state varible. |
References DOMString, ixmlNode_getFirstChild(), ixmlNode_getNodeName(), ixmlNode_getNodeValue(), linecopy(), and UpnpPrintf().
Referenced by handle_query_variable().
static void handle_invoke_action | ( | IN SOCKINFO * | info, |
IN http_message_t * | request, | ||
IN memptr | action_name, | ||
IN IXML_Document * | xml_doc | ||
) | [static] |
Handles the SOAP action request. It checks the integrity of the SOAP action request and gives the call back to the device application.
[in] | info | Socket info. |
[in] | request | HTTP Request. |
[in] | action_name | Name of the SOAP Action. |
[in] | xml_doc | Document containing the SOAP action request. |
References Upnp_Action_Request::ActionName, Upnp_Action_Request::ActionRequest, Upnp_Action_Request::ActionResult, Upnp_Action_Request::CtrlPtIPAddr, Upnp_Action_Request::DevUDN, Upnp_Action_Request::ErrCode, Upnp_Action_Request::ErrStr, get_action_node(), get_device_info(), ixmlDocument_free(), linecopy(), namecopy(), send_action_response(), send_error_response(), Upnp_Action_Request::ServiceID, UPNP_CONTROL_ACTION_REQUEST, UPNP_E_SUCCESS, and UpnpPrintf().
Referenced by soap_device_callback().
static UPNP_INLINE void handle_query_variable | ( | SOCKINFO * | info, |
http_message_t * | request, | ||
IXML_Document * | xml_doc | ||
) | [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] | xml_doc | Document containing the variable request SOAP message. |
References Upnp_State_Var_Request::CtrlPtIPAddr, Upnp_State_Var_Request::CurrentVal, Upnp_State_Var_Request::DevUDN, Upnp_State_Var_Request::ErrCode, Upnp_State_Var_Request::ErrStr, SOCKINFO::foreign_sockaddr, get_device_info(), get_var_name(), ixmlFreeDOMString(), linecopy(), namecopy(), send_error_response(), send_var_query_response(), Upnp_State_Var_Request::ServiceID, Upnp_State_Var_Request::StateVarName, UPNP_CONTROL_GET_VAR_REQUEST, UPNP_E_SUCCESS, and UpnpPrintf().
Referenced by soap_device_callback().
static UPNP_INLINE void send_action_response | ( | SOCKINFO * | info, |
IXML_Document * | action_resp, | ||
http_message_t * | request | ||
) | [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 void send_error_response | ( | IN SOCKINFO * | info, |
IN int | error_code, | ||
IN const char * | err_msg, | ||
IN http_message_t * | hmsg | ||
) | [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(), send_action_response(), and soap_device_callback().
static UPNP_INLINE void send_var_query_response | ( | SOCKINFO * | info, |
const char * | var_value, | ||
http_message_t * | hmsg | ||
) | [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. 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, http_message_t::entity, get_request_type(), handle_invoke_action(), handle_query_variable(), has_xml_content_type(), ixmlDocument_free(), ixmlParseBufferEx(), memptr::length, send_error_response(), and UPNP_E_OUTOF_MEMORY.
Referenced by UpnpInitPreamble().