libUPnP  1.6.17
Defines | Functions | Variables
soap_device.c File Reference
#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"
Include dependency graph for soap_device.c:

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"

Detailed Description


Define Documentation

#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().


Function Documentation

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.

Returns:
UPNP_E_SUCCESS if successful else returns appropriate error.
Parameters:
[in]requestHTTP request.
[in]urnURN.
[out]actionNameName 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.

Returns:
UPNP_E_SUCCESS if successful else returns appropriate error.

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.

Returns:
0 if successful, or -1 if fails.
Parameters:
[in]TempDocThe root DOM node.
[in]NodeNameIXML_Node name to be searched.
[out]RespNodeResponse/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.

Returns:
UPNP_E_SUCCESS if successful else returns appropriate error.
Parameters:
[in]requestHTTP request.
[in]isQueryflag for a querry.
[in]actionDocAction request document.
[in]AddressFamily.
[out]device_udnDevice UDN string.
[out]service_idService ID string.
[out]callbackcallback function of the device application.
[out]cookiecookie 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.

Returns:
0 if successful else returns appropriate error.
Parameters:
[in]requestHTTP request.
[out]action_nameSOAP 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.

Returns:
0 if successful else returns -1.
Parameters:
[in]TempDocDocument containing variable request.
[out]VarNameName 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.

Parameters:
[in]infoSocket info.
[in]requestHTTP Request.
[in]action_nameName of the SOAP Action.
[in]xml_docDocument 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.

Parameters:
[in]infoSocket info.
[in]requestHTTP request.
[in]xml_docDocument 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.

Parameters:
[in]infoSocket info.
[in]action_respThe response document.
[in]requestAction 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.

Parameters:
[in]infoSocket info.
[in]error_codeError code.
[in]err_msgError message.
[in]hmsgHTTP 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.

Parameters:
[in]infoSocket info.
[in]var_valueValue of the state variable.
[in]hmsgHTTP 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.

Parameters:
[in]parserParsed request received by the device.
[in]requestHTTP request.
[in,out]infoSocket 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().