| 1 | #!/bin/false | ||||||||||||||||||||
| 2 | # ABSTRACT: Vendor-specific Information option (code 17) -- enterprise + sub-options | ||||||||||||||||||||
| 3 | # PODNAME: Net::DHCPv6::Option::VendorOpts | ||||||||||||||||||||
| 4 | 15 | ▶ | use strictures 2; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | package Net::DHCPv6::Option::VendorOpts; | ||||||||||||||||||||
| 7 | 15 | $Net::DHCPv6::Option::VendorOpts::VERSION = '0.003'; | |||||||||||||||||||
| 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 qw( | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | $OPTION_VENDOR_OPTS | ||||||||||||||||||||
| 12 | 15 | ); | |||||||||||||||||||
| 13 | 15 | ▶ | use Net::DHCPv6::X::Truncated (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | 15 | ▶ | use parent 'Net::DHCPv6::Option'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | 15 | ▶ | use Ref::Util qw( is_plain_arrayref ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 16 | 15 | ▶ | use namespace::clean; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | 15 | my $EMPTY = q(); | |||||||||||||||||||
| 18 | 15 | my $ENT_NUM_LEN = 4; ## no critic (ValuesAndExpressions::ProhibitMagicNumbers) | |||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 3 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=14.7
Pod
documented
| |||||||||||||||||||||
| 21 | 3 | my ( $class, %args ) = @_; | |||||||||||||||||||
| 22 | 3 | ▶ | croak 'VendorOpts requires enterprise_number' unless defined $args{enterprise_number}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 23 | 2 | $args{code} = $OPTION_VENDOR_OPTS; | |||||||||||||||||||
| 24 | 2 | ▶ | my $sub_data = $args{sub_options} // $EMPTY; | ||||||||||||||||||
|
Condition33%1/3
$args{"sub_options"} // $EMPTY
MC/DC0%0/2
$args{"sub_options"} // $EMPTY
$args{"sub_options"}
$EMPTY
Truth table33%1/3
A // B
A= $args{"sub_options"}B= $EMPTY
| |||||||||||||||||||||
| 25 | 0 | ▶ | $sub_data = join( $EMPTY, map { $_->as_bytes } @{$sub_data} ) if is_plain_arrayref( $sub_data ); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 26 | 2 | $args{data} = pack( 'N', $args{enterprise_number} ) . $sub_data; | |||||||||||||||||||
| 27 | 2 | my $self = $class->SUPER::new( %args ); | |||||||||||||||||||
| 28 | 2 | $self->{enterprise_number} = $args{enterprise_number}; | |||||||||||||||||||
| 29 | 2 | return bless $self, $class; | |||||||||||||||||||
| 30 | } | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 2 | ▶ | sub enterprise_number { return shift->{enterprise_number} } | ||||||||||||||||||
|
Subroutine
enterprise_number: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 1 | ▶ | sub from_bytes_inner { | ||||||||||||||||||
|
Subroutine
from_bytes_inner: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||
| 35 | 1 | my ( $class, $code, $payload ) = @_; | |||||||||||||||||||
| 36 | 1 | ▶ | Net::DHCPv6::X::Truncated->throw( message => 'Truncated VendorOpts option' ) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 37 | if CORE::length( $payload ) < $ENT_NUM_LEN; | ||||||||||||||||||||
| 38 | 1 | my $en = unpack( 'N', substr( $payload, 0, $ENT_NUM_LEN ) ); | |||||||||||||||||||
| 39 | 1 | return $class->new( enterprise_number => $en, sub_options => substr( $payload, $ENT_NUM_LEN ) ); | |||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 15 | $Net::DHCPv6::OptionList::OPTION_CLASS{$OPTION_VENDOR_OPTS} = __PACKAGE__; | |||||||||||||||||||
| 43 | 15 | 1; | |||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | __END__ | ||||||||||||||||||||