| 1 | # | ||||||||||||||||||||||||||||
| 2 | # $Id: Option.pm,v bc01789674fd 2019/05/23 05:51:45 gomor $ | ||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||
| 4 | package Net::Frame::Layer::ICMPv6::Option; | ||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use strict; use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Net::Frame::Layer qw(:consts :subs); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 3 | our @ISA = qw(Net::Frame::Layer); | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 3 | our @AS = qw( | |||||||||||||||||||||||||||
| 11 | type | ||||||||||||||||||||||||||||
| 12 | length | ||||||||||||||||||||||||||||
| 13 | value | ||||||||||||||||||||||||||||
| 14 | ); | ||||||||||||||||||||||||||||
| 15 | 3 | __PACKAGE__->cgBuildIndices; | |||||||||||||||||||||||||||
| 16 | 3 | __PACKAGE__->cgBuildAccessorsScalar(\@AS); | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 3 | ▶ | use Net::Frame::Layer::ICMPv6 qw(:consts); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 21 | shift->SUPER::new( | ||||||||||||||||||||||||||||
| 22 | 1 | type => 0, | |||||||||||||||||||||||||||
| 23 | length => 0, | ||||||||||||||||||||||||||||
| 24 | value => '', | ||||||||||||||||||||||||||||
| 25 | @_, | ||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 0 | ▶ | sub getLength { | ||||||||||||||||||||||||||
|
Subroutine
getLength: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 30 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | return length($self->value) + 2; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 1 | ▶ | sub pack { | ||||||||||||||||||||||||||
|
Subroutine
pack: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 36 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 1 | ▶ | $self->raw($self->SUPER::pack('CCa*', | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | $self->type, $self->length, $self->value, | ||||||||||||||||||||||||||||
| 40 | )) or return; | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 1 | return $self->raw; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 1 | ▶ | sub unpack { | ||||||||||||||||||||||||||
|
Subroutine
unpack: called CC=5 SCAR=17.6
Pod
documented
| |||||||||||||||||||||||||||||
| 46 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 1 | ▶ | my ($type, $length, $tail) = $self->SUPER::unpack('CC a*', $self->raw) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | or return; | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 1 | $self->type($type); | |||||||||||||||||||||||||||
| 52 | 1 | $self->length($length); | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | # Dirty hack. Some systems does not set the length correctly | ||||||||||||||||||||||||||||
| 55 | 1 | ▶ | if ($type == NF_ICMPv6_OPTION_TARGETLINKLAYERADDRESS | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$type == 2 or $type == 1
MC/DC0%0/2
$type == 2 or $type == 1
$type == 2
$type == 1
Truth table33%1/3
A or B
A= $type == 2B= $type == 1
| |||||||||||||||||||||||||||||
| 56 | || $type == NF_ICMPv6_OPTION_SOURCELINKLAYERADDRESS) { | ||||||||||||||||||||||||||||
| 57 | 0 | $length = 6; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 1 | ▶ | my ($value, $payload) = $self->SUPER::unpack("a$length a*", $tail) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | or return; | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 1 | $self->value($value); | |||||||||||||||||||||||||||
| 64 | 1 | $self->payload($payload); | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 1 | return $self; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 0 | ▶ | sub print { | ||||||||||||||||||||||||||
|
Subroutine
print: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 70 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 0 | my $l = $self->layer; | |||||||||||||||||||||||||||
| 73 | 0 | sprintf "$l: type:%02x length:%02x value:%s", | |||||||||||||||||||||||||||
| 74 | $self->type, $self->length, CORE::unpack('H*', $self->value); | ||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 3 | 1; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | __END__ | ||||||||||||||||||||||||||||