Resource Record (RR).
The RR is the basic DNS element that contains actual data. This class allows to create RR and manipulate with the content.
Use ldns_rr_new(), ldns_rr_new_frm_type(), new_frm_fp(), new_frm_fp_l(), new_frm_str() or new_question_frm_str() to create ldns_rr instances.
Returns the address rdf of a LDNS_RR_TYPE_A or LDNS_RR_TYPE_AAAA rr.
Returns: | (ldns_rdf) with the address or None on failure. |
---|
Sets the address of a LDNS_RR_TYPE_A or LDNS_RR_TYPE_AAAA rr.
Parameters: | f (ldns_rdf) – The address to be set. |
---|---|
Throws TypeError: | |
When f of non-ldns_rdf type. | |
Returns: | (bool) True on success, False otherwise. |
Retrieves a class identifier value by looking up its name.
Parameters: | string (str) – Class name. |
---|---|
Throws TypeError: | |
when string of inappropriate type. | |
Returns: | (int) Class identifier value, or 0 if not valid class name given. |
Returns True if the given rr’s are equal.
Also returns True if one record is a DS that represents the same DNSKEY record as the other record.
Parameters: | rr2 (ldns_rr) – The second rr. |
---|---|
Throws TypeError: | |
When rr2 of non-ldns_rr type. | |
Returns: | (bool) True if equal otherwise False. |
Compares two rrs, up to the rdata.
Parameters: | rr2 (ldns_rr) – Rhe second rr. |
---|---|
Throws TypeError: | |
When rr2 of non-ldns_rr type. | |
Returns: | (int) 0 if equal, negative integer if self comes before rr2, positive integer if rr2 comes before self. |
Returns the algorithm of a LDNS_RR_TYPE_DNSKEY rr.
Returns: | (ldns_rdf) with the algorithm or None on failure. |
---|
Returns the flags of a LDNS_RR_TYPE_DNSKEY rr.
Returns: | (ldns_rdf) with the flags or None on failure. |
---|
Returns the key data of a LDNS_RR_TYPE_DNSKEY rr.
Returns: | (ldns_rdf) with the key data or None on failure. |
---|
Get the length of the keydata in bits.
Returns: | (size_t) the keysize in bits. |
---|
Get the length of the keydata in bits.
Parameters: |
|
---|---|
Returns: | (size_t) The length of key data in bits. |
Returns the protocol of a LDNS_RR_TYPE_DNSKEY rr.
Returns: | (ldns_rdf) with the protocol or None on failure. |
---|
Sets the algorithm of a LDNS_RR_TYPE_DNSKEY rr
Parameters: | f (ldns_rdf) – The algorithm to set. |
---|---|
Throws TypeError: | |
When f of non-ldns_rdf type. | |
Returns: | (bool) True on success, False otherwise. |
Sets the flags of a LDNS_RR_TYPE_DNSKEY rr.
Parameters: | f (ldns_rdf) – The flags to be set. |
---|---|
Throws TypeError: | |
When f of non-ldns_rdf type. | |
Returns: | (bool) True on success, False otherwise. |
Sets the key data of a LDNS_RR_TYPE_DNSKEY rr.
Parameters: | f (ldns_rdf) – The key data to set. |
---|---|
Throws TypeError: | |
When f of non-ldns_rdf type. | |
Returns: | (bool) True on success, False otherwise. |
Sets the protocol of a LDNS_RR_TYPE_DNSKEY rr.
Parameters: | f (ldns_rdf) – The protocol to set. |
---|---|
Throws TypeError: | |
When f of non-ldns_rdf type. | |
Returns: | (bool) True on success, False otherwise. |
Returns the class of the rr.
Returns: | (int) The class identifier of the rr. |
---|
Converts an RR class value to its string representation, and returns that string.
Returns: | (str) containing class identification. |
---|
Returns the type of the rr.
Returns: | (int) The type identifier of the rr. |
---|
Converts an RR type value to its string representation, and returns that string.
Returns: | (str) containing type identification. |
---|
Returns the question flag of a rr structure.
Returns: | (bool) True if question flag is set. |
---|
Counts the number of labels of the owner name.
Returns: | (int) The number of labels. |
---|
Returns the mx host of a LDNS_RR_TYPE_MX rr.
Returns: | (ldns_rdf) with the name of the MX host or None on failure. |
---|
Returns the mx preference of a LDNS_RR_TYPE_MX rr.
Returns: | (ldns_rdf) with the preference or None on failure. |
---|
Creates a new rr from a file containing a string.
Parameters: |
|
---|---|
Throws Exception: | |
If raiseException is set and the input cannot be read. |
|
Throws TypeError: | |
When parameters of incorrect types. |
|
Returns: | None when fails, otherwise a tuple containing:
|
Note
The type checking of origin is benevolent. It allows also to pass a dname ldns_rdf object. This will probably change in future.
Creates a new rr from a file containing a string.
Parameters: |
|
---|---|
Throws Exception: | |
If raiseException is set and the input cannot be read. |
|
Throws TypeError: | |
When parameters of incorrect types. |
|
Returns: | None when fails, otherwise a tuple containing:
|
Note
The type checking of origin is benevolent. It allows also to pass a dname ldns_rdf object. This will probably change in future.
Creates an rr object from a string.
The string should be a fully filled-in rr, like “owner_name [space] TTL [space] CLASS [space] TYPE [space] RDATA.”
Parameters: |
|
---|---|
Throws Exception: | |
If raiseExceprion is set and fails. |
|
Throws TypeError: | |
When parameters of incorrect types. |
|
Returns: | (ldns_rr) RR instance or None. |
Note
The type checking of origin is benevolent. It allows also to pass a dname ldns_rdf object. This will probably change in future.
Usage
>>> import ldns
>>> rr = ldns.ldns_rr.new_frm_str("www.nic.cz. IN A 192.168.1.1", 300)
>>> print rr
www.nic.cz. 300 IN A 192.168.1.1
>>> rr = ldns.ldns_rr.new_frm_str("test.nic.cz. 600 IN A 192.168.1.2")
>>> print rr
test.nic.cz. 600 IN A 192.168.1.2
Creates an rr object from a string.
The string should be a fully filled-in rr, like “owner_name [space] TTL [space] CLASS [space] TYPE [space] RDATA”.
Parameters: |
|
---|---|
Throws Exception: | |
If raiseExceprion is set and fails. |
|
Throws TypeError: | |
When parameters of incorrect types. |
|
Returns: | None when fails, otherwise a tuple containing: |
Note
The type checking of origin is benevolent. It allows also to pass a dname ldns_rdf object. This will probably change in future.
Creates an rr object from a string.
The string is like new_frm_str() but without rdata.
Parameters: |
|
---|---|
Throws Exception: | |
If raiseExceprion is set and fails. |
|
Throws TypeError: | |
When parameters of incorrect types. |
|
Returns: | (ldns_rr) RR instance or None. If the object can’t be created and raiseException is True, an exception occurs. |
Note
The type checking of origin is benevolent. It allows also to pass a dname ldns_rdf object. This will probably change in future.
Returns the name of a LDNS_RR_TYPE_NS rr.
Returns: | (ldns_rdf) A dname rdf with the name or None on failure. |
---|
Returns the owner name of an rr structure.
Returns: | (ldns_dname) Owner name or None on failure. |
---|
Removes a rd_field member, it will be popped from the last position.
Returns: | (ldns_rdf) rdf which was popped, None if nothing. |
---|
Prints the data in the resource record to the given file stream (in presentation format).
Parameters: | output – Opened file stream. |
---|---|
Throws TypeError: | |
When output not a file. |
Sets rd_field member, it will be placed in the next available spot.
Parameters: | f (ldns_rdf) – The rdf to be appended. |
---|---|
Throws TypeError: | |
When f of non-ldns_rdf type. | |
Returns: | (bool) Returns True if success, False otherwise. |
Returns the rd_count of an rr structure.
Returns: | (size_t) the rd count of the rr. |
---|
Returns the rdata field with the given index.
Parameters: | nr (positive int) – The index of the rdf to return. |
---|---|
Throws TypeError: | |
When nr not a positive integer. | |
Returns: | (ldns_rdf) The given rdf or None if fails. |
Returns the algorithm identifier of a LDNS_RR_TYPE_RRSIG RR.
Returns: | (ldns_rdf) with the algorithm or None on failure. |
---|
Returns the expiration time of a LDNS_RR_TYPE_RRSIG RR.
Returns: | (ldns_rdf) with the expiration time or None on failure. |
---|
Returns the inception time of a LDNS_RR_TYPE_RRSIG RR.
Returns: | (ldns_rdf) with the inception time or None on failure. |
---|
Returns the keytag of a LDNS_RR_TYPE_RRSIG RR.
Returns: | (ldns_rdf) with the keytag or None on failure. |
---|
Returns the number of labels of a LDNS_RR_TYPE_RRSIG RR.
Returns: | (ldns_rdf) with the number of labels or None on failure. |
---|
Returns the original TTL of a LDNS_RR_TYPE_RRSIG RR.
Returns: | (ldns_rdf) with the original TTL or None on failure. |
---|
Sets the algorithm of a LDNS_RR_TYPE_RRSIG rr.
Parameters: | f (ldns_rdf) – The algorithm to set. |
---|---|
Throws TypeError: | |
when f of non-ldns_rdf type. | |
Returns: | (bool) True on success, False otherwise. |
Sets the expireation date of a LDNS_RR_TYPE_RRSIG rr.
Parameters: | f (ldns_rdf) – The expireation date to set. |
---|---|
Throws TypeError: | |
when f of non-ldns_rdf type. | |
Returns: | (bool) True on success, False otherwise. |
Sets the inception date of a LDNS_RR_TYPE_RRSIG rr.
Parameters: | f (ldns_rdf) – The inception date to set. |
---|---|
Throws TypeError: | |
when f of non-ldns_rdf type. | |
Returns: | (bool) True on success, False otherwise. |
Sets the keytag of a LDNS_RR_TYPE_RRSIG rr.
Parameters: | f (ldns_rdf) – The keytag to set. |
---|---|
Throws TypeError: | |
when f of non-ldns_rdf type. | |
Returns: | (bool) True on success, False otherwise. |
Sets the number of labels of a LDNS_RR_TYPE_RRSIG rr.
Parameters: | f (ldns_rdf) – The number of labels to set. |
---|---|
Throws TypeError: | |
when f of non-ldns_rdf type. | |
Returns: | (bool) True on success, False otherwise. |
Sets the original TTL of a LDNS_RR_TYPE_RRSIG rr.
Parameters: | f (ldns_rdf) – The original TTL to set. |
---|---|
Throws TypeError: | |
when f of non-ldns_rdf type. | |
Returns: | (bool) True on success, False otherwise. |
Sets the signature data of a LDNS_RR_TYPE_RRSIG rr.
Parameters: | f (ldns_rdf) – The signature data to set. |
---|---|
Throws TypeError: | |
when f of non-ldns_rdf type. | |
Returns: | (bool) True on success, False otherwise. |
Sets the signers name of a LDNS_RR_TYPE_RRSIG rr.
Parameters: | f (ldns_rdf) – The signers name to set. |
---|---|
Throws TypeError: | |
when f of non-ldns_rdf type. | |
Returns: | (bool) True on success, False otherwise. |
Sets the typecovered of a LDNS_RR_TYPE_RRSIG rr.
Parameters: | f (ldns_rdf) – The type covered to set. |
---|---|
Throws TypeError: | |
when f of non-ldns_rdf type. | |
Returns: | (bool) True on success, False otherwise. |
Returns the signature data of a LDNS_RR_TYPE_RRSIG RR.
Returns: | (ldns_rdf) with the signature data or None on failure. |
---|
Returns the signers name of a LDNS_RR_TYPE_RRSIG RR.
Returns: | (ldns_rdf) with the signers name or None on failure. |
---|
Returns the type covered of a LDNS_RR_TYPE_RRSIG rr.
Returns: | (ldns_rdf) with the type covered or None on failure. |
---|
Sets the class in the rr.
Parameters: | rr_class (int) – Set to this class. |
---|---|
Throws TypeError: | |
when rr_class of non-integer type. |
Sets the owner in the rr structure.
Parameters: | owner (ldns_dname) – Owner name. |
---|---|
Throws TypeError: | |
when owner of non-ldns_dname type. |
Note
The type checking of owner is benevolent. It allows also to pass a dname ldns_rdf object. This will probably change in future.
Sets the question flag in the rr structure.
Parameters: | question (bool) – Question flag. |
---|
Sets the rd_count in the rr.
Parameters: | count (positive int) – Set to this count. |
---|---|
Throws TypeError: | |
when count of non-integer type. |
Sets a rdf member, it will be set on the position given.
The old value is returned, like pop.
Parameters: |
|
---|---|
Throws TypeError: | |
when mismatching types passed. |
|
Returns: | (ldns_rdf) the old value in the rr, None on failure. |
Sets the ttl in the rr structure.
Parameters: | ttl (positive int) – Set to this ttl. |
---|---|
Throws TypeError: | |
when ttl of non-integer type. |
Sets the type in the rr.
Parameters: | rr_type (ineteger) – Set to this type. |
---|---|
Throws TypeError: | |
when rr_type of non-integer type. |
Converts each dname in a rr to its canonical form.
Returns the ttl of an rr structure.
Returns: | (int) the ttl of the rr. |
---|
Retrieves a rr type identifier value by looking up its name.
Returns 0 if invalid name passed.
Parameters: | string (str) – RR type name. |
---|---|
Throws TypeError: | |
when string of inappropriate type. | |
Returns: | (int) RR type identifier, or 0 if no matching value to identifier found. |
Calculates the uncompressed size of an RR.
Returns: | (inetger) size of the rr. |
---|
Converts an rr’s rdata to wire format, while excluding the owner name and all the stuff before the rdata.
This is needed in DNSSEC key-tag calculation, the ds calculation from the key and maybe elsewhere.
Parameters: | buffer (ldns_buffer) – Buffer to append the result to. |
---|---|
Throws TypeError: | |
when buffer of non-ldns_buffer type. | |
Returns: | (ldns_status) ldns_status |
Converts a rrsig to wire format BUT EXCLUDE the rrsig rdata.
This is needed in DNSSEC verification.
Parameters: | buffer (ldns_buffer) – Buffer to append the result to. |
---|---|
Throws TypeError: | |
when buffer of non-ldns_buffer type. | |
Returns: | (ldns_status) ldns_status |
Copies the rr data to the buffer in wire format.
Parameters: |
|
---|---|
Throws TypeError: | |
when arguments of mismatching types passed. |
|
Returns: | (ldns_status) ldns_status |
Copies the rr data to the buffer in wire format, in canonical format according to RFC3597 (every dname in rdata fields of RR’s mentioned in that RFC will be converted to lower-case).
Parameters: |
|
---|---|
Throws TypeError: | |
when arguments of mismatching types passed. |
|
Returns: | (ldns_status) ldns_status |
Resource Record descriptor.
This structure contains, for all rr types, the rdata fields that are defined.
In order to create a class instance use ldns_rr_descriptor().
Returns the rdf type for the given rdata field number of the rr type for the given descriptor.
Parameters: | field (positive int) – The field number. |
---|---|
Throws TypeError: | |
when field of non-inetger type. | |
Returns: | (int) the rdf type for the field. |
Returns the resource record descriptor for the given type.
Parameters: | rr_type (int) – RR type. |
---|---|
Throws TypeError: | |
when rr_type of inappropriate type. | |
Returns: | (ldns_rr_descriptor) RR descriptor class. |
Returns the maximum number of rdata fields of the rr type this descriptor describes.
Returns: | (int) the maximum number of rdata fields. |
---|
Returns the minimum number of rdata fields of the rr type this descriptor describes.
Returns: | (int) the minimum number of rdata fields. |
---|