lib/Net/DHCPv6.pm

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