soap_device.c File Reference
`#include "config.h"`
`#include "ActionRequest.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>`
Include dependency graph for soap_device.c:

## 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 (IN SOCKINFO *info, IN int error_code, IN const char *err_msg, IN http_message_t *hmsg)
| Sends SOAP error response. More...
static UPNP_INLINE void | send_var_query_response (SOCKINFO *info, const char *var_value, http_message_t *hmsg)
| Sends response of get var status. More...
static UPNP_INLINE void | send_action_response (SOCKINFO *info, IXML_Document *action_resp, http_message_t *request)
| Sends the SOAP action response. More...
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. More...
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. More...
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. More...
static int | get_mpost_acton_hdrval (http_message_t *request, memptr *val)
| Get the SOAPACTION header value for M-POST request. More...
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. More...
static int | check_soap_request (soap_devserv_t *soap_info, IN IXML_Document *xml_doc, IXML_Node **req_node)
| Check validity of the SOAP request per UPnP specification. More...
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. More...

## Variables

static const char * | SOAP_BODY = "Body"
static const char * | SOAP_URN = "http:/""/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"
static const char * | Soap_Memory_out = "Out of Memory"

## Macro Definition Documentation

## SOAP_TIMEOUT

#define SOAP_TIMEOUT UPNP_TIMEOUT

timeout duration in secs for transmission/reception

Referenced by send_action_response(), and send_var_query_response().

## Function Documentation

## check_soap_request()

static int check_soap_request | ( | soap_devserv_t * | soap_info,
|  | IN IXML_Document * | xml_doc,
|  | IXML_Node ** | req_node
| ) |  |

static

Check validity of the SOAP request per UPnP specification.

Returns
  0 if OK, -1 on failure.

Parameters

  [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.

## check_soapaction_hdr()

static int check_soapaction_hdr | ( | http_message_t * | request,
|  | soap_devserv_t * | soap_info
| ) |  |

static

Check the header validity, and get the action name and the version of the service that the CP wants to use.

Returns
  UPNP_E_SUCCESS if OK, error number on failure.

Parameters

  [in] | request | HTTP request.
  [in,out] | soap_info | SOAP device/service information.

Referenced by soap_device_callback().

## get_dev_service()

static int get_dev_service | ( | http_message_t * | request,
|  | int | AddressFamily,
|  | soap_devserv_t * | soap_info
| ) |  |

static

Retrieve SOAP device/service information associated with request-URI, which includes the callback function to hand-over the request to the device application.

Returns
  0 if OK, -1 on error.

Parameters

  [in] | request | HTTP request.
  [in] | AddressFamily | Address family: AF_INET or AF_INET6.
  [out] | soap_info | SOAP device/service information.

References http_message_t::uri.

Referenced by soap_device_callback().

## get_mpost_acton_hdrval()

static int get_mpost_acton_hdrval | ( | http_message_t * | request,
|  | memptr * | val
| ) |  |

static

Get the SOAPACTION header value for M-POST request.

Returns
  UPNP_E_SUCCESS if OK, error number on failure.

Parameters

  [in] | request | HTTP request.
  [out] | val | Buffer to get the header value

## handle_invoke_action()

static void handle_invoke_action | ( | SOCKINFO * | info,
|  | http_message_t * | request,
|  | soap_devserv_t * | soap_info,
|  | IXML_Node * | req_node
| ) |  |

static

Handles the SOAP action request.

Parameters

  [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, ixmlPrintNode(), and memptr::length.

## handle_query_variable()

static UPNP_INLINE void handle_query_variable | ( | SOCKINFO * | info,
|  | http_message_t * | request,
|  | soap_devserv_t * | soap_info,
|  | IXML_Node * | req_node
| ) |  |

static

Handles the SOAP requests to querry the state variables. This functionality has been deprecated in the UPnP V1.0 architecture.

Parameters

  [in] | info | Socket info.
  [in] | request | HTTP Request.
  [in] | soap_info | SOAP device/service information.
  [in] | req_node | Node containing variable name.

References DOMString.

## send_action_response()

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] | info | Socket info.
  [in] | action_resp | The response document.
  [in] | request | Action request document.

References SOAP_TIMEOUT.

## send_error_response()

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] | info | Socket info.
  [in] | error_code | Error code.
  [in] | err_msg | Error message.
  [in] | hmsg | HTTP request.

## send_var_query_response()

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] | info | Socket info.
  [in] | var_value | Value of the state variable.
  [in] | hmsg | HTTP request.

References SOAP_TIMEOUT.

## soap_device_callback()

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.

Parameters

  [in] | parser | Parsed request received by the device.
  [in] | request | HTTP request.
  [in,out] | info | Socket info.

References check_soapaction_hdr(), SOCKINFO::foreign_sockaddr, get_dev_service(), has_xml_content_type(), and UPNP_E_SUCCESS.