| 1 | package Net::UPnP::Service; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | #----------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 4 | # Net::Net::UPnP::Service | ||||||||||||||||||||||||||||
| 5 | #----------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 6 | ▶ | use Net::UPnP; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 6 | ▶ | use Net::UPnP::ActionResponse; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 6 | ▶ | use Net::UPnP::QueryResponse; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 6 | ▶ | use vars qw($_DEVICE $_DEVICE_DESCRIPTION $SERVICETYPE $SERVICEID $SCPDURL $CONTROLURL $EVENTSUBURL); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 6 | $_DEVICE = 'device'; | |||||||||||||||||||||||||||
| 17 | 6 | $_DEVICE_DESCRIPTION = 'device_description'; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 6 | $SERVICETYPE = 'serviceType'; | |||||||||||||||||||||||||||
| 20 | 6 | $SERVICEID = 'serviceId'; | |||||||||||||||||||||||||||
| 21 | 6 | $SCPDURL = 'SCPDURL'; | |||||||||||||||||||||||||||
| 22 | 6 | $CONTROLURL = 'controlURL'; | |||||||||||||||||||||||||||
| 23 | 6 | $EVENTSUBURL = 'eventSubURL'; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | #------------------------------ | ||||||||||||||||||||||||||||
| 26 | # new | ||||||||||||||||||||||||||||
| 27 | #------------------------------ | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 4 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 30 | 4 | my($class) = shift; | |||||||||||||||||||||||||||
| 31 | 4 | my($this) = { | |||||||||||||||||||||||||||
| 32 | $Net::UPnP::Service::_DEVICE => undef, | ||||||||||||||||||||||||||||
| 33 | $Net::UPnP::Service::_DEVICE_DESCRIPTION => '', | ||||||||||||||||||||||||||||
| 34 | }; | ||||||||||||||||||||||||||||
| 35 | 4 | bless $this, $class; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | #------------------------------ | ||||||||||||||||||||||||||||
| 39 | # device | ||||||||||||||||||||||||||||
| 40 | #------------------------------ | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 4 | ▶ | sub setdevice() { | ||||||||||||||||||||||||||
|
Subroutine
setdevice: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 43 | 4 | my($this) = shift; | |||||||||||||||||||||||||||
| 44 | 4 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 4 | $this->{$Net::UPnP::Service::_DEVICE} = $_[0]; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 24 | ▶ | sub getdevice() { | ||||||||||||||||||||||||||
|
Subroutine
getdevice: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 50 | 24 | my($this) = shift; | |||||||||||||||||||||||||||
| 51 | 24 | $this->{$Net::UPnP::Service::_DEVICE}; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | #------------------------------ | ||||||||||||||||||||||||||||
| 55 | # device description | ||||||||||||||||||||||||||||
| 56 | #------------------------------ | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 6 | ▶ | sub setdevicedescription() { | ||||||||||||||||||||||||||
|
Subroutine
setdevicedescription: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 59 | 6 | my($this) = shift; | |||||||||||||||||||||||||||
| 60 | 6 | $this->{$Net::UPnP::Service::_DEVICE_DESCRIPTION} = $_[0]; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 37 | ▶ | sub getdevicedescription() { | ||||||||||||||||||||||||||
|
Subroutine
getdevicedescription: called CC=3 SCAR=12.3
Pod
documented
| |||||||||||||||||||||||||||||
| 64 | 37 | my($this) = shift; | |||||||||||||||||||||||||||
| 65 | 37 | my %args = ( | |||||||||||||||||||||||||||
| 66 | name => undef, | ||||||||||||||||||||||||||||
| 67 | @_, | ||||||||||||||||||||||||||||
| 68 | ); | ||||||||||||||||||||||||||||
| 69 | 37 | ▶ | if ($args{name}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 37 | ▶ | unless ($this->{$Net::UPnP::Service::_DEVICE_DESCRIPTION} =~ m/<$args{name}>(.*)<\/$args{name}>/i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 0 | return ''; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | 37 | return $1; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | 0 | $this->{$Net::UPnP::Service::_DEVICE_DESCRIPTION}; | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | #------------------------------ | ||||||||||||||||||||||||||||
| 79 | # getservicetype | ||||||||||||||||||||||||||||
| 80 | #------------------------------ | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 13 | ▶ | sub getservicetype() { | ||||||||||||||||||||||||||
|
Subroutine
getservicetype: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 83 | 13 | my($this) = shift; | |||||||||||||||||||||||||||
| 84 | 13 | $this->getdevicedescription(name => $Net::UPnP::Service::SERVICETYPE); | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | #------------------------------ | ||||||||||||||||||||||||||||
| 88 | # getserviceid | ||||||||||||||||||||||||||||
| 89 | #------------------------------ | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 0 | ▶ | sub getserviceid() { | ||||||||||||||||||||||||||
|
Subroutine
getserviceid: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 92 | 0 | my($this) = shift; | |||||||||||||||||||||||||||
| 93 | 0 | $this->getdevicedescription(name => $Net::UPnP::Service::SERVICEID); | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | #------------------------------ | ||||||||||||||||||||||||||||
| 97 | # getscpdurl | ||||||||||||||||||||||||||||
| 98 | #------------------------------ | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 0 | ▶ | sub getscpdurl() { | ||||||||||||||||||||||||||
|
Subroutine
getscpdurl: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 101 | 0 | my($this) = shift; | |||||||||||||||||||||||||||
| 102 | 0 | $this->getdevicedescription(name => $Net::UPnP::Service::SCPDURL); | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | #------------------------------ | ||||||||||||||||||||||||||||
| 106 | # getcontrolurl | ||||||||||||||||||||||||||||
| 107 | #------------------------------ | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 24 | ▶ | sub getcontrolurl() { | ||||||||||||||||||||||||||
|
Subroutine
getcontrolurl: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 110 | 24 | my($this) = shift; | |||||||||||||||||||||||||||
| 111 | 24 | $this->getdevicedescription(name => $Net::UPnP::Service::CONTROLURL); | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | #------------------------------ | ||||||||||||||||||||||||||||
| 115 | # geteventsuburl | ||||||||||||||||||||||||||||
| 116 | #------------------------------ | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 0 | ▶ | sub geteventsuburl() { | ||||||||||||||||||||||||||
|
Subroutine
geteventsuburl: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 119 | 0 | my($this) = shift; | |||||||||||||||||||||||||||
| 120 | 0 | $this->getdevicedescription(name => $Net::UPnP::Service::EVENTSUBURL); | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | #------------------------------ | ||||||||||||||||||||||||||||
| 124 | # getposturl | ||||||||||||||||||||||||||||
| 125 | #------------------------------ | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 12 | ▶ | sub getposturl() { | ||||||||||||||||||||||||||
|
Subroutine
getposturl: called CC=9 SCAR=23.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 128 | 12 | my($this) = shift; | |||||||||||||||||||||||||||
| 129 | 12 | my ($ctrl_url) = @_; | |||||||||||||||||||||||||||
| 130 | my ( | ||||||||||||||||||||||||||||
| 131 | 12 | $dev, | |||||||||||||||||||||||||||
| 132 | $location_url, | ||||||||||||||||||||||||||||
| 133 | $url_base, | ||||||||||||||||||||||||||||
| 134 | ); | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 12 | $dev = $this->getdevice(); | |||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 12 | $location_url = $dev->getlocation(); | |||||||||||||||||||||||||||
| 139 | 12 | $url_base = $dev->geturlbase(); | |||||||||||||||||||||||||||
| 140 | 12 | $ctrl_url = $this->getcontrolurl(); | |||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | #print "$location_url\n"; | ||||||||||||||||||||||||||||
| 143 | #print "$url_base\n"; | ||||||||||||||||||||||||||||
| 144 | #print "$ctrl_url\n"; | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 12 | ▶ | unless ($ctrl_url =~ m{http://(.*)}i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 147 | 8 | ▶ | if (0 < length($url_base)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | # Thanks for Thus0 (2005/01/12) | ||||||||||||||||||||||||||||
| 149 | 4 | ▶ | if (rindex($url_base, '/') == (length($url_base)-1) && index($ctrl_url, '/') == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
rindex($url_base, "/") == length($url_base) - 1 and index($ctrl_url, "/") == 0
MC/DC0%0/2
rindex($url_base, "/") == length($url_base) - 1 and index($ctrl_url, "/") == 0
rindex($url_base, "/") == length($url_base) - 1
index($ctrl_url, "/") == 0
Truth table33%1/3
A and B
A= rindex($url_base, "/") == length($url_base) - 1B= index($ctrl_url, "/") == 0
| |||||||||||||||||||||||||||||
| 150 | 4 | $ctrl_url = $url_base . substr($ctrl_url, 1); | |||||||||||||||||||||||||||
| 151 | } else { | ||||||||||||||||||||||||||||
| 152 | 0 | $ctrl_url = $url_base . $ctrl_url; | |||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | else { | ||||||||||||||||||||||||||||
| 156 | 4 | ▶ | if ($location_url =~ m{http://([0-9a-z.-]+)(?::(\d+))?/(.*)}i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 157 | 4 | ▶ | my $port = $2 || 80; | ||||||||||||||||||||||||||
|
Condition100%2/2
$2 || 80
MC/DC100%1/1
$2 || 80
$2
Truth table100%2/2
A
A= $2
| |||||||||||||||||||||||||||||
| 158 | 4 | ▶ | if (defined($3) && 0 < length($3)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $3 and 0 < length $3
MC/DC0%0/2
defined $3 and 0 < length $3
defined $3
0 < length $3
Truth table33%1/3
A and B
A= defined $3B= 0 < length $3
| |||||||||||||||||||||||||||||
| 159 | 4 | $ctrl_url = 'http://' . $1 . ":" . $port . $ctrl_url; | |||||||||||||||||||||||||||
| 160 | } else { | ||||||||||||||||||||||||||||
| 161 | 0 | $ctrl_url = 'http://' . $1 . ":" . $port . '/' . $ctrl_url; | |||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | } else { | ||||||||||||||||||||||||||||
| 164 | 0 | $ctrl_url = $location_url . $ctrl_url; | |||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 12 | return $ctrl_url; | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | #------------------------------ | ||||||||||||||||||||||||||||
| 173 | # postaction | ||||||||||||||||||||||||||||
| 174 | #------------------------------ | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 9 | ▶ | sub postaction() { | ||||||||||||||||||||||||||
|
Subroutine
postaction: called CC=10 SCAR=24.9
Pod
documented
| |||||||||||||||||||||||||||||
| 177 | 9 | my($this) = shift; | |||||||||||||||||||||||||||
| 178 | 9 | my ($action_name, $action_arg, $http_options) = @_; | |||||||||||||||||||||||||||
| 179 | my ( | ||||||||||||||||||||||||||||
| 180 | 9 | $dev, | |||||||||||||||||||||||||||
| 181 | $ctrl_url, | ||||||||||||||||||||||||||||
| 182 | $service_type, | ||||||||||||||||||||||||||||
| 183 | $soap_action, | ||||||||||||||||||||||||||||
| 184 | $soap_content, | ||||||||||||||||||||||||||||
| 185 | $arg_name, | ||||||||||||||||||||||||||||
| 186 | $arg_value, | ||||||||||||||||||||||||||||
| 187 | $post_addr, | ||||||||||||||||||||||||||||
| 188 | $post_port, | ||||||||||||||||||||||||||||
| 189 | $post_path, | ||||||||||||||||||||||||||||
| 190 | $http_req, | ||||||||||||||||||||||||||||
| 191 | $post_res, | ||||||||||||||||||||||||||||
| 192 | $action_res, | ||||||||||||||||||||||||||||
| 193 | $key, | ||||||||||||||||||||||||||||
| 194 | ); | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 9 | $action_res = Net::UPnP::ActionResponse->new(); | |||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | 9 | $dev = $this->getdevice(); | |||||||||||||||||||||||||||
| 199 | 9 | $ctrl_url = $this->getcontrolurl(); | |||||||||||||||||||||||||||
| 200 | 9 | $ctrl_url = $this->getposturl($ctrl_url); | |||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 9 | ▶ | unless ($ctrl_url =~ m{http://([0-9a-z.-]+)(?::(\d+))?/(.*)}i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 203 | #print "Invalid URL : $ctrl_url\n"; | ||||||||||||||||||||||||||||
| 204 | 0 | $post_res = Net::UPnP::HTTPResponse->new(); | |||||||||||||||||||||||||||
| 205 | 0 | $action_res->sethttpresponse($post_res); | |||||||||||||||||||||||||||
| 206 | 0 | return $action_res; | |||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||
| 208 | 9 | $post_addr = $1; | |||||||||||||||||||||||||||
| 209 | 9 | ▶ | $post_port = $2 || 80; | ||||||||||||||||||||||||||
|
Condition100%2/2
$2 || 80
MC/DC100%1/1
$2 || 80
$2
Truth table100%2/2
A
A= $2
| |||||||||||||||||||||||||||||
| 210 | 9 | ▶ | if (index($3, '/') == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 211 | 0 | $post_path = $3; | |||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||
| 213 | else { | ||||||||||||||||||||||||||||
| 214 | 9 | $post_path = '/' . $3; | |||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 9 | $service_type = $this->getservicetype(); | |||||||||||||||||||||||||||
| 218 | 9 | $soap_action = '"' . $service_type . '#' . $action_name . '"'; | |||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | 9 | $soap_content = <<"SOAP_CONTENT"; | |||||||||||||||||||||||||||
| 222 | <?xml version=\"1.0\" encoding=\"utf-8\"?> | ||||||||||||||||||||||||||||
| 223 | <s:Envelope xmlns:s=\"http:\/\/schemas.xmlsoap.org\/soap\/envelope\/\" s:encodingStyle=\"http:\/\/schemas.xmlsoap.org\/soap\/encoding/\"> | ||||||||||||||||||||||||||||
| 224 | \t<s:Body> | ||||||||||||||||||||||||||||
| 225 | \t\t<u:$action_name xmlns:u=\"$service_type\"> | ||||||||||||||||||||||||||||
| 226 | SOAP_CONTENT | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | 9 | ▶ | if (ref $action_arg) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 229 | 9 | ▶ | while (($arg_name, $arg_value) = each (%{$action_arg} ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 230 | 0 | ▶ | if (length($arg_value) <= 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 231 | 0 | $soap_content .= "\t\t\t<$arg_name \/>\n"; | |||||||||||||||||||||||||||
| 232 | 0 | next; | |||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | 0 | $soap_content .= "\t\t\t<$arg_name>$arg_value<\/$arg_name>\n"; | |||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | 9 | $soap_content .= <<"SOAP_CONTENT"; | |||||||||||||||||||||||||||
| 239 | \t\t</u:$action_name> | ||||||||||||||||||||||||||||
| 240 | \t</s:Body> | ||||||||||||||||||||||||||||
| 241 | </s:Envelope> | ||||||||||||||||||||||||||||
| 242 | SOAP_CONTENT | ||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | 9 | ▶ | my %options = %{$http_options || {}}; | ||||||||||||||||||||||||||
|
Condition100%2/2
$http_options || {}
MC/DC100%1/1
$http_options || {}
$http_options
Truth table100%2/2
A
A= $http_options
| |||||||||||||||||||||||||||||
| 245 | 9 | my $allowed = $dev->getallowedaddresses(); | |||||||||||||||||||||||||||
| 246 | 9 | ▶ | $options{allowed_addresses} = $allowed if defined $allowed; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 247 | 9 | $http_req = Net::UPnP::HTTP->new(%options); | |||||||||||||||||||||||||||
| 248 | 9 | $post_res = $http_req->postsoap($post_addr, $post_port, $post_path, $soap_action, $soap_content); | |||||||||||||||||||||||||||
| 249 | 9 | ▶ | $post_res ||= Net::UPnP::HTTPResponse->new(); | ||||||||||||||||||||||||||
|
Condition66%2/3
$post_res ||= "Net::UPnP::HTTPResponse"->new
MC/DC0%0/2
$post_res ||= "Net::UPnP::HTTPResponse"->new
$post_res
"Net::UPnP::HTTPResponse"->new
Truth table66%2/3
A ||= B
A= $post_resB= "Net::UPnP::HTTPResponse"->new
| |||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | 9 | $action_res->sethttpresponse($post_res); | |||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | 9 | return $action_res; | |||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | #------------------------------ | ||||||||||||||||||||||||||||
| 257 | # postcontrol | ||||||||||||||||||||||||||||
| 258 | #------------------------------ | ||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | 3 | ▶ | sub postcontrol() { | ||||||||||||||||||||||||||
|
Subroutine
postcontrol: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 261 | 3 | my($this) = shift; | |||||||||||||||||||||||||||
| 262 | 3 | return $this->postaction(@_); | |||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | #------------------------------ | ||||||||||||||||||||||||||||
| 266 | # postquery | ||||||||||||||||||||||||||||
| 267 | #------------------------------ | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | 3 | ▶ | sub postquery() { | ||||||||||||||||||||||||||
|
Subroutine
postquery: called CC=7 SCAR=20.3
Pod
documented
| |||||||||||||||||||||||||||||
| 270 | 3 | my($this) = shift; | |||||||||||||||||||||||||||
| 271 | 3 | my ($var_name) = @_; | |||||||||||||||||||||||||||
| 272 | my ( | ||||||||||||||||||||||||||||
| 273 | 3 | $dev, | |||||||||||||||||||||||||||
| 274 | $ctrl_url, | ||||||||||||||||||||||||||||
| 275 | $service_type, | ||||||||||||||||||||||||||||
| 276 | $soap_action, | ||||||||||||||||||||||||||||
| 277 | $soap_content, | ||||||||||||||||||||||||||||
| 278 | $post_addr, | ||||||||||||||||||||||||||||
| 279 | $post_port, | ||||||||||||||||||||||||||||
| 280 | $post_path, | ||||||||||||||||||||||||||||
| 281 | $http_req, | ||||||||||||||||||||||||||||
| 282 | $post_res, | ||||||||||||||||||||||||||||
| 283 | $query_res, | ||||||||||||||||||||||||||||
| 284 | ); | ||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | 3 | $query_res = Net::UPnP::QueryResponse->new(); | |||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | 3 | $dev = $this->getdevice(); | |||||||||||||||||||||||||||
| 289 | 3 | $ctrl_url = $this->getcontrolurl(); | |||||||||||||||||||||||||||
| 290 | 3 | $ctrl_url = $this->getposturl($ctrl_url); | |||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | 3 | ▶ | print "ctrl_url=$ctrl_url\n" if ($Net::UPnP::DEBUG); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 293 | 3 | ▶ | unless ($ctrl_url =~ m{http://([0-9a-z.-]+)(?::(\d+))?/(.*)}i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 294 | 0 | $post_res = Net::UPnP::HTTPResponse->new(); | |||||||||||||||||||||||||||
| 295 | 0 | $query_res->sethttpresponse($post_res); | |||||||||||||||||||||||||||
| 296 | 0 | return $query_res; | |||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||
| 298 | 3 | $post_addr = $1; | |||||||||||||||||||||||||||
| 299 | 3 | ▶ | $post_port = $2 || 80; | ||||||||||||||||||||||||||
|
Condition100%2/2
$2 || 80
MC/DC100%1/1
$2 || 80
$2
Truth table100%2/2
A
A= $2
| |||||||||||||||||||||||||||||
| 300 | 3 | ▶ | if (index($3, '/') == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 301 | 0 | $post_path = $3; | |||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||
| 303 | else { | ||||||||||||||||||||||||||||
| 304 | 3 | $post_path = '/' . $3; | |||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||
| 306 | 3 | $service_type = $this->getservicetype(); | |||||||||||||||||||||||||||
| 307 | 3 | $soap_action = '"urn:schemas-upnp-org:control-1-0#QueryStateVariable"'; | |||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | 3 | $soap_content = <<"SOAP_CONTENT"; | |||||||||||||||||||||||||||
| 311 | <?xml version=\"1.0\" encoding=\"utf-8\"?> | ||||||||||||||||||||||||||||
| 312 | <s:Envelope xmlns:s=\"http:\/\/schemas.xmlsoap.org\/soap\/envelope\/\" s:encodingStyle=\"http:\/\/schemas.xmlsoap.org\/soap\/encoding/\"> | ||||||||||||||||||||||||||||
| 313 | \t<s:Body> | ||||||||||||||||||||||||||||
| 314 | \t\t<u:QueryStateVariable xmlns:u=\"urn:schemas-upnp-org:control-1-0\"> | ||||||||||||||||||||||||||||
| 315 | \t\t\t<u:varName>$var_name</u:varName> | ||||||||||||||||||||||||||||
| 316 | \t\t</u:QueryStateVariable> | ||||||||||||||||||||||||||||
| 317 | \t</s:Body> | ||||||||||||||||||||||||||||
| 318 | </s:Envelope> | ||||||||||||||||||||||||||||
| 319 | SOAP_CONTENT | ||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | 3 | my $allowed = $dev->getallowedaddresses(); | |||||||||||||||||||||||||||
| 322 | 3 | ▶ | $http_req = Net::UPnP::HTTP->new(defined($allowed) ? (allowed_addresses => $allowed) : ()); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 323 | 3 | $post_res = $http_req->postsoap($post_addr, $post_port, $post_path, $soap_action, $soap_content); | |||||||||||||||||||||||||||
| 324 | 3 | ▶ | $post_res ||= Net::UPnP::HTTPResponse->new(); | ||||||||||||||||||||||||||
|
Condition33%1/3
$post_res ||= "Net::UPnP::HTTPResponse"->new
MC/DC0%0/2
$post_res ||= "Net::UPnP::HTTPResponse"->new
$post_res
"Net::UPnP::HTTPResponse"->new
Truth table33%1/3
A ||= B
A= $post_resB= "Net::UPnP::HTTPResponse"->new
| |||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | 3 | $query_res->sethttpresponse($post_res); | |||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | 3 | return $query_res; | |||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | 6 | 1; | |||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | __END__ | ||||||||||||||||||||||||||||