libunbound : ub_result from ub_resolve_event callback

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.

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

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

regards,
-antony

Hi Antony,

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