lib/Net/DHCPv6/Option/NtpServer.pm

filter: Statementstmt 98.3% 58 / 59 Branchbran 62.5% 5 / 8 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 13 / 13 Podpod 100% 3 / 3 totaltotal 93.0% 80 / 86 CC 6 SCAR 8.1
CC
6
Cov
93%
from_bytes_inner
5.1
new
2.0
BEGIN
1.0
CRAP 2.3
« blib/lib/Net/DHCPv6.pm ↑ Summary lib/Net/DHCPv6/Option/IANA.pm »
1 #!/bin/false
2 # ABSTRACT: NTP Server option (code 56) -- sub-options for NTP configuration per RFC 5908
3 # PODNAME: Net::DHCPv6::Option::NtpServer
4 15 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 package Net::DHCPv6::Option::NtpServer;
7 15 $Net::DHCPv6::Option::NtpServer::VERSION = '0.002';
8 15 ▶use Net::DHCPv6::OptionList;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 15 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 15 ▶use Net::DHCPv6::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 15 ▶use Net::DHCPv6::X::Truncated;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 15 ▶use parent 'Net::DHCPv6::Option';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 15 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 15 my $EMPTY = q();
15  
16 my %SUBOPT_DECODE = (
17 1 ▶ 1 => sub { my ( $v ) = @_; return { subopt => 1, type => 'address', value => $v } },
Subroutine __ANON__: called CC=1 SCAR=0.0
18 1 ▶ 2 => sub { my ( $v ) = @_; return { subopt => 2, type => 'fqdn', value => $v } },
Subroutine __ANON__: called CC=1 SCAR=0.0
19 1 ▶ 3 => sub { my ( $v ) = @_; return { subopt => 3, type => 'domain', value => $v } },
Subroutine __ANON__: called CC=1 SCAR=0.0
20 15 );
21  
22 sub new {
23 1 ▶ my ( $class, %args ) = @_;
Subroutine new: called CC=2 SCAR=6.9
Pod documented
24 1 $args{code} = $OPTION_NTP_SERVER;
25 1 ▶ my $entries = $args{entries} // [];
Condition50%1/2
$args{"entries"} // []
l!l
10
MC/DC0%0/1
$args{"entries"} // []
$args{"entries"}
Truth table50%1/2
A
A= $args{"entries"}
Aresult
11
00
26 $args{data} =
27 1 join( $EMPTY, map { pack( 'n n', $_->{subopt}, CORE::length( $_->{value} ) ) . $_->{value} } @{$entries} );
28 1 my $self = $class->SUPER::new( %args );
29 1 $self->{entries} = $entries;
30 1 return bless $self, $class;
31 }
32  
33 5 ▶sub entries { return shift->{entries} }
Subroutine entries: called CC=1 SCAR=0.0
Pod documented
34  
35 sub from_bytes_inner {
36 1 ▶ my ( $class, $code, $payload ) = @_;
Subroutine from_bytes_inner: called CC=5 SCAR=16.3
Pod documented
37 1 my @entries;
38 1 my $len = CORE::length( $payload );
39 1 my $off = 0;
40 1 ▶ while ( $off + 4 <= $len ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($off + 4 <= $len) 3 1 4
41 3 my $sc = unpack( 'n', substr( $payload, $off, 2 ) );
42 3 my $slen = unpack( 'n', substr( $payload, $off + 2, 2 ) );
43 3 $off += 4;
44 3 ▶ Net::DHCPv6::X::Truncated->throw( message => 'Truncated NtpServer sub-option' )
Branch: 1 branch
BranchTrueFalseTotal
if $off + $slen > $len 0 3 3
45 if $off + $slen > $len;
46 3 my $sv = substr( $payload, $off, $slen );
47 3 $off += $slen;
48 3 my $decoder = $SUBOPT_DECODE{$sc};
49 3 ▶ if ( $decoder ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($decoder) { } 3 0 3
50 3 push @entries, $decoder->( $sv );
51 }
52 else {
53 0 push @entries, { subopt => $sc, value => $sv };
54 }
55 }
56 1 ▶ Net::DHCPv6::X::Truncated->throw( message => 'Truncated NtpServer sub-option header' )
Branch: 1 branch
BranchTrueFalseTotal
if $off != $len 0 1 1
57 if $off != $len;
58 1 return $class->new( entries => \@entries );
59 }
60  
61 15 $Net::DHCPv6::OptionList::OPTION_CLASS{$OPTION_NTP_SERVER} = __PACKAGE__;
62 15 1;
63  
64 __END__
« blib/lib/Net/DHCPv6.pm ↑ Summary lib/Net/DHCPv6/Option/IANA.pm »