5 -----------------------
7 .. class:: module_qstate
9 Module state, per query.
11 This class provides these data attributes:
15 (:class:`query_info`) Informations about query being answered. Name, RR type, RR class.
17 .. attribute:: query_flags
19 (uint16) Flags for query. See QF_BIT\_ predefined constants.
21 .. attribute:: is_priming
23 If this is a (stub or root) priming query (with hints).
27 comm_reply contains server replies.
29 .. attribute:: return_msg
31 (:class:`dns_msg`) The reply message, with message for client and calling module (read-only attribute).
32 Note that if you want to create of modify return_msg you should use :class:`DNSMessage`.
34 .. attribute:: return_rcode
36 The rcode, in case of error, instead of a reply message. Determines whether the return_msg contains reply.
40 Region for this query. Cleared when query process finishes.
44 Which module is executing.
46 .. attribute:: ext_state[]
52 Environment for this query.
54 .. attribute:: mesh_info
56 Mesh related information for this query.
64 This class provides these data attributes:
68 The original question in the wireformat format (e.g. \\x03www\\x03nic\\x02cz\\x00 for www.nic.cz)
70 .. attribute:: qname_len
72 Lenght of question name (number of bytes).
74 .. attribute:: qname_list[]
76 The question ``qname`` converted into list of labels (e.g. ['www','nic','cz',''] for www.nic.cz)
78 .. attribute:: qname_str
80 The question ``qname`` converted into string (e.g. www.nic.cz. for www.nic.cz)
84 The class type asked for. See RR_TYPE\_ predefined constants.
86 .. attribute:: qtype_str
88 The ``qtype`` in display presentation format (string) (e.g 'A' for RR_TYPE_A)
92 The question class. See RR_CLASS\_ predefined constants.
94 .. attribute:: qclass_str
96 The ``qclass`` in display presentation format (string).
101 .. class:: reply_info
103 This class provides these data attributes:
107 The flags for the answer, host byte order.
109 .. attribute:: qdcount
111 Number of RRs in the query section.
112 If qdcount is not 0, then it is 1, and the data that appears
113 in the reply is the same as the query_info.
118 TTL of the entire reply (for negative caching).
119 only for use when there are 0 RRsets in this message.
120 if there are RRsets, check those instead.
122 .. attribute:: security
124 The security status from DNSSEC validation of this message. See sec_status\_ predefined constants.
126 .. attribute:: an_numrrsets
128 Number of RRsets in each section.
129 The answer section. Add up the RRs in every RRset to calculate
130 the number of RRs, and the count for the dns packet.
131 The number of RRs in RRsets can change due to RRset updates.
133 .. attribute:: ns_numrrsets
135 Count of authority section RRsets
137 .. attribute:: ar_numrrsets
139 Count of additional section RRsets
141 .. attribute:: rrset_count
143 Number of RRsets: an_numrrsets + ns_numrrsets + ar_numrrsets
145 .. attribute:: rrsets[]
147 (:class:`ub_packed_rrset_key`) List of RR sets in the order in which they appear in the reply message.
148 Number of elements is ancount + nscount + arcount RRsets.
152 (:class:`rrset_ref`) Packed array of ids (see counts) and pointers to packed_rrset_key.
153 The number equals ancount + nscount + arcount RRsets.
154 These are sorted in ascending pointer, the locking order. So
155 this list can be locked (and id, ttl checked), to see if
156 all the data is available and recent enough.
164 Region allocated message reply
166 This class provides these data attributes:
170 (:class:`query_info`) Informations about query.
174 (:class:`reply_info`) This attribute points to the packed reply structure.
178 ----------------------
180 .. class:: packed_rrset_key
182 The identifying information for an RRset.
184 This class provides these data attributes:
188 The domain name. If not empty (for ``id = None``) it is allocated, and
189 contains the wireformat domain name. This dname is not canonicalized.
190 E.g., the dname contains \\x03www\\x03nic\\x02cz\\x00 for www.nic.cz.
192 .. attribute:: dname_len
194 Length of the domain name, including last 0 root octet.
196 .. attribute:: dname_list[]
198 The domain name ``dname`` converted into list of labels (see :attr:`query_info.qname_list`).
200 .. attribute:: dname_str
202 The domain name ``dname`` converted into string (see :attr:`query_info.qname_str`).
210 The rrset type in network format.
212 .. attribute:: type_str
214 The rrset type in display presentation format.
216 .. attribute:: rrset_class
218 The rrset class in network format.
220 .. attribute:: rrset_class_str
222 The rrset class in display presentation format.
225 -------------------------
227 .. class:: ub_packed_rrset_key
229 This structure contains an RRset. A set of resource records that
230 share the same domain name, type and class.
231 Due to memory management and threading, the key structure cannot be
232 deleted, although the data can be. The id can be set to 0 to store and the
233 structure can be recycled with a new id.
235 The :class:`ub_packed_rrset_key` provides these data attributes:
239 (:class:`lruhash_entry`) Entry into hashtable. Note the lock is never destroyed,
240 even when this key is retired to the cache.
241 the data pointer (if not None) points to a :class:`packed_rrset`.
245 The ID of this rrset. unique, based on threadid + sequenceno.
246 ids are not reused, except after flushing the cache.
247 zero is an unused entry, and never a valid id.
248 Check this value after getting entry.lock.
249 The other values in this struct may only be altered after changing
250 the id (which needs a writelock on entry.lock).
254 (:class:`packed_rrset_key`) RR set data.
258 -------------------------
260 .. class:: lruhash_entry
262 The :class:`ub_packed_rrset_key` provides these data attributes:
266 rwlock for access to the contents of the entry. Note that you cannot change hash and key, if so, you have to delete it to change hash or key.
270 (:class:`packed_rrset_data`) entry data stored in wireformat (RRs and RRsigs).
273 -----------------------
275 .. class:: packed_rrset_data
277 Rdata is stored in wireformat. The dname is stored in wireformat.
279 TTLs are stored as absolute values (and could be expired).
281 RRSIGs are stored in the arrays after the regular rrs.
283 You need the packed_rrset_key to know dname, type, class of the
284 resource records in this RRset. (if signed the rrsig gives the type too).
286 The :class:`packed_rrset_data` provides these data attributes:
290 TTL (in seconds like time()) of the RRset.
291 Same for all RRs see rfc2181(5.2).
297 .. attribute:: rrsig_count
299 Number of rrsigs, if 0 no rrsigs.
303 The trustworthiness of the RRset data.
305 .. attribute:: security
307 Security status of the RRset data. See sec_status\_ predefined constants.
309 .. attribute:: rr_len[]
311 Length of every RR's rdata, rr_len[i] is size of rr_data[i].
313 .. attribute:: rr_ttl[]
315 TTL of every rr. rr_ttl[i] ttl of rr i.
317 .. attribute:: rr_data[]
319 Array of RR's rdata (list of strings). The rdata is stored in uncompressed wireformat.
320 The first 16B of rr_data[i] is rdlength in network format.
326 .. class:: DNSMessage
328 Abstract representation of DNS message.
332 This example shows how to create an authoritative answer response
336 msg = DNSMessage(qstate.qinfo.qname_str, RR_TYPE_A, RR_CLASS_IN, PKT_AA)
339 if (qstate.qinfo.qtype == RR_TYPE_A) or (qstate.qinfo.qtype == RR_TYPE_ANY):
340 msg.answer.append("%s 10 IN A 127.0.0.1" % qstate.qinfo.qname_str)
342 #set qstate.return_msg
343 if not msg.set_return_msg(qstate):
344 raise Exception("Can't create response")
346 The :class:`DNSMessage` provides these methods and data attributes:
348 .. method:: __init__(self, rr_name, rr_type, rr_class = RR_CLASS_IN, query_flags = 0, default_ttl = 0)
350 Prepares an answer (DNS packet) from qiven information. Query flags are combination of PKT_xx contants.
352 .. method:: set_return_msg(self, qstate)
354 This method fills qstate return message according to the given informations.
355 It takes lists of RRs in each section of answer, created necessray RRsets in wire format and store the result in :attr:`qstate.return_msg`.
358 .. attribute:: rr_name
362 .. attribute:: rr_type
366 .. attribute:: rr_class
368 RR class of question.
370 .. attribute:: default_ttl
372 Default time-to-live.
374 .. attribute:: query_flags
376 Query flags. See PKT\_ predefined constants.
378 .. attribute:: question[]
380 List of resource records that should appear (in the same order) in question section of answer.
382 .. attribute:: answer[]
384 List of resource records that should appear (in the same order) in answer section of answer.
386 .. attribute:: authority[]
388 List of resource records that should appear (in the same order) in authority section of answer.
390 .. attribute:: additional[]
392 List of resource records that should appear (in the same order) in additional section of answer.
395 -----------------------
397 .. class:: pythonmod_env
399 Global state for the module.
401 This class provides these data attributes:
405 Here you can keep your own data shared across each thread.
409 Python script filename.
411 .. attribute:: qstate
416 -----------------------
418 .. class:: pythonmod_qstate
420 Per query state for the iterator module.
422 This class provides these data attributes:
426 Here you can keep your own private data (each thread has own data object).