| 1 | #!/bin/false | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: NIS Servers option (code 27) -- list of IPv6 addresses | ||||||||||||||||||||||||||||
| 3 | # PODNAME: Net::DHCPv6::Option::NisServers | ||||||||||||||||||||||||||||
| 4 | 15 | ▶ | use strictures 2; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | package Net::DHCPv6::Option::NisServers; | ||||||||||||||||||||||||||||
| 7 | 15 | $Net::DHCPv6::Option::NisServers::VERSION = '0.002'; | |||||||||||||||||||||||||||
| 8 | 15 | ▶ | use Net::DHCPv6::OptionList; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 15 | ▶ | use Net::DHCPv6::Constants; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 15 | ▶ | use Net::DHCPv6::X::Truncated; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 15 | ▶ | use parent 'Net::DHCPv6::Option'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 15 | ▶ | use Ref::Util qw( is_plain_arrayref ); | ||||||||||||||||||||||||||
|
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 | sub new { | ||||||||||||||||||||||||||||
| 17 | 2 | ▶ | my ( $class, %args ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||
| 18 | 2 | my $addresses = $class->_pick_addrs( \%args, 'servers' ); | |||||||||||||||||||||||||||
| 19 | 2 | ▶ | if ( !defined $addresses && $args{addresses} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $addresses and $args{"addresses"}
MC/DC0%0/2
not defined $addresses and $args{"addresses"}
not defined $addresses
$args{"addresses"}
Truth table33%1/3
not(A) and B
A= not defined $addressesB= $args{"addresses"}
| |||||||||||||||||||||||||||||
| 20 | 0 | ▶ | my $list = is_plain_arrayref( $args{addresses} ) ? $args{addresses} : [ $args{addresses} ]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 0 | $addresses = [ map { $class->_resolve_ipv6( $_ ) } @{$list} ]; | |||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | 2 | ▶ | $addresses //= []; | ||||||||||||||||||||||||||
|
Condition50%1/2
$addresses //= []
MC/DC0%0/1
$addresses //= []
$addresses
Truth table50%1/2
A
A= $addresses
| |||||||||||||||||||||||||||||
| 24 | 2 | $args{code} = $OPTION_NIS_SERVERS; | |||||||||||||||||||||||||||
| 25 | 2 | $args{data} = join( $EMPTY, @{$addresses} ); | |||||||||||||||||||||||||||
| 26 | 2 | my $self = $class->SUPER::new( %args ); | |||||||||||||||||||||||||||
| 27 | 2 | $self->{servers} = $addresses; | |||||||||||||||||||||||||||
| 28 | 2 | return bless $self, $class; | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 2 | ▶ | sub servers_raw { return shift->{servers} } | ||||||||||||||||||||||||||
|
Subroutine
servers_raw: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | sub servers { | ||||||||||||||||||||||||||||
| 34 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
servers: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 35 | 2 | return [ map { $self->_format_ipv6( $_ ) } @{ $self->{servers} } ]; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | sub from_bytes_inner { | ||||||||||||||||||||||||||||
| 39 | 2 | ▶ | my ( $class, $code, $payload ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
from_bytes_inner: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 40 | 2 | ▶ | Net::DHCPv6::X::Truncated->throw( message => 'Truncated NisServers option' ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | if CORE::length( $payload ) % $IPV6_ADDR_LEN != 0; | ||||||||||||||||||||||||||||
| 42 | 1 | my @addrs; | |||||||||||||||||||||||||||
| 43 | 1 | ▶ | while ( CORE::length( $payload ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 1 | push @addrs, substr( $payload, 0, $IPV6_ADDR_LEN, q() ); | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | 1 | return $class->new( servers_raw => \@addrs ); | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 15 | $Net::DHCPv6::OptionList::OPTION_CLASS{$OPTION_NIS_SERVERS} = __PACKAGE__; | |||||||||||||||||||||||||||
| 50 | 15 | 1; | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | __END__ | ||||||||||||||||||||||||||||