1Net::DNS::Header(3) User Contributed Perl Documentation Net::DNS::Header(3)
2
3
4
6 Net::DNS::Header - DNS packet header
7
9 use Net::DNS;
10
11 $packet = new Net::DNS::Packet;
12 $header = $packet->header;
13
15 "Net::DNS::Header" represents the header portion of a DNS packet.
16
18 new
19 $header = new Net::DNS::Header($packet);
20
21 Constructor method which returns a "Net::DNS::Header" object
22 representing the header section of the specified packet.
23
24 string
25 print $packet->header->string;
26
27 Returns a string representation of the packet header.
28
29 id
30 print "query id = ", $packet->header->id, "\n";
31 $packet->header->id(1234);
32
33 Gets or sets the query identification number.
34
35 A random value is assigned if the argument value is undefined.
36
37 opcode
38 print "query opcode = ", $packet->header->opcode, "\n";
39 $packet->header->opcode("UPDATE");
40
41 Gets or sets the query opcode (the purpose of the query).
42
43 rcode
44 print "query response code = ", $packet->header->rcode, "\n";
45 $packet->header->rcode("SERVFAIL");
46
47 Gets or sets the query response code (the status of the query).
48
49 qr
50 print "query response flag = ", $packet->header->qr, "\n";
51 $packet->header->qr(0);
52
53 Gets or sets the query response flag.
54
55 aa
56 print "answer is ", $packet->header->aa ? "" : "non-", "authoritative\n";
57 $packet->header->aa(0);
58
59 Gets or sets the authoritative answer flag.
60
61 tc
62 print "packet is ", $packet->header->tc ? "" : "not ", "truncated\n";
63 $packet->header->tc(0);
64
65 Gets or sets the truncated packet flag.
66
67 rd
68 print "recursion was ", $packet->header->rd ? "" : "not ", "desired\n";
69 $packet->header->rd(0);
70
71 Gets or sets the recursion desired flag.
72
73 ra
74 print "recursion is ", $packet->header->ra ? "" : "not ", "available\n";
75 $packet->header->ra(0);
76
77 Gets or sets the recursion available flag.
78
79 z
80 Unassigned bit, should always be zero.
81
82 ad
83 print "The result has ", $packet->header->ad ? "" : "not", "been verified\n";
84
85 Relevant in DNSSEC context.
86
87 (The AD bit is only set on answers where signatures have been
88 cryptographically verified or the server is authoritative for the data
89 and is allowed to set the bit by policy.)
90
91 cd
92 print "checking was ", $packet->header->cd ? "not" : "", "desired\n";
93 $packet->header->cd(0);
94
95 Gets or sets the checking disabled flag.
96
97 qdcount, zocount
98 print "# of question records: ", $packet->header->qdcount, "\n";
99
100 Returns the number of records in the question section of the packet.
101 In dynamic update packets, this field is known as "zocount" and refers
102 to the number of RRs in the zone section.
103
104 ancount, prcount
105 print "# of answer records: ", $packet->header->ancount, "\n";
106
107 Returns the number of records in the answer section of the packet which
108 may, in the case of corrupt packets, differ from the actual number of
109 records. In dynamic update packets, this field is known as "prcount"
110 and refers to the number of RRs in the prerequisite section.
111
112 nscount, upcount
113 print "# of authority records: ", $packet->header->nscount, "\n";
114
115 Returns the number of records in the authority section of the packet
116 which may, in the case of corrupt packets, differ from the actual
117 number of records. In dynamic update packets, this field is known as
118 "upcount" and refers to the number of RRs in the update section.
119
120 arcount, adcount
121 print "# of additional records: ", $packet->header->arcount, "\n";
122
123 Returns the number of records in the additional section of the packet
124 which may, in the case of corrupt packets, differ from the actual
125 number of records. In dynamic update packets, this field is known as
126 "adcount".
127
129 do
130 print "DNSSEC_OK flag was ", $packet->header->do ? "not" : "", "set\n";
131 $packet->header->do(1);
132
133 Gets or sets the EDNS DNSSEC OK flag.
134
135 Extended rcode
136 EDNS extended rcodes are handled transparently by
137 $packet->header->rcode().
138
139 UDP packet size
140 $udp_max = $packet->edns->size;
141 $udp_max = $packet->header->size;
142
143 EDNS offers a mechanism to advertise the maximum UDP packet size which
144 can be assembled by the local network stack.
145
146 UDP size advertisement can be viewed as either a header extension or an
147 EDNS feature. Endless debate is avoided by supporting both views.
148
149 edns
150 $header = $packet->header;
151 $version = $header->edns->version;
152 @options = $header->edns->options;
153 $option = $header->edns->option(n);
154 $udp_max = $packet->edns->size;
155
156 Auxiliary function which provides access to the EDNS protocol extension
157 OPT RR.
158
160 Copyright (c)1997-2002 Michael Fuhr.
161
162 Portions Copyright (c)2002-2004 Chris Reinhardt.
163
164 Portions Copyright (c)2012 Dick Franks.
165
166 All rights reserved.
167
168 This program is free software; you may redistribute it and/or modify it
169 under the same terms as Perl itself.
170
172 perl, Net::DNS, Net::DNS::Packet, Net::DNS::RR::OPT RFC 1035 Section
173 4.1.1
174
175
176
177perl v5.16.3 2016-11-05 Net::DNS::Header(3)