File: //usr/local/ssl/lib/python2.4/site-packages/dns/renderer.pyc
mò
w§Qc @ sn d Z d k Z d k Z d k Z d k Z d k Z d k Z d Z d Z d Z
d Z d e f d „ ƒ YZ
d S( s* Help for building DNS wire format messagesNi i i i t Rendererc B s‰ t Z d Z e d d e d „ Z d „ Z d „ Z e i i d „ Z
d „ Z d „ Z e d „ Z
e i i d
„ Z d „ Z d „ Z RS(
st Helper class for building DNS wire-format messages.
Most applications can use the higher-level L{dns.message.Message}
class and its to_wire() method to generate wire-format messages.
This class is for those applications which need finer control
over the generation of messages.
Typical use::
r = dns.renderer.Renderer(id=1, flags=0x80, max_size=512)
r.add_question(qname, qtype, qclass)
r.add_rrset(dns.renderer.ANSWER, rrset_1)
r.add_rrset(dns.renderer.ANSWER, rrset_2)
r.add_rrset(dns.renderer.AUTHORITY, ns_rrset)
r.add_edns(0, 0, 4096)
r.add_rrset(dns.renderer.ADDTIONAL, ad_rrset_1)
r.add_rrset(dns.renderer.ADDTIONAL, ad_rrset_2)
r.write_header()
r.add_tsig(keyname, secret, 300, 1, 0, '', request_mac)
wire = r.get_wire()
@ivar output: where rendering is written
@type output: cStringIO.StringIO object
@ivar id: the message id
@type id: int
@ivar flags: the message flags
@type flags: int
@ivar max_size: the maximum size of the message
@type max_size: int
@ivar origin: the origin to use when rendering relative names
@type origin: dns.name.Name object
@ivar compress: the compression table
@type compress: dict
@ivar section: the section currently being rendered
@type section: int (dns.renderer.QUESTION, dns.renderer.ANSWER,
dns.renderer.AUTHORITY, or dns.renderer.ADDITIONAL)
@ivar counts: list of the number of RRs in each section
@type counts: int list of length 4
@ivar mac: the MAC of the rendered message (if TSIG was used)
@type mac: string
i iÿÿ c C s¡ t i ƒ | _ | d j o t i d d ƒ | _ n
| | _ | | _ | | _ | | _
h | _ t | _
d d d d g | _ | i i d d ƒ d | _ d S( sô Initialize a new renderer.
@param id: the message id
@type id: int
@param flags: the DNS message flags
@type flags: int
@param max_size: the maximum message size; the default is 65535.
If rendering results in a message greater than I{max_size},
then L{dns.exception.TooBig} will be raised.
@type max_size: int
@param origin: the origin to use when rendering relative names
@type origin: dns.name.Namem or None.
i iÿÿ t i t N( t cStringIOt StringIOt selft outputt idt Nonet randomt randintt flagst max_sizet origint compresst QUESTIONt sectiont countst writet mac( R R R R R
( ( t0 /usr/lib/python2.4/site-packages/dns/renderer.pyt __init__J s
c C s€ | i i | ƒ | i i ƒ g } x; | i i ƒ D]* \ } } | | j o | i
| ƒ q3 q3 Wx | D] } | i | =qh Wd S( sÕ Truncate the output buffer at offset I{where}, and remove any
compression table entries that pointed beyond the truncation
point.
@param where: the offset
@type where: int
N( R R t seekt wheret truncatet keys_to_deleteR t iteritemst kt vt append( R R R R R ( ( R t _rollbackg s
c C sA | i | j o- | i | j o t i i ‚ n | | _ n d S( sZ Set the renderer's current section.
Sections must be rendered order: QUESTION, ANSWER, AUTHORITY,
ADDITIONAL. Sections may be empty.
@param section: the section
@type section: int
@raises dns.exception.FormError: an attempt was made to set
a section value less than the current section.
N( R R t dnst exceptiont FormError( R R ( ( R t _set_sectiony s
c C sª | i t ƒ | i i ƒ } | i | i | i | i ƒ | i i
t i d | | ƒ ƒ | i i ƒ } | | i j o | i | ƒ t i i ‚ n | i t c d 7<d S( s Add a question to the message.
@param qname: the question name
@type qname: dns.name.Name
@param rdtype: the question rdata type
@type rdtype: int
@param rdclass: the question rdata class
@type rdclass: int
s !HHi N( R R"