| 1 | #!/bin/false | ||
| 2 | # ABSTRACT: Reconfigure Message option (code 19) -- 1-byte msg-type | ||
| 3 | # PODNAME: Net::DHCPv6::Option::ReconfMsg | ||
| 4 | use strictures 2; | ||
| 5 | |||
| 6 | package Net::DHCPv6::Option::ReconfMsg; | ||
| 7 | $Net::DHCPv6::Option::ReconfMsg::VERSION = '0.002'; | ||
| 8 | use Net::DHCPv6::OptionList; | ||
| 9 | use Carp qw( croak ); | ||
| 10 | use Net::DHCPv6::Constants; | ||
| 11 | use Net::DHCPv6::X::Truncated; | ||
| 12 | use parent 'Net::DHCPv6::Option'; | ||
| 13 | use namespace::clean; | ||
| 14 | |||
| 15 | sub new { | ||
| 16 | my ( $class, %args ) = @_; | ||
| 17 | croak 'ReconfMsg requires msg_type' unless defined $args{msg_type}; | ||
| 18 | $args{code} = $OPTION_RECONF_MSG; | ||
| 19 | $args{data} = pack( 'C', $args{msg_type} ); | ||
| 20 | my $self = $class->SUPER::new( %args ); | ||
| 21 | $self->{msg_type} = $args{msg_type}; | ||
| 22 | return bless $self, $class; | ||
| 23 | } | ||
| 24 | |||
| 25 | sub msg_type { return shift->{msg_type} } | ||
| 26 | |||
| 27 | sub from_bytes_inner { | ||
| 28 | my ( $class, $code, $payload ) = @_; | ||
| 29 | Net::DHCPv6::X::Truncated->throw( message => 'Truncated ReconfMsg option' ) | ||
| 30 | if CORE::length( $payload ) < 1; | ||
| 31 | my $type = unpack( 'C', $payload ); | ||
| 32 | return $class->new( msg_type => $type ); | ||
| 33 | } | ||
| 34 | |||
| 35 | $Net::DHCPv6::OptionList::OPTION_CLASS{$OPTION_RECONF_MSG} = __PACKAGE__; | ||
| 36 | 1; | ||
| 37 | |||
| 38 | __END__ |