File Coverage

blib/lib/Net/DNS/RR/RP.pm
Criterion Covered Total %
statement 42 42 100.0
branch 4 4 100.0
condition n/a
subroutine 12 12 100.0
pod 2 2 100.0
total 60 60 100.0


line stmt bran cond sub pod time code
1             package Net::DNS::RR::RP;
2              
3 1     1   7 use strict;
  1         2  
  1         29  
4 1     1   4 use warnings;
  1         2  
  1         56  
5             our $VERSION = (qw$Id: RP.pm 1898 2023-02-15 14:27:22Z willem $)[2];
6              
7 1     1   5 use base qw(Net::DNS::RR);
  1         5  
  1         104  
8              
9              
10             =head1 NAME
11              
12             Net::DNS::RR::RP - DNS RP resource record
13              
14             =cut
15              
16 1     1   6 use integer;
  1         2  
  1         13  
17              
18 1     1   47 use Net::DNS::DomainName;
  1         1  
  1         39  
19 1     1   461 use Net::DNS::Mailbox;
  1         2  
  1         382  
20              
21              
22             sub _decode_rdata { ## decode rdata from wire-format octet string
23 1     1   1 my ( $self, $data, $offset ) = @_;
24              
25 1         9 ( $self->{mbox}, $offset ) = Net::DNS::Mailbox2535->decode( $data, $offset );
26 1         5 $self->{txtdname} = Net::DNS::DomainName2535->decode( $data, $offset );
27 1         2 return;
28             }
29              
30              
31             sub _encode_rdata { ## encode rdata as wire-format octet string
32 5     5   11 my ( $self, $offset, @opaque ) = @_;
33              
34 5         8 my $txtdname = $self->{txtdname};
35 5         13 my $rdata = $self->{mbox}->encode( $offset, @opaque );
36 5         15 $rdata .= $txtdname->encode( $offset + length($rdata), @opaque );
37 5         17 return $rdata;
38             }
39              
40              
41             sub _format_rdata { ## format rdata portion of RR string.
42 2     2   3 my $self = shift;
43              
44 2         34 my @rdata = ( $self->{mbox}->string, $self->{txtdname}->string );
45 2         13 return @rdata;
46             }
47              
48              
49             sub _parse_rdata { ## populate RR from rdata in argument list
50 1     1   3 my ( $self, @argument ) = @_;
51              
52 1         2 for (qw(mbox txtdname)) { $self->$_( shift @argument ) }
  2         6  
53 1         5 return;
54             }
55              
56              
57             sub mbox {
58 4     4 1 15 my ( $self, @value ) = @_;
59 4         6 for (@value) { $self->{mbox} = Net::DNS::Mailbox2535->new($_) }
  2         7  
60 4 100       21 return $self->{mbox} ? $self->{mbox}->address : undef;
61             }
62              
63              
64             sub txtdname {
65 4     4 1 866 my ( $self, @value ) = @_;
66 4         8 for (@value) { $self->{txtdname} = Net::DNS::DomainName2535->new($_) }
  2         22  
67 4 100       21 return $self->{txtdname} ? $self->{txtdname}->name : undef;
68             }
69              
70              
71             1;
72             __END__