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

Matthijs Mekking matthijs at nlnetlabs.nl
Fri Nov 30 09:15:49 UTC 2012


Hi Mike,

It is hard to tell, the code example is obviously not complete. What 
error is ldns_wire2pkt giving you? Perhaps you can use ldns_pkt_print() 
to see how the new packet looks like.

Also, I guess you want to use ldns_str2rdf_dname() instead of 
ldns_str2rdf_str() .

Best regards,
   Matthijs


On 11/29/2012 10:41 PM, Michael Ellery wrote:
> 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
>
>
>
> _______________________________________________
> 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