| 1 | # | ||||||||||||||||||
| 2 | # $Id: RAW.pm 2002 2015-02-15 16:50:35Z gomor $ | ||||||||||||||||||
| 3 | # | ||||||||||||||||||
| 4 | package Net::Packet::RAW; | ||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 6 | 1 | ▶ | use warnings; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 7 | |||||||||||||||||||
| 8 | 1 | require Net::Packet::Layer2; | |||||||||||||||||
| 9 | 1 | our @ISA = qw(Net::Packet::Layer2); | |||||||||||||||||
| 10 | 1 | __PACKAGE__->cgBuildIndices; | |||||||||||||||||
| 11 | |||||||||||||||||||
| 12 | 1 | ▶ | use Net::Packet::Consts qw(:layer); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 13 | |||||||||||||||||||
| 14 | 1 | ▶ | no strict 'vars'; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 15 | |||||||||||||||||||
| 16 | 0 | ▶ | sub pack { shift->[$__raw] = '' } | ||||||||||||||||
|
Subroutine
pack: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 17 | |||||||||||||||||||
| 18 | 0 | ▶ | sub unpack { | ||||||||||||||||
|
Subroutine
unpack: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 19 | 0 | my $self = shift; | |||||||||||||||||
| 20 | 0 | $self->[$__payload] = $self->[$__raw]; | |||||||||||||||||
| 21 | 0 | 1; | |||||||||||||||||
| 22 | } | ||||||||||||||||||
| 23 | |||||||||||||||||||
| 24 | 0 | ▶ | sub encapsulate { | ||||||||||||||||
|
Subroutine
encapsulate: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||
| 25 | 0 | my $self = shift; | |||||||||||||||||
| 26 | |||||||||||||||||||
| 27 | 0 | ▶ | return NP_LAYER_NONE() if ! $self->[$__payload]; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 28 | |||||||||||||||||||
| 29 | # With RAW layer, we must guess which type is the first layer | ||||||||||||||||||
| 30 | 0 | my $payload = CORE::unpack('H*', $self->[$__payload]); | |||||||||||||||||
| 31 | |||||||||||||||||||
| 32 | # XXX: may not work on big-endian arch | ||||||||||||||||||
| 33 | 0 | ▶ | if ($payload =~ /^4/) { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 34 | 0 | return NP_LAYER_IPv4(); | |||||||||||||||||
| 35 | } | ||||||||||||||||||
| 36 | elsif ($payload =~ /^6/) { | ||||||||||||||||||
| 37 | 0 | return NP_LAYER_IPv6(); | |||||||||||||||||
| 38 | } | ||||||||||||||||||
| 39 | elsif ($payload =~ /^0001....06/) { | ||||||||||||||||||
| 40 | 0 | return NP_LAYER_ARP(); | |||||||||||||||||
| 41 | } | ||||||||||||||||||
| 42 | |||||||||||||||||||
| 43 | 0 | return NP_LAYER_UNKNOWN(); | |||||||||||||||||
| 44 | } | ||||||||||||||||||
| 45 | |||||||||||||||||||
| 46 | 1 | 1; | |||||||||||||||||
| 47 | |||||||||||||||||||
| 48 | __END__ | ||||||||||||||||||