Packet/DescL4.pm

filter: Statementstmt 50.0% 15 / 30 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 38.4% 5 / 13 Podpod n/a totaltotal 44.4% 20 / 45 CC 2 SCAR 7.9
CC
2
Cov
47%
new
6.0
_isFamily
2.0
isFamilyIpv4
2.0
CRAP 2.2
« Packet/Layer2.pm ↑ Summary Packet/CDP/TypeCapabilities.pm »
1 #
2 # $Id: DescL4.pm 2002 2015-02-15 16:50:35Z gomor $
3 #
4 package Net::Packet::DescL4;
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 require Net::Packet::Desc;
10 our @ISA = qw(Net::Packet::Desc);
11 __PACKAGE__->cgBuildIndices;
12  
13 1 ▶use Net::Packet::Consts qw(:desc :layer);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶use Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 require Socket6;
17 require Net::Write::Layer4;
18  
19 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
20 0 my $self = shift->SUPER::new(
21 protocol => NP_DESC_IPPROTO_TCP,
22 family => NP_LAYER_IPv4,
23 @_,
24 );
25  
26 0 ▶ confess("@{[(caller(0))[3]]}: you must pass `target' parameter\n")
Branch: 1 branch
BranchTrueFalseTotal
unless $self->target 0 0 0
27 unless $self->target;
28  
29 0 my $families = {
30 NP_LAYER_IPv4() => AF_INET(),
31 NP_LAYER_IPv6() => AF_INET6(),
32 };
33  
34 my $nwrite = Net::Write::Layer4->new(
35 dst => $self->target,
36 0 family => $families->{$self->family},
37 protocol => $self->protocol,
38 );
39 0 $nwrite->open;
40 0 $self->_io($nwrite);
41  
42 0 $self;
43 }
44  
45 #
46 # Helpers
47 #
48  
49 0 ▶sub _isFamily { shift->family eq shift }
Subroutine _isFamily: not called CC=1 SCAR=6.9
50 0 ▶sub isFamilyIpv4 { shift->_isFamily(NP_LAYER_IPv4) }
Subroutine isFamilyIpv4: not called CC=1 SCAR=6.9
51 0 ▶sub isFamilyIpv6 { shift->_isFamily(NP_LAYER_IPv6) }
Subroutine isFamilyIpv6: not called CC=1 SCAR=6.9
52  
53 0 ▶sub _isProtocol { shift->protocol eq shift }
Subroutine _isProtocol: not called CC=1 SCAR=6.9
54 0 ▶sub isProtocolTcp { shift->_isProtocol(NP_DESC_IPPROTO_TCP) }
Subroutine isProtocolTcp: not called CC=1 SCAR=6.9
55 0 ▶sub isProtocolUdp { shift->_isProtocol(NP_DESC_IPPROTO_UDP) }
Subroutine isProtocolUdp: not called CC=1 SCAR=6.9
56 0 ▶sub isProtocolIcmpv4 { shift->_isProtocol(NP_DESC_IPPROTO_ICMPv4) }
Subroutine isProtocolIcmpv4: not called CC=1 SCAR=6.9
57  
58 1;
59  
60 __END__
« Packet/Layer2.pm ↑ Summary Packet/CDP/TypeCapabilities.pm »