diff --git a/test/root1.xml b/test/root1.xml new file mode 100644 index 000000000..94b71d44b --- /dev/null +++ b/test/root1.xml @@ -0,0 +1,135 @@ + + + + 1 + 0 + + http://127.0.0.1 + + + + + urn:schemas-upnp-org:device:InternetGatewayDevice:1 + / + Xtreme N GIGABIT Router + D-Link Systems + http://www.dlink.com + Xtreme N GIGABIT Router + Xtreme N GIGABIT Router + DIR-655 + http://www.dlink.com + none + uuid:E17FAEB7-CABB-3BCC-9C36-7207D5397C0E + + + + 00000-00001 + + + urn:schemas-upnp-org:service:Layer3Forwarding:1 + + urn:upnp-org:serviceId:L3Forwarding1 + http://192.168.0.1:4444/l3fw + http://192.168.0.1:9393/l3fw + http://192.168.0.1/l3fw.xml + + + + + urn:schemas-upnp-org:device:WANDevice:1 + + Xtreme N GIGABIT Router + D-Link Systems + http://www.dlink.com + Xtreme N GIGABIT Router + Xtreme N GIGABIT Router + DIR-655 + http://www.dlink.com + none + uuid:EC4A6889-B956-363F-9849-62C053B72D72 + + 00000-00001 + + + urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1 + + urn:upnp-org:serviceId:WANCommonIFC1 + http://192.168.0.1:4444/wcommifc + http://192.168.0.1:9393/wcommifc + http://192.168.0.1/WANCommonIFC1.xml + + + + + urn:schemas-upnp-org:device:WANConnectionDevice:1 + + Xtreme N GIGABIT Router + D-Link Systems + http://www.dlink.com + Xtreme N GIGABIT Router + Xtreme N GIGABIT Router + DIR-655 + http://www.dlink.com + none + uuid:8843AAB0-7191-39C5-A763-9592A8C5AB32 + + 00000-00001 + + + urn:schemas-upnp-org:service:WANIPConnection:1 + + urn:upnp-org:serviceId:WANIPConn1 + http://127.0.0.1:%d/wipconn + http://192.168.0.1:9393/wipconn + http://192.168.0.1/WANIPConn1.xml + + + + + + + + + + urn:schemas-wifialliance-org:device:WFADevice:1 + / + WFADevice + D-Link Systems + http://www.dlink.com + Xtreme N GIGABIT Router + Xtreme N GIGABIT Router + DIR-655 + http://www.dlink.com + none + + uuid:003F35AE-C81C-3EE7-972E-8AEF712289D5 + + + + + + + + + 00000-00001 + + + urn:schemas-wifialliance-org:service:WFAWLANConfig:1 + + + + urn:wifialliance-org:serviceId:WFAWLANConfig1 + http://192.168.0.1:8832/wfawc + http://192.168.0.1:8456/wfawc + http://192.168.0.1/WFAwc.xml + + + + + + + + + + + diff --git a/test/root2.xml b/test/root2.xml new file mode 100644 index 000000000..84a1d819e --- /dev/null +++ b/test/root2.xml @@ -0,0 +1 @@ +10http://127.0.0.1:%durn:schemas-upnp-org:device:InternetGatewayDevice:1http://192.168.0.1:80D-Link RouterD-Linkhttp://www.dlink.comInternet Access RouterD-Link Routeruuid:upnp-InternetGatewayDevice-1_0-12345678900001123456789001urn:schemas-upnp-org:service:Layer3Forwarding:1urn:upnp-org:serviceId:L3Forwarding1/Layer3Forwarding/Layer3Forwarding/Layer3Forwarding.xmlurn:schemas-upnp-org:device:WANDevice:1WANDeviceD-Linkhttp://www.dlink.comInternet Access RouterD-Link Router1http://support.dlink.com12345678900001uuid:upnp-WANDevice-1_0-12345678900001123456789001urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1urn:upnp-org:serviceId:WANCommonInterfaceConfig/WANCommonInterfaceConfig/WANCommonInterfaceConfig/WANCommonInterfaceConfig.xmlurn:schemas-upnp-org:device:WANConnectionDevice:1WAN Connection DeviceD-Linkhttp://www.dlink.comInternet Access RouterD-Link Router1http://support.dlink.com12345678900001uuid:upnp-WANConnectionDevice-1_0-12345678900001123456789001urn:schemas-upnp-org:service:WANIPConnection:1urn:upnp-org:serviceId:WANIPConnection/WANIPConnection/WANIPConnection/WANIPConnection.xml diff --git a/test/test_upnp.cpp b/test/test_upnp.cpp index bf717228a..255030857 100644 --- a/test/test_upnp.cpp +++ b/test/test_upnp.cpp @@ -47,87 +47,6 @@ using namespace libtorrent; broadcast_socket* sock = 0; int g_port = 0; -char upnp_xml[] = -"" -"" -"1" -"0" -"" -"http://127.0.0.1:%d" -"" -"" -"urn:schemas-upnp-org:device:InternetGatewayDevice:1" -"" -"http://192.168.0.1:80" -"D-Link Router" -"D-Link" -"http://www.dlink.com" -"Internet Access Router" -"D-Link Router" -"uuid:upnp-InternetGatewayDevice-1_0-12345678900001" -"123456789001" -"" -"" -"urn:schemas-upnp-org:service:Layer3Forwarding:1" -"urn:upnp-org:serviceId:L3Forwarding1" -"/Layer3Forwarding" -"/Layer3Forwarding" -"/Layer3Forwarding.xml" -"" -"" -"" -"" -"urn:schemas-upnp-org:device:WANDevice:1" -"WANDevice" -"D-Link" -"http://www.dlink.com" -"Internet Access Router" -"D-Link Router" -"1" -"http://support.dlink.com" -"12345678900001" -"uuid:upnp-WANDevice-1_0-12345678900001" -"123456789001" -"" -"" -"" -"urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1" -"" -"urn:upnp-org:serviceId:WANCommonInterfaceConfig" -"/WANCommonInterfaceConfig" -"/WANCommonInterfaceConfig" -"/WANCommonInterfaceConfig.xml" -"" -"" -"" -"" -"urn:schemas-upnp-org:device:WANConnectionDevice:1" -"WAN Connection Device" -"D-Link" -"http://www.dlink.com" -"Internet Access Router" -"D-Link Router" -"1" -"http://support.dlink.com" -"12345678900001" -"uuid:upnp-WANConnectionDevice-1_0-12345678900001" -"123456789001" -"" -"" -"urn:schemas-upnp-org:service:WANIPConnection:1" -"urn:upnp-org:serviceId:WANIPConnection" -"/WANIPConnection" -"/WANIPConnection" -"/WANIPConnection.xml" -"" -"" -"" -"" -"" -"" -"" -""; - char soap_add_response[] = "" @@ -202,16 +121,22 @@ void callback(int mapping, address const& ip, int port, error_code const& err) //TODO: store the callbacks and verify that the ports were successful } -int test_main() +int run_upnp_test(char const* root_filename, char const* router_model, char const* control_name) { libtorrent::io_service ios; g_port = start_web_server(); + + std::vector buf; + error_code ec; + load_file(root_filename, buf, ec); + buf.push_back(0); + FILE* xml_file = fopen("upnp.xml", "w+"); - fprintf(xml_file, upnp_xml, g_port); + fprintf(xml_file, &buf[0], g_port); fclose(xml_file); - std::ofstream xml("WANIPConnection", std::ios::trunc); + std::ofstream xml(control_name, std::ios::trunc); xml.write(soap_add_response, sizeof(soap_add_response)-1); xml.close(); @@ -226,7 +151,6 @@ int test_main() upnp_handler->discover_device(); libtorrent::deadline_timer timer(ios); - error_code ec; timer.expires_from_now(seconds(10), ec); timer.async_wait(boost::bind(&libtorrent::io_service::stop, boost::ref(ios))); @@ -246,7 +170,7 @@ int test_main() xml.close(); std::cerr << "router: " << upnp_handler->router_model() << std::endl; - TEST_CHECK(upnp_handler->router_model() == "D-Link Router"); + TEST_CHECK(upnp_handler->router_model() == router_model); upnp_handler->close(); sock->close(); @@ -260,8 +184,16 @@ int test_main() stop_web_server(); + callbacks.clear(); + delete sock; return 0; } +int test_main() +{ + run_upnp_test("root1.xml", "Xtreme N GIGABIT Router", "wipconn"); + run_upnp_test("root2.xml", "D-Link Router", "WANIPConnection"); + return 0; +}