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