| 1 | package Net::DNS::RR::IPSECKEY; | ||||||||||||||||||||||
| 2 | |||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 5 | 2 | our $VERSION = (qw$Id: IPSECKEY.pm 2003 2025-01-21 12:06:06Z willem $)[2]; | |||||||||||||||||||||
| 6 | |||||||||||||||||||||||
| 7 | 2 | ▶ | use base qw(Net::DNS::RR); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 8 | |||||||||||||||||||||||
| 9 | |||||||||||||||||||||||
| 10 | =head1 NAME | ||||||||||||||||||||||
| 11 | |||||||||||||||||||||||
| 12 | Net::DNS::RR::IPSECKEY - DNS IPSECKEY resource record | ||||||||||||||||||||||
| 13 | |||||||||||||||||||||||
| 14 | =cut | ||||||||||||||||||||||
| 15 | |||||||||||||||||||||||
| 16 | 2 | ▶ | use integer; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 17 | |||||||||||||||||||||||
| 18 | 2 | ▶ | use Carp; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 19 | |||||||||||||||||||||||
| 20 | 2 | ▶ | use Net::DNS::DomainName; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 21 | 2 | ▶ | use Net::DNS::RR::A; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 22 | 2 | ▶ | use Net::DNS::RR::AAAA; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 23 | |||||||||||||||||||||||
| 24 | 2 | ▶ | use constant BASE64 => defined eval { require MIME::Base64 }; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 25 | |||||||||||||||||||||||
| 26 | 2 | my %wireformat = ( | |||||||||||||||||||||
| 27 | 0 => 'C3 a0 a*', | ||||||||||||||||||||||
| 28 | 1 => 'C3 a4 a*', | ||||||||||||||||||||||
| 29 | 2 => 'C3 a16 a*', | ||||||||||||||||||||||
| 30 | 3 => 'C3 a* a*', | ||||||||||||||||||||||
| 31 | ); | ||||||||||||||||||||||
| 32 | |||||||||||||||||||||||
| 33 | |||||||||||||||||||||||
| 34 | 30 | ▶ | sub _decode_rdata { ## decode rdata from wire-format octet string | ||||||||||||||||||||
|
Subroutine
_decode_rdata: called CC=5 SCAR=16.1
| |||||||||||||||||||||||
| 35 | 30 | my ( $self, $data, $offset, @opaque ) = @_; | |||||||||||||||||||||
| 36 | |||||||||||||||||||||||
| 37 | 30 | my $limit = $offset + $self->{rdlength}; | |||||||||||||||||||||
| 38 | |||||||||||||||||||||||
| 39 | 30 | @{$self}{qw(precedence gatetype algorithm)} = unpack "\@$offset C3", $$data; | |||||||||||||||||||||
| 40 | 30 | $offset += 3; | |||||||||||||||||||||
| 41 | |||||||||||||||||||||||
| 42 | 30 | my $gatetype = $self->{gatetype}; | |||||||||||||||||||||
| 43 | 30 | ▶ | if ( not $gatetype ) { | ||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||
| 44 | 7 | delete $self->{gateway}; # no gateway | |||||||||||||||||||||
| 45 | |||||||||||||||||||||||
| 46 | } elsif ( $gatetype == 1 ) { | ||||||||||||||||||||||
| 47 | 7 | $self->{gateway} = unpack "\@$offset a4", $$data; | |||||||||||||||||||||
| 48 | 7 | $offset += 4; | |||||||||||||||||||||
| 49 | |||||||||||||||||||||||
| 50 | } elsif ( $gatetype == 2 ) { | ||||||||||||||||||||||
| 51 | 7 | $self->{gateway} = unpack "\@$offset a16", $$data; | |||||||||||||||||||||
| 52 | 7 | $offset += 16; | |||||||||||||||||||||
| 53 | |||||||||||||||||||||||
| 54 | } elsif ( $gatetype == 3 ) { | ||||||||||||||||||||||
| 55 | 8 | my $name; | |||||||||||||||||||||
| 56 | 8 | ( $name, $offset ) = Net::DNS::DomainName->decode( $data, $offset, @opaque ); | |||||||||||||||||||||
| 57 | 8 | $self->{gateway} = $name->encode; | |||||||||||||||||||||
| 58 | |||||||||||||||||||||||
| 59 | } else { | ||||||||||||||||||||||
| 60 | 1 | die "unknown gateway type ($gatetype)"; | |||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||
| 62 | |||||||||||||||||||||||
| 63 | 29 | $self->keybin( substr $$data, $offset, $limit - $offset ); | |||||||||||||||||||||
| 64 | 29 | return; | |||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||
| 66 | |||||||||||||||||||||||
| 67 | |||||||||||||||||||||||
| 68 | 9 | ▶ | sub _encode_rdata { ## encode rdata as wire-format octet string | ||||||||||||||||||||
|
Subroutine
_encode_rdata: called CC=2 SCAR=6.9
| |||||||||||||||||||||||
| 69 | 9 | my $self = shift; | |||||||||||||||||||||
| 70 | |||||||||||||||||||||||
| 71 | 9 | my $gatetype = $self->gatetype; | |||||||||||||||||||||
| 72 | 9 | ▶ | my $gateway = $self->{gateway} || ''; | ||||||||||||||||||||
|
Condition100%2/2
$self->{'gateway'} || ''
MC/DC100%1/1
$self->{'gateway'} || ''
$self->{'gateway'}
Truth table100%2/2
A
A= $self->{'gateway'}
| |||||||||||||||||||||||
| 73 | 9 | my $precedence = $self->precedence; | |||||||||||||||||||||
| 74 | 9 | my $algorithm = $self->algorithm; | |||||||||||||||||||||
| 75 | 9 | my $keybin = $self->keybin; | |||||||||||||||||||||
| 76 | |||||||||||||||||||||||
| 77 | 9 | return pack $wireformat{$gatetype}, $precedence, $gatetype, $algorithm, $gateway, $keybin; | |||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||
| 79 | |||||||||||||||||||||||
| 80 | |||||||||||||||||||||||
| 81 | 23 | ▶ | sub _format_rdata { ## format rdata portion of RR string. | ||||||||||||||||||||
|
Subroutine
_format_rdata: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 82 | 23 | my $self = shift; | |||||||||||||||||||||
| 83 | |||||||||||||||||||||||
| 84 | 23 | return $self->SUPER::_format_rdata() unless BASE64; | |||||||||||||||||||||
| 85 | 23 | my @rdata = map { $self->$_ } qw(precedence gatetype algorithm); | |||||||||||||||||||||
| 86 | 23 | my @base64 = split /\s+/, MIME::Base64::encode( $self->keybin ); | |||||||||||||||||||||
| 87 | 23 | push @rdata, ( $self->gateway, @base64 ); | |||||||||||||||||||||
| 88 | 23 | return @rdata; | |||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||
| 90 | |||||||||||||||||||||||
| 91 | |||||||||||||||||||||||
| 92 | 7 | ▶ | sub _parse_rdata { ## populate RR from rdata in argument list | ||||||||||||||||||||
|
Subroutine
_parse_rdata: called CC=2 SCAR=6.9
| |||||||||||||||||||||||
| 93 | 7 | my ( $self, @argument ) = @_; | |||||||||||||||||||||
| 94 | |||||||||||||||||||||||
| 95 | 7 | foreach (qw(precedence gatetype algorithm gateway)) { $self->$_( shift @argument ) } | |||||||||||||||||||||
| 96 | 7 | $self->key(@argument); | |||||||||||||||||||||
| 97 | 7 | return; | |||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||
| 99 | |||||||||||||||||||||||
| 100 | |||||||||||||||||||||||
| 101 | 42 | ▶ | sub precedence { | ||||||||||||||||||||
|
Subroutine
precedence: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||
| 102 | 42 | my ( $self, @value ) = @_; | |||||||||||||||||||||
| 103 | 42 | for (@value) { $self->{precedence} = 0 + $_ } | |||||||||||||||||||||
| 104 | 42 | ▶ | return $self->{precedence} || 0; | ||||||||||||||||||||
|
Condition100%2/2
$self->{'precedence'} || 0
MC/DC100%1/1
$self->{'precedence'} || 0
$self->{'precedence'}
Truth table100%2/2
A
A= $self->{'precedence'}
| |||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||
| 106 | |||||||||||||||||||||||
| 107 | |||||||||||||||||||||||
| 108 | 71 | ▶ | sub gatetype { | ||||||||||||||||||||
|
Subroutine
gatetype: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 109 | 71 | ▶ | return shift->{gatetype} || 0; | ||||||||||||||||||||
|
Condition100%2/2
+(shift())->{'gatetype'} || 0
MC/DC100%1/1
+(shift())->{'gatetype'} || 0
+(shift())->{'gatetype'}
Truth table100%2/2
A
A= +(shift())->{'gatetype'}
| |||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||
| 111 | |||||||||||||||||||||||
| 112 | |||||||||||||||||||||||
| 113 | 42 | ▶ | sub algorithm { | ||||||||||||||||||||
|
Subroutine
algorithm: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||
| 114 | 42 | my ( $self, @value ) = @_; | |||||||||||||||||||||
| 115 | 42 | for (@value) { $self->{algorithm} = 0 + $_ } | |||||||||||||||||||||
| 116 | 42 | ▶ | return $self->{algorithm} || 0; | ||||||||||||||||||||
|
Condition100%2/2
$self->{'algorithm'} || 0
MC/DC100%1/1
$self->{'algorithm'} || 0
$self->{'algorithm'}
Truth table100%2/2
A
A= $self->{'algorithm'}
| |||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||
| 118 | |||||||||||||||||||||||
| 119 | |||||||||||||||||||||||
| 120 | 42 | ▶ | sub gateway { | ||||||||||||||||||||
|
Subroutine
gateway: called CC=12 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||
| 121 | 42 | my ( $self, @value ) = @_; | |||||||||||||||||||||
| 122 | |||||||||||||||||||||||
| 123 | 42 | for (@value) { | |||||||||||||||||||||
| 124 | 13 | ▶ | /^\.*$/ && do { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 125 | 2 | $self->{gatetype} = 0; | |||||||||||||||||||||
| 126 | 2 | delete $self->{gateway}; # no gateway | |||||||||||||||||||||
| 127 | 2 | last; | |||||||||||||||||||||
| 128 | }; | ||||||||||||||||||||||
| 129 | 11 | ▶ | /:.*:/ && do { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 130 | 2 | $self->{gatetype} = 2; | |||||||||||||||||||||
| 131 | 2 | $self->{gateway} = Net::DNS::RR::AAAA::address( {}, $_ ); | |||||||||||||||||||||
| 132 | 2 | last; | |||||||||||||||||||||
| 133 | }; | ||||||||||||||||||||||
| 134 | 9 | ▶ | /\.\d+$/ && do { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 135 | 2 | $self->{gatetype} = 1; | |||||||||||||||||||||
| 136 | 2 | $self->{gateway} = Net::DNS::RR::A::address( {}, $_ ); | |||||||||||||||||||||
| 137 | 2 | last; | |||||||||||||||||||||
| 138 | }; | ||||||||||||||||||||||
| 139 | 7 | ▶ | /\..+/ && do { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 140 | 6 | $self->{gatetype} = 3; | |||||||||||||||||||||
| 141 | 6 | $self->{gateway} = Net::DNS::DomainName->new($_)->encode; | |||||||||||||||||||||
| 142 | 6 | last; | |||||||||||||||||||||
| 143 | }; | ||||||||||||||||||||||
| 144 | 1 | croak 'unrecognised gateway type'; | |||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||
| 146 | |||||||||||||||||||||||
| 147 | 41 | ▶ | if ( defined wantarray ) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 148 | 29 | my $gateway = $self->{gateway}; | |||||||||||||||||||||
| 149 | 29 | for ( $self->gatetype ) { | |||||||||||||||||||||
| 150 | 29 | ▶ | /^1$/ && return Net::DNS::RR::A::address( {address => $gateway} ); | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 151 | 23 | ▶ | /^2$/ && return Net::DNS::RR::AAAA::address( {address => $gateway} ); | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 152 | 17 | ▶ | /^3$/ && return Net::DNS::DomainName->decode( \$gateway )->name; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||
| 154 | 7 | ▶ | return wantarray ? '.' : undef; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||
| 156 | 12 | return; | |||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||
| 158 | |||||||||||||||||||||||
| 159 | |||||||||||||||||||||||
| 160 | 12 | ▶ | sub key { | ||||||||||||||||||||
|
Subroutine
key: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 161 | 12 | my ( $self, @value ) = @_; | |||||||||||||||||||||
| 162 | 12 | ▶ | return MIME::Base64::encode( $self->keybin(), "" ) unless scalar @value; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 163 | 8 | return $self->keybin( MIME::Base64::decode( join "", @value ) ); | |||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||
| 165 | |||||||||||||||||||||||
| 166 | |||||||||||||||||||||||
| 167 | 75 | ▶ | sub keybin { | ||||||||||||||||||||
|
Subroutine
keybin: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||
| 168 | 75 | my ( $self, @value ) = @_; | |||||||||||||||||||||
| 169 | 75 | for (@value) { $self->{keybin} = $_ } | |||||||||||||||||||||
| 170 | 75 | ▶ | return $self->{keybin} || ""; | ||||||||||||||||||||
|
Condition100%2/2
$self->{'keybin'} || ''
MC/DC100%1/1
$self->{'keybin'} || ''
$self->{'keybin'}
Truth table100%2/2
A
A= $self->{'keybin'}
| |||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||
| 172 | |||||||||||||||||||||||
| 173 | |||||||||||||||||||||||
| 174 | 2 | ▶ | sub pubkey { return &key; } | ||||||||||||||||||||
|
Subroutine
pubkey: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||
| 175 | |||||||||||||||||||||||
| 176 | |||||||||||||||||||||||
| 177 | 0 | ▶ | my $function = sub { ## sort RRs in numerically ascending order. | ||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||
| 178 | 0 | return $Net::DNS::a->{'preference'} <=> $Net::DNS::b->{'preference'}; | |||||||||||||||||||||
| 179 | 2 | }; | |||||||||||||||||||||
| 180 | |||||||||||||||||||||||
| 181 | 2 | __PACKAGE__->set_rrsort_func( 'preference', $function ); | |||||||||||||||||||||
| 182 | |||||||||||||||||||||||
| 183 | 2 | __PACKAGE__->set_rrsort_func( 'default_sort', $function ); | |||||||||||||||||||||
| 184 | |||||||||||||||||||||||
| 185 | |||||||||||||||||||||||
| 186 | 2 | 1; | |||||||||||||||||||||
| 187 | __END__ | ||||||||||||||||||||||