| 1 | # IO::Socket::INET6.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # Copyright (c) 1997-8 Graham Barr <gbarr@pobox.com>. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # This program is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # Modified by Rafael Martinez-Torres <rafael.martinez@novagnet.com> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # Euro6IX project (www.euro6ix.org) 2003. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | package IO::Socket::INET6; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 8 | ▶ | use 5.008; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 8 | our(@ISA, $VERSION); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # Do it so we won't import any symbols from IO::Socket which it does export | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # by default: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # <LeoNerd> IO::Socket is stupidstupidstupid beyond belief. Despite being an | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # object class, it has an import method | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # <LeoNerd> So you have to use IO::Socket (); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | # <LeoNerd> Having done that, this test is now clean | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 8 | ▶ | use IO::Socket (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 8 | ▶ | use Socket (qw( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | AF_INET6 PF_INET6 SOCK_RAW SOCK_STREAM INADDR_ANY SOCK_DGRAM | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | AF_INET SO_REUSEADDR SO_REUSEPORT AF_UNSPEC SO_BROADCAST | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | sockaddr_in | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # IO::Socket and Socket already import stuff here - possibly AF_INET6 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # and PF_INET6 so selectively import things from Socket6. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 8 | ▶ | use Socket6 ( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 8 | qw(AI_PASSIVE getaddrinfo | |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | sockaddr_in6 unpack_sockaddr_in6_all pack_sockaddr_in6_all in6addr_any) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 8 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 8 | ▶ | use Errno; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 8 | @ISA = qw(IO::Socket); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 8 | $VERSION = "2.73"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | #Purpose: allow protocol independent protocol and original interface. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 8 | ▶ | my $EINVAL = exists(&Errno::EINVAL) ? Errno::EINVAL() : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 8 | IO::Socket::INET6->register_domain( AF_INET6 ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 8 | my %socket_type = ( tcp => SOCK_STREAM, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | udp => SOCK_DGRAM, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | icmp => SOCK_RAW | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 107 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 107 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 107 | ▶ | unshift(@_, "PeerAddr") if @_ == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 107 | return $class->SUPER::new(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # Parsing analysis: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # addr,port,and proto may be syntactically related... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 107 | ▶ | sub _sock_info { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sock_info: called CC=24 SCAR=40.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 107 | my($addr,$port,$proto) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 107 | my $origport = $port; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 107 | my @proto = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 107 | my @serv = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 107 | ▶ | if (defined $addr) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 4 | ▶ | if (!Socket6::inet_pton(AF_INET6,$addr)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 2 | ▶ | if($addr =~ s,^\[([\da-fA-F:]+)\]:([\w\(\)/]+)$,$1,) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | $port = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } elsif($addr =~ s,^\[(::[\da-fA-F.:]+)\]:([\w\(\)/]+)$,$1,) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $port = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } elsif($addr =~ s,^\[([\da-fA-F:]+)\],$1,) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | $port = $origport; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } elsif($addr =~ s,:([\w\(\)/]+)$,,) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $port = $1 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # $proto as "string". | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 107 | ▶ | if(defined $proto && $proto =~ /\D/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $proto and $proto =~ /\D/
MC/DC50%1/2
defined $proto and $proto =~ /\D/
defined $proto
$proto =~ /\D/
Truth table66%2/3
A and B
A= defined $protoB= $proto =~ /\D/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 6 | ▶ | if(@proto = getprotobyname($proto)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | $proto = $proto[2] || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$proto[2] || undef
MC/DC0%0/1
$proto[2] || undef
$proto[2]
Truth table0%0/2
A
A= $proto[2]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 6 | $@ = "Bad protocol '$proto'"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 6 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 101 | ▶ | if(defined $port) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 100 | ▶ | my $defport = ($port =~ s,\((\d+)\)$,,) ? $1 : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 100 | my $pnum = ($port =~ m,^(\d+)$,)[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 100 | ▶ | @serv = getservbyname($port, $proto[0] || "") | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$proto[0] || ''
MC/DC0%0/1
$proto[0] || ''
$proto[0]
Truth table0%0/2
A
A= $proto[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | if ($port =~ m,\D,); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 100 | ▶ | $port = $serv[2] || $defport || $pnum; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$serv[2] || $defport || $pnum
$serv[2] or $defport
MC/DC0%0/3
$serv[2] || $defport || $pnum
$serv[2]
$defport
$pnum
Truth table25%1/4
A or B || C
A= $serv[2]B= $defportC= $pnum
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 100 | ▶ | unless (defined $port) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | $@ = "Bad service '$origport'"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 100 | ▶ | $proto = (getprotobyname($serv[3]))[2] || undef | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition20%1/5
@serv and not $proto
(getprotobyname $serv[3])[2] || undef
MC/DC0%0/2
@serv and not $proto
@serv
not $proto
MC/DC0%0/1
(getprotobyname $serv[3])[2] || undef
(getprotobyname $serv[3])[2]
Truth table33%1/3
A and not(B)
A= @servB= not $proto
Truth table0%0/2
A
A= (getprotobyname $serv[3])[2]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | if @serv && !$proto; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | #printf "Selected port is $port and proto is $proto \n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 101 | ▶ | return ($addr || undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
$addr || undef
$port || undef
$proto || undef
MC/DC100%1/1
$addr || undef
$addr
MC/DC100%1/1
$port || undef
$port
MC/DC0%0/1
$proto || undef
$proto
Truth table100%2/2
A
A= $addr
Truth table100%2/2
A
A= $port
Truth table50%1/2
A
A= $proto
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | $port || undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | $proto || undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 107 | ▶ | sub _error { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_error: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 107 | my $sock = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 107 | my $err = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 107 | local($!); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 107 | my $title = ref($sock).": "; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 107 | ▶ | $@ = join("", $_[0] =~ /^$title/ ? "" : $title, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 107 | ▶ | close($sock) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | if(defined fileno($sock)); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 107 | $! = $err; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 107 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 107 | ▶ | sub configure { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
configure: called CC=64 SCAR=73.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 107 | my($sock,$arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | $arg->{LocalAddr} = $arg->{LocalHost} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 107 | ▶ | if exists $arg->{LocalHost} && !exists $arg->{LocalAddr}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $arg->{"LocalHost"} and not exists $arg->{"LocalAddr"}
MC/DC0%0/2
exists $arg->{"LocalHost"} and not exists $arg->{"LocalAddr"}
exists $arg->{"LocalHost"}
not exists $arg->{"LocalAddr"}
Truth table33%1/3
A and not(B)
A= exists $arg->{"LocalHost"}B= not exists $arg->{"LocalAddr"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | $arg->{PeerAddr} = $arg->{PeerHost} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 107 | ▶ | if exists $arg->{PeerHost} && !exists $arg->{PeerAddr}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $arg->{"PeerHost"} and not exists $arg->{"PeerAddr"}
MC/DC0%0/2
exists $arg->{"PeerHost"} and not exists $arg->{"PeerAddr"}
exists $arg->{"PeerHost"}
not exists $arg->{"PeerAddr"}
Truth table33%1/3
A and not(B)
A= exists $arg->{"PeerHost"}B= not exists $arg->{"PeerAddr"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 107 | my $family = $arg->{Domain}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | # in case no local and peer is given we prefer AF_INET6 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | # because we are IO::Socket::INET6 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 107 | ▶ | $family ||= ! $arg->{LocalAddr} && ! $arg->{PeerAddr} && AF_INET6 | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition90%9/10
$family ||= !($arg->{"LocalAddr"} || $arg->{"PeerAddr"}) && 10 || 0
!($arg->{'LocalAddr'} || $arg->{'PeerAddr'}) && 10 || 0
not $arg->{"LocalAddr"} || $arg->{"PeerAddr"} and 10
$arg->{'LocalAddr'} || $arg->{'PeerAddr'}
MC/DC0%0/3
$family ||= !($arg->{"LocalAddr"} || $arg->{"PeerAddr"}) && 10 || 0
$family
$arg->{'LocalAddr'}
$arg->{'PeerAddr'}
Truth table0%0/4
A ||= not(B || C)
A= $familyB= $arg->{'LocalAddr'}C= $arg->{'PeerAddr'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | || AF_UNSPEC; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | # parse Local* | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | my ($laddr,$lport,$proto) = _sock_info( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | $arg->{LocalAddr}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | $arg->{LocalPort}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | $arg->{Proto} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 107 | ▶ | ) or return _error($sock, $!, "sock_info: $@"); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 101 | ▶ | $laddr ||= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$laddr ||= ""
MC/DC100%1/1
$laddr ||= ""
$laddr
Truth table100%2/2
A
A= $laddr
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 101 | ▶ | $lport ||= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$lport ||= 0
MC/DC100%1/1
$lport ||= 0
$lport
Truth table100%2/2
A
A= $lport
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 101 | ▶ | $proto ||= (getprotobyname('tcp'))[2]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$proto ||= (getprotobyname "tcp")[2]
MC/DC0%0/2
$proto ||= (getprotobyname "tcp")[2]
$proto
(getprotobyname "tcp")[2]
Truth table33%1/3
A ||= B
A= $protoB= (getprotobyname "tcp")[2]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # MSWin32 expects at least one of $laddr or $lport to be specified | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # and does not accept 0 for $lport if $laddr is specified. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 101 | ▶ | if ($^O eq 'MSWin32') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | if ((!$laddr) && (!$lport)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$laddr || $lport
MC/DC0%0/2
$laddr || $lport
$laddr
$lport
Truth table0%0/3
A || B
A= $laddrB= $lport
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | $laddr = ($family == AF_INET) ? '0.0.0.0' : '::'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $lport = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } elsif (!$lport) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | $lport = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 101 | ▶ | my $type = $arg->{Type} || $socket_type{(getprotobynumber($proto))[0]}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$arg->{'Type'} || $socket_type{(getprotobynumber $proto)[0]}
MC/DC0%0/2
$arg->{'Type'} || $socket_type{(getprotobynumber $proto)[0]}
$arg->{'Type'}
$socket_type{(getprotobynumber $proto)[0]}
Truth table33%1/3
A || B
A= $arg->{'Type'}B= $socket_type{(getprotobynumber $proto)[0]}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | # parse Peer* | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 101 | my($rport,$raddr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 101 | ▶ | unless(exists $arg->{Listen}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | ($raddr,$rport) = _sock_info( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | $arg->{PeerAddr}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | $arg->{PeerPort}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | $proto | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | ) or return _error($sock, $!, "sock_info: $@"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | # find out all combinations of local and remote addr with | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | # the same family | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 101 | my @lres = getaddrinfo($laddr,$lport,$family,$type,$proto,AI_PASSIVE); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 101 | ▶ | return _error($sock, $EINVAL, "getaddrinfo: $lres[0]") if @lres<5; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 101 | my @rres; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 101 | ▶ | if ( defined $raddr ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | @rres = getaddrinfo($raddr,$rport,$family,$type,$proto); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | return _error($sock, $EINVAL, "getaddrinfo: $rres[0]") if @rres<5; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 101 | my @flr; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 101 | ▶ | if (@rres) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | # Collect all combinations with the same family in lres and rres | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | # the order we search should be defined by the order of @rres, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | # not @lres! | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | for( my $r=0;$r<@rres;$r+=5 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | for( my $l=0;$l<@lres;$l+=5) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | my $fam_listen = $lres[$l]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | next if $rres[$r] != $fam_listen; # must be same family | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | push @flr,[ $fam_listen,$lres[$l+3],$rres[$r+3] ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 101 | ▶ | for( my $l=0;$l<@lres;$l+=5) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 303 | my $fam_listen = $lres[$l]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 303 | my $lsockaddr = $lres[$l+3]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | # collect only the binding side | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 303 | push @flr,[ $fam_listen,$lsockaddr ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | # try to bind and maybe connect | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | # if multihomed try all combinations until success | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 101 | for my $flr (@flr) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 101 | my ($family,$lres,$rres) = @$flr; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 101 | ▶ | if ( $family == AF_INET6) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 100 | ▶ | if ($arg->{LocalFlow} || $arg->{LocalScope}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$arg->{"LocalFlow"} or $arg->{"LocalScope"}
MC/DC0%0/2
$arg->{"LocalFlow"} or $arg->{"LocalScope"}
$arg->{"LocalFlow"}
$arg->{"LocalScope"}
Truth table33%1/3
A or B
A= $arg->{"LocalFlow"}B= $arg->{"LocalScope"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | my @sa_in6 = unpack_sockaddr_in6_all($lres); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | $sa_in6[1] = $arg->{LocalFlow} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$arg->{'LocalFlow'} || 0
MC/DC0%0/1
$arg->{'LocalFlow'} || 0
$arg->{'LocalFlow'}
Truth table0%0/2
A
A= $arg->{'LocalFlow'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | $sa_in6[3] = _scope_ntohl($arg->{LocalScope}) || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
&_scope_ntohl($arg->{'LocalScope'}) || 0
MC/DC0%0/1
&_scope_ntohl($arg->{'LocalScope'}) || 0
&_scope_ntohl($arg->{'LocalScope'})
Truth table0%0/2
A
A= &_scope_ntohl($arg->{'LocalScope'})
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | $lres = pack_sockaddr_in6_all(@sa_in6); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 101 | ▶ | $sock->socket($family, $type, $proto) or | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | return _error($sock, $!, "socket: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | if (defined $arg->{Blocking}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | defined $sock->blocking($arg->{Blocking}) or | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | return _error($sock, $!, "sockopt: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | if ($arg->{Reuse} || $arg->{ReuseAddr}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$arg->{"Reuse"} or $arg->{"ReuseAddr"}
MC/DC0%0/2
$arg->{"Reuse"} or $arg->{"ReuseAddr"}
$arg->{"Reuse"}
$arg->{"ReuseAddr"}
Truth table0%0/3
A or B
A= $arg->{"Reuse"}B= $arg->{"ReuseAddr"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | $sock->sockopt(SO_REUSEADDR,1) or | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | return _error($sock, $!, "sockopt: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | if ($arg->{ReusePort}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | $sock->sockopt(SO_REUSEPORT,1) or | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | return _error($sock, $!, "sockopt: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | if ($arg->{Broadcast}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | $sock->sockopt(SO_BROADCAST,1) or | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | return _error($sock, $!, "sockopt: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | if ( $family == AF_INET ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | my ($p,$a) = sockaddr_in($lres); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | $sock->bind($lres) or return _error($sock, $!, "bind: $!") | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/8
($a ne "\000\000\000\000" || $p != 0) && ($sock->bind($lres) || (return _error($sock, $!, "bind: $!")))
$a ne "\0\0\0\0" or $p != 0
$sock->bind($lres) or return _error($sock, $!, "bind: $!")
MC/DC0%0/3
($a ne "\000\000\000\000" || $p != 0) && ($sock->bind($lres) || (return _error($sock, $!, "bind: $!")))
$a ne "\0\0\0\0"
$p != 0
$sock->bind($lres)
Truth table0%0/5
A or B && C
A= $a ne "\0\0\0\0"B= $p != 0C= $sock->bind($lres)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | if ($a ne INADDR_ANY or $p!=0); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | my ($p,$a) = sockaddr_in6($lres); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | $sock->bind($lres) or return _error($sock, $!, "bind: $!") | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/8
($a ne in6addr_any() || $p != 0) && ($sock->bind($lres) || (return _error($sock, $!, "bind: $!")))
$a ne in6addr_any() or $p != 0
$sock->bind($lres) or return _error($sock, $!, "bind: $!")
MC/DC0%0/3
($a ne in6addr_any() || $p != 0) && ($sock->bind($lres) || (return _error($sock, $!, "bind: $!")))
$a ne in6addr_any()
$p != 0
$sock->bind($lres)
Truth table0%0/5
A or B && C
A= $a ne in6addr_any()B= $p != 0C= $sock->bind($lres)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | if ($a ne in6addr_any or $p!=0); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | if(exists $arg->{Listen}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | $sock->listen($arg->{Listen} || 5) or | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$arg->{'Listen'} || 5
MC/DC0%0/1
$arg->{'Listen'} || 5
$arg->{'Listen'}
Truth table0%0/2
A
A= $arg->{'Listen'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | return _error($sock, $!, "listen: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | # connect only if PeerAddr and thus $rres is given | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | last if ! $rres; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | if ( $family == AF_INET6) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | if ($arg->{PeerFlow} || $arg->{PeerScope}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$arg->{"PeerFlow"} or $arg->{"PeerScope"}
MC/DC0%0/2
$arg->{"PeerFlow"} or $arg->{"PeerScope"}
$arg->{"PeerFlow"}
$arg->{"PeerScope"}
Truth table0%0/3
A or B
A= $arg->{"PeerFlow"}B= $arg->{"PeerScope"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | my @sa_in6 = unpack_sockaddr_in6_all($rres); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | $sa_in6[1] = $arg->{PeerFlow} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$arg->{'PeerFlow'} || 0
MC/DC0%0/1
$arg->{'PeerFlow'} || 0
$arg->{'PeerFlow'}
Truth table0%0/2
A
A= $arg->{'PeerFlow'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | $sa_in6[3] = _scope_ntohl($arg->{PeerScope}) || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
&_scope_ntohl($arg->{'PeerScope'}) || 0
MC/DC0%0/1
&_scope_ntohl($arg->{'PeerScope'}) || 0
&_scope_ntohl($arg->{'PeerScope'})
Truth table0%0/2
A
A= &_scope_ntohl($arg->{'PeerScope'})
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | $rres = pack_sockaddr_in6_all(@sa_in6); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | undef $@; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | last if $sock->connect($rres); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | return _error($sock, $!, $@ || "Timeout") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | if ! $arg->{MultiHomed}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$@ || 'Timeout'
MC/DC0%0/1
$@ || 'Timeout'
$@
Truth table0%0/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | return $sock; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | sub _scope_ntohl($) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_scope_ntohl: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | # As of Socket6 0.17 the scope field is incorrectly put into | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | # network byte order when it should be in host byte order | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | # in the sockaddr_in6 structure. We correct for that here. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | if ((Socket6->VERSION <= 0.17) && (pack('s', 0x1234) ne pack('n', 0x1234))) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
"Socket6"->VERSION <= "0.17" and
MC/DC0%0/1
"Socket6"->VERSION <= "0.17" and
"Socket6"->VERSION <= "0.17"
Truth table0%0/2
A
A= "Socket6"->VERSION <= "0.17"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | unpack('N', pack('V', $_[0])); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | sub sockdomain | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sockdomain: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | my $sock = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | $sock->SUPER::sockdomain(@_) || AF_INET6; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | sub accept | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
accept: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | my $sock = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | my ($new, $peer) = $sock->SUPER::accept(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | return unless defined($new); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ${*$new}{io_socket_domain} = ${*$sock}{io_socket_domain}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ${*$new}{io_socket_type} = ${*$sock}{io_socket_type}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ${*$new}{io_socket_proto} = ${*$sock}{io_socket_proto}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | return wantarray ? ($new, $peer) : $new; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | sub bind { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bind: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | @_ == 2 or | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | croak 'usage: $sock->bind(NAME) '; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | my $sock = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | return $sock->SUPER::bind( shift ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | sub connect { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
connect: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | @_ == 2 or | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | croak 'usage: $sock->connect(NAME) '; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | my $sock = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | return $sock->SUPER::connect( shift ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | sub sockaddr { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sockaddr: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | @_ == 1 or croak 'usage: $sock->sockaddr()'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | my ($sock) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | return undef unless (my $name = $sock->sockname); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | ($sock->sockdomain == AF_INET) ? (sockaddr_in($name))[1] : (sockaddr_in6($name))[1]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | sub sockport { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sockport: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | @_ == 1 or croak 'usage: $sock->sockport()'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | my($sock) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | return undef unless (my $name = $sock->sockname); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | ($sock->sockdomain == AF_INET) ? (sockaddr_in($name))[0] : (sockaddr_in6($name))[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | ▶ | sub sockhost { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sockhost: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | @_ == 1 or croak 'usage: $sock->sockhost()'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | my ($sock) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | return undef unless (my $addr = $sock->sockaddr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | Socket6::inet_ntop($sock->sockdomain, $addr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | sub sockflow | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sockflow: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | @_ == 1 or croak 'usage: $sock->sockflow()'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | my ($sock) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | return undef unless (my $name = $sock->sockname); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | ($sock->sockdomain == AF_INET6) ? (unpack_sockaddr_in6_all($name))[1] : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | sub sockscope | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sockscope: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | @_ == 1 or croak 'usage: $sock->sockscope()'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | my ($sock) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | return undef unless (my $name = $sock->sockname); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | _scope_ntohl(($sock->sockdomain == AF_INET6) ? (unpack_sockaddr_in6_all($name))[3] : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | sub peeraddr { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
peeraddr: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | @_ == 1 or croak 'usage: $sock->peeraddr()'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | my ($sock) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | return undef unless (my $name = $sock->peername); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | ($sock->sockdomain == AF_INET) ? (sockaddr_in($name))[1] : (sockaddr_in6($name))[1]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | sub peerport { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
peerport: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | @_ == 1 or croak 'usage: $sock->peerport()'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | my($sock) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | return undef unless (my $name = $sock->peername); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | ($sock->sockdomain == AF_INET) ? (sockaddr_in($name))[0] : (sockaddr_in6($name))[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | sub peerhost { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
peerhost: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | @_ == 1 or croak 'usage: $sock->peerhost()'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | my ($sock) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | return undef unless (my $addr = $sock->peeraddr); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | Socket6::inet_ntop($sock->sockdomain, $addr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | sub peerflow | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
peerflow: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | @_ == 1 or croak 'usage: $sock->peerflow()'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | my ($sock) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | return undef unless (my $name = $sock->peername); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | _scope_ntohl(($sock->sockdomain == AF_INET6) ? (unpack_sockaddr_in6_all($name))[1] : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | sub peerscope | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
peerscope: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | @_ == 1 or croak 'usage: $sock->peerscope()'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | my ($sock) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | return undef unless (my $name = $sock->peername); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | ($sock->sockdomain == AF_INET6) ? (unpack_sockaddr_in6_all($name))[3] : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 8 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||