libevent 2.1.13 Event notification library

Loading...
Searching...
No Matches
dns_compat.h File Reference

Potentially non-threadsafe versions of the functions in dns.h: provided only for backwards compatibility. More...

`#include <event2/event-config.h>`
`#include <event2/util.h>`
`#include <event2/visibility.h>`

Go to the source code of this file.

## Functions
EVENT2_EXPORT_SYMBOL struct evdns_server_port * | evdns_add_server_port (evutil_socket_t socket, int flags, evdns_request_callback_fn_type callback, void *user_data)
| As evdns_server_new_with_base.
EVENT2_EXPORT_SYMBOL int | evdns_clear_nameservers_and_suspend (void)
| Remove all configured nameservers, and suspend all pending resolves.
EVENT2_EXPORT_SYMBOL int | evdns_count_nameservers (void)
| Get the number of configured nameservers.
EVENT2_EXPORT_SYMBOL struct evdns_base * | evdns_get_global_base (void)
| Return the global evdns_base created by event_init() and used by the other deprecated functions.
EVENT2_EXPORT_SYMBOL int | evdns_init (void)
| Initialize the asynchronous DNS library.
EVENT2_EXPORT_SYMBOL int | evdns_nameserver_add (unsigned long int address)
| Add a nameserver.
EVENT2_EXPORT_SYMBOL int | evdns_nameserver_ip_add (const char *ip_as_string)
| Add a nameserver.
EVENT2_EXPORT_SYMBOL int | evdns_resolv_conf_parse (int flags, const char *const filename)
| Parse a resolv.conf file.
EVENT2_EXPORT_SYMBOL int | evdns_resolve_ipv4 (const char *name, int flags, evdns_callback_type callback, void *ptr)
| Lookup an A record for a given name.
EVENT2_EXPORT_SYMBOL int | evdns_resolve_ipv6 (const char *name, int flags, evdns_callback_type callback, void *ptr)
| Lookup an AAAA record for a given name.
EVENT2_EXPORT_SYMBOL int | evdns_resolve_reverse (const struct in_addr *in, int flags, evdns_callback_type callback, void *ptr)
| Lookup a PTR record for a given IP address.
EVENT2_EXPORT_SYMBOL int | evdns_resolve_reverse_ipv6 (const struct in6_addr *in, int flags, evdns_callback_type callback, void *ptr)
| Lookup a PTR record for a given IPv6 address.
EVENT2_EXPORT_SYMBOL int | evdns_resume (void)
| Resume normal operation and continue any suspended resolve requests.
EVENT2_EXPORT_SYMBOL void | evdns_search_add (const char *domain)
| Add a domain to the list of search domains.
EVENT2_EXPORT_SYMBOL void | evdns_search_clear (void)
| Clear the list of search domains.
EVENT2_EXPORT_SYMBOL void | evdns_search_ndots_set (const int ndots)
| Set the 'ndots' parameter for searches.
EVENT2_EXPORT_SYMBOL int | evdns_set_option (const char *option, const char *val, int flags)
| Set the value of a configuration option.
EVENT2_EXPORT_SYMBOL void | evdns_shutdown (int fail_requests)
| Shut down the asynchronous DNS resolver and terminate all active requests.

## Detailed Description

Potentially non-threadsafe versions of the functions in dns.h: provided only for backwards compatibility.

## Function Documentation

## ◆ evdns_add_server_port()

EVENT2_EXPORT_SYMBOL struct evdns_server_port * evdns_add_server_port | ( | evutil_socket_t | socket,
|  | int | flags,
|  | evdns_request_callback_fn_type | callback,
|  | void * | user_data )

As evdns_server_new_with_base.

Deprecated
  This function is deprecated because it does not allow the caller to specify which even_base it uses. The recommended function is evdns_add_server_port_with_base().

## ◆ evdns_clear_nameservers_and_suspend()

EVENT2_EXPORT_SYMBOL int evdns_clear_nameservers_and_suspend | ( | void |  | ) |

Remove all configured nameservers, and suspend all pending resolves.

Resolves will not necessarily be re-attempted until evdns_resume() is called.

Deprecated
  This function is deprecated because it does not allow the caller to specify which evdns_base it applies to. The recommended function is evdns_base_clear_nameservers_and_suspend().

Returns
  0 if successful, or -1 if an error occurred

See also
  evdns_resume()

## ◆ evdns_count_nameservers()

EVENT2_EXPORT_SYMBOL int evdns_count_nameservers | ( | void |  | ) |

Get the number of configured nameservers.

This returns the number of configured nameservers (not necessarily the number of running nameservers). This is useful for double-checking whether our calls to the various nameserver configuration functions have been successful.

Deprecated
  This function is deprecated because it does not allow the caller to specify which evdns_base it applies to. The recommended function is evdns_base_count_nameservers().

Returns
  the number of configured nameservers

See also
  evdns_nameserver_add()

## ◆ evdns_get_global_base()

EVENT2_EXPORT_SYMBOL struct evdns_base * evdns_get_global_base | ( | void |  | ) |

Return the global evdns_base created by event_init() and used by the other deprecated functions.

Deprecated
  This function is deprecated because use of the global evdns_base is error-prone.

## ◆ evdns_init()

EVENT2_EXPORT_SYMBOL int evdns_init | ( | void |  | ) |

Initialize the asynchronous DNS library.

This function initializes support for non-blocking name resolution by calling evdns_resolv_conf_parse() on UNIX and evdns_config_windows_nameservers() on Windows.

Deprecated
  This function is deprecated because it always uses the current event base, and is easily confused by multiple calls to event_init(), and so is not safe for multithreaded use. Additionally, it allocates a global structure that only one thread can use. The replacement is evdns_base_new().

Returns
  0 if successful, or -1 if an error occurred

See also
  evdns_shutdown()

## ◆ evdns_nameserver_add()

EVENT2_EXPORT_SYMBOL int evdns_nameserver_add | ( | unsigned long int | address | ) |

Add a nameserver.

The address should be an IPv4 address in network byte order. The type of address is chosen so that it matches in_addr.s_addr.

Deprecated
  This function is deprecated because it does not allow the caller to specify which evdns_base it applies to. The recommended function is evdns_base_nameserver_add().

Parameters

  address | an IP address in network byte order

Returns
  0 if successful, or -1 if an error occurred

See also
  evdns_nameserver_ip_add()

## ◆ evdns_nameserver_ip_add()

EVENT2_EXPORT_SYMBOL int evdns_nameserver_ip_add | ( | const char * | ip_as_string | ) |

Add a nameserver.

This wraps the evdns_nameserver_add() function by parsing a string as an IP address and adds it as a nameserver.

Deprecated
  This function is deprecated because it does not allow the caller to specify which evdns_base it applies to. The recommended function is evdns_base_nameserver_ip_add().

Returns
  0 if successful, or -1 if an error occurred

See also
  evdns_nameserver_add()

## ◆ evdns_resolv_conf_parse()

EVENT2_EXPORT_SYMBOL int evdns_resolv_conf_parse | ( | int | flags,
|  | const char *const | filename )

Parse a resolv.conf file.

The 'flags' parameter determines what information is parsed from the resolv.conf file. See the man page for resolv.conf for the format of this file.

The following directives are not parsed from the file: sortlist, rotate, no-check-names, inet6, debug.

If this function encounters an error, the possible return values are: 1 = failed to open file, 2 = failed to stat file, 3 = file too large, 4 = out of memory, 5 = short read from file, 6 = no nameservers listed in the file

Deprecated
  This function is deprecated because it does not allow the caller to specify which evdns_base it applies to. The recommended function is evdns_base_resolv_conf_parse().

Parameters

  flags | any of DNS_OPTION_NAMESERVERS|DNS_OPTION_SEARCH|DNS_OPTION_MISC| DNS_OPTIONS_ALL
  filename | the path to the resolv.conf file

Returns
  0 if successful, or various positive error codes if an error occurred (see above)

See also
  resolv.conf(3), evdns_config_windows_nameservers()

## ◆ evdns_resolve_ipv4()

EVENT2_EXPORT_SYMBOL int evdns_resolve_ipv4 | ( | const char * | name,
|  | int | flags,
|  | evdns_callback_type | callback,
|  | void * | ptr )

Lookup an A record for a given name.

Deprecated
  This function is deprecated because it does not allow the caller to specify which evdns_base it applies to. The recommended function is evdns_base_resolve_ipv4().

Parameters

  name | a DNS hostname
  flags | either 0, or DNS_QUERY_NO_SEARCH to disable searching for this query.
  callback | a callback function to invoke when the request is completed
  ptr | an argument to pass to the callback function

Returns
  0 if successful, or -1 if an error occurred

See also
  evdns_resolve_ipv6(), evdns_resolve_reverse(), evdns_resolve_reverse_ipv6()

## ◆ evdns_resolve_ipv6()

EVENT2_EXPORT_SYMBOL int evdns_resolve_ipv6 | ( | const char * | name,
|  | int | flags,
|  | evdns_callback_type | callback,
|  | void * | ptr )

Lookup an AAAA record for a given name.

Parameters

  name | a DNS hostname
  flags | either 0, or DNS_QUERY_NO_SEARCH to disable searching for this query.
  callback | a callback function to invoke when the request is completed
  ptr | an argument to pass to the callback function

Returns
  0 if successful, or -1 if an error occurred

See also
  evdns_resolve_ipv4(), evdns_resolve_reverse(), evdns_resolve_reverse_ipv6()

## ◆ evdns_resolve_reverse()

EVENT2_EXPORT_SYMBOL int evdns_resolve_reverse | ( | const struct in_addr * | in,
|  | int | flags,
|  | evdns_callback_type | callback,
|  | void * | ptr )

Lookup a PTR record for a given IP address.

Deprecated
  This function is deprecated because it does not allow the caller to specify which evdns_base it applies to. The recommended function is evdns_base_resolve_reverse().

Parameters

  in | an IPv4 address
  flags | either 0, or DNS_QUERY_NO_SEARCH to disable searching for this query.
  callback | a callback function to invoke when the request is completed
  ptr | an argument to pass to the callback function

Returns
  0 if successful, or -1 if an error occurred

See also
  evdns_resolve_reverse_ipv6()

## ◆ evdns_resolve_reverse_ipv6()

EVENT2_EXPORT_SYMBOL int evdns_resolve_reverse_ipv6 | ( | const struct in6_addr * | in,
|  | int | flags,
|  | evdns_callback_type | callback,
|  | void * | ptr )

Lookup a PTR record for a given IPv6 address.

Deprecated
  This function is deprecated because it does not allow the caller to specify which evdns_base it applies to. The recommended function is evdns_base_resolve_reverse_ipv6().

Parameters

  in | an IPv6 address
  flags | either 0, or DNS_QUERY_NO_SEARCH to disable searching for this query.
  callback | a callback function to invoke when the request is completed
  ptr | an argument to pass to the callback function

Returns
  0 if successful, or -1 if an error occurred

See also
  evdns_resolve_reverse_ipv6()

## ◆ evdns_resume()

EVENT2_EXPORT_SYMBOL int evdns_resume | ( | void |  | ) |

Resume normal operation and continue any suspended resolve requests.

Re-attempt resolves left in limbo after an earlier call to evdns_clear_nameservers_and_suspend().

Deprecated
  This function is deprecated because it does not allow the caller to specify which evdns_base it applies to. The recommended function is evdns_base_resume().

Returns
  0 if successful, or -1 if an error occurred

See also
  evdns_clear_nameservers_and_suspend()

## ◆ evdns_search_add()

EVENT2_EXPORT_SYMBOL void evdns_search_add | ( | const char * | domain | ) |

Add a domain to the list of search domains.

Deprecated
  This function is deprecated because it does not allow the caller to specify which evdns_base it applies to. The recommended function is evdns_base_search_add().

Parameters

  domain | the domain to be added to the search list

## ◆ evdns_search_clear()

EVENT2_EXPORT_SYMBOL void evdns_search_clear | ( | void |  | ) |

Clear the list of search domains.

Deprecated
  This function is deprecated because it does not allow the caller to specify which evdns_base it applies to. The recommended function is evdns_base_search_clear().

## ◆ evdns_search_ndots_set()

EVENT2_EXPORT_SYMBOL void evdns_search_ndots_set | ( | const int | ndots | ) |

Set the 'ndots' parameter for searches.

Sets the number of dots which, when found in a name, causes the first query to be without any search domain.

Deprecated
  This function is deprecated because it does not allow the caller to specify which evdns_base it applies to. The recommended function is evdns_base_search_ndots_set().

Parameters

  ndots | the new ndots parameter

## ◆ evdns_set_option()

EVENT2_EXPORT_SYMBOL int evdns_set_option | ( | const char * | option,
|  | const char * | val,
|  | int | flags )

Set the value of a configuration option.

The currently available configuration options are:

ndots, timeout, max-timeouts, max-inflight, and attempts

Deprecated
  This function is deprecated because it does not allow the caller to specify which evdns_base it applies to. The recommended function is evdns_base_set_option().

Parameters

  option | the name of the configuration option to be modified
  val | the value to be set
  flags | Ignored.

Returns
  0 if successful, or -1 if an error occurred

## ◆ evdns_shutdown()

EVENT2_EXPORT_SYMBOL void evdns_shutdown | ( | int | fail_requests | ) |

Shut down the asynchronous DNS resolver and terminate all active requests.

If the 'fail_requests' option is enabled, all active requests will return an empty result with the error flag set to DNS_ERR_SHUTDOWN. Otherwise, the requests will be silently discarded.

Deprecated
  This function is deprecated because it does not allow the caller to specify which evdns_base it applies to. The recommended function is evdns_base_shutdown().

Parameters

  fail_requests | if zero, active requests will be aborted; if non-zero, active requests will return DNS_ERR_SHUTDOWN.

See also
  evdns_init()