/**************************************************************************** * Function : check_soap_body * * Parameters : * IN IXML_Document *doc : soap body xml document * IN const char *urn : * IN const char *actionName : Name of the requested action * * Description : This function checks the soap body xml came in the * SOAP request. * * Return : int * UPNP_E_SUCCESS if successful else returns appropriate error * * Note : ****************************************************************************/ static int check_soap_body( IN IXML_Document * doc, IN const char *urn, IN const char *actionName ) { IXML_NodeList *nl = NULL; IXML_Node *bodyNode = NULL; IXML_Node *actionNode = NULL; const DOMString ns = NULL; const DOMString name = NULL; int ret_code = UPNP_E_INVALID_ACTION; nl = ixmlDocument_getElementsByTagNameNS( doc, SOAP_URN, SOAP_BODY ); if( nl ) { bodyNode = ixmlNodeList_item( nl, 0 ); if( bodyNode ) { actionNode = ixmlNode_getFirstChild( bodyNode ); if( actionNode ) { ns = ixmlNode_getNamespaceURI( actionNode ); name = ixmlNode_getLocalName( actionNode ); if (name && ns && !strcmp( actionName, name ) && !strcmp( urn, ns ) ) { ret_code = UPNP_E_SUCCESS; } } } ixmlNodeList_free( nl ); } return ret_code; }
/******************************************************************************** * upnp_igd_state_update * * Description: * Handle a uPnP event that was received. Process the event and update * the appropriate service state table. * * Parameters: * igd_ctxt -- The upnp igd context * device_node -- The device updated * service -- The service updated * changed_variables -- The updated variables * values -- The values of variables to update * ********************************************************************************/ void upnp_igd_state_update(upnp_igd_context* igd_ctxt, upnp_igd_device_node *device_node, int service, IXML_Document *changed_variables, char **values) { IXML_NodeList *properties; IXML_NodeList *variables; IXML_Element *property; IXML_Element *variable; long unsigned int length; long unsigned int length1; long unsigned int i; int j; char *tmpstate = NULL; upnp_igd_print(igd_ctxt, UPNP_IGD_DEBUG, "IGD State Update (service %d):", service); /* Find all of the e:property tags in the document */ properties = ixmlDocument_getElementsByTagNameNS(changed_variables, UPNPDeviceType, "property"); if (properties) { length = ixmlNodeList_length(properties); for (i = 0; i < length; i++) { /* Loop through each property change found */ property = (IXML_Element *)ixmlNodeList_item(properties, i); /* For each variable name in the state table, * check if this is a corresponding property change */ for (j = 0; j < IGDVarCount[service]; j++) { variables = ixmlElement_getElementsByTagNameNS(property, IGDServiceType[service], IGDVarName[service][j]); /* If a match is found, extract * the value, and update the state table */ if (variables) { length1 = ixmlNodeList_length(variables); if (length1) { variable = (IXML_Element *) ixmlNodeList_item(variables, 0); tmpstate = upnp_igd_get_element_value(igd_ctxt, variable); if (tmpstate) { if(strcmp(values[j], tmpstate)) { upnp_igd_strncpy(values[j], tmpstate, IGD_MAX_VAR_LEN); upnp_igd_var_updated(igd_ctxt, device_node, service, j, values[j]); } } if (tmpstate) { free(tmpstate); } tmpstate = NULL; } ixmlNodeList_free(variables); variables = NULL; } } } ixmlNodeList_free(properties); } return; }
/*! * \brief Checks the soap body xml came in the SOAP request. * * \return UPNP_E_SUCCESS if successful else returns appropriate error. */ static int check_soap_body( /* [in] soap body xml document. */ IN IXML_Document *doc, /* [in] URN. */ IN const char *urn, /* [in] Name of the requested action. */ IN const char *actionName) { IXML_NodeList *nl = NULL; IXML_Node *bodyNode = NULL; IXML_Node *actionNode = NULL; const DOMString ns = NULL; const DOMString name = NULL; int ret_code = UPNP_E_INVALID_ACTION; nl = ixmlDocument_getElementsByTagNameNS(doc, SOAP_URN, SOAP_BODY); if (nl) { bodyNode = ixmlNodeList_item(nl, 0); if (bodyNode) { actionNode = ixmlNode_getFirstChild(bodyNode); if (actionNode) { ns = ixmlNode_getNamespaceURI(actionNode); name = ixmlNode_getLocalName(actionNode); /* Don't check version number, to accept a * request comming on a v1 service when * publishing a v2 service */ if (name && ns && !strcmp(actionName, name) && !strncmp(urn, ns, strlen (urn) - 2)) ret_code = UPNP_E_SUCCESS; } } ixmlNodeList_free(nl); } return ret_code; }
RTPXML_NodeList *rtpxmlDocument_getElementsByTagNameNS(RTPXML_Document* doc,DOMString namespaceURI,DOMString localName) { return (RTPXML_NodeList *)ixmlDocument_getElementsByTagNameNS((IXML_Document *)doc, namespaceURI,localName); }