ba54c712141b9764a2e06ed8dfb35bc3154b53c7Timo Sirainen /* the idle_timeout_msecs works only with the dns_client_* API.
ba54c712141b9764a2e06ed8dfb35bc3154b53c7Timo Sirainen 0 = disconnect immediately */
8836c374dc344a48d4f6cefdf224089f3a0c40c6Stephan Bosch /* ioloop to run the lookup on (defaults to current_ioloop) */
17fc2a887a5683b2e1bbd6bd9fdf0cdb97b509fbTimo Sirainen /* all is ok if ret=0, otherwise it contains net_gethosterror()
17fc2a887a5683b2e1bbd6bd9fdf0cdb97b509fbTimo Sirainen compatible error code. error string is always set if ret != 0. */
17fc2a887a5683b2e1bbd6bd9fdf0cdb97b509fbTimo Sirainen /* how many milliseconds the lookup took. */
d29c3ac4da9857ffcce57eec726d042c292e2becTimo Sirainen /* for IP lookup: */
d29c3ac4da9857ffcce57eec726d042c292e2becTimo Sirainen /* for PTR lookup: */
17fc2a887a5683b2e1bbd6bd9fdf0cdb97b509fbTimo Sirainentypedef void dns_lookup_callback_t(const struct dns_lookup_result *result,
7d102c66eb1755e1894cf56e3594cd744e855238Timo Sirainen/* Do asynchronous DNS lookup via dns-client UNIX socket. Returns 0 if lookup
7d102c66eb1755e1894cf56e3594cd744e855238Timo Sirainen started, -1 if there was an error communicating with the UNIX socket.
7d102c66eb1755e1894cf56e3594cd744e855238Timo Sirainen When failing with -1, the callback is called before returning from the
17fc2a887a5683b2e1bbd6bd9fdf0cdb97b509fbTimo Sirainenint dns_lookup(const char *host, const struct dns_lookup_settings *set,
27a44fcfd8d19bffe0f267f20a2b5d3fe7600fddTimo Sirainen dns_lookup_callback_t *callback, void *context,
7d102c66eb1755e1894cf56e3594cd744e855238Timo Sirainen#define dns_lookup(host, set, callback, context, lookup_r) \
27a44fcfd8d19bffe0f267f20a2b5d3fe7600fddTimo Sirainen const struct dns_lookup_result *, typeof(context))), \
27a44fcfd8d19bffe0f267f20a2b5d3fe7600fddTimo Sirainen set, (dns_lookup_callback_t *)callback, context, lookup_r)
d29c3ac4da9857ffcce57eec726d042c292e2becTimo Sirainen dns_lookup_callback_t *callback, void *context,
d29c3ac4da9857ffcce57eec726d042c292e2becTimo Sirainen#define dns_lookup_ptr(host, set, callback, context, lookup_r) \
d29c3ac4da9857ffcce57eec726d042c292e2becTimo Sirainen const struct dns_lookup_result *, typeof(context))), \
d29c3ac4da9857ffcce57eec726d042c292e2becTimo Sirainen set, (dns_lookup_callback_t *)callback, context, lookup_r)
7d102c66eb1755e1894cf56e3594cd744e855238Timo Sirainen/* Abort the DNS lookup without calling the callback. */
7d102c66eb1755e1894cf56e3594cd744e855238Timo Sirainenvoid dns_lookup_abort(struct dns_lookup **lookup);
96e3a90451b495d8bedbe5dd731539269cb8c08dStephan Boschvoid dns_lookup_switch_ioloop(struct dns_lookup *lookup);
ba54c712141b9764a2e06ed8dfb35bc3154b53c7Timo Sirainen/* Alternative API for clients that need to do multiple DNS lookups. */
ba54c712141b9764a2e06ed8dfb35bc3154b53c7Timo Sirainenstruct dns_client *dns_client_init(const struct dns_lookup_settings *set);
ba54c712141b9764a2e06ed8dfb35bc3154b53c7Timo Sirainenvoid dns_client_deinit(struct dns_client **client);
ba54c712141b9764a2e06ed8dfb35bc3154b53c7Timo Sirainen/* Connect immediately to the dns-lookup socket. */
ba54c712141b9764a2e06ed8dfb35bc3154b53c7Timo Sirainenint dns_client_connect(struct dns_client *client, const char **error_r);
ba54c712141b9764a2e06ed8dfb35bc3154b53c7Timo Sirainenint dns_client_lookup(struct dns_client *client, const char *host,
ba54c712141b9764a2e06ed8dfb35bc3154b53c7Timo Sirainen dns_lookup_callback_t *callback, void *context,
ba54c712141b9764a2e06ed8dfb35bc3154b53c7Timo Sirainen#define dns_client_lookup(client, host, callback, context, lookup_r) \
ba54c712141b9764a2e06ed8dfb35bc3154b53c7Timo Sirainen const struct dns_lookup_result *, typeof(context))), \
ba54c712141b9764a2e06ed8dfb35bc3154b53c7Timo Sirainen (dns_lookup_callback_t *)callback, context, lookup_r)
ba54c712141b9764a2e06ed8dfb35bc3154b53c7Timo Sirainenint dns_client_lookup_ptr(struct dns_client *client, const struct ip_addr *ip,
ba54c712141b9764a2e06ed8dfb35bc3154b53c7Timo Sirainen dns_lookup_callback_t *callback, void *context,
ba54c712141b9764a2e06ed8dfb35bc3154b53c7Timo Sirainen#define dns_client_lookup_ptr(client, host, callback, context, lookup_r) \
ba54c712141b9764a2e06ed8dfb35bc3154b53c7Timo Sirainen const struct dns_lookup_result *, typeof(context))), \
ba54c712141b9764a2e06ed8dfb35bc3154b53c7Timo Sirainen (dns_lookup_callback_t *)callback, context, lookup_r)