| 1 | #!/usr/bin/false | ||||||||||||
| 2 | # ABSTRACT: Status Code option (code 13) | ||||||||||||
| 3 | # PODNAME: Net::DHCPv6::Option::StatusCode | ||||||||||||
| 4 | package Net::DHCPv6::Option::StatusCode; | ||||||||||||
| 5 | 15 | $Net::DHCPv6::Option::StatusCode::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 parent 'Net::DHCPv6::Option'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | 15 | ▶ | use namespace::clean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 12 | |||||||||||||
| 13 | sub new { | ||||||||||||
| 14 | 5 | ▶ | my ( $class, %args ) = @_; | ||||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||
| 15 | 5 | ▶ | croak 'StatusCode requires status_code' unless defined $args{status_code}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 16 | 4 | $args{code} = $OPTION_STATUS_CODE; | |||||||||||
| 17 | 4 | ▶ | $args{message} = $args{message} // ''; | ||||||||||
|
Condition50%1/2
$args{"message"} // ""
MC/DC0%0/1
$args{"message"} // ""
$args{"message"}
Truth table50%1/2
A
A= $args{"message"}
| |||||||||||||
| 18 | 4 | $args{data} = pack( 'n', $args{status_code} ) . $args{message}; | |||||||||||
| 19 | 4 | my $self = $class->SUPER::new( %args ); | |||||||||||
| 20 | 4 | $self->{status_code} = $args{status_code}; | |||||||||||
| 21 | 4 | $self->{message} = $args{message}; | |||||||||||
| 22 | 4 | bless $self, $class; | |||||||||||
| 23 | } | ||||||||||||
| 24 | |||||||||||||
| 25 | 3 | ▶ | sub status_code { shift->{status_code} } | ||||||||||
|
Subroutine
status_code: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 26 | 3 | ▶ | sub message { shift->{message} } | ||||||||||
|
Subroutine
message: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 27 | |||||||||||||
| 28 | sub from_bytes_inner { | ||||||||||||
| 29 | 4 | ▶ | my ( $class, $code, $data ) = @_; | ||||||||||
|
Subroutine
from_bytes_inner: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||
| 30 | 4 | ▶ | Net::DHCPv6::X::Truncated->throw( message => 'Truncated StatusCode option' ) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 31 | if CORE::length( $data ) < 2; | ||||||||||||
| 32 | 3 | my $sc = unpack( 'n', substr( $data, 0, 2 ) ); | |||||||||||
| 33 | 3 | my $msg = substr( $data, 2 ); | |||||||||||
| 34 | 3 | return $class->new( status_code => $sc, message => $msg ); | |||||||||||
| 35 | } | ||||||||||||
| 36 | |||||||||||||
| 37 | sub as_bytes { | ||||||||||||
| 38 | 1 | ▶ | my $self = shift; | ||||||||||
|
Subroutine
as_bytes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 39 | 1 | my $data = pack( 'n', $self->{status_code} ) . $self->{message}; | |||||||||||
| 40 | 1 | return pack( 'nn', $self->{code}, CORE::length( $data ) ) . $data; | |||||||||||
| 41 | } | ||||||||||||
| 42 | |||||||||||||
| 43 | 15 | $Net::DHCPv6::OptionList::OPTION_CLASS{$OPTION_STATUS_CODE} = __PACKAGE__; | |||||||||||
| 44 | |||||||||||||
| 45 | 15 | 1; | |||||||||||
| 46 | |||||||||||||
| 47 | __END__ | ||||||||||||