/** * Parse the service description from the service's SCPD URL. Do not call * this from user applications. * * @param service The service in question * @return TRUE if successful; otherwise FALSE */ BOOL cg_upnp_controlpoint_parsescservicescpd(CgUpnpService *service) { CgNetURL *scpdURL; BOOL scpdParseSuccess; cg_log_debug_l4("Entering...\n"); scpdURL = cg_upnp_service_getscpdurl(service); if ( NULL == scpdURL ) return FALSE; cg_log_debug_s("SCPD URL: %s\n", cg_net_url_getrequest(scpdURL)); scpdParseSuccess = cg_upnp_service_parsedescriptionurl(service, scpdURL); cg_net_url_delete(scpdURL); if (scpdParseSuccess == TRUE) return TRUE; #if defined(CG_UPNP_USE_STDDCP) if (cg_upnp_service_hasstddcp(service)) { char *stdDCP = cg_upnp_service_getstddcp(service); scpdParseSuccess = cg_upnp_service_parsedescription(service, stdDCP, cg_strlen(stdDCP)); } #endif cg_log_debug_l4("Leaving...\n"); return scpdParseSuccess; }
void cg_upnp_control_request_sethostfromservice(CgSoapRequest *soapReq, CgUpnpService *service) { CgHttpRequest *httpReq; CgNetURL *ctrlURL; cg_log_debug_l4("Entering...\n"); httpReq = cg_soap_request_gethttprequest(soapReq); ctrlURL = cg_upnp_service_getcontrolurl(service); cg_log_debug_s("Ctrl URL: %s - %d -%s", cg_net_url_gethost(ctrlURL), cg_net_url_getport(ctrlURL), cg_net_url_getpath(ctrlURL)); //cg_http_request_seturi(httpReq, cg_xml_node_getchildnodevalue(cg_upnp_service_getservicenode(service), CG_UPNP_SERVICE_CONTROL_URL)); cg_http_request_seturi(httpReq, cg_net_url_getrequest(ctrlURL)); /**** Host ****/ cg_net_url_delete(httpReq->postURL); httpReq->postURL = ctrlURL; cg_log_debug_s("Post URL: %s - %d -%s", cg_net_url_gethost(httpReq->postURL), cg_net_url_getport(httpReq->postURL), cg_net_url_getpath(httpReq->postURL)); cg_log_debug_l4("Leaving...\n"); }
static void cg_upnp_event_subscription_request_setservice(CgUpnpSubscriptionRequest *subReq, CgUpnpService *service) { CgNetURL *eventSubURL; cg_log_debug_l4("Entering...\n"); eventSubURL = cg_upnp_service_geteventsuburl(service); cg_http_request_seturi(subReq, cg_net_url_getrequest(eventSubURL)); cg_net_url_delete(subReq->postURL); subReq->postURL = eventSubURL; cg_log_debug_l4("Leaving...\n"); }
void cg_http_request_delete(CgHttpRequest *httpReq) { cg_log_debug_l4("Entering...\n"); cg_http_packet_clean((CgHttpPacket *)httpReq); cg_string_delete(httpReq->method); cg_string_delete(httpReq->version); cg_string_delete(httpReq->uri); /* ADD Fabrice Fontaine Orange 23/04/2007 */ /* Memory leak correction */ cg_string_delete(httpReq->userAgent); /* ADD END Fabrice Fontaine Orange 23/04/2007 */ cg_http_response_delete(httpReq->httpRes); cg_net_url_delete(httpReq->postURL); free(httpReq); cg_log_debug_l4("Leaving...\n"); }
static CgUpnpDevice *cg_upnp_controlpoint_createdevicefromssdkpacket(CgUpnpSSDPPacket *ssdpPkt) { const char *location; CgNetURL *url; CgUpnpDevice *dev; BOOL parseSuccess; cg_log_debug_l4("Entering...\n"); location = cg_upnp_ssdp_packet_getlocation(ssdpPkt); if (cg_strlen(location) <= 0) return NULL; dev = cg_upnp_device_new(); url = cg_net_url_new(); cg_net_url_set(url, location); parseSuccess = cg_upnp_device_parsedescriptionurl(dev, url); cg_net_url_delete(url); if (parseSuccess == FALSE) { cg_upnp_device_delete(dev); return NULL; } cg_upnp_device_setssdppacket(dev, ssdpPkt); #ifndef CG_OPTIMIZED_CP_MODE if (cg_upnp_controlpoint_parseservicesfordevice(dev, ssdpPkt) == FALSE) { cg_upnp_device_delete(dev); return NULL; } #endif cg_log_debug_l4("Leaving...\n"); return dev; }
void ClinkTestCase::testServiceAbsoluteURL() { CgNetURL *url; const char *urlStr; /******************************************************************************** * O:serviceURLStr ?:baseURLStr ?:locationURLStr ********************************************************************************/ /* O:serviceURLStr -:baseURLStr -:locationURLStr */ url = cg_upnp_service_mangleabsoluteurl("http://192.168.0.1:80/serviceURL", NULL, NULL); urlStr = cg_net_url_getvalue(url); CPPUNIT_ASSERT(strcmp(urlStr, "http://192.168.0.1:80/serviceURL") == 0); cg_net_url_delete(url); /* O:serviceURLStr O:baseURLStr -:locationURLStr */ url = cg_upnp_service_mangleabsoluteurl("http://192.168.0.1:80/serviceURL", "http://192.168.0.2:80/", NULL); urlStr = cg_net_url_getvalue(url); CPPUNIT_ASSERT(strcmp(urlStr, "http://192.168.0.1:80/serviceURL") == 0); cg_net_url_delete(url); /* O:serviceURLStr -:baseURLStr O:locationURLStr */ url = cg_upnp_service_mangleabsoluteurl("http://192.168.0.1:80/serviceURL", NULL, "http://192.168.0.3:80/"); urlStr = cg_net_url_getvalue(url); CPPUNIT_ASSERT(strcmp(urlStr, "http://192.168.0.1:80/serviceURL") == 0); cg_net_url_delete(url); /* O:serviceURLStr O:baseURLStr O:locationURLStr */ url = cg_upnp_service_mangleabsoluteurl("http://192.168.0.1:80/serviceURL", "http://192.168.0.2:80/", "http://192.168.0.3:80/"); urlStr = cg_net_url_getvalue(url); CPPUNIT_ASSERT(strcmp(urlStr, "http://192.168.0.1:80/serviceURL") == 0); cg_net_url_delete(url); /******************************************************************************** * X:serviceURLStr X:baseURLStr X:locationURLStr ********************************************************************************/ /* O:serviceURLStr X:baseURLStr X:locationURLStr */ url = cg_upnp_service_mangleabsoluteurl("/serviceURL", NULL, NULL); urlStr = cg_net_url_getvalue(url); // FIXME //CPPUNIT_ASSERT(strcmp(urlStr, "/serviceURL") == 0); cg_net_url_delete(url); /******************************************************************************** * X:serviceURLStr O:baseURLStr -:locationURLStr (CASE01) ********************************************************************************/ /* X:serviceURLStr O:baseURLStr -:locationURLStr */ url = cg_upnp_service_mangleabsoluteurl("/serviceURL", "http://192.168.0.2:80/", NULL); urlStr = cg_net_url_getvalue(url); CPPUNIT_ASSERT(strcmp(urlStr, "http://192.168.0.2:80/serviceURL") == 0); cg_net_url_delete(url); /* X:serviceURLStr O:baseURLStr -:locationURLStr */ url = cg_upnp_service_mangleabsoluteurl("serviceURL", "http://192.168.0.2:80", NULL); urlStr = cg_net_url_getvalue(url); CPPUNIT_ASSERT(strcmp(urlStr, "http://192.168.0.2:80/serviceURL") == 0); cg_net_url_delete(url); /* X:serviceURLStr O:baseURLStr -:locationURLStr */ url = cg_upnp_service_mangleabsoluteurl("serviceURL", "http://192.168.0.2:80/", NULL); urlStr = cg_net_url_getvalue(url); CPPUNIT_ASSERT(strcmp(urlStr, "http://192.168.0.2:80/serviceURL") == 0); cg_net_url_delete(url); /* X:serviceURLStr O:baseURLStr -:locationURLStr */ url = cg_upnp_service_mangleabsoluteurl("/serviceURL", "http://192.168.0.2:80", NULL); urlStr = cg_net_url_getvalue(url); CPPUNIT_ASSERT(strcmp(urlStr, "http://192.168.0.2:80/serviceURL") == 0); cg_net_url_delete(url); /******************************************************************************** * X:serviceURLStr O:baseURLStr -:locationURLStr (CASE02) ********************************************************************************/ /* X:serviceURLStr O:baseURLStr -:locationURLStr */ url = cg_upnp_service_mangleabsoluteurl("/serviceURL", "http://192.168.0.2:80/device/", NULL); urlStr = cg_net_url_getvalue(url); CPPUNIT_ASSERT(strcmp(urlStr, "http://192.168.0.2:80/serviceURL") == 0); cg_net_url_delete(url); /* X:serviceURLStr O:baseURLStr -:locationURLStr */ url = cg_upnp_service_mangleabsoluteurl("serviceURL", "http://192.168.0.2:80/device/", NULL); urlStr = cg_net_url_getvalue(url); CPPUNIT_ASSERT(strcmp(urlStr, "http://192.168.0.2:80/device/serviceURL") == 0); cg_net_url_delete(url); /******************************************************************************** * X:serviceURLStr -:baseURLStr O:locationURLStr (CASE01) ********************************************************************************/ /* X:serviceURLStr -:baseURLStr O:locationURLStr */ url = cg_upnp_service_mangleabsoluteurl("/serviceURL", NULL, "http://192.168.0.3:80/"); urlStr = cg_net_url_getvalue(url); CPPUNIT_ASSERT(strcmp(urlStr, "http://192.168.0.3:80/serviceURL") == 0); cg_net_url_delete(url); /* X:serviceURLStr -:baseURLStr O:locationURLStr */ url = cg_upnp_service_mangleabsoluteurl("serviceURL", NULL, "http://192.168.0.3:80"); urlStr = cg_net_url_getvalue(url); CPPUNIT_ASSERT(strcmp(urlStr, "http://192.168.0.3:80/serviceURL") == 0); cg_net_url_delete(url); /* X:serviceURLStr -:baseURLStr O:locationURLStr */ url = cg_upnp_service_mangleabsoluteurl("serviceURL", NULL, "http://192.168.0.3:80/"); urlStr = cg_net_url_getvalue(url); CPPUNIT_ASSERT(strcmp(urlStr, "http://192.168.0.3:80/serviceURL") == 0); cg_net_url_delete(url); /* X:serviceURLStr -:baseURLStr O:locationURLStr */ url = cg_upnp_service_mangleabsoluteurl("/serviceURL", NULL, "http://192.168.0.3:80"); urlStr = cg_net_url_getvalue(url); CPPUNIT_ASSERT(strcmp(urlStr, "http://192.168.0.3:80/serviceURL") == 0); cg_net_url_delete(url); /******************************************************************************** * X:serviceURLStr -:baseURLStr O:locationURLStr (CASE02) ********************************************************************************/ /* X:serviceURLStr -:baseURLStr O:locationURLStr */ url = cg_upnp_service_mangleabsoluteurl("/serviceURL", NULL, "http://192.168.0.3:80/device/"); urlStr = cg_net_url_getvalue(url); CPPUNIT_ASSERT(strcmp(urlStr, "http://192.168.0.3:80/serviceURL") == 0); cg_net_url_delete(url); /* X:serviceURLStr -:baseURLStr O:locationURLStr */ url = cg_upnp_service_mangleabsoluteurl("serviceURL", NULL, "http://192.168.0.3:80/device/"); urlStr = cg_net_url_getvalue(url); CPPUNIT_ASSERT(strcmp(urlStr, "http://192.168.0.3:80/device/serviceURL") == 0); cg_net_url_delete(url); }