Subject: | Feature request: allow tweak to header fields |
Date: | Wed, 31 Jul 2013 11:42:35 +0200 (CEST) |
To: | bug-Net-DNS [...] rt.cpan.org |
From: | Havard Eidnes <he [...] uninett.no> |
Hi,
this may be somewhat related to RT#37104, "Feature Request -
export and document DNS::Resolver::make_query_packet".
I just came back from fixing fpdns from
https://github.com/kirei/fpdns
to work with Net::DNS 0.69. This required one change to fpdns
(NS_NOTIFY_OP -> NOTIFY), but also triggered the need for getting
rid of these warnings (and lack of feature):
header->qdcount attribute is read-only at /usr/pkg/lib/perl5/vendor_perl/5.16.0/Net/DNS/Fingerprint.pm line 2174.
header->ancount attribute is read-only at /usr/pkg/lib/perl5/vendor_perl/5.16.0/Net/DNS/Fingerprint.pm line 2175.
header->nscount attribute is read-only at /usr/pkg/lib/perl5/vendor_perl/5.16.0/Net/DNS/Fingerprint.pm line 2176.
header->arcount attribute is read-only at /usr/pkg/lib/perl5/vendor_perl/5.16.0/Net/DNS/Fingerprint.pm line 2177.
This comes from fpdns's function fp2header:
sub fp2header {
my @list = split(/,/, shift);
my $header = shift;
$header->qr(shift @list);
$header->opcode(shift @list);
$header->aa(shift @list);
$header->tc(shift @list);
$header->rd(shift @list);
$header->ra(shift @list);
$header->ad(shift @list);
$header->cd(shift @list);
$header->rcode(shift @list);
$header->qdcount(shift @list);
$header->ancount(shift @list);
$header->nscount(shift @list);
$header->arcount(shift @list);
}
specifically the 4 last lines. I beleive the attached diff adds
this feature to Net::DNS (actual testing has been skimpy, though,
so I may have made a mistake...), but at least gets rid of the
warnings.
Regards,
- HÃ¥vard
--- lib/Net/DNS/Header.pm.orig 2012-12-05 12:03:11.000000000 +0000
+++ lib/Net/DNS/Header.pm
@@ -334,8 +334,9 @@ sub cd {
=head2 qdcount, zocount
print "# of question records: ", $packet->header->qdcount, "\n";
+ $packet->header->qdcount($n);
-Gets the number of records in the question section of the packet.
+Gets or sets the number of records in the question section of the packet.
In dynamic update packets, this field is known as C<zocount> and refers
to the number of RRs in the zone section.
@@ -347,15 +348,16 @@ sub qdcount {
my $self = shift;
my $xpkt = $self->{xbody};
return $self->{count}[0] || scalar @{$xpkt->{question}} unless @_;
- carp 'header->qdcount attribute is read-only' unless $warned;
+ $self->{count}[0] = @_;
}
=head2 ancount, prcount
print "# of answer records: ", $packet->header->ancount, "\n";
+ $packet->header->ancount($n);
-Gets the number of records in the answer section of the packet.
+Gets or sets the number of records in the answer section of the packet.
In dynamic update packets, this field is known as C<prcount> and refers
to the number of RRs in the prerequisite section.
@@ -365,15 +367,16 @@ sub ancount {
my $self = shift;
my $xpkt = $self->{xbody};
return $self->{count}[1] || scalar @{$xpkt->{answer}} unless @_;
- carp 'header->ancount attribute is read-only' unless $warned;
+ $self->{count}[1] = @_;
}
=head2 nscount, upcount
print "# of authority records: ", $packet->header->nscount, "\n";
+ $packet->header->nscount($n);
-Gets the number of records in the authority section of the packet.
+Gets or sets the number of records in the authority section of the packet.
In dynamic update packets, this field is known as C<upcount> and refers
to the number of RRs in the update section.
@@ -383,15 +386,16 @@ sub nscount {
my $self = shift;
my $xpkt = $self->{xbody};
return $self->{count}[2] || scalar @{$xpkt->{authority}} unless @_;
- carp 'header->nscount attribute is read-only' unless $warned;
+ $self->{count}[2] = @_;
}
=head2 arcount, adcount
print "# of additional records: ", $packet->header->arcount, "\n";
+ $packet->header->arcount($n);
-Gets the number of records in the additional section of the packet.
+Gets or sets the number of records in the additional section of the packet.
In dynamic update packets, this field is known as C<adcount>.
=cut
@@ -400,7 +404,7 @@ sub arcount {
my $self = shift;
my $xpkt = $self->{xbody};
return $self->{count}[3] || scalar @{$xpkt->{additional}} unless @_;
- carp 'header->arcount attribute is read-only' unless $warned;
+ $self->{count}[3] = @_;
}
sub zocount { &qdcount; }