blib/lib/Net/UPnP/GW/Gateway.pm

filter: Statementstmt 81.7% 148 / 181 Branchbran 70.0% 49 / 70 Conditioncond 59.2% 16 / 27 MC/DCmcdc 35.7% 5 / 14 Subroutinesub 92.8% 26 / 28 Podpod 72.2% 13 / 18 totaltotal 76.0% 257 / 338 CC 47 SCAR 19.0
CC
47
Cov
77%
getportmappingentries
16.3
gettotalbytesreceived
12.0
gettotalbytessent
12.0
CRAP 6.7
« examples/dms2vodcast.pl ↑ Summary blib/lib/Net/UPnP/Service.pm »
1 package Net::UPnP::GW::Gateway;
2  
3 #-----------------------------------------------------------------
4 # Net::UPnP::GW::Gateway
5 #-----------------------------------------------------------------
6  
7 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 ▶use Net::UPnP::HTTP;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use Net::UPnP::Device;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use Net::UPnP::Service;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 4 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 4 ▶use vars qw($_DEVICE $_CONNECTION_SERVICE_TYPE $DEVICE_TYPE $WANIPCONNECTION_SERVICE_TYPE $WANPPPCONNECTION_SERVICE_TYPE $WANCOMMONINTERFACECONFIG_SERVICE_TYPE);
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 4 $_DEVICE = 'device';
18 4 $_CONNECTION_SERVICE_TYPE = 'connection_service_type';
19  
20 4 $DEVICE_TYPE = 'urn:schemas-upnp-org:device:InternetGatewayDevice:1';
21 4 $WANIPCONNECTION_SERVICE_TYPE = 'urn:schemas-upnp-org:service:WANIPConnection:1';
22 4 $WANPPPCONNECTION_SERVICE_TYPE = 'urn:schemas-upnp-org:service:WANPPPConnection:1';
23 4 $WANCOMMONINTERFACECONFIG_SERVICE_TYPE = 'urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1';
24  
25 #------------------------------
26 # new
27 #------------------------------
28  
29 11 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
30 11 my($class) = shift;
31 11 my %args = @_;
32 my($this) = {
33 $Net::UPnP::GW::Gateway::_DEVICE => undef,
34 $Net::UPnP::GW::Gateway::_CONNECTION_SERVICE_TYPE => $args{connection_service_type},
35 11 };
36 11 bless $this, $class;
37 }
38  
39 #------------------------------
40 # device
41 #------------------------------
42  
43 10 ▶sub setdevice() {
Subroutine setdevice: called CC=2 SCAR=7.1
Pod undocumented
44 10 my($this) = shift;
45 10 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 10 0 10
46 10 $this->{$Net::UPnP::GW::Gateway::_DEVICE} = $_[0];
47 }
48 }
49  
50 44 ▶sub getdevice() {
Subroutine getdevice: called CC=1 SCAR=0.0
Pod undocumented
51 44 my($this) = shift;
52 44 $this->{$Net::UPnP::GW::Gateway::_DEVICE};
53 }
54  
55 #------------------------------
56 # connection service
57 #------------------------------
58  
59 # Service types tried, in order, when no type has been set explicitly.
60 # Dial-up (PPPoE/PPPoA) routers often provide only WANPPPConnection
61 # (RT #60372).
62 27 ▶sub _connection_service_types {
Subroutine _connection_service_types: called CC=1 SCAR=0.0
63 27 return ($Net::UPnP::GW::Gateway::WANIPCONNECTION_SERVICE_TYPE,
64 $Net::UPnP::GW::Gateway::WANPPPCONNECTION_SERVICE_TYPE);
65 }
66  
67 2 ▶sub setconnectionservicetype {
Subroutine setconnectionservicetype: called CC=1 SCAR=0.0
Pod documented
68 2 my($this) = shift;
69 2 $this->{$Net::UPnP::GW::Gateway::_CONNECTION_SERVICE_TYPE} = $_[0];
70 }
71  
72 27 ▶sub getconnectionservice {
Subroutine getconnectionservice: called CC=6 SCAR=17.9
Pod documented
73 27 my($this) = shift;
74 27 my $dev = $this->getdevice();
75 27 ▶ return undef unless $dev;
Branch: 1 branch
BranchTrueFalseTotal
unless $dev 1 26 27
76 26 my $type = $this->{$Net::UPnP::GW::Gateway::_CONNECTION_SERVICE_TYPE};
77 26 ▶ my @types = (defined($type) && length($type)) ? ($type) : _connection_service_types();
Branch: 1 branch
BranchTrueFalseTotal
defined $type && length $type ? : 4 22 26
Condition66%2/3
defined $type and length $type
!ll&&!rl&&r
2204
MC/DC50%1/2
defined $type and length $type
defined $type length $type
Truth table66%2/3
A and B
A= defined $typeB= length $type
ABresult
0X0
100
111
78 26 foreach my $service_type (@types) {
79 38 my $service = $dev->getservicebyname($service_type);
80 38 ▶ return $service if $service;
Branch: 1 branch
BranchTrueFalseTotal
if $service 20 18 38
81 }
82 6 return undef;
83 }
84  
85 7 ▶sub getconnectionservicetype {
Subroutine getconnectionservicetype: called CC=7 SCAR=19.6
Pod documented
86 7 my($this) = shift;
87 7 my $service = $this->getconnectionservice();
88 7 ▶ return '' unless $service;
Branch: 1 branch
BranchTrueFalseTotal
unless $service 1 6 7
89 6 my $type = $this->{$Net::UPnP::GW::Gateway::_CONNECTION_SERVICE_TYPE};
90 6 ▶ return $type if defined($type) && length($type);
Branch: 1 branch
BranchTrueFalseTotal
if defined $type and length $type 1 5 6
Condition66%2/3
defined $type and length $type
!ll&&!rl&&r
501
MC/DC50%1/2
defined $type and length $type
defined $type length $type
Truth table66%2/3
A and B
A= defined $typeB= length $type
ABresult
0X0
100
111
91 5 my $dev = $this->getdevice();
92 5 foreach my $service_type (_connection_service_types()) {
93 7 my $found = $dev->getservicebyname($service_type);
94 7 ▶ return $service_type if $found && $found == $service;
Branch: 1 branch
BranchTrueFalseTotal
if $found and $found == $service 5 2 7
Condition66%2/3
$found and $found == $service
!ll&&!rl&&r
205
MC/DC50%1/2
$found and $found == $service
$found $found == $service
Truth table66%2/3
A and B
A= $foundB= $found == $service
ABresult
0X0
100
111
95 }
96 0 return '';
97 }
98  
99 4 ▶sub _connectionaction {
Subroutine _connectionaction: called CC=3 SCAR=11.0
100 4 my($this, $action_name) = @_;
101 4 my $service = $this->getconnectionservice();
102 4 ▶ return undef unless $service;
Branch: 1 branch
BranchTrueFalseTotal
unless $service 1 3 4
103 3 my $action_res = $service->postaction($action_name);
104 3 ▶ return undef unless $action_res->getstatuscode() == 200;
Branch: 1 branch
BranchTrueFalseTotal
unless $action_res->getstatuscode == 200 0 3 3
105 3 return $action_res->getargumentlist();
106 }
107  
108 #------------------------------
109 # getstatusinfo
110 #------------------------------
111  
112 2 ▶sub getstatusinfo {
Subroutine getstatusinfo: called CC=2 SCAR=6.9
Pod documented
113 2 my($this) = shift;
114 2 ▶ my $arg_list = $this->_connectionaction('GetStatusInfo') or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $arg_list = $this->_connectionaction("GetStatusInfo") or return undef 1 1 2
115 return {
116 ConnectionStatus => $arg_list->{'NewConnectionStatus'},
117 LastConnectionError => $arg_list->{'NewLastConnectionError'},
118 1 Uptime => $arg_list->{'NewUptime'},
119 };
120 }
121  
122 #------------------------------
123 # getconnectiontypeinfo
124 #------------------------------
125  
126 1 ▶sub getconnectiontypeinfo {
Subroutine getconnectiontypeinfo: called CC=2 SCAR=7.1
Pod documented
127 1 my($this) = shift;
128 1 ▶ my $arg_list = $this->_connectionaction('GetConnectionTypeInfo') or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $arg_list = $this->_connectionaction("GetConnectionTypeInfo") or return undef 1 0 1
129 return {
130 ConnectionType => $arg_list->{'NewConnectionType'},
131 1 PossibleConnectionTypes => $arg_list->{'NewPossibleConnectionTypes'},
132 };
133 }
134  
135 #------------------------------
136 # getlinklayermaxbitrates (WANPPPConnection only)
137 #------------------------------
138  
139 2 ▶sub getlinklayermaxbitrates {
Subroutine getlinklayermaxbitrates: called CC=3 SCAR=11.0
Pod documented
140 2 my($this) = shift;
141 2 ▶ return undef unless $this->getconnectionservicetype() eq $Net::UPnP::GW::Gateway::WANPPPCONNECTION_SERVICE_TYPE;
Branch: 1 branch
BranchTrueFalseTotal
unless $this->getconnectionservicetype eq $Net::UPnP::GW::Gateway::WANPPPCONNECTION_SERVICE_TYPE 1 1 2
142 1 ▶ my $arg_list = $this->_connectionaction('GetLinkLayerMaxBitRates') or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $arg_list = $this->_connectionaction("GetLinkLayerMaxBitRates") or return undef 1 0 1
143 return {
144 UpstreamMaxBitRate => $arg_list->{'NewUpstreamMaxBitRate'},
145 1 DownstreamMaxBitRate => $arg_list->{'NewDownstreamMaxBitRate'},
146 };
147 }
148  
149 #------------------------------
150 # getexternalipaddress
151 #------------------------------
152  
153 3 ▶sub getexternalipaddress {
Subroutine getexternalipaddress: called CC=3 SCAR=11.0
Pod documented
154 3 my($this) = shift;
155
156 my (
157 3 $dev,
158 $wanipcon_service,
159 $action_res,
160 $arg_list,
161 $ipaddr,
162 );
163
164 3 $dev = $this->getdevice();
165 3 $wanipcon_service = $this->getconnectionservice();
166 3 ▶ unless ($wanipcon_service) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($wanipcon_service) 1 2 3
167 1 return "";
168 }
169 2 $action_res = $wanipcon_service->postaction("GetExternalIPAddress");
170 2 ▶ if ($action_res->getstatuscode() != 200) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action_res->getstatuscode != 200) 0 2 2
171 0 return "";
172 }
173 2 $arg_list = $action_res->getargumentlist();
174 2 $ipaddr = $arg_list->{'NewExternalIPAddress'};
175
176 2 return $ipaddr;
177 }
178  
179 #------------------------------
180 # getportmappingnumberofentries
181 #------------------------------
182  
183 2 ▶sub getportmappingnumberofentries {
Subroutine getportmappingnumberofentries: called CC=4 SCAR=14.3
Pod documented
184 2 my($this) = shift;
185  
186 my (
187 2 $dev,
188 $wanipcon_service,
189 $query_res,
190 );
191
192 2 $dev = $this->getdevice();
193 2 $wanipcon_service = $this->getconnectionservice();
194 2 ▶ unless ($wanipcon_service) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($wanipcon_service) 1 1 2
195 1 return 0;
196 }
197
198 1 $query_res = $wanipcon_service->postquery("PortMappingNumberOfEntries");
199  
200 1 ▶ if ($query_res->getstatuscode() != 200) {
Branch: 1 branch
BranchTrueFalseTotal
if ($query_res->getstatuscode != 200) 0 1 1
201 0 return 0;
202 }
203  
204 1 ▶ if( $query_res->getvalue() =~ /^(\d+)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($query_res->getvalue =~ /^(\d+)$/) { } 0 1 1
205 0 return $1;
206 } else {
207 1 return scalar($this->getportmappingentries());
208 }
209 }
210  
211  
212 #------------------------------
213 # getportmapping
214 #------------------------------
215  
216 7 ▶sub getportmappingentries {
Subroutine getportmappingentries: called CC=15 SCAR=27.9
Pod documented
217 7 my($this) = shift;
218 7 my %args = (max_entries => 1024, timeout => 30, @_);
219 croak 'Invalid mapping entry limit' unless defined($args{max_entries})
220 7 ▶ && $args{max_entries} =~ /\A\d+\z/ && Net::UPnP::HTTP::_isfinite(0 + $args{max_entries}) && $args{max_entries} > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"max_entries"} and $args{"max_entries"} =~ /\A\d+\z/ and Net::UPnP::HTTP::_isfinite(0 + $args{"max_entries"}) and $args{"max_entries"} > 0 1 6 7
Condition55%5/9
defined $args{"max_entries"} and $args{"max_entries"} =~ /\A\d+\z/ and Net::UPnP::HTTP::_isfinite(0 + $args{"max_entries"}) and $args{"max_entries"} > 0
!ll&&!rl&&r
106
defined $args{"max_entries"} and $args{"max_entries"} =~ /\A\d+\z/ and Net::UPnP::HTTP::_isfinite(0 + $args{"max_entries"})
!ll&&!rl&&r
016
defined $args{"max_entries"} and $args{"max_entries"} =~ /\A\d+\z/
!ll&&!rl&&r
007
MC/DC25%1/4
defined $args{"max_entries"} and $args{"max_entries"} =~ /\A\d+\z/ and Net::UPnP::HTTP::_isfinite(0 + $args{"max_entries"}) and $args{"max_entries"} > 0
defined $args{"max_entries"} $args{"max_entries"} =~ /\A\d+\z/ Net::UPnP::HTTP::_isfinite(0 + $args{"max_entries"}) $args{"max_entries"} > 0
Truth table40%2/5
A and B and C and D
A= defined $args{"max_entries"}B= $args{"max_entries"} =~ /\A\d+\z/C= Net::UPnP::HTTP::_isfinite(0 + $args{"max_entries"})D= $args{"max_entries"} > 0
ABCDresult
0XXX0
10XX0
110X0
11100
11111
221 croak 'Invalid mapping timeout' unless defined($args{timeout})
222 6 ▶ && $args{timeout} =~ /\A\d+(?:\.\d+)?\z/ && Net::UPnP::HTTP::_isfinite(0 + $args{timeout}) && $args{timeout} > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"timeout"} and $args{"timeout"} =~ /\A\d+(?:\.\d+)?\z/ and Net::UPnP::HTTP::_isfinite(0 + $args{"timeout"}) and $args{"timeout"} > 0 1 5 6
Condition55%5/9
defined $args{"timeout"} and $args{"timeout"} =~ /\A\d+(?:\.\d+)?\z/ and Net::UPnP::HTTP::_isfinite(0 + $args{"timeout"}) and $args{"timeout"} > 0
!ll&&!rl&&r
105
defined $args{"timeout"} and $args{"timeout"} =~ /\A\d+(?:\.\d+)?\z/ and Net::UPnP::HTTP::_isfinite(0 + $args{"timeout"})
!ll&&!rl&&r
015
defined $args{"timeout"} and $args{"timeout"} =~ /\A\d+(?:\.\d+)?\z/
!ll&&!rl&&r
006
MC/DC25%1/4
defined $args{"timeout"} and $args{"timeout"} =~ /\A\d+(?:\.\d+)?\z/ and Net::UPnP::HTTP::_isfinite(0 + $args{"timeout"}) and $args{"timeout"} > 0
defined $args{"timeout"} $args{"timeout"} =~ /\A\d+(?:\.\d+)?\z/ Net::UPnP::HTTP::_isfinite(0 + $args{"timeout"}) $args{"timeout"} > 0
Truth table40%2/5
A and B and C and D
A= defined $args{"timeout"}B= $args{"timeout"} =~ /\A\d+(?:\.\d+)?\z/C= Net::UPnP::HTTP::_isfinite(0 + $args{"timeout"})D= $args{"timeout"} > 0
ABCDresult
0XXX0
10XX0
110X0
11100
11111
223 5 $this->{error} = '';
224 5 my $deadline = Net::UPnP::HTTP::_now() + $args{timeout};
225
226 my (
227 5 @port_mapping,
228 $dev,
229 $port_mapping_num,
230 $wanipcon_service,
231 $n,
232 %req_arg,
233 $action_res,
234 $arg_list,
235 $ipaddr,
236 );
237
238 5 $dev = $this->getdevice();
239 5 $wanipcon_service = $this->getconnectionservice();
240 5 ▶ unless ($wanipcon_service) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($wanipcon_service) 0 5 5
241 0 return @port_mapping;
242 }
243
244 5 $n = 0;
245 5 ▶ while ($n < $args{max_entries}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n < $args{"max_entries"}) 1035 3 1038
246 1035 ▶ if (Net::UPnP::HTTP::_now() >= $deadline) {
Branch: 1 branch
BranchTrueFalseTotal
if (Net::UPnP::HTTP::_now() >= $deadline) 1 1034 1035
247 1 $this->{error} = 'Port mapping deadline exceeded';
248 1 last;
249 }
250 %req_arg = (
251 1034 'NewPortMappingIndex' => $n,
252 );
253
254 1034 $action_res = $wanipcon_service->postaction("GetGenericPortMappingEntry", \%req_arg, {deadline => $deadline});
255 #print "[$n]" .$action_res->getstatuscode() . "\n";
256 #print %req_arg;
257 1034 ▶ if ($action_res->getstatuscode() != 200) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action_res->getstatuscode != 200) 1 1033 1034
258 1 ▶ $this->{error} = 'Port mapping request failed' if !$action_res->getstatuscode();
Branch: 1 branch
BranchTrueFalseTotal
unless $action_res->getstatuscode 0 1 1
259 1 last;
260 }
261 1033 $arg_list = $action_res->getargumentlist();
262 #print $arg_list;
263 1033 push(@port_mapping, $arg_list);
264 1033 ++$n;
265 }
266 5 ▶ if ($n == $args{max_entries}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n == $args{"max_entries"}) 3 2 5
267 3 $this->{error} = 'Port mapping entry limit reached';
268 }
269
270 5 return @port_mapping;
271 }
272  
273 4 ▶sub geterror { $_[0]->{error} || '' }
Subroutine geterror: called CC=2 SCAR=6.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{"error"} or "" 3 1 4
274  
275 # deprecated method - mapped to new name
276 1 ▶sub getportmappingentry { getportmappingentries(@_); }
Subroutine getportmappingentry: called CC=1 SCAR=0.0
Pod undocumented
277  
278  
279 #------------------------------
280 # addportmapping
281 #------------------------------
282  
283 1 ▶sub addportmapping {
Subroutine addportmapping: called CC=3 SCAR=11.4
Pod documented
284 1 my($this) = shift;
285 1 my %args = (
286 NewRemoteHost => '',
287 NewExternalPort => '',
288 NewProtocol => '',
289 NewInternalPort => '',
290 NewInternalClient => '',
291 NewEnabled => 1,
292 NewPortMappingDescription => '',
293 NewLeaseDuration => 0,
294 @_,
295 );
296
297 my (
298 1 $dev,
299 $wanipcon_service,
300 $action_res,
301 $arg_list,
302 $ipaddr,
303 %req_arg,
304 );
305
306 1 $dev = $this->getdevice();
307 1 $wanipcon_service = $this->getconnectionservice();
308 1 ▶ unless ($wanipcon_service) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($wanipcon_service) 0 1 1
309 0 return 0;
310 }
311
312 %req_arg = (
313 'NewRemoteHost' => $args{NewRemoteHost},
314 'NewExternalPort' => $args{NewExternalPort},
315 'NewProtocol' => $args{NewProtocol},
316 'NewInternalPort' => $args{NewInternalPort},
317 'NewInternalClient' => $args{NewInternalClient},
318 'NewEnabled' => $args{NewEnabled},
319 'NewPortMappingDescription' => $args{NewPortMappingDescription},
320 'NewLeaseDuration' => $args{NewLeaseDuration},
321 1 );
322
323 1 $action_res = $wanipcon_service->postaction("AddPortMapping", \%req_arg);
324 1 ▶ if ($action_res->getstatuscode() != 200) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action_res->getstatuscode != 200) 0 1 1
325 0 return 0;
326 }
327 1 return 1;
328 }
329  
330 #------------------------------
331 # deleteportmapping
332 #------------------------------
333  
334 1 ▶sub deleteportmapping {
Subroutine deleteportmapping: called CC=3 SCAR=11.4
Pod documented
335 1 my($this) = shift;
336 1 my %args = (
337 NewRemoteHost => '',
338 NewExternalPort => '',
339 NewProtocol => '',
340 @_,
341 );
342
343 my (
344 1 $dev,
345 $wanipcon_service,
346 $action_res,
347 $arg_list,
348 $ipaddr,
349 %req_arg,
350 );
351
352 1 $dev = $this->getdevice();
353 1 $wanipcon_service = $this->getconnectionservice();
354 1 ▶ unless ($wanipcon_service) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($wanipcon_service) 0 1 1
355 0 return 0;
356 }
357
358 %req_arg = (
359 'NewRemoteHost' => $args{NewRemoteHost},
360 'NewExternalPort' => $args{NewExternalPort},
361 'NewProtocol' => $args{NewProtocol},
362 1 );
363
364 1 $action_res = $wanipcon_service->postaction("DeletePortMapping", \%req_arg);
365 1 ▶ if ($action_res->getstatuscode() != 200) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action_res->getstatuscode != 200) 0 1 1
366 0 return 0;
367 }
368 1 return 1;
369 }
370  
371 #------------------------------
372 # gettotalbytesreceived
373 #------------------------------
374  
375 0 ▶sub gettotalbytesreceived {
Subroutine gettotalbytesreceived: not called CC=3 SCAR=24.8
Pod documented
376 0 my($this) = shift;
377
378 my (
379 0 $dev,
380 $wanconif_service,
381 $action_res,
382 $arg_list,
383 $totalBytes,
384 );
385
386 0 $dev = $this->getdevice();
387 0 $wanconif_service = $dev->getservicebyname($Net::UPnP::GW::Gateway::WANCOMMONINTERFACECONFIG_SERVICE_TYPE);
388 0 ▶ unless ($wanconif_service) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($wanconif_service) 0 0 0
389 0 return "";
390 }
391 0 $action_res = $wanconif_service->postaction("GetTotalBytesReceived");
392 0 ▶ if ($action_res->getstatuscode() != 200) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action_res->getstatuscode != 200) 0 0 0
393 0 return "";
394 }
395 0 $arg_list = $action_res->getargumentlist();
396 0 $totalBytes = $arg_list->{'NewTotalBytesReceived'};
397
398 0 return $totalBytes;
399 }
400  
401 # Backward-compatible alias for the historical misspelling (RT #123509).
402 4 ▶{ no warnings 'once'; *gettotalbytesrecieved = \&gettotalbytesreceived; }
Subroutine BEGIN: called CC=1 SCAR=0.0
403  
404 #------------------------------
405 # gettotalbytessent
406 #------------------------------
407  
408 0 ▶sub gettotalbytessent {
Subroutine gettotalbytessent: not called CC=3 SCAR=24.8
Pod undocumented
409 0 my($this) = shift;
410  
411 my (
412 0 $dev,
413 $wanconif_service,
414 $action_res,
415 $arg_list,
416 $totalBytes,
417 );
418  
419 0 $dev = $this->getdevice();
420 0 $wanconif_service = $dev->getservicebyname($Net::UPnP::GW::Gateway::WANCOMMONINTERFACECONFIG_SERVICE_TYPE);
421 0 ▶ unless ($wanconif_service) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($wanconif_service) 0 0 0
422 0 return "";
423 }
424 0 $action_res = $wanconif_service->postaction("GetTotalBytesSent");
425 0 ▶ if ($action_res->getstatuscode() != 200) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action_res->getstatuscode != 200) 0 0 0
426 0 return "";
427 }
428 0 $arg_list = $action_res->getargumentlist();
429 0 $totalBytes = $arg_list->{'NewTotalBytesSent'};
430  
431 0 return $totalBytes;
432 }
433  
434 4 1;
435  
436 __END__
« examples/dms2vodcast.pl ↑ Summary blib/lib/Net/UPnP/Service.pm »