1Net::DNS::Header(3)   User Contributed Perl Documentation  Net::DNS::Header(3)
2
3
4

NAME

6       Net::DNS::Header - DNS packet header
7

SYNOPSIS

9           use Net::DNS;
10
11           $packet = new Net::DNS::Packet;
12           $header = $packet->header;
13

DESCRIPTION

15       "Net::DNS::Header" represents the header portion of a DNS packet.
16

METHODS

18   $packet->header
19           $packet = new Net::DNS::Packet;
20           $header = $packet->header;
21
22       Net::DNS::Header objects emanate from the Net::DNS::Packet header()
23       method, and contain an opaque reference to the parent Packet object.
24
25       Header objects may be assigned to suitably scoped lexical variables.
26       They should never be stored in global variables or persistent data
27       structures.
28
29   string
30           print $packet->header->string;
31
32       Returns a string representation of the packet header.
33
34   print
35           $packet->header->print;
36
37       Prints the string representation of the packet header.
38
39   id
40           print "query id = ", $packet->header->id, "\n";
41           $packet->header->id(1234);
42
43       Gets or sets the query identification number.
44
45       A random value is assigned if the argument value is undefined.
46
47   opcode
48           print "query opcode = ", $packet->header->opcode, "\n";
49           $packet->header->opcode("UPDATE");
50
51       Gets or sets the query opcode (the purpose of the query).
52
53   rcode
54           print "query response code = ", $packet->header->rcode, "\n";
55           $packet->header->rcode("SERVFAIL");
56
57       Gets or sets the query response code (the status of the query).
58
59   qr
60           print "query response flag = ", $packet->header->qr, "\n";
61           $packet->header->qr(0);
62
63       Gets or sets the query response flag.
64
65   aa
66           print "response is ", $packet->header->aa ? "" : "non-", "authoritative\n";
67           $packet->header->aa(0);
68
69       Gets or sets the authoritative answer flag.
70
71   tc
72           print "packet is ", $packet->header->tc ? "" : "not ", "truncated\n";
73           $packet->header->tc(0);
74
75       Gets or sets the truncated packet flag.
76
77   rd
78           print "recursion was ", $packet->header->rd ? "" : "not ", "desired\n";
79           $packet->header->rd(0);
80
81       Gets or sets the recursion desired flag.
82
83   ra
84           print "recursion is ", $packet->header->ra ? "" : "not ", "available\n";
85           $packet->header->ra(0);
86
87       Gets or sets the recursion available flag.
88
89   z
90       Unassigned bit, should always be zero.
91
92   ad
93           print "The response has ", $packet->header->ad ? "" : "not", "been verified\n";
94
95       Relevant in DNSSEC context.
96
97       (The AD bit is only set on a response where signatures have been
98       cryptographically verified or the server is authoritative for the data
99       and is allowed to set the bit by policy.)
100
101   cd
102           print "checking was ", $packet->header->cd ? "not" : "", "desired\n";
103           $packet->header->cd(0);
104
105       Gets or sets the checking disabled flag.
106
107   qdcount, zocount
108           print "# of question records: ", $packet->header->qdcount, "\n";
109
110       Returns the number of records in the question section of the packet.
111       In dynamic update packets, this field is known as "zocount" and refers
112       to the number of RRs in the zone section.
113
114   ancount, prcount
115           print "# of answer records: ", $packet->header->ancount, "\n";
116
117       Returns the number of records in the answer section of the packet which
118       may, in the case of corrupt packets, differ from the actual number of
119       records.  In dynamic update packets, this field is known as "prcount"
120       and refers to the number of RRs in the prerequisite section.
121
122   nscount, upcount
123           print "# of authority records: ", $packet->header->nscount, "\n";
124
125       Returns the number of records in the authority section of the packet
126       which may, in the case of corrupt packets, differ from the actual
127       number of records.  In dynamic update packets, this field is known as
128       "upcount" and refers to the number of RRs in the update section.
129
130   arcount, adcount
131           print "# of additional records: ", $packet->header->arcount, "\n";
132
133       Returns the number of records in the additional section of the packet
134       which may, in the case of corrupt packets, differ from the actual
135       number of records.  In dynamic update packets, this field is known as
136       "adcount".
137

EDNS Protocol Extensions

139   do
140           print "DNSSEC_OK flag was ", $packet->header->do ? "not" : "", "set\n";
141           $packet->header->do(1);
142
143       Gets or sets the EDNS DNSSEC OK flag.
144
145   Extended rcode
146       EDNS extended rcodes are handled transparently by
147       $packet->header->rcode().
148
149   UDP packet size
150           $udp_max = $packet->header->size;
151           $udp_max = $packet->edns->size;
152
153       EDNS offers a mechanism to advertise the maximum UDP packet size which
154       can be assembled by the local network stack.
155
156       UDP size advertisement can be viewed as either a header extension or an
157       EDNS feature.  Endless debate is avoided by supporting both views.
158
159   edns
160           $header  = $packet->header;
161           $version = $header->edns->version;
162           @options = $header->edns->options;
163           $option  = $header->edns->option(n);
164           $udp_max = $packet->edns->size;
165
166       Auxiliary function which provides access to the EDNS protocol extension
167       OPT RR.
168
170       Copyright (c)1997 Michael Fuhr.
171
172       Portions Copyright (c)2002,2003 Chris Reinhardt.
173
174       Portions Copyright (c)2012 Dick Franks.
175
176       All rights reserved.
177

LICENSE

179       Permission to use, copy, modify, and distribute this software and its
180       documentation for any purpose and without fee is hereby granted,
181       provided that the above copyright notice appear in all copies and that
182       both that copyright notice and this permission notice appear in
183       supporting documentation, and that the name of the author not be used
184       in advertising or publicity pertaining to distribution of the software
185       without specific prior written permission.
186
187       THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
188       OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
189       MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
190       IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
191       CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
192       TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
193       SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
194

SEE ALSO

196       perl, Net::DNS, Net::DNS::Packet, Net::DNS::RR::OPT RFC 1035 Section
197       4.1.1
198
199
200
201perl v5.30.0                      2019-07-26               Net::DNS::Header(3)
Impressum