| 1 | # | ||||||||||
| 2 | # $Id: SOA.pm 49 2009-05-31 13:15:34Z VinsWorldcom $ | ||||||||||
| 3 | # | ||||||||||
| 4 | package Net::Frame::Layer::DNS::RR::SOA; | ||||||||||
| 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 @AS = qw( | |||||||||
| 11 | mname | ||||||||||
| 12 | rname | ||||||||||
| 13 | serial | ||||||||||
| 14 | refresh | ||||||||||
| 15 | retry | ||||||||||
| 16 | expire | ||||||||||
| 17 | minimum | ||||||||||
| 18 | ); | ||||||||||
| 19 | 7 | __PACKAGE__->cgBuildIndices; | |||||||||
| 20 | 7 | __PACKAGE__->cgBuildAccessorsScalar(\@AS); | |||||||||
| 21 | |||||||||||
| 22 | 7 | ▶ | use Net::Frame::Layer::DNS qw(:subs); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | |||||||||||
| 24 | 1 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 25 | shift->SUPER::new( | ||||||||||
| 26 | 1 | mname => 'localhost', | |||||||||
| 27 | rname => 'administrator.localhost', | ||||||||||
| 28 | serial => 0, | ||||||||||
| 29 | refresh => 0, | ||||||||||
| 30 | retry => 0, | ||||||||||
| 31 | expire => 0, | ||||||||||
| 32 | minimum => 0, | ||||||||||
| 33 | @_, | ||||||||||
| 34 | ); | ||||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 0 | ▶ | sub getLength { | ||||||||
|
Subroutine
getLength: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 38 | 0 | my $self = shift; | |||||||||
| 39 | |||||||||||
| 40 | 0 | my $mnamelen = 1; | |||||||||
| 41 | 0 | my $rnamelen = 1; | |||||||||
| 42 | 0 | ▶ | if (length($self->mname) > 0) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 0 | $mnamelen = length($self->mname) + 2 | |||||||||
| 44 | } | ||||||||||
| 45 | 0 | ▶ | if (length($self->rname) > 0) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | 0 | $rnamelen = length($self->rname) + 2 | |||||||||
| 47 | } | ||||||||||
| 48 | 0 | return $mnamelen + $rnamelen + 20 # 4 bytes x 5 values (serial, refresh ...) | |||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | 2 | ▶ | sub pack { | ||||||||
|
Subroutine
pack: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 52 | 2 | my $self = shift; | |||||||||
| 53 | |||||||||||
| 54 | 2 | my $mname = Net::Frame::Layer::DNS::dnsAton($self->mname); | |||||||||
| 55 | 2 | my $rname = Net::Frame::Layer::DNS::dnsAton($self->rname); | |||||||||
| 56 | |||||||||||
| 57 | 2 | ▶ | $self->raw($self->SUPER::pack('H*H*NNNNN', | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | $mname, | ||||||||||
| 59 | $rname, | ||||||||||
| 60 | $self->serial, | ||||||||||
| 61 | $self->refresh, | ||||||||||
| 62 | $self->retry, | ||||||||||
| 63 | $self->expire, | ||||||||||
| 64 | $self->minimum | ||||||||||
| 65 | )) or return; | ||||||||||
| 66 | |||||||||||
| 67 | 2 | return $self->raw; | |||||||||
| 68 | } | ||||||||||
| 69 | |||||||||||
| 70 | 0 | ▶ | sub unpack { | ||||||||
|
Subroutine
unpack: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 71 | 0 | my $self = shift; | |||||||||
| 72 | |||||||||||
| 73 | 0 | my ($mname, $ptr) = dnsNtoa($self->raw); | |||||||||
| 74 | 0 | my ($rname, $ptr1) = dnsNtoa(substr $self->raw, $ptr); | |||||||||
| 75 | |||||||||||
| 76 | 0 | $self->mname($mname); | |||||||||
| 77 | 0 | $self->rname($rname); | |||||||||
| 78 | |||||||||||
| 79 | 0 | ▶ | my ($serial, $refresh, $retry, $expire, $minimum, $payload) = | ||||||||
|
Branch: 1 branch
| |||||||||||
| 80 | $self->SUPER::unpack('NNNNN a*', (substr $self->raw, $ptr+$ptr1)) | ||||||||||
| 81 | or return; | ||||||||||
| 82 | |||||||||||
| 83 | 0 | $self->serial($serial); | |||||||||
| 84 | 0 | $self->refresh($refresh); | |||||||||
| 85 | 0 | $self->retry($retry); | |||||||||
| 86 | 0 | $self->expire($expire); | |||||||||
| 87 | 0 | $self->minimum($minimum); | |||||||||
| 88 | |||||||||||
| 89 | 0 | $self->payload($payload); | |||||||||
| 90 | |||||||||||
| 91 | 0 | return $self; | |||||||||
| 92 | } | ||||||||||
| 93 | |||||||||||
| 94 | 0 | ▶ | sub encapsulate { | ||||||||
|
Subroutine
encapsulate: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 95 | 0 | my $self = shift; | |||||||||
| 96 | |||||||||||
| 97 | 0 | ▶ | return $self->nextLayer if $self->nextLayer; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 98 | |||||||||||
| 99 | 0 | ▶ | if ($self->payload) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 100 | 0 | return 'DNS::RR'; | |||||||||
| 101 | } | ||||||||||
| 102 | |||||||||||
| 103 | 0 | NF_LAYER_NONE; | |||||||||
| 104 | } | ||||||||||
| 105 | |||||||||||
| 106 | 2 | ▶ | sub print { | ||||||||
|
Subroutine
print: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 107 | 2 | my $self = shift; | |||||||||
| 108 | |||||||||||
| 109 | 2 | my $l = $self->layer; | |||||||||
| 110 | 2 | my $buf = sprintf | |||||||||
| 111 | "$l: mname:%s rname:%s\n". | ||||||||||
| 112 | "$l: serial:%d refresh:%d retry:%d\n". | ||||||||||
| 113 | "$l: expire:%d minimum:%d", | ||||||||||
| 114 | $self->mname, $self->rname, | ||||||||||
| 115 | $self->serial, $self->refresh, $self->retry, | ||||||||||
| 116 | $self->expire, $self->minimum; | ||||||||||
| 117 | |||||||||||
| 118 | 2 | return $buf; | |||||||||
| 119 | } | ||||||||||
| 120 | |||||||||||
| 121 | 7 | 1; | |||||||||
| 122 | |||||||||||
| 123 | __END__ | ||||||||||