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