← Index
NYTProf Performance Profile   « line view »
For /usr/local/libexec/sympa/task_manager-debug.pl
  Run on Tue Jun 1 22:32:51 2021
Reported on Tue Jun 1 22:35:13 2021

Filename/usr/local/lib/perl5/site_perl/Net/DNS/Update.pm
StatementsExecuted 0 statements in 0s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
0000s0sNet::DNS::Update::::BEGIN@3Net::DNS::Update::BEGIN@3
0000s0sNet::DNS::Update::::BEGIN@32Net::DNS::Update::BEGIN@32
0000s0sNet::DNS::Update::::BEGIN@33Net::DNS::Update::BEGIN@33
0000s0sNet::DNS::Update::::BEGIN@35Net::DNS::Update::BEGIN@35
0000s0sNet::DNS::Update::::BEGIN@37Net::DNS::Update::BEGIN@37
0000s0sNet::DNS::Update::::BEGIN@4Net::DNS::Update::BEGIN@4
0000s0sNet::DNS::Update::::__ANON__Net::DNS::Update::__ANON__ (xsub)
0000s0sNet::DNS::Update::::newNet::DNS::Update::new
0000s0sNet::DNS::Update::::pushNet::DNS::Update::push
0000s0sNet::DNS::Update::::unique_pushNet::DNS::Update::unique_push
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Net::DNS::Update;
2
3use strict;
4use warnings;
5
6our $VERSION = (qw$Id: Update.pm 1814 2020-10-14 21:49:16Z willem $)[2];
7
8
9=head1 NAME
10
11Net::DNS::Update - DNS dynamic update packet
12
13=head1 SYNOPSIS
14
15 use Net::DNS;
16
17 $update = Net::DNS::Update->new( 'example.com', 'IN' );
18
19 $update->push( prereq => nxrrset('host.example.com. AAAA') );
20 $update->push( update => rr_add('host.example.com. 86400 AAAA 2001::DB8::F00') );
21
22=head1 DESCRIPTION
23
24Net::DNS::Update is a subclass of Net::DNS::Packet, to be used for
25making DNS dynamic updates.
26
27Programmers should refer to RFC2136 for dynamic update semantics.
28
29=cut
30
31
32use integer;
33use Carp;
34
35use base qw(Net::DNS::Packet);
36
37use Net::DNS::Resolver;
38
39
40=head1 METHODS
41
42=head2 new
43
44 $update = Net::DNS::Update->new;
45 $update = Net::DNS::Update->new( 'example.com' );
46 $update = Net::DNS::Update->new( 'example.com', 'IN' );
47
48Returns a Net::DNS::Update object suitable for performing a DNS
49dynamic update. Specifically, it creates a packet with the header
50opcode set to UPDATE and the zone record type to SOA (per RFC 2136,
51Section 2.3).
52
53Programs must use the push() method to add RRs to the prerequisite
54and update sections before performing the update.
55
56Arguments are the zone name and the class. The zone and class may
57be undefined or omitted and default to the default domain from the
58resolver configuration and IN respectively.
59
60=cut
61
62sub new {
63 my ( $class, $zone, @rrclass ) = @_;
64
65 my ($domain) = grep { defined && length } ( $zone, Net::DNS::Resolver->searchlist );
66
67 my $self = __PACKAGE__->SUPER::new( $domain, 'SOA', @rrclass );
68
69 my $header = $self->header;
70 $header->opcode('UPDATE');
71 $header->qr(0);
72 $header->rd(0);
73
74 return $self;
75}
76
77
78=head2 push
79
80 $ancount = $update->push( prereq => $rr );
81 $nscount = $update->push( update => $rr );
82 $arcount = $update->push( additional => $rr );
83
84 $nscount = $update->push( update => $rr1, $rr2, $rr3 );
85 $nscount = $update->push( update => @rr );
86
87Adds RRs to the specified section of the update packet.
88
89Returns the number of resource records in the specified section.
90
91Section names may be abbreviated to the first three characters.
92
93=cut
94
95sub push {
96 my $self = shift;
97 my $list = $self->_section(shift);
98 my @arg = grep { ref($_) } @_;
99
100 my ($zone) = $self->zone;
101 my $zclass = $zone->zclass;
102 my @rr = grep { $_->class( $_->class =~ /ANY|NONE/ ? () : $zclass ) } @arg;
103
104 return CORE::push( @$list, @rr );
105}
106
107
108=head2 unique_push
109
110 $ancount = $update->unique_push( prereq => $rr );
111 $nscount = $update->unique_push( update => $rr );
112 $arcount = $update->unique_push( additional => $rr );
113
114 $nscount = $update->unique_push( update => $rr1, $rr2, $rr3 );
115 $nscount = $update->unique_push( update => @rr );
116
117Adds RRs to the specified section of the update packet provided
118that the RRs are not already present in the same section.
119
120Returns the number of resource records in the specified section.
121
122Section names may be abbreviated to the first three characters.
123
124=cut
125
126sub unique_push {
127 my $self = shift;
128 my $list = $self->_section(shift);
129 my @arg = grep { ref($_) } @_;
130
131 my ($zone) = $self->zone;
132 my $zclass = $zone->zclass;
133 my @rr = grep { $_->class( $_->class =~ /ANY|NONE/ ? () : $zclass ) } @arg;
134
135 my %unique = map { ( bless( {%$_, ttl => 0}, ref $_ )->canonical => $_ ) } ( @rr, @$list );
136
137 return scalar( @$list = values %unique );
138}
139
140
1411;
142
143__END__