| 1 | # | ||||||||||
| 2 | # $Id: Fragment.pm 47 2015-01-20 18:20:28Z gomor $ | ||||||||||
| 3 | # | ||||||||||
| 4 | package Net::Frame::Layer::IPv6::Fragment; | ||||||||||
| 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 | our $VERSION = '1.07'; | |||||||||
| 8 | |||||||||||
| 9 | 3 | ▶ | use Net::Frame::Layer qw(:consts :subs); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 3 | ▶ | use Exporter; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 3 | our @ISA = qw(Net::Frame::Layer Exporter); | |||||||||
| 12 | |||||||||||
| 13 | 3 | our @AS = qw( | |||||||||
| 14 | nextHeader | ||||||||||
| 15 | reserved | ||||||||||
| 16 | fragmentOffset | ||||||||||
| 17 | res | ||||||||||
| 18 | mFlag | ||||||||||
| 19 | identification | ||||||||||
| 20 | ); | ||||||||||
| 21 | 3 | __PACKAGE__->cgBuildIndices; | |||||||||
| 22 | 3 | __PACKAGE__->cgBuildAccessorsScalar(\@AS); | |||||||||
| 23 | |||||||||||
| 24 | 3 | ▶ | use Net::Frame::Layer::IPv6 qw(:consts); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | |||||||||||
| 26 | sub new { | ||||||||||
| 27 | shift->SUPER::new( | ||||||||||
| 28 | 1 | ▶ | nextHeader => NF_IPv6_PROTOCOL_TCP, | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 29 | reserved => 0, | ||||||||||
| 30 | fragmentOffset => 0, | ||||||||||
| 31 | res => 0, | ||||||||||
| 32 | mFlag => 0, | ||||||||||
| 33 | identification => 0, | ||||||||||
| 34 | @_, | ||||||||||
| 35 | ); | ||||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 0 | ▶ | sub getLength { 8 } | ||||||||
|
Subroutine
getLength: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 39 | |||||||||||
| 40 | sub pack { | ||||||||||
| 41 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
pack: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 42 | |||||||||||
| 43 | 1 | my $fragmentOffset = Bit::Vector->new_Dec(13, $self->fragmentOffset); | |||||||||
| 44 | 1 | my $res = Bit::Vector->new_Dec( 2, $self->res); | |||||||||
| 45 | 1 | my $mFlag = Bit::Vector->new_Dec( 1, $self->mFlag); | |||||||||
| 46 | 1 | my $v16 = $fragmentOffset->Concat_List($res, $mFlag); | |||||||||
| 47 | |||||||||||
| 48 | 1 | ▶ | my $raw = $self->SUPER::pack('CCnN', | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | $self->nextHeader, $self->reserved, $v16->to_Dec, $self->identification | ||||||||||
| 50 | ) or return; | ||||||||||
| 51 | |||||||||||
| 52 | 1 | return $self->raw($raw); | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | sub unpack { | ||||||||||
| 56 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
unpack: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 57 | |||||||||||
| 58 | 1 | ▶ | my ($nextHeader, $reserved, $fragflags, $identification, $payload) = | ||||||||
|
Branch: 1 branch
| |||||||||||
| 59 | $self->SUPER::unpack('CCnN a*', $self->raw) | ||||||||||
| 60 | or return; | ||||||||||
| 61 | |||||||||||
| 62 | 1 | $self->nextHeader($nextHeader); | |||||||||
| 63 | 1 | $self->reserved($reserved); | |||||||||
| 64 | |||||||||||
| 65 | 1 | my $v16 = Bit::Vector->new_Dec(16, $fragflags); | |||||||||
| 66 | |||||||||||
| 67 | 1 | $self->fragmentOffset($v16->Chunk_Read(13, 3)); | |||||||||
| 68 | 1 | $self->res ($v16->Chunk_Read( 2, 1)); | |||||||||
| 69 | 1 | $self->mFlag ($v16->Chunk_Read( 1, 0)); | |||||||||
| 70 | |||||||||||
| 71 | 1 | $self->identification($identification); | |||||||||
| 72 | |||||||||||
| 73 | 1 | $self->payload($payload); | |||||||||
| 74 | |||||||||||
| 75 | 1 | return $self; | |||||||||
| 76 | } | ||||||||||
| 77 | |||||||||||
| 78 | sub encapsulate { | ||||||||||
| 79 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
encapsulate: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 80 | |||||||||||
| 81 | 0 | ▶ | return $self->nextLayer if $self->nextLayer; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 82 | |||||||||||
| 83 | 0 | ▶ | if ($self->payload) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 84 | 0 | my $next = $self->nextHeader; | |||||||||
| 85 | 0 | return Net::Frame::Layer::IPv6->new(nextHeader => $self->nextHeader)->encapsulate; | |||||||||
| 86 | } | ||||||||||
| 87 | |||||||||||
| 88 | 0 | return NF_LAYER_NONE; | |||||||||
| 89 | } | ||||||||||
| 90 | |||||||||||
| 91 | sub print { | ||||||||||
| 92 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
print: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 93 | |||||||||||
| 94 | 0 | my $l = $self->layer; | |||||||||
| 95 | 0 | my $buf = sprintf | |||||||||
| 96 | "$l: nextHeader:0x%02x reserved:%d fragmentOffset:0x%04x\n". | ||||||||||
| 97 | "$l: res:%d mFlag:%d identification:%d", | ||||||||||
| 98 | $self->nextHeader, $self->reserved, $self->fragmentOffset, | ||||||||||
| 99 | $self->res, $self->mFlag, $self->identification; | ||||||||||
| 100 | |||||||||||
| 101 | 0 | return $buf; | |||||||||
| 102 | } | ||||||||||
| 103 | |||||||||||
| 104 | 3 | 1; | |||||||||
| 105 | |||||||||||
| 106 | __END__ | ||||||||||