[Pdns-dev] Translation from text or wire format to DNSResourceRecord

Peter van Dijk peter.van.dijk at powerdns.com
Sun Dec 3 20:38:12 UTC 2017


Hello Jim,

On 15 Nov 2017, at 12:01, Jim McDonald wrote:

>    I'm writing a PowerDNS module that obtains data from an external 
> source, and this data is being received in text or wire format.  For 
> example, obtaining a test SOA record from the module's lookup() 
> returns:
>
>
>     example.com.    3600    IN      
> SOA     ns1.example.com. hostmaster.example.com. 1 900 900 1800 
> 60
>
>
> in text format and
>
>
> 076578616d706c6503636f6d000006000100000e10003d036e7331076578616d706c6503636f6d000a686f73746d6173746572076578616d706c6503636f6d00000000010000038400000384000007080000003c
>
>
> in wire format.  Is there some in-built way to translate either of 
> these formats to a DNSResourceRecord so that it can be returned by the 
> module's get()?

You can look at almost any backend (GSQLBackend::extractRecord comes to 
mind) to get the translation from text. The exception is tinydnsbackend 
- the tinydns data.cdb file holds wire format data. Look at the use of 
PacketReader and mastermake in TinyDNSBackend::get to see how that might 
be done, after decoding from hex, in your case. Note that the tinydns 
example expects slightly less preamble than your hex dump appears to 
have.

Kind regards,
-- 
Peter van Dijk
PowerDNS.COM BV - https://www.powerdns.com/


More information about the Pdns-dev mailing list