Commit 3e2e4da7 authored by rygelgit's avatar rygelgit

More additions to enable dynamic retrieval of Service control URL. More fixes...

More additions to enable dynamic retrieval of Service control URL. More fixes when testing with DLNA CTT for DIAGC
parent 4b59fad2
......@@ -41,42 +41,44 @@ use responsevalidator::ResponseValidator;
START:
our ($TEST_OPTION, $HOSTIP, $HOSTPORT) = '';
our ($TEST_OPTION, $HOSTIP, $HOSTPORT, $CONTROL_URL) = '';
print "------- Choose an option -------\n";
print "\33[1;33m------- Choose an option -------\33[m\n";
print "1. Search DIAGE capable devices \n";
print "2. Manual DIAGE device testing \n";
print "3. Exit Application \n";
print "Enter the option number : ";
print "\33[1;33mEnter the option number : \33[m";
our $SEARCH_OPTS = <>;
chomp $SEARCH_OPTS;
switch($SEARCH_OPTS){
case 1 {
my ($diage_devices, $diage_ip, $diage_port) = SearchDevices::lookup_diage_device;
print "Choose the corresponding device number to start testing: :\n";
my ($diage_devices, $diage_ip, $diage_port, $control_url) = SearchDevices::lookup_diage_device;
print "\33[1;33mChoose the corresponding device number to start testing: \33[m\n";
my $device_count=0;
print "****************************************\n";
print "****************************************\n";
foreach my $device_temp (@$diage_devices) {
print "----------------------------------------\n";
print "[" . ($device_count + 1) . "] : " . $device_temp->getfriendlyname() . "\n";
print "Device IP : " . @$diage_ip[$device_count] . "\n";
print "Device Port : " . @$diage_port[$device_count] . "\n";
print "----------------------------------------\33[m\n";
print "\33[1;33m[" . ($device_count + 1) . "] : " . $device_temp->getfriendlyname() . "\33[m\n";
print "\33[1;33mDevice IP : " . @$diage_ip[$device_count] . "\33[m\n";
print "\33[1;33mDevice Port : " . @$diage_port[$device_count] . "\33[m\n";
print "\33[1;33mControl URL : " . @$control_url[$device_count] . "\33[m\n";
$device_count++;
}
print "****************************************\n";
print "****************************************\n";
print "Choose the device number: ";
print "\33[1;33mChoose the device number: \33[m";
my $DEVICE_NO = <>;
chomp $DEVICE_NO;
$HOSTIP = @$diage_ip[$DEVICE_NO - 1];
$HOSTPORT = @$diage_port[$DEVICE_NO - 1];
$CONTROL_URL = @$control_url[$DEVICE_NO - 1];
Util::print_diagc_start;
}
case 2 {
......@@ -93,76 +95,76 @@ while (1) {
GET_USER_OPT:
$TEST_OPTION = Util::get_user_options;
if ($SEARCH_OPTS eq '2') {
($HOSTIP, $HOSTPORT) = Util::get_manual_device_details;
($HOSTIP, $HOSTPORT, $CONTROL_URL) = Util::get_manual_device_details;
}
switch($TEST_OPTION){
case 1 {
my $devicestatus_response = DeviceStatusRequest::devicestatus_request($HOSTIP, $HOSTPORT);
my $devicestatus_response = DeviceStatusRequest::devicestatus_request($HOSTIP, $HOSTPORT, $CONTROL_URL);
ResponseValidator::valiate_soap_response($devicestatus_response);
}
case 2 {
print "Enter the Test number for CancelTest : ";
my $TESTID = <>;
chomp $TESTID;
my $canceltest_response = CancelTestRequest::canceltest_request($HOSTIP, $HOSTPORT, $TESTID);
my $canceltest_response = CancelTestRequest::canceltest_request($HOSTIP, $HOSTPORT, $TESTID, $CONTROL_URL);
ResponseValidator::valiate_soap_response($canceltest_response);
}
case 3 {
my $activetestids_response = GetActiveTestIDsRequest::activetestids_request($HOSTIP, $HOSTPORT);
my $activetestids_response = GetActiveTestIDsRequest::activetestids_request($HOSTIP, $HOSTPORT, $CONTROL_URL);
ResponseValidator::valiate_soap_response($activetestids_response);
}
case 4 {
print "Enter the HostName to perform NSLookup : ";
my $HOST_NAME = <>;
chomp $HOST_NAME;
my $nslookup_req_response = NSLookUpRequest::nslookup_request($HOSTIP, $HOSTPORT, $HOST_NAME);
my $nslookup_req_response = NSLookUpRequest::nslookup_request($HOSTIP, $HOSTPORT, $HOST_NAME, $CONTROL_URL);
ResponseValidator::valiate_soap_response($nslookup_req_response);
}
case 5 {
print "Enter the HostName to perform Ping : ";
my $HOST_NAME = <>;
chomp $HOST_NAME;
my $ping_req_response = PingRequest::ping_request($HOSTIP, $HOSTPORT, $HOST_NAME);
my $ping_req_response = PingRequest::ping_request($HOSTIP, $HOSTPORT, $HOST_NAME, $CONTROL_URL);
ResponseValidator::valiate_soap_response($ping_req_response);
}
case 6 {
print "Enter the HostName to perform traceroute : ";
my $HOST_NAME = <>;
chomp $HOST_NAME;
my $traceroute_req_request = TracerouteRequest::traceroute_request($HOSTIP, $HOSTPORT, $HOST_NAME);
my $traceroute_req_request = TracerouteRequest::traceroute_request($HOSTIP, $HOSTPORT, $HOST_NAME, $CONTROL_URL);
ResponseValidator::valiate_soap_response($traceroute_req_request);
}
case 7 {
my $testidsreq_response = TestIDsRequest::testids_request($HOSTIP, $HOSTPORT);
my $testidsreq_response = TestIDsRequest::testids_request($HOSTIP, $HOSTPORT, $CONTROL_URL);
ResponseValidator::valiate_soap_response($testidsreq_response);
}
case 8 {
print "Enter the Test number for TestInfo : ";
my $TESTID_INFO = <>;
chomp $TESTID_INFO;
my $testinfo_response = TestInfoRequest::testinfo_request($HOSTIP, $HOSTPORT, $TESTID_INFO);
my $testinfo_response = TestInfoRequest::testinfo_request($HOSTIP, $HOSTPORT, $TESTID_INFO, $CONTROL_URL);
ResponseValidator::valiate_soap_response($testinfo_response);
}
case 9 {
print "Enter the Test number for GetNSLookupResult : ";
my $TESTID_INFO = <>;
chomp $TESTID_INFO;
my $nslookup_res_response = NSLookUpResponse::nslookup_response($HOSTIP, $HOSTPORT, $TESTID_INFO);
my $nslookup_res_response = NSLookUpResponse::nslookup_response($HOSTIP, $HOSTPORT, $TESTID_INFO, $CONTROL_URL);
ResponseValidator::valiate_soap_response($nslookup_res_response);
}
case 10 {
print "Enter the Test number for GetPingResult : ";
my $TESTID_INFO = <>;
chomp $TESTID_INFO;
my $ping_res_response = PingResponse::ping_response($HOSTIP, $HOSTPORT, $TESTID_INFO);
my $ping_res_response = PingResponse::ping_response($HOSTIP, $HOSTPORT, $TESTID_INFO, $CONTROL_URL);
ResponseValidator::valiate_soap_response($ping_res_response);
}
case 11 {
print "Enter the Test number for GetTracerouteResult : ";
my $TESTID_INFO = <>;
chomp $TESTID_INFO;
my $traceroute_res_response = TracerouteResponse::traceroute_response($HOSTIP, $HOSTPORT, $TESTID_INFO);
my $traceroute_res_response = TracerouteResponse::traceroute_response($HOSTIP, $HOSTPORT, $TESTID_INFO, $CONTROL_URL);
ResponseValidator::valiate_soap_response($traceroute_res_response);
}
case ('x') { goto START; }
......
#!/usr/bin/perl
# Copyright (c) 2014, CableLabs, Inc.
# All rights reserved.
#
# Author: Parthiban Balasubramanian<p.balasubramanian@cablelabs.com>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
use strict;
use Switch;
# Call Lookup DIAGE test
use test::DiageTest;
1;
Install Switch & UPnP Perl module before using the script:
----------------------------------------------
sudo apt-get install libswitch-perl libnet-upnp-perl
sudo apt-get install libswitch-perl libnet-upnp-perl libxml-libxml-perl
Running the script:
-------------------
......
......@@ -42,5 +42,5 @@ our $canceltest_request_message2="</TestID>
</s:Envelope>";
sub canceltest_request {
return SocketCalls::invoke_soap_request($_[0], $_[1], $canceltest_request_message1 . $_[2] . $canceltest_request_message2, $canceltest_action);
return SocketCalls::invoke_soap_request($_[0], $_[1], $canceltest_request_message1 . $_[2] . $canceltest_request_message2, $canceltest_action, $_[3]);
}
......@@ -39,5 +39,5 @@ our $devicestatus_request_message = "<?xml version=\"1.0\" encoding=\"utf-8\"?>
</s:Envelope>";
sub devicestatus_request {
return SocketCalls::invoke_soap_request($_[0], $_[1], $devicestatus_request_message,$devicestatus_action);
return SocketCalls::invoke_soap_request($_[0], $_[1], $devicestatus_request_message,$devicestatus_action,$_[2]);
}
......@@ -39,5 +39,5 @@ our $activetestids_request_message = "<?xml version=\"1.0\" encoding=\"utf-8\"?>
</s:Envelope>";
sub activetestids_request {
return SocketCalls::invoke_soap_request($_[0], $_[1], $activetestids_request_message, $activetestids_action);
return SocketCalls::invoke_soap_request($_[0], $_[1], $activetestids_request_message, $activetestids_action, $_[2]);
}
......@@ -52,5 +52,5 @@ sub nslookup_request {
} else {
$host_value = $host_value . $_[2];
}
return SocketCalls::invoke_soap_request($_[0], $_[1], $nslookup_request_message1 . $host_value . $nslookup_request_message2, $nslookup_action);
return SocketCalls::invoke_soap_request($_[0], $_[1], $nslookup_request_message1 . $host_value . $nslookup_request_message2, $nslookup_action, $_[3]);
}
......@@ -53,5 +53,5 @@ sub ping_request {
} else {
$host_value = $host_value . $_[2];
}
return SocketCalls::invoke_soap_request($_[0], $_[1], $ping_request_message1 . $host_value . $ping_request_message2, $ping_action);
return SocketCalls::invoke_soap_request($_[0], $_[1], $ping_request_message1 . $host_value . $ping_request_message2, $ping_action, $_[3]);
}
......@@ -39,5 +39,5 @@ our $testids_request_message = "<?xml version=\"1.0\" encoding=\"utf-8\"?>
</s:Envelope>";
sub testids_request {
return SocketCalls::invoke_soap_request($_[0], $_[1], $testids_request_message, $testids_action);
return SocketCalls::invoke_soap_request($_[0], $_[1], $testids_request_message, $testids_action, $_[2]);
}
......@@ -42,5 +42,5 @@ our $testinfo_request_message2="</TestID>
</s:Envelope>";
sub testinfo_request {
return SocketCalls::invoke_soap_request($_[0], $_[1], $testinfo_request_message1 . $_[2] . $testinfo_request_message2, $testinfo_action);
return SocketCalls::invoke_soap_request($_[0], $_[1], $testinfo_request_message1 . $_[2] . $testinfo_request_message2, $testinfo_action,$_[3]);
}
......@@ -53,5 +53,5 @@ sub traceroute_request {
} else {
$host_value = $host_value . $_[2];
}
return SocketCalls::invoke_soap_request($_[0], $_[1], $traceroute_request_message1 . $host_value . $traceroute_request_message2, $traceroute_action);
return SocketCalls::invoke_soap_request($_[0], $_[1], $traceroute_request_message1 . $host_value . $traceroute_request_message2, $traceroute_action, $_[3]);
}
......@@ -42,5 +42,5 @@ our $nslookup_response_message2="</TestID>
</s:Envelope>";
sub nslookup_response {
return SocketCalls::invoke_soap_request($_[0], $_[1], $nslookup_response_message1 . $_[2] . $nslookup_response_message2, $nslookup_response_action);
return SocketCalls::invoke_soap_request($_[0], $_[1], $nslookup_response_message1 . $_[2] . $nslookup_response_message2, $nslookup_response_action, $_[3]);
}
......@@ -42,7 +42,7 @@ our $ping_response_message2="</TestID>
</s:Envelope>";
sub ping_response {
return SocketCalls::invoke_soap_request($_[0], $_[1], $ping_response_message1 . $_[2] . $ping_response_message2, $ping_response_action);
return SocketCalls::invoke_soap_request($_[0], $_[1], $ping_response_message1 . $_[2] . $ping_response_message2, $ping_response_action, $_[3]);
}
1;
......@@ -42,5 +42,5 @@ our $traceroute_response_message2="</TestID>
</s:Envelope>";
sub traceroute_response {
return SocketCalls::invoke_soap_request($_[0], $_[1], $traceroute_response_message1 . $_[2] . $traceroute_response_message2, $traceroute_response_action);
return SocketCalls::invoke_soap_request($_[0], $_[1], $traceroute_response_message1 . $_[2] . $traceroute_response_message2, $traceroute_response_action, $_[3]);
}
#!/usr/bin/perl
# Copyright (c) 2014, CableLabs, Inc.
# All rights reserved.
#
# Author: Parthiban Balasubramanian<p.balasubramanian@cablelabs.com>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
package DiageTest;
use utils::SearchDevices;
SearchDevices::lookup_diage_device;
1;
......@@ -32,32 +32,49 @@ package SearchDevices;
use utils::UPnPWrapper;
use Net::UPnP::Device;
use Net::UPnP::ControlPoint;
use XML::LibXML;
sub search_devices {
my ($devices, $ip, $port) = UPnPWrapper::search();
print "Total Devices found on network : " .@$devices . "\n";
print "\33[1;36mTotal Devices found on network : " .@$devices . "\33[m\n";
return ($devices, $ip, $port);
}
sub lookup_diage_device {
my ($device_list_search, $device_ip_list, $device_port_list) = search_devices;
$devNum= 0;
my (@temp_device_list, @temp_device_ip, @temp_device_port)= ();
my (@temp_device_list, @temp_device_ip, @temp_device_port, @temp_scpd_url)= ();
foreach my $dev_temp (@$device_list_search) {
unless ($dev_temp->getservicebyname('urn:schemas-upnp-org:service:BasicManagement:2')) {
$devNum++;
next;
}
my $parser = XML::LibXML->new;
$doc = $parser->parse_string($dev_temp->getdescription());
my @nodes = $doc->getElementsByTagName("service");
foreach my $node (@nodes) {
if ($node->hasChildNodes()){
print "Before serviceType";
if ($node->getChildrenByTagName( "serviceType" ) eq 'urn:schemas-upnp-org:service:BasicManagement:2') {
push (@temp_scpd_url, $node->getChildrenByTagName("controlURL")->string_value());
print "Before controlURL";
}
}
}
push (@temp_device_list , $dev_temp);
push (@temp_device_ip, @$device_ip_list[$devNum]);
push (@temp_device_port, @$device_port_list[$devNum]);
# print "[" . ($devNum + 1) . "] : " . $dev_temp->getfriendlyname() . "\n";
# print "Device IP : " . @$device_ip_list[$devNum] . "\n";
# print "Device Port : " . @$device_port_list[$devNum] . "\n";
#print "[" . ($devNum + 1) . "] : " . $dev_temp->getfriendlyname() . "\n";
#print "Device IP : " . @$device_ip_list[$devNum] . "\n";
#print "Device Port : " . @$device_port_list[$devNum] . "\n";
$devNum++;
}
print "Devices with DIAGE capability: " . @temp_device_list . "\n";
return (\@temp_device_list, \@temp_device_ip, \@temp_device_port);
print "\33[1;36mDevices with DIAGE capability: " . @temp_device_list . "\33[m\n";
#print "DIAGC Control URL: " . "@temp_scpd_url" . "\n";
return (\@temp_device_list, \@temp_device_ip, \@temp_device_port, \@temp_scpd_url);
}
1;
......@@ -29,7 +29,7 @@
package SoapHeaders;
our $content_type = "text/xml; charset=utf-8";
our $control_url = "/Control/ODIDMediaServer/RygelBasicManagement";
#our $control_url = "/Control/ODIDMediaServer/RygelBasicManagement";
our $http_prefix = 'http://';
our $separator = ':';
1;
......@@ -38,7 +38,7 @@ sub invoke_soap_request {
#print "The passed port no :" . $_[1] . "\n";
#print "Request Message : " . $_[2] . "\n";
#print "Soap Action :".$_[3] . "\n";
my $post_url = $SoapHeaders::http_prefix . $_[0] . $SoapHeaders::separator . $_[1] . $SoapHeaders::control_url;
my $post_url = $SoapHeaders::http_prefix . $_[0] . $SoapHeaders::separator . $_[1] . $_[4];
#print $post_url;
my $user_agent = LWP::UserAgent->new();
my $soap_request = HTTP::Request->new(POST => $post_url);
......
......@@ -27,30 +27,31 @@ send(SSDP_SOCK, $ssdp_header, 0, $ssdp_multicast_msg);
my @device_list=();
my @device_addr=();
my @device_port=();
my $ssdp_response = '';
my ($reader_input, $reader_output, $ssdp_res_msg) = '';
my ($reader_input, $reader_output, $ssdp_res_msg, $ssdp_response) = '';
vec($reader_input, fileno(SSDP_SOCK), 1) = 1;
while( select($reader_output = $reader_input, undef, undef, 10) ) {
recv(SSDP_SOCK, $ssdp_response, 4096, 0);
print $ssdp_response . "\n";
print "\33[1;32m" . $ssdp_response . "\33[m\n";
unless ($ssdp_response =~ m/LOCATION[ :]+(.*)\r/i) {
next;
}
my $location = $1;
unless ($location =~ m/http:\/\/([0-9a-z.]+)[:]*([0-9]*)\/(.*)/i) {
next;
}
my $host_address = $1;
my $host_port = $2;
my $dev_path = '/' . $3;
my $http_request = Net::UPnP::HTTP->new();
print "Waiting for SSDP response..... \n\n";
my $post_response = $http_request->post($host_address, $host_port, "GET", $dev_path, "", "");
my $post_content = $post_response->getcontent();
print "$post_content";
my $dev = Net::UPnP::Device->new();
$dev->setssdp($ssdp_response);
$dev->setdescription($post_content);
......@@ -63,7 +64,7 @@ close(SSDP_SOCK);
# Multiple arrays cannot be passed by value., If passed then all the values will be dumped into the first array
# So return the array references. And also use my qualifier, so that a new instance will be created where it is assigned.
return (\@device_list, \@device_addr, \@device_port);
return ( \@device_list, \@device_addr, \@device_port);
}
1;
......@@ -63,7 +63,11 @@ sub get_manual_device_details {
our $PORT = <>;
chomp $PORT;
print "\n";
return ($IP, $PORT);
print "Enter the DIAGE Control URL : ";
our $CONTROL_URL = <>;
chomp $CONTROL_URL;
print "\n";
return ($IP, $PORT, $CONTROL_URL);
}
1;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment