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