| 1 | # | ||||||||||
| 2 | # $Id: CNAME.pm 49 2009-05-31 13:15:34Z VinsWorldcom $ | ||||||||||
| 3 | # | ||||||||||
| 4 | package Net::Frame::Layer::DNS::RR::CNAME; | ||||||||||
| 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 | cname | ||||||||||
| 12 | ); | ||||||||||
| 13 | 7 | __PACKAGE__->cgBuildIndices; | |||||||||
| 14 | 7 | __PACKAGE__->cgBuildAccessorsScalar(\@AS); | |||||||||
| 15 | |||||||||||
| 16 | 7 | ▶ | use Net::Frame::Layer::DNS qw(:subs); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | |||||||||||
| 18 | 1 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 19 | shift->SUPER::new( | ||||||||||
| 20 | 1 | cname => 'localhost', | |||||||||
| 21 | @_, | ||||||||||
| 22 | ); | ||||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 0 | ▶ | sub getLength { | ||||||||
|
Subroutine
getLength: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 26 | 0 | my $self = shift; | |||||||||
| 27 | # Add 2 for first encoding length and trailing '\0' (see dnsAton()) | ||||||||||
| 28 | 0 | return length($self->cname) + 2 | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 2 | ▶ | sub pack { | ||||||||
|
Subroutine
pack: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 32 | 2 | my $self = shift; | |||||||||
| 33 | |||||||||||
| 34 | 2 | my $name = dnsAton($self->cname); | |||||||||
| 35 | |||||||||||
| 36 | 2 | ▶ | $self->raw($self->SUPER::pack('H*', | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | $name | ||||||||||
| 38 | )) or return; | ||||||||||
| 39 | |||||||||||
| 40 | 2 | return $self->raw; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 0 | ▶ | sub unpack { | ||||||||
|
Subroutine
unpack: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 44 | 0 | my $self = shift; | |||||||||
| 45 | |||||||||||
| 46 | 0 | my ($name, $ptr) = dnsNtoa($self->raw); | |||||||||
| 47 | |||||||||||
| 48 | 0 | $self->cname($name); | |||||||||
| 49 | |||||||||||
| 50 | 0 | $self->payload(substr $self->raw, $ptr); | |||||||||
| 51 | |||||||||||
| 52 | 0 | return $self; | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 0 | ▶ | sub encapsulate { | ||||||||
|
Subroutine
encapsulate: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 56 | 0 | my $self = shift; | |||||||||
| 57 | |||||||||||
| 58 | 0 | ▶ | return $self->nextLayer if $self->nextLayer; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 59 | |||||||||||
| 60 | 0 | ▶ | if ($self->payload) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 61 | 0 | return 'DNS::RR'; | |||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | 0 | NF_LAYER_NONE; | |||||||||
| 65 | } | ||||||||||
| 66 | |||||||||||
| 67 | 2 | ▶ | sub print { | ||||||||
|
Subroutine
print: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 68 | 2 | my $self = shift; | |||||||||
| 69 | |||||||||||
| 70 | 2 | my $l = $self->layer; | |||||||||
| 71 | 2 | my $buf = sprintf | |||||||||
| 72 | "$l: cname:%s", | ||||||||||
| 73 | $self->cname; | ||||||||||
| 74 | |||||||||||
| 75 | 2 | return $buf; | |||||||||
| 76 | } | ||||||||||
| 77 | |||||||||||
| 78 | 7 | 1; | |||||||||
| 79 | |||||||||||
| 80 | __END__ | ||||||||||