Commit 5f58fe7d authored by rygelgit's avatar rygelgit

Whitespace changes. TODO: Still few refactoring of code in DIAGC.pl remaining....

Whitespace changes. TODO: Still few refactoring of code in DIAGC.pl remaining. But the base functionality is ready for testing devices.
parent b4134cc8
......@@ -49,9 +49,9 @@ our $ping_request_message2="</Host>
sub ping_request {
my $host_value = "";
if ($_[2] eq '') {
$host_value = $host_value . $host_ping;
$host_value = $host_value . $host_ping;
} else {
$host_value = $host_value . $_[2];
$host_value = $host_value . $_[2];
}
return SocketCalls::invoke_soap_request($_[0], $_[1], $ping_request_message1 . $host_value . $ping_request_message2, $ping_action);
}
......@@ -49,9 +49,9 @@ our $traceroute_request_message2="</Host>
sub traceroute_request {
my $host_value = "";
if ($_[2] eq '') {
$host_value = $host_value . $host_ping;
$host_value = $host_value . $host_ping;
} else {
$host_value = $host_value . $_[2];
$host_value = $host_value . $_[2];
}
return SocketCalls::invoke_soap_request($_[0], $_[1], $traceroute_request_message1 . $host_value . $traceroute_request_message2, $traceroute_action);
}
......@@ -33,13 +33,13 @@ sub valiate_soap_response {
my $soap_response = $_[0];
if($soap_response->is_success) {
print "************Success*************\n";
print "************Success*************\n";
print_message ($soap_response);
} else {
print "************Error*************\n";
print_message ($soap_response);
}
print "\n************End of Action*************\n";
print "************Error*************\n";
print_message ($soap_response);
}
print "\n************End of Action*************\n";
}
sub print_message {
......
......@@ -34,30 +34,30 @@ use Net::UPnP::Device;
use Net::UPnP::ControlPoint;
sub search_devices {
my ($devices, $ip, $port) = UPnPWrapper::search();
print "Total Devices found on network : " .@$devices . "\n";
my ($devices, $ip, $port) = UPnPWrapper::search();
print "Total Devices found on network : " .@$devices . "\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)= ();
foreach my $dev_temp (@$device_list_search) {
unless ($dev_temp->getservicebyname('urn:schemas-upnp-org:service:BasicManagement:2')) {
$devNum++;
my ($device_list_search, $device_ip_list, $device_port_list) = search_devices;
$devNum= 0;
my (@temp_device_list, @temp_device_ip, @temp_device_port)= ();
foreach my $dev_temp (@$device_list_search) {
unless ($dev_temp->getservicebyname('urn:schemas-upnp-org:service:BasicManagement:2')) {
$devNum++;
next;
}
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";
$devNum++;
}
print "Devices with DIAGE capability: " . @temp_device_list . "\n";
return (\@temp_device_list, \@temp_device_ip, \@temp_device_port);
# 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);
}
1;
......@@ -31,32 +31,32 @@ my @device_port=();
my ($reader_input, $reader_output, $ssdp_res_msg) = '';
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";
recv(SSDP_SOCK, $ssdp_response, 4096, 0);
print $ssdp_response . "\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();
my $post_response = $http_request->post($host_address, $host_port, "GET", $dev_path, "", "");
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();
my $post_response = $http_request->post($host_address, $host_port, "GET", $dev_path, "", "");
my $post_content = $post_response->getcontent();
my $post_content = $post_response->getcontent();
my $dev = Net::UPnP::Device->new();
$dev->setssdp($ssdp_response);
$dev->setdescription($post_content);
my $dev = Net::UPnP::Device->new();
$dev->setssdp($ssdp_response);
$dev->setdescription($post_content);
push(@device_list, $dev);
push(@device_addr,$host_address);
push(@device_port,$host_port);
push(@device_list, $dev);
push(@device_addr,$host_address);
push(@device_port,$host_port);
}
close(SSDP_SOCK);
......
......@@ -52,7 +52,7 @@ sub get_user_options {
print "Input the number corresponding to the action to be invoked : ";
our $USR_OPT = <>;
chomp $USR_OPT;
return $USR_OPT;
return $USR_OPT;
}
sub get_manual_device_details {
......
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