/*================================================================ * ixmlElement_getElementsByTagName * Returns a nodeList of all descendant Elements with a given * tag name, in the order in which they are encountered in a preorder * traversal of this element tree. * External function. * * Parameters: * tagName: the name of the tag to match on. The special value "*" * matches all tags. * * Return Value: * a nodeList of matching element nodes. * *=================================================================*/ IXML_NodeList * ixmlElement_getElementsByTagName( IN IXML_Element * element, IN char *tagName ) { IXML_NodeList *returnNodeList = NULL; if( ( element != NULL ) && ( tagName != NULL ) ) { ixmlNode_getElementsByTagName( ( IXML_Node * ) element, tagName, &returnNodeList ); } return returnNodeList; }
IXML_NodeList *ixmlElement_getElementsByTagName( IXML_Element *element, const DOMString tagName) { IXML_NodeList *returnNodeList = NULL; if (element != NULL && tagName != NULL) { ixmlNode_getElementsByTagName( (IXML_Node *)element, tagName, &returnNodeList); } return returnNodeList; }
/*================================================================ * ixmlDocument_getElementsByTagName * Returns a nodeList of all the Elements with a given tag name * in the order in which they are encountered in a preorder traversal * of the document tree. * External function. * Parameters: * tagName: the name of the tag to match on. The special value "*" * matches all tags. * Return Value: * A new nodeList object containing all the matched Elements. * *=================================================================*/ IXML_NodeList * ixmlDocument_getElementsByTagName( IN IXML_Document * doc, IN char *tagName ) { IXML_NodeList *returnNodeList = NULL; if( ( doc == NULL ) || ( tagName == NULL ) ) { return NULL; } ixmlNode_getElementsByTagName( ( IXML_Node * ) doc, tagName, &returnNodeList ); return returnNodeList; }
IXML_NodeList *ixmlDocument_getElementsByTagName( IXML_Document *doc, const DOMString tagName) { IXML_NodeList *returnNodeList = NULL; if (doc == NULL || tagName == NULL) { return NULL; } ixmlNode_getElementsByTagName((IXML_Node *)doc, tagName, &returnNodeList); return returnNodeList; }
int WscUPnPCPHandleActionResponse( IN struct Upnp_Action_Complete *a_event) { IXML_NodeList *nodeList = NULL, *msgNodeList = NULL; IXML_Node *element, *child = NULL; char *varName = NULL; struct upnpDeviceNode *nodePtr; char *inStr = NULL, *pWscU2KMsg = NULL; unsigned char *decodeStr = NULL; int i, decodeLen = 0, wscU2KMsgLen; unsigned int UPnPDevIP = 0; DBGPRINTF(RT_DBG_INFO, "ErrCode = %d, CtrlUrl=%s!\n", a_event->ErrCode, a_event->CtrlUrl); if(a_event->ActionResult == NULL || a_event->ErrCode != 0) return 0; // Check if this device is already in the list nodePtr = WscDeviceList; while (nodePtr) { if(strcmp(nodePtr->device.services.ControlURL, a_event->CtrlUrl) == 0) { UPnPDevIP = nodePtr->device.ipAddr; nodePtr->device.timeCount = nodePtr->device.AdvrTimeOut; break; } nodePtr = nodePtr->next; } if (UPnPDevIP == 0) goto done; DBGPRINTF(RT_DBG_INFO, "Find the ActionResponse Device IP=%x\n", UPnPDevIP); /* We just support following ActionResponse from remote device. */ for (i=0; i < CP_RESP_SUPPORT_LIST_NUM; i++) { DBGPRINTF(RT_DBG_INFO, "check actionResNames[%d]=%s!\n", i, actionResNames[i]); nodeList = ixmlDocument_getElementsByTagName(a_event->ActionResult, actionResNames[i]); if(nodeList){ varName = stateVarNames[i]; break; } } if(nodeList == NULL) { DBGPRINTF(RT_DBG_INFO, "UnSupportted ActResponse!\n"); goto done; } if ((element = ixmlNodeList_item(nodeList, 0))) { //First check if we have supportted State Variable name! ixmlNode_getElementsByTagName(element, varName, &msgNodeList); if(msgNodeList != NULL) { DBGPRINTF(RT_DBG_INFO, "find stateVarName=%s!\n", varName); while((child = ixmlNode_getFirstChild(element))!= NULL) { // Find the Response text content! if (ixmlNode_getNodeType(child) == eTEXT_NODE) { inStr = strdup(ixmlNode_getNodeValue(child)); break; } element = child; } ixmlNodeList_free(msgNodeList); } } // Here depends on the ActionRequest and ActionResponse, dispatch to correct handler! if(inStr!= NULL) { DBGPRINTF(RT_DBG_INFO, "Receive a %s Message!\n", actionResNames[i]); DBGPRINTF(RT_DBG_INFO, "\tinStr=%s!\n", inStr); decodeLen = ILibBase64Decode((unsigned char *)inStr, strlen(inStr), &decodeStr); if((decodeLen > 0) && (ioctl_sock >= 0)) { RTMP_WSC_U2KMSG_HDR *msgHdr; WscEnvelope *msgEnvelope; int msgQIdx = -1; /* Prepare the msg buffers */ wscU2KMsgLen = wscU2KMsgCreate(&pWscU2KMsg, (char *)decodeStr, decodeLen, EAP_FRAME_TYPE_WSC); if (wscU2KMsgLen == 0) goto done; /* Prepare the msg envelope */ if ((msgEnvelope = wscEnvelopeCreate()) == NULL) goto done; msgEnvelope->callBack = wscCPPutMessage; /* Lock the msgQ and check if we can get a valid mailbox to insert our request! */ if (wscMsgQInsert(msgEnvelope, &msgQIdx) != WSC_SYS_SUCCESS) goto done; // Fill the session ID to the U2KMsg buffer header. msgHdr = (RTMP_WSC_U2KMSG_HDR *)pWscU2KMsg; msgHdr->envID = msgEnvelope->envID; // copy the Addr1 & Addr2 memcpy(msgHdr->Addr1, HostMacAddr, MAC_ADDR_LEN); memcpy(msgHdr->Addr2, &UPnPDevIP, sizeof(unsigned int)); // Now send the msg to kernel space. DBGPRINTF(RT_DBG_INFO, "(%s):Ready to send pWscU2KMsg(len=%d) to kernel by ioctl(%d)!\n", __FUNCTION__, wscU2KMsgLen, ioctl_sock); //wsc_hexdump("U2KMsg", pWscU2KMsg, wscU2KMsgLen); if(wsc_set_oid(RT_OID_WSC_EAPMSG, pWscU2KMsg, wscU2KMsgLen) != 0) wscEnvelopeRemove(msgEnvelope, msgQIdx); } } done: if (nodeList) ixmlNodeList_free(nodeList); if (inStr) free(inStr); if (pWscU2KMsg) free(pWscU2KMsg); if (decodeStr) free(decodeStr); //wsc_printEvent(UPNP_CONTROL_ACTION_COMPLETE, (void *)a_event); return 0; }