| 1 | package Net::UPnP::GW::Gateway; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | #----------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # Net::UPnP::GW::Gateway | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | #----------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Net::UPnP::HTTP; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Net::UPnP::Device; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use Net::UPnP::Service; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use vars qw($_DEVICE $DEVICE_TYPE $WANIPCONNECTION_SERVICE_TYPE $WANCOMMONINTERFACECONFIG_SERVICE_TYPE); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | $_DEVICE = 'device'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | $DEVICE_TYPE = 'urn:schemas-upnp-org:device:InternetGatewayDevice:1'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | $WANIPCONNECTION_SERVICE_TYPE = 'urn:schemas-upnp-org:service:WANIPConnection:1'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | $WANCOMMONINTERFACECONFIG_SERVICE_TYPE = 'urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | #------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | #------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 6 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 6 | my($class) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 6 | my($this) = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | $Net::UPnP::GW::Gateway::_DEVICE => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 6 | bless $this, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | #------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # device | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | #------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 6 | ▶ | sub setdevice() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setdevice: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 6 | my($this) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 6 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 6 | $this->{$Net::UPnP::GW::Gateway::_DEVICE} = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 6 | ▶ | sub getdevice() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getdevice: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 6 | my($this) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 6 | $this->{$Net::UPnP::GW::Gateway::_DEVICE}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | #------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | # getexternalipaddress | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | #------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub getexternalipaddress { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getexternalipaddress: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my($this) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | my ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | $dev, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | $wanipcon_service, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | $action_res, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | $arg_list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | $ipaddr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | $dev = $this->getdevice(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | $wanipcon_service = $dev->getservicebyname($Net::UPnP::GW::Gateway::WANIPCONNECTION_SERVICE_TYPE); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | unless ($wanipcon_service) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | return ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | $action_res = $wanipcon_service->postaction("GetExternalIPAddress"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | if ($action_res->getstatuscode() != 200) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | return ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | $arg_list = $action_res->getargumentlist(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | $ipaddr = $arg_list->{'NewExternalIPAddress'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | return $ipaddr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | #------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # getportmappingnumberofentries | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | #------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 1 | ▶ | sub getportmappingnumberofentries { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getportmappingnumberofentries: called CC=4 SCAR=15.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | my($this) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | my ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 1 | $dev, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | $wanipcon_service, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | $query_res, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | $dev = $this->getdevice(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | $wanipcon_service = $dev->getservicebyname($Net::UPnP::GW::Gateway::WANIPCONNECTION_SERVICE_TYPE); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 1 | ▶ | unless ($wanipcon_service) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 1 | $query_res = $wanipcon_service->postquery("PortMappingNumberOfEntries"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | ▶ | if ($query_res->getstatuscode() != 200) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 1 | ▶ | if( $query_res->getvalue() =~ /^(\d+)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | return $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 1 | return scalar($this->getportmappingentries()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | #------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | # getportmapping | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | #------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 7 | ▶ | sub getportmappingentries { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getportmappingentries: called CC=15 SCAR=27.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 7 | my($this) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 7 | my %args = (max_entries => 1024, timeout => 30, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | croak 'Invalid mapping entry limit' unless defined($args{max_entries}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 7 | ▶ | && $args{max_entries} =~ /\A\d+\z/ && POSIX::isfinite(0 + $args{max_entries}) && $args{max_entries} > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition55%5/9
defined $args{"max_entries"} and $args{"max_entries"} =~ /\A\d+\z/ and POSIX::isfinite(0 + $args{"max_entries"}) and $args{"max_entries"} > 0
defined $args{"max_entries"} and $args{"max_entries"} =~ /\A\d+\z/ and POSIX::isfinite(0 + $args{"max_entries"})
defined $args{"max_entries"} and $args{"max_entries"} =~ /\A\d+\z/
MC/DC25%1/4
defined $args{"max_entries"} and $args{"max_entries"} =~ /\A\d+\z/ and POSIX::isfinite(0 + $args{"max_entries"}) and $args{"max_entries"} > 0
defined $args{"max_entries"}
$args{"max_entries"} =~ /\A\d+\z/
POSIX::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= POSIX::isfinite(0 + $args{"max_entries"})D= $args{"max_entries"} > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | croak 'Invalid mapping timeout' unless defined($args{timeout}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 6 | ▶ | && $args{timeout} =~ /\A\d+(?:\.\d+)?\z/ && POSIX::isfinite(0 + $args{timeout}) && $args{timeout} > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition55%5/9
defined $args{"timeout"} and $args{"timeout"} =~ /\A\d+(?:\.\d+)?\z/ and POSIX::isfinite(0 + $args{"timeout"}) and $args{"timeout"} > 0
defined $args{"timeout"} and $args{"timeout"} =~ /\A\d+(?:\.\d+)?\z/ and POSIX::isfinite(0 + $args{"timeout"})
defined $args{"timeout"} and $args{"timeout"} =~ /\A\d+(?:\.\d+)?\z/
MC/DC25%1/4
defined $args{"timeout"} and $args{"timeout"} =~ /\A\d+(?:\.\d+)?\z/ and POSIX::isfinite(0 + $args{"timeout"}) and $args{"timeout"} > 0
defined $args{"timeout"}
$args{"timeout"} =~ /\A\d+(?:\.\d+)?\z/
POSIX::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= POSIX::isfinite(0 + $args{"timeout"})D= $args{"timeout"} > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 5 | $this->{error} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 5 | my $deadline = Net::UPnP::HTTP::_now() + $args{timeout}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | my ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 5 | @port_mapping, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | $dev, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | $port_mapping_num, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | $wanipcon_service, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | $n, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | %req_arg, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | $action_res, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | $arg_list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | $ipaddr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 5 | $dev = $this->getdevice(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 5 | $wanipcon_service = $dev->getservicebyname($Net::UPnP::GW::Gateway::WANIPCONNECTION_SERVICE_TYPE); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 5 | ▶ | unless ($wanipcon_service) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | return @port_mapping; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 5 | $n = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 5 | ▶ | while ($n < $args{max_entries}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 1035 | ▶ | if (Net::UPnP::HTTP::_now() >= $deadline) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 1 | $this->{error} = 'Port mapping deadline exceeded'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | %req_arg = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 1034 | 'NewPortMappingIndex' => $n, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 1034 | $action_res = $wanipcon_service->postaction("GetGenericPortMappingEntry", \%req_arg, {deadline => $deadline}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | #print "[$n]" .$action_res->getstatuscode() . "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | #print %req_arg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 1034 | ▶ | if ($action_res->getstatuscode() != 200) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 1 | ▶ | $this->{error} = 'Port mapping request failed' if !$action_res->getstatuscode(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 1033 | $arg_list = $action_res->getargumentlist(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | #print $arg_list; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 1033 | push(@port_mapping, $arg_list); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 1033 | ++$n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 5 | ▶ | if ($n == $args{max_entries}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 3 | $this->{error} = 'Port mapping entry limit reached'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 5 | return @port_mapping; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 4 | ▶ | sub geterror { $_[0]->{error} || '' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
geterror: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | # deprecated method - mapped to new name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 1 | ▶ | sub getportmappingentry { getportmappingentries(@_); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getportmappingentry: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | #------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | # addportmapping | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | #------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | sub addportmapping { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
addportmapping: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | my($this) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | my %args = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | NewRemoteHost => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | NewExternalPort => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | NewProtocol => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | NewInternalPort => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | NewInternalClient => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | NewEnabled => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | NewPortMappingDescription => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | NewLeaseDuration => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | @_, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | my ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | $dev, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | $wanipcon_service, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | $action_res, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | $arg_list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | $ipaddr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | %req_arg, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $dev = $this->getdevice(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $wanipcon_service = $dev->getservicebyname($Net::UPnP::GW::Gateway::WANIPCONNECTION_SERVICE_TYPE); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | unless ($wanipcon_service) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | %req_arg = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 'NewRemoteHost' => $args{NewRemoteHost}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 'NewExternalPort' => $args{NewExternalPort}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 'NewProtocol' => $args{NewProtocol}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 'NewInternalPort' => $args{NewInternalPort}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 'NewInternalClient' => $args{NewInternalClient}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 'NewEnabled' => $args{NewEnabled}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 'NewPortMappingDescription' => $args{NewPortMappingDescription}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 'NewLeaseDuration' => $args{NewLeaseDuration}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | $action_res = $wanipcon_service->postaction("AddPortMapping", \%req_arg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | if ($action_res->getstatuscode() != 200) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | #------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | # deleteportmapping | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | #------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | sub deleteportmapping { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deleteportmapping: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | my($this) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | my %args = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | NewRemoteHost => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | NewExternalPort => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | NewProtocol => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | @_, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | my ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | $dev, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | $wanipcon_service, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | $action_res, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | $arg_list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | $ipaddr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | %req_arg, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | $dev = $this->getdevice(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | $wanipcon_service = $dev->getservicebyname($Net::UPnP::GW::Gateway::WANIPCONNECTION_SERVICE_TYPE); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | unless ($wanipcon_service) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | %req_arg = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 'NewRemoteHost' => $args{NewRemoteHost}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 'NewExternalPort' => $args{NewExternalPort}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 'NewProtocol' => $args{NewProtocol}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | $action_res = $wanipcon_service->postaction("DeletePortMapping", \%req_arg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | if ($action_res->getstatuscode() != 200) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | #------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | # gettotalbytesreceived | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | #------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | sub gettotalbytesreceived { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gettotalbytesreceived: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | my($this) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | my ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | $dev, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | $wanconif_service, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | $action_res, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | $arg_list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | $totalBytes, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | $dev = $this->getdevice(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | $wanconif_service = $dev->getservicebyname($Net::UPnP::GW::Gateway::WANCOMMONINTERFACECONFIG_SERVICE_TYPE); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | unless ($wanconif_service) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | return ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | $action_res = $wanconif_service->postaction("GetTotalBytesReceived"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | if ($action_res->getstatuscode() != 200) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | return ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | $arg_list = $action_res->getargumentlist(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | $totalBytes = $arg_list->{'NewTotalBytesReceived'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | return $totalBytes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | # Backward-compatible alias for the historical misspelling (RT #123509). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 2 | *gettotalbytesrecieved = \&gettotalbytesreceived; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | #------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | # gettotalbytessent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | #------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | sub gettotalbytessent { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gettotalbytessent: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | my($this) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | my ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | $dev, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | $wanconif_service, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | $action_res, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | $arg_list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | $totalBytes, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | $dev = $this->getdevice(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | $wanconif_service = $dev->getservicebyname($Net::UPnP::GW::Gateway::WANCOMMONINTERFACECONFIG_SERVICE_TYPE); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | unless ($wanconif_service) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | return ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | $action_res = $wanconif_service->postaction("GetTotalBytesSent"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | if ($action_res->getstatuscode() != 200) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | return ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | $arg_list = $action_res->getargumentlist(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | $totalBytes = $arg_list->{'NewTotalBytesSent'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | return $totalBytes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||