[ldns-users] Python rdf.data()

Jack Bates iwbl5o at nottheoilrig.com
Wed Aug 28 18:34:37 UTC 2013


Thank you Karel, I want to access certificate association data from a 
TLSA RR. From C I would use ldns_rdf_data() and ldns_rdf_size(), is that 
right? From Python, how do you use the return value from rdf.data()?

The RDF is type HEX, so str(rdf) returns hex digits. I can convert them 
back to bytes, but rdf.data() and rdf.size() seemed like the more direct 
way to get the bytes?

On 22/08/13 05:31 AM, Karel Slany wrote:
> Greetings,
>
> Python's ldns_rdf.data() creates a thin wrapper around the ldns C
> function ldns_rdf_data(). Function ldns_rdf_data() returns a pointer to
> an internal data field of the manipulated rdf.
>
> Actually, I don't know the actual reason why you are trying to access
> this low level structures. Manipulating them from Python can be tricky
> as you can easily end up with corrupted memory.
>
> In order to meet your desire I can add a new method ldns_rdf.data_str()
> which would return a Python string containing copy of the rdf data
> field. However, in Python3 this would be error-prone, because Python3
> uses unicode strings. At the moment I cannot guess, whether the approach
> would be reliabe in Python3.
>
> Please give more information about the reason why you want to use
> ldns_rdf.data(). Perhaps we could think of a more convenient solution.
>
> K.
>
> Am 22.08.2013 10:56, schrieb Willem Toorop:
>> Hi Jack,
>>
>> I suspect raw access is not supported by pyldns.
>> Karel, could shed some light on this?
>>
>> -- Willem
>>
>> Op 22-08-13 01:13, Jack Bates schreef:
>>> I am working with the Python wrapper for ldns.
>>>
>>> rdf.data() returns something like
>>> <Swig Object of type 'uint8_t *' at 0xb742f938>
>>>
>>> and rdf.size() returns the number of bytes. How do I read the bytes?
>>>
>>> Thanks!
>>> _______________________________________________
>>> ldns-users mailing list
>>> ldns-users at open.nlnetlabs.nl
>>> http://open.nlnetlabs.nl/mailman/listinfo/ldns-users
>>
>> _______________________________________________
>> ldns-users mailing list
>> ldns-users at open.nlnetlabs.nl
>> http://open.nlnetlabs.nl/mailman/listinfo/ldns-users
>>



More information about the ldns-users mailing list