pldns Module

ldns is a C library developed by NLnetLabs,  It provides a complete set of functions for handling dns records, as well as DNS resolvers, etc.
This Module provides methods from ldns that can be used to analyse DNS records;
it is not a complete python extension of all the ldns functionality.

Module Methods

These allow you acess to the ldns routines that map a (small integer) DNS object into a descriptive string.

opcodestr() pldns.opcodestr(integer) ->  aString

Returns a string describing a DNS operation code value
rcodestr()
pldns.rcodestr(integer) -> aString

Returns a string describing a DNS result code value
typestr()
pldns.typestr(integer) -> aString

Returns a string describing a DNS Resource Record type
errorstr()
rldns_obj.errorstr(ldns_obj.status) ->  anInteger

Returns a string describing an ldns status code.

Class LdnsRR

Ldns functions (see below) return tuples of LdnsRR objects.  Each such object contains all the information from a single Resource Record in a DNS datagram.

Instance Attributes
owner
rr.owner -> aString

Returns the RR owner's FQDN (fully qualified domain name)
type
rr.type -> anInteger

Returns the RR's type as a small integer
ttl
rr.ttl ->  anInteger

Returns the RR's TTL (Time To Live) in seconds
rdata
rr.rdata->  aString

Returns a string with all the information about the RR.  Since different RR types have different data items, the string is similar to those returned by dig for RRs.
str
ipf.proto ->  aString

Returns a string containing all the information about the RR, in a format similar to that returned by dig for an RR.

Class Ldns

An Ldns object contains all the information from a DNS datagram.

Class functions
ldns()
pldns.ldns(udp.payload) -> anLdns_obj

This function creates an ldns object. It's argument is a DNS datagram from plt, either udp.payload or tcp.payload.
is_ok()
rldns_obj.status-> True or False

Returns True if the ldns object was created without problems.
Instance Attributes
status
rldns_obj.status-> anInteger

Returns zero if the ldns object was created without problems,
or an ldns status code otherwise.
ident ldns_obj.ident->  anInteger

Returns the datagram's ident value (16-bit unsigned integer).
is_response
ldns_obj.is_response ->  True or False

Returns True if the datagram is a response.
opcode
ldns_obj.opcode ->  anInteger

Returns the datagram's opcode field.
rcode
ildns_obj.rcode ->  aString

Returns the datagram's rcode field.
query_rr_list
ldns_obj.query_rr_list ->  a list of LdnsRRs

Returns a a list of LdnsRR objects from the datagram's
Query section.
response_rr_list
ldns_obj.response_r_list ->  a list of LdnsRRs

Returns a a list of LdnsRR objects from the datagram's
Response section.
auth_rr_list ldns_obj.auth_rr_list ->  a list of LdnsRRs

Returns a a list of LdnsRR objects from the datagram's
Authority section.
addit_rr_list ldns_obj.->  a list of LdnsRRs

Returns a a list of LdnsRR objects from the datagram's
Additional section.

Nevil Brownlee
Tue, 19 Aug 14 (NZST)