/*! * \brief Handles the SOAP requests to querry the state variables. * This functionality has been deprecated in the UPnP V1.0 architecture. */ static UPNP_INLINE void handle_query_variable( IN SOCKINFO *info, IN http_message_t *request, IN IXML_Document *xml_doc) { UpnpStateVarRequest *variable = UpnpStateVarRequest_new(); Upnp_FunPtr soap_event_callback; void *cookie; char var_name[LINE_SIZE]; const char *err_str; int err_code; if (get_var_name(xml_doc, var_name) != 0) { send_error_response(info, SOAP_INVALID_VAR, Soap_Invalid_Var, request); return; } /* get info for event */ err_code = get_device_info(request, 1, xml_doc, info->foreign_sockaddr.ss_family, (UpnpString *)UpnpStateVarRequest_get_DevUDN(variable), (UpnpString *)UpnpStateVarRequest_get_ServiceID(variable), &soap_event_callback, &cookie); if (err_code != 0) { send_error_response(info, SOAP_INVALID_VAR, Soap_Invalid_Var, request); return; } UpnpStateVarRequest_set_ErrCode(variable, UPNP_E_SUCCESS); UpnpStateVarRequest_strcpy_StateVarName(variable, var_name); UpnpStateVarRequest_set_CtrlPtIPAddr(variable, &info->foreign_sockaddr); /* send event */ soap_event_callback(UPNP_CONTROL_GET_VAR_REQUEST, variable, cookie); UpnpPrintf(UPNP_INFO, SOAP, __FILE__, __LINE__, "Return from callback for var request\n"); /* validate, and handle result */ if (UpnpStateVarRequest_get_CurrentVal(variable) == NULL) { err_code = SOAP_ACTION_FAILED; err_str = Soap_Action_Failed; send_error_response(info, SOAP_INVALID_VAR, Soap_Invalid_Var, request); return; } if (UpnpStateVarRequest_get_ErrCode(variable) != UPNP_E_SUCCESS) { if (UpnpString_get_Length(UpnpStateVarRequest_get_ErrStr(variable)) > 0) { err_code = SOAP_INVALID_VAR; err_str = Soap_Invalid_Var; } else { err_code = UpnpStateVarRequest_get_ErrCode(variable); err_str = UpnpStateVarRequest_get_ErrStr_cstr(variable); } send_error_response(info, err_code, err_str, request); return; } /* send response */ send_var_query_response(info, UpnpStateVarRequest_get_CurrentVal(variable), request); UpnpStateVarRequest_delete(variable); }
/*! * \brief Handles the SOAP requests to querry the state variables. * This functionality has been deprecated in the UPnP V1.0 architecture. */ static UPNP_INLINE void handle_query_variable( int iface, /*! [in] Socket info. */ SOCKINFO *info, /*! [in] HTTP request. */ http_message_t *request, /*! [in] Document containing the variable request SOAP message. */ IXML_Document *xml_doc) { Upnp_FunPtr soap_event_callback; void *cookie; char var_name[LINE_SIZE]; struct Upnp_State_Var_Request variable; const char *err_str; int err_code; /* get var name */ if (get_var_name(xml_doc, var_name) != 0) { send_error_response(info, SOAP_INVALID_VAR, Soap_Invalid_Var, request); return; } /* get info for event */ err_code = get_device_info(iface, request, 1, xml_doc, info->foreign_sockaddr.ss_family, variable.DevUDN, variable.ServiceID, &soap_event_callback, &cookie); if (err_code != 0) { send_error_response(info, SOAP_INVALID_VAR, Soap_Invalid_Var, request); return; } linecopy(variable.ErrStr, ""); variable.ErrCode = UPNP_E_SUCCESS; namecopy(variable.StateVarName, var_name); variable.CurrentVal = NULL; variable.CtrlPtIPAddr = info->foreign_sockaddr; /* send event */ soap_event_callback(UPNP_CONTROL_GET_VAR_REQUEST, &variable, cookie); UpnpPrintf(UPNP_INFO, SOAP, __FILE__, __LINE__, "Return from callback for var request\n"); /* validate, and handle result */ if (variable.CurrentVal == NULL) { send_error_response(info, SOAP_INVALID_VAR, Soap_Invalid_Var, request); return; } if (variable.ErrCode != UPNP_E_SUCCESS) { if (strlen(variable.ErrStr) > 0) { err_code = SOAP_INVALID_VAR; err_str = Soap_Invalid_Var; } else { err_code = variable.ErrCode; err_str = variable.ErrStr; } send_error_response(info, err_code, err_str, request); return; } /* send response */ send_var_query_response(info, variable.CurrentVal, request); ixmlFreeDOMString(variable.CurrentVal); }
/**************************************************************************** * Function : handle_query_variable * * Parameters : * IN SOCKINFO *info : Socket info * IN http_message_t* request : HTTP request * IN IXML_Document *xml_doc : Document containing the variable request * SOAP message * * Description : This action handles the SOAP requests to querry the * state variables. This functionality has been deprecated in * the UPnP V1.0 architecture * * Return : void * * Note : ****************************************************************************/ static UPNP_INLINE void handle_query_variable( IN SOCKINFO * info, IN http_message_t * request, IN IXML_Document * xml_doc ) { Upnp_FunPtr soap_event_callback; void *cookie; char var_name[LINE_SIZE]; struct Upnp_State_Var_Request variable; const char *err_str; int err_code; // get var name if( get_var_name( xml_doc, var_name ) != 0 ) { send_error_response( info, SOAP_INVALID_VAR, Soap_Invalid_Var, request ); return; } // get info for event if( get_device_info( request, 1, xml_doc, variable.DevUDN, variable.ServiceID, &soap_event_callback, &cookie ) != 0 ) { send_error_response( info, SOAP_INVALID_VAR, Soap_Invalid_Var, request ); return; } linecopy( variable.ErrStr, "" ); variable.ErrCode = UPNP_E_SUCCESS; namecopy( variable.StateVarName, var_name ); variable.CurrentVal = NULL; variable.CtrlPtIPAddr = info->foreign_ip_addr; // send event soap_event_callback( UPNP_CONTROL_GET_VAR_REQUEST, &variable, cookie ); UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__, "Return from callback for var request\n" ); // validate, and handle result if( variable.CurrentVal == NULL ) { err_code = SOAP_ACTION_FAILED; err_str = Soap_Action_Failed; send_error_response( info, SOAP_INVALID_VAR, Soap_Invalid_Var, request ); return; } if( variable.ErrCode != UPNP_E_SUCCESS ) { if( strlen( variable.ErrStr ) > 0 ) { err_code = SOAP_INVALID_VAR; err_str = Soap_Invalid_Var; } else { err_code = variable.ErrCode; err_str = variable.ErrStr; } send_error_response( info, err_code, err_str, request ); return; } // send response send_var_query_response( info, variable.CurrentVal, request ); ixmlFreeDOMString( variable.CurrentVal ); }