| 1 | #!/bin/false | ||||||||||
| 2 | # ABSTRACT: Elapsed Time option (code 8) -- 16-bit centiseconds | ||||||||||
| 3 | # PODNAME: Net::DHCPv6::Option::ElapsedTime | ||||||||||
| 4 | 15 | ▶ | use strictures 2; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | package Net::DHCPv6::Option::ElapsedTime; | ||||||||||
| 7 | 15 | $Net::DHCPv6::Option::ElapsedTime::VERSION = '0.002'; | |||||||||
| 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; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 15 | ▶ | use Net::DHCPv6::X::BadOption; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 15 | ▶ | use parent 'Net::DHCPv6::Option'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 15 | ▶ | use namespace::clean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | sub new { | ||||||||||
| 16 | 29 | ▶ | my ( $class, %args ) = @_; | ||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 17 | 29 | ▶ | croak 'ElapsedTime requires centiseconds' unless defined $args{centiseconds}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | 28 | $args{code} = $OPTION_ELAPSED_TIME; | |||||||||
| 19 | 28 | $args{data} = pack( 'n', $args{centiseconds} ); | |||||||||
| 20 | 28 | my $self = $class->SUPER::new( %args ); | |||||||||
| 21 | 28 | $self->{centiseconds} = $args{centiseconds}; | |||||||||
| 22 | 28 | return bless $self, $class; | |||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 11 | ▶ | sub centiseconds { return shift->{centiseconds} } | ||||||||
|
Subroutine
centiseconds: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 26 | |||||||||||
| 27 | sub from_bytes_inner { | ||||||||||
| 28 | 27 | ▶ | my ( $class, $code, $payload ) = @_; | ||||||||
|
Subroutine
from_bytes_inner: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 29 | 27 | ▶ | Net::DHCPv6::X::BadOption->throw( message => 'ElapsedTime option must be exactly 2 bytes' ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | if CORE::length( $payload ) != 2; | ||||||||||
| 31 | 26 | my $cs = unpack( 'n', $payload ); | |||||||||
| 32 | 26 | return $class->new( centiseconds => $cs ); | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 15 | $Net::DHCPv6::OptionList::OPTION_CLASS{$OPTION_ELAPSED_TIME} = __PACKAGE__; | |||||||||
| 36 | |||||||||||
| 37 | 15 | 1; | |||||||||
| 38 | |||||||||||
| 39 | __END__ | ||||||||||