lib/Net/DHCPv6.pm

filter: Statementstmt 99.5% 238 / 239 Branchbran 91.6% 11 / 12 Conditioncond 77.7% 7 / 9 MC/DCmcdc 66.6% 4 / 6 Subroutinesub 100% 76 / 76 Podpod 100% 9 / 9 totaltotal 98.2% 345 / 351 CC 10 SCAR 2.9
CC
10
Cov
98%
decode_with_error
4.1
decode_or_null
3.0
decode_or_croak
3.0
CRAP 1.3
« lib/Net/DHCPv6/Option/InfoRefreshTime.pm ↑ Summary lib/Net/DHCPv6/Option/ORO.pm »
1 #!/usr/bin/false
2 # ABSTRACT: DHCPv6 packet decoder/encoder
3 # PODNAME: Net::DHCPv6
4 package Net::DHCPv6;
5 13 $Net::DHCPv6::VERSION = '0.001';
6 13 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 13 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 13 ▶use Net::DHCPv6::DUID;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # Option classes — loaded so they register in the dispatch tables
11 13 ▶use Net::DHCPv6::Option::AftrName;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 13 ▶use Net::DHCPv6::Option::Auth;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 13 ▶use Net::DHCPv6::Option::BootfileParam;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 13 ▶use Net::DHCPv6::Option::BootfileUrl;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 13 ▶use Net::DHCPv6::Option::CaptivePortal;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 13 ▶use Net::DHCPv6::Option::ClientArchType;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 13 ▶use Net::DHCPv6::Option::ClientFqdn;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 13 ▶use Net::DHCPv6::Option::ClientId;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 13 ▶use Net::DHCPv6::Option::ClientLinkLayerAddr;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 13 ▶use Net::DHCPv6::Option::DnsServers;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 13 ▶use Net::DHCPv6::Option::DomainList;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 13 ▶use Net::DHCPv6::Option::ElapsedTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 13 ▶use Net::DHCPv6::Option::Generic;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 13 ▶use Net::DHCPv6::Option::IAAddr;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 13 ▶use Net::DHCPv6::Option::IANA;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 13 ▶use Net::DHCPv6::Option::IAPD;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 13 ▶use Net::DHCPv6::Option::IAPrefix;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 13 ▶use Net::DHCPv6::Option::IATA;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 13 ▶use Net::DHCPv6::Option::InfMaxRt;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 13 ▶use Net::DHCPv6::Option::InfoRefreshTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 13 ▶use Net::DHCPv6::Option::InterfaceId;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 13 ▶use Net::DHCPv6::Option::NewPosixTimezone;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 13 ▶use Net::DHCPv6::Option::NewTzdbTimezone;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 13 ▶use Net::DHCPv6::Option::NisDomainName;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 13 ▶use Net::DHCPv6::Option::NisServers;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 13 ▶use Net::DHCPv6::Option::NispDomainName;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 13 ▶use Net::DHCPv6::Option::NispServers;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 13 ▶use Net::DHCPv6::Option::NtpServer;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 13 ▶use Net::DHCPv6::Option::ORO;
Subroutine BEGIN: called CC=1 SCAR=0.0
40 13 ▶use Net::DHCPv6::Option::PdExclude;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 13 ▶use Net::DHCPv6::Option::Preference;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 13 ▶use Net::DHCPv6::Option::RapidCommit;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 13 ▶use Net::DHCPv6::Option::ReconfAccept;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 13 ▶use Net::DHCPv6::Option::ReconfMsg;
Subroutine BEGIN: called CC=1 SCAR=0.0
45 13 ▶use Net::DHCPv6::Option::RelayMsg;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 13 ▶use Net::DHCPv6::Option::RemoteId;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 13 ▶use Net::DHCPv6::Option::RSOO;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 13 ▶use Net::DHCPv6::Option::ServerId;
Subroutine BEGIN: called CC=1 SCAR=0.0
49 13 ▶use Net::DHCPv6::Option::SipServerA;
Subroutine BEGIN: called CC=1 SCAR=0.0
50 13 ▶use Net::DHCPv6::Option::SipServerD;
Subroutine BEGIN: called CC=1 SCAR=0.0
51 13 ▶use Net::DHCPv6::Option::MudUrl;
Subroutine BEGIN: called CC=1 SCAR=0.0
52 13 ▶use Net::DHCPv6::Option::SolMaxRt;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 13 ▶use Net::DHCPv6::Option::StatusCode;
Subroutine BEGIN: called CC=1 SCAR=0.0
54 13 ▶use Net::DHCPv6::Option::SubscriberId;
Subroutine BEGIN: called CC=1 SCAR=0.0
55 13 ▶use Net::DHCPv6::Option::Unicast;
Subroutine BEGIN: called CC=1 SCAR=0.0
56 13 ▶use Net::DHCPv6::Option::UserClass;
Subroutine BEGIN: called CC=1 SCAR=0.0
57 13 ▶use Net::DHCPv6::Option::VendorClass;
Subroutine BEGIN: called CC=1 SCAR=0.0
58 13 ▶use Net::DHCPv6::Option::VendorOpts;
Subroutine BEGIN: called CC=1 SCAR=0.0
59  
60 # Message classes
61 13 ▶use Net::DHCPv6::Message::Solicit;
Subroutine BEGIN: called CC=1 SCAR=0.0
62 13 ▶use Net::DHCPv6::Message::Advertise;
Subroutine BEGIN: called CC=1 SCAR=0.0
63 13 ▶use Net::DHCPv6::Message::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
64 13 ▶use Net::DHCPv6::Message::Confirm;
Subroutine BEGIN: called CC=1 SCAR=0.0
65 13 ▶use Net::DHCPv6::Message::Renew;
Subroutine BEGIN: called CC=1 SCAR=0.0
66 13 ▶use Net::DHCPv6::Message::Rebind;
Subroutine BEGIN: called CC=1 SCAR=0.0
67 13 ▶use Net::DHCPv6::Message::Reply;
Subroutine BEGIN: called CC=1 SCAR=0.0
68 13 ▶use Net::DHCPv6::Message::Release;
Subroutine BEGIN: called CC=1 SCAR=0.0
69 13 ▶use Net::DHCPv6::Message::Decline;
Subroutine BEGIN: called CC=1 SCAR=0.0
70 13 ▶use Net::DHCPv6::Message::Reconfigure;
Subroutine BEGIN: called CC=1 SCAR=0.0
71 13 ▶use Net::DHCPv6::Message::InformationRequest;
Subroutine BEGIN: called CC=1 SCAR=0.0
72 13 ▶use Net::DHCPv6::Message::RelayForw;
Subroutine BEGIN: called CC=1 SCAR=0.0
73 13 ▶use Net::DHCPv6::Message::RelayReply;
Subroutine BEGIN: called CC=1 SCAR=0.0
74  
75 13 ▶use Net::DHCPv6::OptionList;
Subroutine BEGIN: called CC=1 SCAR=0.0
76 13 ▶use Net::DHCPv6::Packet;
Subroutine BEGIN: called CC=1 SCAR=0.0
77 13 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
78  
79 # Packet-level decoders
80 sub decode_or_croak {
81 28 ▶ my ( $class, $bytes ) = @_;
Subroutine decode_or_croak: called CC=3 SCAR=11.0
Pod documented
82 28 ▶ croak 'No data provided' unless defined $bytes && CORE::length( $bytes ) >= 4;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $bytes and length $bytes >= 4 2 26 28
Condition100%3/3
defined $bytes and length $bytes >= 4
!ll&&!rl&&r
1126
MC/DC100%2/2
defined $bytes and length $bytes >= 4
defined $bytes length $bytes >= 4
Truth table100%3/3
A and B
A= defined $bytesB= length $bytes >= 4
ABresult
0X0
100
111
83 26 return Net::DHCPv6::Packet->from_bytes( $bytes );
84 }
85  
86 sub decode_or_null {
87 3 ▶ my ( $class, $bytes ) = @_;
Subroutine decode_or_null: called CC=3 SCAR=11.0
Pod documented
88 3 ▶ return unless defined $bytes && CORE::length( $bytes ) >= 4;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $bytes and length $bytes >= 4 2 1 3
Condition66%2/3
defined $bytes and length $bytes >= 4
!ll&&!rl&&r
021
MC/DC50%1/2
defined $bytes and length $bytes >= 4
defined $bytes length $bytes >= 4
Truth table66%2/3
A and B
A= defined $bytesB= length $bytes >= 4
ABresult
0X0
100
111
89 1 my $packet;
90 1 eval { $packet = Net::DHCPv6::Packet->from_bytes( $bytes ); };
91 1 return $packet;
92 }
93  
94 sub decode_with_error {
95 28 ▶ my ( $class, $bytes ) = @_;
Subroutine decode_with_error: called CC=4 SCAR=14.1
Pod documented
96 28 my $packet;
97 my $error;
98 28 ▶ if ( !defined $bytes || CORE::length( $bytes ) < 4 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $bytes or length $bytes < 4) { } 1 27 28
Condition66%2/3
not defined $bytes or length $bytes < 4
l!l&&r!l&&!r
0127
MC/DC50%1/2
not defined $bytes or length $bytes < 4
not defined $bytes length $bytes < 4
Truth table66%2/3
not(A) or B
A= not defined $bytesB= length $bytes < 4
ABresult
1X1
011
000
99 1 $error = 'No data provided';
100 }
101 else {
102 27 eval { $packet = Net::DHCPv6::Packet->from_bytes( $bytes ); 1 }
103 27 ▶ or do { $error = $@; };
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $packet = "Net::DHCPv6::Packet"->from_bytes($bytes); 1 } } or do { $error = $@ } 0 27 27
104 }
105 28 return ( $packet, $error );
106 }
107  
108 # DUID streaming helpers
109 sub decode_duid_with_error {
110 6 ▶ my ( $class, $bytes ) = @_;
Subroutine decode_duid_with_error: called CC=1 SCAR=0.0
Pod documented
111 6 return Net::DHCPv6::DUID->try_from_bytes( $bytes );
112 }
113  
114 sub decode_duid_or_null {
115 3 ▶ my ( $class, $bytes ) = @_;
Subroutine decode_duid_or_null: called CC=1 SCAR=0.0
Pod documented
116 3 my ( $duid ) = Net::DHCPv6::DUID->try_from_bytes( $bytes );
117 3 return $duid;
118 }
119  
120 sub decode_duid_or_croak {
121 3 ▶ my ( $class, $bytes ) = @_;
Subroutine decode_duid_or_croak: called CC=2 SCAR=6.9
Pod documented
122 3 my ( $duid, $error ) = Net::DHCPv6::DUID->try_from_bytes( $bytes );
123 3 ▶ croak $error if $error;
Branch: 1 branch
BranchTrueFalseTotal
if $error 2 1 3
124 1 return $duid;
125 }
126  
127 # Option-list streaming helpers
128 sub decode_options_with_error {
129 5 ▶ my ( $class, $bytes ) = @_;
Subroutine decode_options_with_error: called CC=1 SCAR=0.0
Pod documented
130 5 return Net::DHCPv6::OptionList->try_from_bytes( $bytes );
131 }
132  
133 sub decode_options_or_null {
134 2 ▶ my ( $class, $bytes ) = @_;
Subroutine decode_options_or_null: called CC=1 SCAR=0.0
Pod documented
135 2 my ( $ol ) = Net::DHCPv6::OptionList->try_from_bytes( $bytes );
136 2 return $ol;
137 }
138  
139 sub decode_options_or_croak {
140 2 ▶ my ( $class, $bytes ) = @_;
Subroutine decode_options_or_croak: called CC=2 SCAR=6.9
Pod documented
141 2 my ( $ol, $error ) = Net::DHCPv6::OptionList->try_from_bytes( $bytes );
142 2 ▶ croak $error if $error;
Branch: 1 branch
BranchTrueFalseTotal
if $error 1 1 2
143 1 return $ol;
144 }
145  
146 13 1;
147  
148 __END__
« lib/Net/DHCPv6/Option/InfoRefreshTime.pm ↑ Summary lib/Net/DHCPv6/Option/ORO.pm »