| 1 | # | ||||||||||
| 2 | # $Id: SNAP.pm 16 2010-06-03 12:46:53Z gomor $ | ||||||||||
| 3 | # | ||||||||||
| 4 | package Net::Frame::Layer::LLC::SNAP; | ||||||||||
| 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 | ▶ | use Net::Frame::Layer qw(:consts); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | our @ISA = qw(Net::Frame::Layer); | |||||||||
| 10 | |||||||||||
| 11 | 1 | our @AS = qw( | |||||||||
| 12 | oui | ||||||||||
| 13 | pid | ||||||||||
| 14 | ); | ||||||||||
| 15 | 1 | __PACKAGE__->cgBuildIndices; | |||||||||
| 16 | 1 | __PACKAGE__->cgBuildAccessorsScalar(\@AS); | |||||||||
| 17 | |||||||||||
| 18 | 1 | ▶ | no strict 'vars'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | |||||||||||
| 20 | 1 | ▶ | use Net::Frame::Layer::LLC qw(:consts); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 1 | require Bit::Vector; | |||||||||
| 22 | |||||||||||
| 23 | sub new { | ||||||||||
| 24 | shift->SUPER::new( | ||||||||||
| 25 | 1 | ▶ | oui => NF_LLC_SNAP_OUI_CISCO, | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 26 | pid => NF_LLC_SNAP_PID_CDP, | ||||||||||
| 27 | @_, | ||||||||||
| 28 | ); | ||||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 0 | ▶ | sub getLength { NF_LLC_SNAP_HDR_LEN } | ||||||||
|
Subroutine
getLength: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 32 | |||||||||||
| 33 | sub pack { | ||||||||||
| 34 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
pack: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 35 | |||||||||||
| 36 | 1 | my $oui = Bit::Vector->new_Dec(24, $self->[$__oui]); | |||||||||
| 37 | |||||||||||
| 38 | 1 | ▶ | $self->[$__raw] = $self->SUPER::pack('B24n', | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | $oui->to_Bin, | ||||||||||
| 40 | $self->[$__pid], | ||||||||||
| 41 | ) or return undef; | ||||||||||
| 42 | |||||||||||
| 43 | 1 | $self->[$__raw]; | |||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | sub unpack { | ||||||||||
| 47 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
unpack: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 48 | |||||||||||
| 49 | 1 | ▶ | my ($oui, $pid, $payload) = $self->SUPER::unpack('B24n a*', $self->[$__raw]) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | or return undef; | ||||||||||
| 51 | |||||||||||
| 52 | 1 | my $v24 = Bit::Vector->new_Bin(24, $oui); | |||||||||
| 53 | 1 | $self->[$__oui] = $v24->to_Dec; | |||||||||
| 54 | 1 | $self->[$__pid] = $pid; | |||||||||
| 55 | |||||||||||
| 56 | 1 | $self->[$__payload] = $payload; | |||||||||
| 57 | |||||||||||
| 58 | 1 | $self; | |||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | sub encapsulate { | ||||||||||
| 62 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
encapsulate: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 63 | |||||||||||
| 64 | 0 | ▶ | return $self->[$__nextLayer] if $self->[$__nextLayer]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 65 | |||||||||||
| 66 | 0 | my $types = { | |||||||||
| 67 | NF_LLC_SNAP_PID_CDP() => 'CDP', | ||||||||||
| 68 | NF_LLC_SNAP_PID_STP() => 'STP', | ||||||||||
| 69 | NF_LLC_SNAP_PID_IPX() => 'IPX', | ||||||||||
| 70 | }; | ||||||||||
| 71 | |||||||||||
| 72 | 0 | ▶ | $types->{$self->[$__pid]} || NF_LAYER_UNKNOWN; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 73 | } | ||||||||||
| 74 | |||||||||||
| 75 | sub print { | ||||||||||
| 76 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
print: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 77 | |||||||||||
| 78 | 0 | my $l = $self->layer; | |||||||||
| 79 | 0 | sprintf "$l: oui:0x%06x pid:0x%04x", | |||||||||
| 80 | $self->[$__oui], $self->[$__pid]; | ||||||||||
| 81 | } | ||||||||||
| 82 | |||||||||||
| 83 | 1 | 1; | |||||||||
| 84 | |||||||||||
| 85 | __END__ | ||||||||||