| 1 | #!/usr/bin/false | ||||||||||
| 2 | # ABSTRACT: PD Exclude option (code 67) — prefix to exclude from IA_PD | ||||||||||
| 3 | # PODNAME: Net::DHCPv6::Option::PdExclude | ||||||||||
| 4 | package Net::DHCPv6::Option::PdExclude; | ||||||||||
| 5 | 15 | $Net::DHCPv6::Option::PdExclude::VERSION = '0.001'; | |||||||||
| 6 | 15 | ▶ | use strictures 2; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 15 | ▶ | use Carp qw(croak); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 15 | ▶ | use Net::DHCPv6::Constants; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 15 | ▶ | use Net::DHCPv6::X::Truncated; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 15 | ▶ | use Net::DHCPv6::X::BadOption; | ||||||||
|
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 namespace::clean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | sub new { | ||||||||||
| 15 | 4 | ▶ | my ( $class, %args ) = @_; | ||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 16 | 4 | ▶ | croak 'PdExclude requires prefix_length' unless defined $args{prefix_length}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | 3 | ▶ | croak 'PdExclude requires address' unless $args{address}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | 2 | $args{code} = $OPTION_PD_EXCLUDE; | |||||||||
| 19 | 2 | $args{data} = pack( 'C', $args{prefix_length} ) . $args{address}; | |||||||||
| 20 | 2 | my $self = $class->SUPER::new( %args ); | |||||||||
| 21 | 2 | $self->{prefix_length} = $args{prefix_length}; | |||||||||
| 22 | 2 | $self->{address} = $args{address}; | |||||||||
| 23 | 2 | bless $self, $class; | |||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 2 | ▶ | sub prefix_length { shift->{prefix_length} } | ||||||||
|
Subroutine
prefix_length: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 27 | 1 | ▶ | sub address { shift->{address} } | ||||||||
|
Subroutine
address: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 28 | |||||||||||
| 29 | sub from_bytes_inner { | ||||||||||
| 30 | 1 | ▶ | my ( $class, $code, $data ) = @_; | ||||||||
|
Subroutine
from_bytes_inner: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||
| 31 | 1 | ▶ | Net::DHCPv6::X::Truncated->throw( message => 'Truncated PdExclude option' ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | if CORE::length( $data ) < 2; | ||||||||||
| 33 | 1 | my $plen = unpack( 'C', substr( $data, 0, 1 ) ); | |||||||||
| 34 | 1 | my $addr_len = ( $plen + 7 ) >> 3; | |||||||||
| 35 | 1 | ▶ | Net::DHCPv6::X::Truncated->throw( message => 'Truncated PdExclude address' ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | if 1 + $addr_len > CORE::length( $data ); | ||||||||||
| 37 | 1 | my $addr = substr( $data, 1, $addr_len ); | |||||||||
| 38 | 1 | return $class->new( prefix_length => $plen, address => $addr ); | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | sub as_bytes { | ||||||||||
| 42 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
as_bytes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 43 | 1 | my $data = pack( 'C', $self->{prefix_length} ) . $self->{address}; | |||||||||
| 44 | 1 | return pack( 'nn', $self->{code}, CORE::length( $data ) ) . $data; | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 15 | $Net::DHCPv6::OptionList::OPTION_CLASS{$OPTION_PD_EXCLUDE} = __PACKAGE__; | |||||||||
| 48 | 15 | 1; | |||||||||
| 49 | |||||||||||
| 50 | __END__ | ||||||||||