Maintained by: NLnet Labs

libunbound : ub_result from ub_resolve_event callback

W.C.A. Wijngaards
Mon Mar 20 10:39:41 CET 2017


Hi Antony,

On 20/03/17 10:27, Antony Antony via Unbound-users wrote:
> Hello,
> I am using ub_resolve_event, with libvent. The result in the callback function is type  void* packet. Which is new to me. ub_resolve and ub_resolve_async return a type ub_result. 
> 

This is the description from the header file.
*   with packet: a buffer with DNS wireformat packet with the answer.
*        do not inspect if rcode != 0.
*        do not write or free the packet buffer, it is used internally
*        in unbound (for other callbacks that want the same data).


> How do I convert the 'void *packet' to 'struct ub_result*'?

ldns has functions to convert a wireformat packet to something readable.

>  
> from unbound-event.h
> void callback(void* mydata, int rcode, void* packet, int packet_len,               int sec, char* why_bogus) 
> 
> The ub_result is documented. I couldn't find anything about packet.
> 
> The the program already use libevent and call event_base_loop. I gave try with ub_resolve_async. The forked thread get stuck in event loop. It never call the callback function or ub_process. tcpdump can see dns queries going out and replies coming back. Still 

You have to call ub_process.  It does not call that for you.  You either
listen on the fd (from the fd() function) for a wakeup and then call
ub_process, or you call ub_process at some other time when it is
convenient for you.

Best regards, Wouter

> 
> regards,
> -antony
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <https://unbound.nlnetlabs.nl/pipermail/unbound-users/attachments/20170320/9f77b7d7/attachment.sig>