| 1 | #!/bin/false | ||
| 2 | # ABSTRACT: Option Request option (code 6) | ||
| 3 | # PODNAME: Net::DHCPv6::Option::ORO | ||
| 4 | use strictures 2; | ||
| 5 | |||
| 6 | package Net::DHCPv6::Option::ORO; | ||
| 7 | $Net::DHCPv6::Option::ORO::VERSION = '0.002'; | ||
| 8 | use Net::DHCPv6::OptionList; | ||
| 9 | use Carp qw( croak ); | ||
| 10 | use Net::DHCPv6::Constants; | ||
| 11 | use Net::DHCPv6::X::BadOption; | ||
| 12 | use parent 'Net::DHCPv6::Option'; | ||
| 13 | use namespace::clean; | ||
| 14 | |||
| 15 | sub new { | ||
| 16 | my ( $class, %args ) = @_; | ||
| 17 | croak 'ORO requires requested_options (arrayref)' unless $args{requested_options}; | ||
| 18 | $args{code} = $OPTION_ORO; | ||
| 19 | $args{data} = pack( 'n*', @{ $args{requested_options} } ); | ||
| 20 | my $self = $class->SUPER::new( %args ); | ||
| 21 | $self->{requested_options} = $args{requested_options}; | ||
| 22 | return bless $self, $class; | ||
| 23 | } | ||
| 24 | |||
| 25 | sub requested_options { return shift->{requested_options} } | ||
| 26 | |||
| 27 | sub from_bytes_inner { | ||
| 28 | my ( $class, $code, $payload ) = @_; | ||
| 29 | Net::DHCPv6::X::BadOption->throw( message => 'ORO data must have even length' ) | ||
| 30 | if CORE::length( $payload ) % 2 != 0; | ||
| 31 | my @codes = unpack( 'n*', $payload ); | ||
| 32 | return $class->new( requested_options => \@codes ); | ||
| 33 | } | ||
| 34 | |||
| 35 | $Net::DHCPv6::OptionList::OPTION_CLASS{$OPTION_ORO} = __PACKAGE__; | ||
| 36 | |||
| 37 | 1; | ||
| 38 | |||
| 39 | __END__ |