| 1 | # | ||||||||||
| 2 | # $Id: NULL.pm 2002 2015-02-15 16:50:35Z gomor $ | ||||||||||
| 3 | # | ||||||||||
| 4 | package Net::Packet::NULL; | ||||||||||
| 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 | |||||||||||
| 11 | 1 | ▶ | use Net::Packet::Consts qw(:null :layer); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 1 | our @AS = qw( | |||||||||
| 14 | type | ||||||||||
| 15 | ); | ||||||||||
| 16 | 1 | __PACKAGE__->cgBuildIndices; | |||||||||
| 17 | 1 | __PACKAGE__->cgBuildAccessorsScalar(\@AS); | |||||||||
| 18 | |||||||||||
| 19 | 1 | ▶ | no strict 'vars'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | |||||||||||
| 21 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 22 | shift->SUPER::new( | ||||||||||
| 23 | 0 | type => NP_NULL_TYPE_IPv4, | |||||||||
| 24 | @_, | ||||||||||
| 25 | ); | ||||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | 0 | ▶ | sub getLength { NP_NULL_HDR_LEN } | ||||||||
|
Subroutine
getLength: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 29 | |||||||||||
| 30 | 0 | ▶ | sub pack { | ||||||||
|
Subroutine
pack: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 31 | 0 | my $self = shift; | |||||||||
| 32 | 0 | ▶ | $self->[$__raw] = $self->SUPER::pack('N', $self->[$__type]) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | or return undef; | ||||||||||
| 34 | 0 | 1; | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 0 | ▶ | sub unpack { | ||||||||
|
Subroutine
unpack: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 38 | 0 | my $self = shift; | |||||||||
| 39 | |||||||||||
| 40 | 0 | ▶ | my ($type, $payload) = $self->SUPER::unpack('N a*', $self->[$__raw]) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | or return undef; | ||||||||||
| 42 | |||||||||||
| 43 | 0 | $self->[$__type] = $type; | |||||||||
| 44 | 0 | $self->[$__payload] = $payload; | |||||||||
| 45 | |||||||||||
| 46 | 0 | 1; | |||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | 0 | ▶ | sub encapsulate { | ||||||||
|
Subroutine
encapsulate: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 50 | 0 | my $types = { | |||||||||
| 51 | NP_NULL_TYPE_IPv4() => NP_LAYER_IPv4(), | ||||||||||
| 52 | NP_NULL_TYPE_IPv6() => NP_LAYER_IPv6(), | ||||||||||
| 53 | }; | ||||||||||
| 54 | |||||||||||
| 55 | 0 | ▶ | $types->{shift->[$__type]} || NP_LAYER_UNKNOWN(); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | 0 | ▶ | sub print { | ||||||||
|
Subroutine
print: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 59 | 0 | my $self = shift; | |||||||||
| 60 | |||||||||||
| 61 | 0 | my $l = $self->layer; | |||||||||
| 62 | 0 | my $i = $self->is; | |||||||||
| 63 | 0 | sprintf "$l:+$i: type:0x%04x", $self->type; | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | # | ||||||||||
| 67 | # Helpers | ||||||||||
| 68 | # | ||||||||||
| 69 | |||||||||||
| 70 | 0 | ▶ | sub _isType { shift->[$__type] == shift() } | ||||||||
|
Subroutine
_isType: not called CC=1 SCAR=6.9
| |||||||||||
| 71 | 0 | ▶ | sub isTypeIpv4 { shift->_isType(NP_NULL_TYPE_IPv4) } | ||||||||
|
Subroutine
isTypeIpv4: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 72 | 0 | ▶ | sub isTypeIpv6 { shift->_isType(NP_NULL_TYPE_IPv6) } | ||||||||
|
Subroutine
isTypeIpv6: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 73 | 0 | ▶ | sub isTypeIp { my $self = shift; $self->isTypeIpv4 || $self->isTypeIpv6 } | ||||||||
|
Subroutine
isTypeIp: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||
| 74 | |||||||||||
| 75 | 1 | 1; | |||||||||
| 76 | |||||||||||
| 77 | __END__ | ||||||||||