| 1 | # | ||||||||||
| 2 | # $Id: v1.pm 49 2009-05-31 13:15:34Z VinsWorldcom $ | ||||||||||
| 3 | # | ||||||||||
| 4 | package Net::Frame::Layer::RIPng::v1; | ||||||||||
| 5 | 7 | ▶ | use strict; use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 7 | ▶ | use Net::Frame::Layer qw(:consts :subs); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 7 | our @ISA = qw(Net::Frame::Layer Exporter); | |||||||||
| 9 | |||||||||||
| 10 | 7 | our %EXPORT_TAGS = ( | |||||||||
| 11 | consts => [qw( | ||||||||||
| 12 | NF_RIPNG_METRIC_INFINITY | ||||||||||
| 13 | )], | ||||||||||
| 14 | ); | ||||||||||
| 15 | our @EXPORT_OK = ( | ||||||||||
| 16 | 7 | @{$EXPORT_TAGS{consts}}, | |||||||||
| 17 | ); | ||||||||||
| 18 | |||||||||||
| 19 | 7 | ▶ | use constant NF_RIPNG_METRIC_INFINITY => 16; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | |||||||||||
| 21 | 7 | our @AS = qw( | |||||||||
| 22 | prefix | ||||||||||
| 23 | routeTag | ||||||||||
| 24 | prefixLength | ||||||||||
| 25 | metric | ||||||||||
| 26 | ); | ||||||||||
| 27 | 7 | __PACKAGE__->cgBuildIndices; | |||||||||
| 28 | 7 | __PACKAGE__->cgBuildAccessorsScalar(\@AS); | |||||||||
| 29 | |||||||||||
| 30 | 2 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 31 | shift->SUPER::new( | ||||||||||
| 32 | 2 | prefix => '::', | |||||||||
| 33 | routeTag => 0, | ||||||||||
| 34 | prefixLength => 64, | ||||||||||
| 35 | metric => 1, | ||||||||||
| 36 | @_, | ||||||||||
| 37 | ); | ||||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | 1 | ▶ | sub full { | ||||||||
|
Subroutine
full: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 41 | shift->SUPER::new( | ||||||||||
| 42 | 1 | prefix => '::', | |||||||||
| 43 | routeTag => 0, | ||||||||||
| 44 | prefixLength => 0, | ||||||||||
| 45 | metric => NF_RIPNG_METRIC_INFINITY, | ||||||||||
| 46 | @_, | ||||||||||
| 47 | ); | ||||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 0 | ▶ | sub getLength { 20 } | ||||||||
|
Subroutine
getLength: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 51 | |||||||||||
| 52 | 5 | ▶ | sub pack { | ||||||||
|
Subroutine
pack: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||
| 53 | 5 | my $self = shift; | |||||||||
| 54 | |||||||||||
| 55 | 5 | ▶ | $self->raw($self->SUPER::pack('a16nCC', | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | inet6Aton($self->prefix), | ||||||||||
| 57 | $self->routeTag, | ||||||||||
| 58 | $self->prefixLength, | ||||||||||
| 59 | $self->metric | ||||||||||
| 60 | )) or return; | ||||||||||
| 61 | |||||||||||
| 62 | 5 | return $self->raw; | |||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | 1 | ▶ | sub unpack { | ||||||||
|
Subroutine
unpack: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 66 | 1 | my $self = shift; | |||||||||
| 67 | |||||||||||
| 68 | 1 | ▶ | my ($prefix, $routeTag, $prefixLength, $metric, $payload) = | ||||||||
|
Branch: 1 branch
| |||||||||||
| 69 | $self->SUPER::unpack('a16nCC a*', $self->raw) | ||||||||||
| 70 | or return; | ||||||||||
| 71 | |||||||||||
| 72 | 1 | $self->prefix(inet6Ntoa($prefix)); | |||||||||
| 73 | 1 | $self->routeTag($routeTag); | |||||||||
| 74 | 1 | $self->prefixLength($prefixLength); | |||||||||
| 75 | 1 | $self->metric($metric); | |||||||||
| 76 | |||||||||||
| 77 | 1 | $self->payload($payload); | |||||||||
| 78 | |||||||||||
| 79 | 1 | return $self; | |||||||||
| 80 | } | ||||||||||
| 81 | |||||||||||
| 82 | 1 | ▶ | sub encapsulate { | ||||||||
|
Subroutine
encapsulate: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||
| 83 | 1 | my $self = shift; | |||||||||
| 84 | |||||||||||
| 85 | 1 | ▶ | return $self->nextLayer if $self->nextLayer; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 86 | |||||||||||
| 87 | 1 | ▶ | if ($self->payload) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 88 | 0 | return "RIPng::v1"; | |||||||||
| 89 | } | ||||||||||
| 90 | |||||||||||
| 91 | 1 | NF_LAYER_NONE; | |||||||||
| 92 | } | ||||||||||
| 93 | |||||||||||
| 94 | 5 | ▶ | sub print { | ||||||||
|
Subroutine
print: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 95 | 5 | my $self = shift; | |||||||||
| 96 | |||||||||||
| 97 | 5 | my $l = $self->layer; | |||||||||
| 98 | 5 | my $buf = sprintf | |||||||||
| 99 | "$l: prefix:%s\n". | ||||||||||
| 100 | "$l: routeTag:%d prefixLength:%d metric:%d", | ||||||||||
| 101 | $self->prefix, | ||||||||||
| 102 | $self->routeTag, $self->prefixLength, $self->metric; | ||||||||||
| 103 | |||||||||||
| 104 | 5 | return $buf; | |||||||||
| 105 | } | ||||||||||
| 106 | |||||||||||
| 107 | 7 | 1; | |||||||||
| 108 | |||||||||||
| 109 | __END__ | ||||||||||