mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
dns_core: Create new API ast_dns_resolve_ipv6_and_ipv4
The new function takes in a pointer to an ast_sockaddr structure, a hostname and an optional port and then dispatches parallel "AAAA" and "A" record queries. If an "AAAA" record is returned, it's parsed into the ast_sockaddr structure along with the port if it was supplied. If no "AAAA" record was returned, the first "A" record returned (if any) is parsed instead. This is a synchronous call. If you need asynchronous lookups, use ast_dns_query_set_resolve_async and roll your own. Change-Id: I194b0b0e73da94b35cc35263a868ffac3a8d0a95
This commit is contained in:
@@ -28,6 +28,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "asterisk/netsock2.h"
|
||||
|
||||
/*! \brief Opaque structure for an active DNS query */
|
||||
struct ast_dns_query_active;
|
||||
|
||||
@@ -269,6 +271,26 @@ int ast_dns_resolve_cancel(struct ast_dns_query_active *active);
|
||||
*/
|
||||
int ast_dns_resolve(const char *name, int rr_type, int rr_class, struct ast_dns_result **result);
|
||||
|
||||
/*!
|
||||
* \brief Synchronously resolves host to an AAAA or A record
|
||||
* \since 16.6.0
|
||||
*
|
||||
* \param address A pointer to an ast_sockaddr structure to receive the IPv6 or IPv4 address
|
||||
* \param host The hostname to resolve
|
||||
* \param port (optional) A port to parse into the final ast_sockaddr structure
|
||||
*
|
||||
* \retval 0 success - query was completed and result is available
|
||||
* \retval -1 failure
|
||||
*
|
||||
* \note This function makes parallel queries for both AAAA and A records for the host.
|
||||
* The first returned AAAA record (if any) is used and if not found, the first A record
|
||||
* is used.
|
||||
*
|
||||
* \warning This function is synchronous and will block until records are returned or an error
|
||||
* occurrs.
|
||||
*/
|
||||
int ast_dns_resolve_ipv6_and_ipv4(struct ast_sockaddr *address, const char *host, const char *port);
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user