Filename | /usr/local/lib/perl5/site_perl/Net/DNS/RR/AAAA.pm |
Statements | Executed 10 statements in 1.22ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 57µs | 66µs | BEGIN@9 | Net::DNS::RR::AAAA::
1 | 1 | 1 | 34µs | 64µs | BEGIN@10 | Net::DNS::RR::AAAA::
1 | 1 | 1 | 31µs | 36µs | BEGIN@20 | Net::DNS::RR::AAAA::
1 | 1 | 1 | 24µs | 288µs | BEGIN@11 | Net::DNS::RR::AAAA::
0 | 0 | 0 | 0s | 0s | _decode_rdata | Net::DNS::RR::AAAA::
0 | 0 | 0 | 0s | 0s | _encode_rdata | Net::DNS::RR::AAAA::
0 | 0 | 0 | 0s | 0s | _format_rdata | Net::DNS::RR::AAAA::
0 | 0 | 0 | 0s | 0s | _parse_rdata | Net::DNS::RR::AAAA::
0 | 0 | 0 | 0s | 0s | address | Net::DNS::RR::AAAA::
0 | 0 | 0 | 0s | 0s | address_long | Net::DNS::RR::AAAA::
0 | 0 | 0 | 0s | 0s | address_short | Net::DNS::RR::AAAA::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Net::DNS::RR::AAAA; | ||||
2 | |||||
3 | # | ||||
4 | # $Id: AAAA.pm 1597 2017-09-22 08:04:02Z willem $ | ||||
5 | # | ||||
6 | 1 | 2µs | our $VERSION = (qw$LastChangedRevision: 1597 $)[1]; | ||
7 | |||||
8 | |||||
9 | 2 | 74µs | 2 | 74µs | # spent 66µs (57+8) within Net::DNS::RR::AAAA::BEGIN@9 which was called:
# once (57µs+8µs) by Net::DNS::RR::OPT::CLIENT_SUBNET::BEGIN@241 at line 9 # spent 66µs making 1 call to Net::DNS::RR::AAAA::BEGIN@9
# spent 8µs making 1 call to strict::import |
10 | 2 | 72µs | 2 | 94µs | # spent 64µs (34+30) within Net::DNS::RR::AAAA::BEGIN@10 which was called:
# once (34µs+30µs) by Net::DNS::RR::OPT::CLIENT_SUBNET::BEGIN@241 at line 10 # spent 64µs making 1 call to Net::DNS::RR::AAAA::BEGIN@10
# spent 30µs making 1 call to warnings::import |
11 | 2 | 81µs | 2 | 552µs | # spent 288µs (24+264) within Net::DNS::RR::AAAA::BEGIN@11 which was called:
# once (24µs+264µs) by Net::DNS::RR::OPT::CLIENT_SUBNET::BEGIN@241 at line 11 # spent 288µs making 1 call to Net::DNS::RR::AAAA::BEGIN@11
# spent 264µs making 1 call to base::import |
12 | |||||
13 | =head1 NAME | ||||
14 | |||||
15 | Net::DNS::RR::AAAA - DNS AAAA resource record | ||||
16 | |||||
17 | =cut | ||||
18 | |||||
19 | |||||
20 | 2 | 978µs | 2 | 41µs | # spent 36µs (31+5) within Net::DNS::RR::AAAA::BEGIN@20 which was called:
# once (31µs+5µs) by Net::DNS::RR::OPT::CLIENT_SUBNET::BEGIN@241 at line 20 # spent 36µs making 1 call to Net::DNS::RR::AAAA::BEGIN@20
# spent 5µs making 1 call to integer::import |
21 | |||||
22 | |||||
23 | sub _decode_rdata { ## decode rdata from wire-format octet string | ||||
24 | my $self = shift; | ||||
25 | my ( $data, $offset ) = @_; | ||||
26 | |||||
27 | $self->{address} = unpack "\@$offset a16", $$data; | ||||
28 | } | ||||
29 | |||||
30 | |||||
31 | sub _encode_rdata { ## encode rdata as wire-format octet string | ||||
32 | my $self = shift; | ||||
33 | |||||
34 | pack 'a16', $self->{address}; | ||||
35 | } | ||||
36 | |||||
37 | |||||
38 | sub _format_rdata { ## format rdata portion of RR string. | ||||
39 | my $self = shift; | ||||
40 | |||||
41 | $self->address_short; | ||||
42 | } | ||||
43 | |||||
44 | |||||
45 | sub _parse_rdata { ## populate RR from rdata in argument list | ||||
46 | my $self = shift; | ||||
47 | |||||
48 | $self->address(shift); | ||||
49 | } | ||||
50 | |||||
51 | |||||
52 | sub address_long { | ||||
53 | my $addr = pack 'a*@16', grep defined, shift->{address}; | ||||
54 | sprintf '%x:%x:%x:%x:%x:%x:%x:%x', unpack 'n8', $addr; | ||||
55 | } | ||||
56 | |||||
57 | |||||
58 | sub address_short { | ||||
59 | my $addr = pack 'a*@16', grep defined, shift->{address}; | ||||
60 | for ( sprintf ':%x:%x:%x:%x:%x:%x:%x:%x:', unpack 'n8', $addr ) { | ||||
61 | s/(:0[:0]+:)(?!.+:0\1)/::/; # squash longest zero sequence | ||||
62 | s/^:// unless /^::/; # prune LH : | ||||
63 | s/:$// unless /::$/; # prune RH : | ||||
64 | return $_; | ||||
65 | } | ||||
66 | } | ||||
67 | |||||
68 | |||||
69 | sub address { | ||||
70 | my $self = shift; | ||||
71 | |||||
72 | return address_long($self) unless scalar @_; | ||||
73 | |||||
74 | my $addr = shift; | ||||
75 | my @parse = split /:/, "0$addr"; | ||||
76 | |||||
77 | if ( (@parse)[$#parse] =~ /\./ ) { # embedded IPv4 | ||||
78 | my @ip4 = split /\./, pop(@parse); | ||||
79 | my $rhs = pop(@ip4); | ||||
80 | my @ip6 = map { /./ ? hex($_) : (0) x ( 7 - @parse ) } @parse; | ||||
81 | return $self->{address} = pack 'n6 C4', @ip6, @ip4, (0) x ( 3 - @ip4 ), $rhs; | ||||
82 | } | ||||
83 | |||||
84 | # Note: pack() masks overlarge values, mostly without warning. | ||||
85 | my @expand = map { /./ ? hex($_) : (0) x ( 9 - @parse ) } @parse; | ||||
86 | $self->{address} = pack 'n8', @expand; | ||||
87 | } | ||||
88 | |||||
89 | |||||
90 | 1 | 8µs | 1; | ||
91 | __END__ |