Resource record data field.
The data is a network ordered array of bytes, which size is specified by the (16-bit) size field. To correctly parse it, use the type specified in the (16-bit) type field with a value from ldns_rdf_type.
Checks whether the given dname string is absolute (i.e., ends with a ‘.’).
Returns: | (bool) True or False |
---|
Note
This method was malfunctioning in ldns-1.3.16 and also possibly earlier.
Warning
It is scheduled to be deprecated and removed. Convert ldns_rdf to ldns_dname to use the method.
Reverses an rdf, only actually useful for AAAA and A records.
The returned rdf has the type LDNS_RDF_TYPE_DNAME!
Returns: | (ldns_rdf) The reversed rdf (a newly created rdf). |
---|
Concatenates rd2 after this dname (rd2 is copied, this dname is modified).
Parameters: | rd2 (ldns_rdf) – The right-hand side. |
---|---|
Throws TypeError: | |
When rd2 of non-ldns_rdf or non-ldns_dname type. | |
Returns: | (ldns_status) LDNS_STATUS_OK on success. |
Warning
It is scheduled to be deprecated and removed. Convert ldns_rdf to ldns_dname.
Concatenates two dnames together.
Parameters: | rd2 (ldns_rdf) – The right-hand side. |
---|---|
Throws TypeError: | |
When rd2 of non-ldns_rdf or non-ldns_dname type. | |
Returns: | (ldns_rdf) A new rdf with left-hand side + right-hand side content None when error. |
Warning
It is scheduled to be deprecated and removed. Convert ldns_rdf to ldns_dname.
Returns the data of the rdf.
Returns: | (uint8_t *) uint8_t* pointer to the rdf’s data. |
---|
Returns the data of the rdf as a bytearray.
Returns: | (bytearray) Bytearray containing the rdf data. |
---|
Compares two dname rdf according to the algorithm for ordering in RFC4034 Section 6.
Parameters: | other (ldns_rdf) – The second dname rdf to compare. |
---|---|
Throws TypeError: | |
When not a ldns_rdf used. | |
Throws Exception: | |
When not dnames compared. | |
Returns: | (int) -1, 0 or 1 if self comes before other, self is equal or self comes after other respectively. |
Warning
It is scheduled to be deprecated and removed. Convert ldns_rdf to ldns_dname.
Creates a new dname rdf instance from a given string.
This static method is equivalent to using of default ldns_rdf constructor.
Parameters: | string (string) – String to use. |
---|---|
Throws TypeError: | |
When not a string used. | |
Returns: | ldns_rdf or None if error. |
Warning
It is scheduled to be deprecated and removed. Use ldns_dname constructor instead.
Returns the type of the rdf.
We need to prepend the prefix get_ here to prevent conflict with the rdf_type TYPE.
Returns: | (ldns_rdf_type) Identifier of the type. |
---|
Returns the type of the rdf as a human readable string.
Returns: | String containing rdf type. |
---|
Check whether the middle lays in the interval defined by this and next (this <= middle < next).
This method is useful for nsec checking
Parameters: | |
---|---|
Throws TypeError: | |
When middle or next of non-ldns_rdf type. |
|
Throws Exception: | |
When non-dname rdfs compared. |
|
Returns: | (int) 0 on error or unknown, -1 when middle is in the interval, 1 when not. |
Warning
It is scheduled to be deprecated and removed. Convert ldns_rdf to ldns_dname.
Tests whether the name of the given instance falls under parent (i.e., is a sub-domain of parent).
This function will return False if the given dnames are equal.
Parameters: | parent (ldns_rdf) – The parent’s name. |
---|---|
Throws TypeError: | |
When parent of non-ldns_rdf type. | |
Returns: | (bool) True if this falls under parent, otherwise False. |
Warning
It is scheduled to be deprecated and removed. Convert ldns_rdf to ldns_dname.
Look inside the rdf and if it is an LDNS_RDF_TYPE_DNAME try and retrieve a specific label.
The labels are numbered starting from 0 (left most).
Parameters: | labelpos (integer) – Index of the label. (Labels are numbered 0, which is the left most.) |
---|---|
Throws TypeError: | |
When labelpos of non-integer type. | |
Returns: | (ldns_rdf) A new rdf with the label as name or None on error. |
Warning
It is scheduled to be deprecated and removed. Convert ldns_rdf to ldns_dname.
Count the number of labels inside a LDNS_RDF_DNAME type rdf.
Returns: | (uint8_t) The number of labels. Will return 0 if not a dname. |
---|
Warning
It is scheduled to be deprecated and removed. Convert ldns_rdf to ldns_dname.
Chop one label off the left side of a dname.
(e.g., wwww.nlnetlabs.nl, becomes nlnetlabs.nl)
Returns: | (ldns_rdf) The remaining dname or None when error. |
---|
Warning
It is scheduled to be deprecated and removed. Convert ldns_rdf to ldns_dname.
Put a dname into canonical format (i.e., convert to lower case).
Performs no action if not a dname.
Warning
This method is scheduled to be deprecated and removed. Convert ldns_rdf to ldns_dname to use the method.
Creates a new rdf from a string of a given type.
Parameters: |
|
---|---|
Throws TypeError: | |
When parameters of mismatching types. |
|
Throws Exception: | |
When raiseException set and rdf couldn’t be created. |
|
Returns: | ldns_rdf object or None. If the object can’t be created and raiseException is True, an exception occurs. |
Usage
>>> rdf = ldns.ldns_rdf.new_frm_str("74.125.43.99", ldns.LDNS_RDF_TYPE_A)
>>> print rdf, rdf.get_type_str()
A 74.125.43.99
>>> name = ldns.ldns_resolver.new_frm_file().get_name_by_addr(rdf)
>>> if (name): print name
99.43.125.74.in-addr.arpa. 85277 IN PTR bw-in-f99.google.com.
Prints the data in the rdata field to the given output file stream (in presentation format).
Returns a clone of the given dname with the labels reversed.
When reversing non-dnames a ”.” (root name) dname is returned.
Throws Exception: | |
---|---|
When used on non-dname rdfs. | |
Returns: | (ldns_rdf) Clone of the dname with the labels reversed or ”.”. |
Warning
It is scheduled to be deprecated and removed. Convert ldns_rdf to ldns_dname.
Sets the data portion of the rdf.
The data are not copied, but are assigned to the rdf, data are decoupled from the Python engine.
Parameters: | data (void *) – Data to be set. |
---|
Sets the size of the rdf.
Parameters: | size (integer) – The new size. |
---|---|
Throws TypeError: | |
When size of non-integer type. |
Sets the type of the rdf.
Parameters: | atype (integer) – rdf type |
---|---|
Throws TypeError: | |
When atype of non-integer type. |
Returns the size of the rdf.
Returns: | (size_t) uint16_t with the size. |
---|
Copies the rdata data to the buffer in wire format.
Parameters: | buffer – Buffer to append the rdf to. |
---|---|
Throws TypeError: | |
When buffer of non-ldns_buffer type. | |
Returns: | (ldns_status) ldns_status |
Copies the rdata data to the buffer in wire format. If the rdata is a dname, the letters will be converted to lower case during the conversion.
Parameters: | buffer (ldns_buffer) – LDNS buffer. |
---|---|
Throws TypeError: | |
When buffer of non-ldns_buffer type. | |
Returns: | (ldns_status) ldns_status |