« blib/lib/Net/DHCPv6/Option/BootfileUrl.pm
↑ Summary
blib/lib/Net/DHCPv6/Option/ClientArchType.pm »
| 1 | #!/bin/false | ||
| 2 | # ABSTRACT: DHCP Captive-Portal option (code 103) -- captive portal API URI | ||
| 3 | # PODNAME: Net::DHCPv6::Option::CaptivePortal | ||
| 4 | use strictures 2; | ||
| 5 | |||
| 6 | package Net::DHCPv6::Option::CaptivePortal; | ||
| 7 | $Net::DHCPv6::Option::CaptivePortal::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 'CaptivePortal requires uri' unless defined $args{uri}; | ||
| 18 | $args{code} = $OPTION_CAPTIVE_PORTAL; | ||
| 19 | $args{data} = $args{uri}; | ||
| 20 | my $self = $class->SUPER::new( %args ); | ||
| 21 | $self->{uri} = $args{uri}; | ||
| 22 | return bless $self, $class; | ||
| 23 | } | ||
| 24 | |||
| 25 | sub uri { return shift->{uri} } | ||
| 26 | |||
| 27 | sub from_bytes_inner { | ||
| 28 | my ( $class, $code, $payload ) = @_; | ||
| 29 | Net::DHCPv6::X::Truncated->throw( message => 'Truncated CaptivePortal option' ) | ||
| 30 | if CORE::length( $payload ) == 0; | ||
| 31 | return $class->new( uri => $payload ); | ||
| 32 | } | ||
| 33 | |||
| 34 | $Net::DHCPv6::OptionList::OPTION_CLASS{$OPTION_CAPTIVE_PORTAL} = __PACKAGE__; | ||
| 35 | 1; | ||
| 36 | |||
| 37 | __END__ |