[ldns-users] simple use case - change domain in query

Michael Ellery mellery451 at gmail.com
Thu Nov 29 21:41:33 UTC 2012


Hello LDNS users,

I'm trying to use LDNS to tweak an existing DNS request. In this case, I want to modify the domain in the query. Here is the code I've tried so far (minus error checking):

/* dns_data, dns_data_len, and new_domain are inputs */

    ldns_pkt    *query     = NULL;
    ldns_rr     *question  = NULL;
    ldns_rdf    *new_name  = NULL;
    uint8_t     *new_dns_data = NULL
    size_t       new_dns_data_len = 0U;

    ldns_wire2pkt(&query, dns_data, dns_data_len);
    ldns_str2rdf_str(&new_name, new_domain);
    question = ldns_rr_list_rr(ldns_pkt_question(query), 0U);
    ldns_rr_set_owner(question, new_name);
    ldns_pkt2wire(&new_dns_data, query, &new_dns_data_len);
    ldns_pkt_free(query);


The code runs and doesn't produce any errors (I'm checking return codes), but the resulting buffer in new_dns_data subsequently fails in a call to ldns_wire2pkt, so I assume that means it's invalid or corrupt.

Any thoughts about what I'm doing wrong or another way to accomplish what I'd like to do (change the FQDN in the query..).

Thanks,
Mike Ellery

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nlnetlabs.nl/pipermail/ldns-users/attachments/20121129/8de2c691/attachment.htm>


More information about the ldns-users mailing list