[ldns-users] Programmatically creating a zone

Bryan Duff bduff at ecessa.com
Thu Sep 2 20:55:55 UTC 2010


 On 09/02/10 14:43, Ray Bellis wrote:
>>> Is the real issue figuring how to create an "ldns_rr"?
>> Yes, I think that is the main difficulty.
>>
>> ldns_rr_new_frm_str_internal() is what I've been looking at as the
>> template for creating my own ldns_rr.  It looks like it has all the
>> init, and assignment code that I would need. 
>>
>> It seems like this function is the most like what I want.
> Well, that depends on what the source of your RRs is.
>
> I've used ldns_rr_new_frm_str() before (not the _internal variant):
>
>   ldns_rr *rr;
>   ldns_rdf *origin = ldns_dname_new_frm_str(origin_str);
>   ldns_rr_new_frm_str(&rr, rr_str, ttl, origin, NULL);
>
> (where "origin_str" is $ORIGIN and "rr_str" is the RR in the form "@ RTYPE RDATA")

Ahh, I see - that does look much simpler.

As long as I create the "@ RTYPE RDATA" correctly (it's probably still
much less error prone than probably duplication alot of code in the
_internal function).

Thanks.

> Alternatively, it's possible (but tedious) to create it one field at a time:
>
>   ldns_rr *rr = ldns_rr_new();
>   ldns_rdf *owner = ldns_dname_new_frm_str(owner_str);
>   ldns_rr_set_owner(rr, owner);
>   ldns_rr_set_ttl(rr, ttl);
>   ldns_rr_set_type(rr, rtype);
>   ...
>
> [not sure how to set the RDATA yet, the _frm_str method is probably easier in many cases, but this method is probably faster if you have the RDATA already in wire format instead of ASCII].
>
> Ray
>
-Bryan



More information about the ldns-users mailing list