Package dns :: Module message :: Class Message
[show private | hide private]
[frames | no frames]

Class Message

object --+
         |
        Message

Known Subclasses:
Update

A DNS message.
Method Summary
  __init__(self, id)
bool __eq__(self, other)
Two messages are equal if they have the same content in the header, question, answer, and authority sections.
bool __ne__(self, other)
Are two messages not equal?
a new object with type S, a subtype of T __new__(S, ...)
  __repr__(self)
  __str__(self)
dns.rrset.RRset object find_rrset(self, section, name, rdclass, rdtype, covers, deleting, create, force_unique)
Find the RRset with the given attributes in the specified section.
dns.rrset.RRset object or None get_rrset(self, section, name, rdclass, rdtype, covers, deleting, create, force_unique)
Get the RRset with the given attributes in the specified section.
bool is_response(self, other)
Is other a response to self?
int rcode(self)
Return the rcode.
  set_rcode(self, rcode)
Set the rcode.
string to_text(self, origin, relativize, **kw)
Convert the message to text.
string to_wire(self, origin, max_size, **kw)
Return a string containing the message in DNS compressed wire format.
  use_edns(self, edns, ednsflags, payload)
Configure EDNS behavior.
  use_tsig(self, keyring, keyname, fudge, original_id, tsig_error, other_data)
When sending, a TSIG signature using the specified keyring and keyname should be added.

Instance Variable Summary
list of dns.rrset.RRset objects additional - The additional data section.
list of dns.rrset.RRset objects answer - The answer section.
list of dns.rrset.RRset objects authority - The authority section.
int edns - The EDNS level to use.
long ednsflags - The EDNS flags
bool first - Is this message standalone, or the first of a multi message sequence? This variable is used when validating TSIG signatures on messages which are part of a zone transfer.
int flags - The DNS flags of the message.
int fudge - TSIG time fudge; default is 300 seconds.
bool had_tsig - Did the message decoded from wire format have a TSIG signature?
int id - The query id; the default is a randomly chosen id.
dns.name.Name object keyname - The TSIG keyname to use.
dict keyring - The TSIG keyring to use.
string mac - The TSIG MAC for this message.
bool multi - Is this message part of a multi-message sequence? The default is false.
dns.name.Name object origin - The origin of the zone in messages which are used for zone transfers or for DNS dynamic updates.
int original_id - TSIG original id; defaults to the message's id
string other_data - TSIG other data.
int payload - The EDNS payload size.
list of dns.rrset.RRset objects question - The question section.
string request_mac - The TSIG MAC of the request message associated with this message; used when validating TSIG signatures.
hmac.HMAC object tsig_ctx - The TSIG signature context associated with this message.
int tsig_error - TSIG error code; default is 0.
bool xfr - Is the message being used to contain the results of a DNS zone transfer? The default is False.

Method Details

__eq__(self, other)
(Equality operator)

Two messages are equal if they have the same content in the header, question, answer, and authority sections.
Returns:
bool

__ne__(self, other)

Are two messages not equal?
Returns:
bool

__new__(S, ...)

Returns:
a new object with type S, a subtype of T

find_rrset(self, section, name, rdclass, rdtype, covers=0, deleting=None, create=False, force_unique=False)

Find the RRset with the given attributes in the specified section.
Parameters:
section - the section of the message to look in, e.g. self.answer.
           (type=list of dns.rrset.RRset objects)
name - the name of the RRset
           (type=dns.name.Name object)
rdclass - the class of the RRset
           (type=int)
rdtype - the type of the RRset
           (type=int)
covers - the covers value of the RRset
           (type=int)
deleting - the deleting value of the RRset
           (type=int)
create - If True, create the RRset if it is not found. The created RRset is appended to section.
           (type=bool)
force_unique - If True and create is also True, create a new RRset regardless of whether a matching RRset exists already.
           (type=bool)
Returns:
dns.rrset.RRset object
Raises:
KeyError - the RRset was not found and create was False

get_rrset(self, section, name, rdclass, rdtype, covers=0, deleting=None, create=False, force_unique=False)

Get the RRset with the given attributes in the specified section.

If the RRset is not found, None is returned.
Parameters:
section - the section of the message to look in, e.g. self.answer.
           (type=list of dns.rrset.RRset objects)
name - the name of the RRset
           (type=dns.name.Name object)
rdclass - the class of the RRset
           (type=int)
rdtype - the type of the RRset
           (type=int)
covers - the covers value of the RRset
           (type=int)
deleting - the deleting value of the RRset
           (type=int)
create - If True, create the RRset if it is not found. The created RRset is appended to section.
           (type=bool)
force_unique - If True and create is also True, create a new RRset regardless of whether a matching RRset exists already.
           (type=bool)
Returns:
dns.rrset.RRset object or None

is_response(self, other)

Is other a response to self?
Returns:
bool

rcode(self)

Return the rcode.
Returns:
int

set_rcode(self, rcode)

Set the rcode.
Parameters:
rcode - the rcode
           (type=int)

to_text(self, origin=None, relativize=True, **kw)

Convert the message to text.

The origin, relativize, and any other keyword arguments are passed to the rrset to_wire() method.
Returns:
string

to_wire(self, origin=None, max_size=65535, **kw)

Return a string containing the message in DNS compressed wire format.

Additional keyword arguments are passed to the rrset to_wire() method.
Parameters:
origin - The origin to be appended to any relative names.
           (type=dns.name.Name object)
max_size - The maximum size of the wire format output.
           (type=int)
Returns:
string
Raises:
dns.exception.TooBig - max_size was exceeded

use_edns(self, edns, ednsflags, payload)

Configure EDNS behavior.
Parameters:
edns - The EDNS level to use. Specifying None or -1 means 'do not use EDNS'.
           (type=int or None)
ednsflags - EDNS flag values.
           (type=int)
payload - The EDNS sender's payload field, which is the maximum size of UDP datagram the sender can handle.
           (type=int)

See also: RFC 2671

use_tsig(self, keyring, keyname=None, fudge=300, original_id=None, tsig_error=0, other_data='')

When sending, a TSIG signature using the specified keyring and keyname should be added.
Parameters:
keyring - The TSIG keyring to use; defaults to None.
           (type=dict)
keyname - The name of the TSIG key to use; defaults to None. The key must be defined in the keyring. If a keyring is specified but a keyname is not, then the key used will be the first key in the keyring. Note that the order of keys in a dictionary is not defined, so applications should supply a keyname when a keyring is used, unless they know the keyring contains only one key.
           (type=dns.name.Name or string)
fudge - TSIG time fudge; default is 300 seconds.
           (type=int)
original_id - TSIG original id; defaults to the message's id
           (type=int)
tsig_error - TSIG error code; default is 0.
           (type=int)
other_data - TSIG other data.
           (type=string)

Instance Variable Details

additional

The additional data section.
Type:
list of dns.rrset.RRset objects

answer

The answer section.
Type:
list of dns.rrset.RRset objects

authority

The authority section.
Type:
list of dns.rrset.RRset objects

edns

The EDNS level to use. The default is -1, no Edns.
Type:
int

ednsflags

The EDNS flags
Type:
long

first

Is this message standalone, or the first of a multi message sequence? This variable is used when validating TSIG signatures on messages which are part of a zone transfer.
Type:
bool

flags

The DNS flags of the message. @see: RFC 1035 for an explanation of these flags.
Type:
int

fudge

TSIG time fudge; default is 300 seconds.
Type:
int

had_tsig

Did the message decoded from wire format have a TSIG signature?
Type:
bool

id

The query id; the default is a randomly chosen id.
Type:
int

keyname

The TSIG keyname to use. The default is None.
Type:
dns.name.Name object

keyring

The TSIG keyring to use. The default is None.
Type:
dict

mac

The TSIG MAC for this message.
Type:
string

multi

Is this message part of a multi-message sequence? The default is false. This variable is used when validating TSIG signatures on messages which are part of a zone transfer.
Type:
bool

origin

The origin of the zone in messages which are used for zone transfers or for DNS dynamic updates. The default is None.
Type:
dns.name.Name object

original_id

TSIG original id; defaults to the message's id
Type:
int

other_data

TSIG other data.
Type:
string

payload

The EDNS payload size. The default is 0.
Type:
int

question

The question section.
Type:
list of dns.rrset.RRset objects

request_mac

The TSIG MAC of the request message associated with this message; used when validating TSIG signatures. @see: RFC 2845 for more information on TSIG fields.
Type:
string

tsig_ctx

The TSIG signature context associated with this message. The default is None.
Type:
hmac.HMAC object

tsig_error

TSIG error code; default is 0.
Type:
int

xfr

Is the message being used to contain the results of a DNS zone transfer? The default is False.
Type:
bool

Generated by Epydoc 1.1 on Sun Jun 6 13:48:47 2004 http://epydoc.sf.net