Commit 935a0728 authored by Simon Morlat's avatar Simon Morlat

Adapt to belle-sip's changes in resolver api. This avoids useless DNS queries...

Adapt to belle-sip's changes in resolver api. This avoids useless DNS queries when Record-route headers contain hostnames instead of IP addresses.
Using hostnames is better because it abstracts IPv4/IPv6.
parent 82dc9ac4
This diff is collapsed.
# Change Log
All notable changes to this project will be documented in this file.
Group changes to describe their impact on the project, as follows:
Added for new features.
Changed for changes in existing functionality.
Deprecated for once-stable features removed in upcoming releases.
Removed for deprecated features removed in this release.
Fixed for any bug fixes.
Security to invite users to upgrade in case of vulnerabilities.
## [Incomming]
### Added
- Avoid some SIP DNS lookups by keeping SRV target names
......@@ -41,7 +41,7 @@ static void linphone_nat_policy_destroy(LinphoneNatPolicy *policy) {
if (policy->ref) belle_sip_free(policy->ref);
if (policy->stun_server) belle_sip_free(policy->stun_server);
if (policy->stun_server_username) belle_sip_free(policy->stun_server_username);
if (policy->stun_addrinfo) bctbx_freeaddrinfo(policy->stun_addrinfo);
if (policy->resolver_results) belle_sip_object_unref(policy->resolver_results);
if (policy->stun_resolver_context) {
belle_sip_resolver_context_cancel(policy->stun_resolver_context);
belle_sip_object_unref(policy->stun_resolver_context);
......@@ -185,9 +185,9 @@ void linphone_nat_policy_set_stun_server(LinphoneNatPolicy *policy, const char *
if (new_stun_server != NULL) {
policy->stun_server = new_stun_server;
}
if (policy->stun_addrinfo) {
bctbx_freeaddrinfo(policy->stun_addrinfo);
policy->stun_addrinfo = NULL;
if (policy->resolver_results) {
belle_sip_object_unref(policy->resolver_results);
policy->resolver_results = NULL;
}
if (policy->stun_resolver_context){
belle_sip_resolver_context_cancel(policy->stun_resolver_context);
......@@ -213,18 +213,21 @@ void linphone_nat_policy_set_stun_server_username(LinphoneNatPolicy *policy, con
if (new_username != NULL) policy->stun_server_username = new_username;
}
static void stun_server_resolved(void *data, const char *name, struct addrinfo *addrinfo, uint32_t ttl) {
static void stun_server_resolved(void *data, belle_sip_resolver_results_t *results) {
LinphoneNatPolicy *policy = (LinphoneNatPolicy *)data;
if (policy->stun_addrinfo) {
bctbx_freeaddrinfo(policy->stun_addrinfo);
policy->stun_addrinfo = NULL;
if (policy->resolver_results) {
belle_sip_object_unref(policy->resolver_results);
policy->resolver_results = NULL;
}
if (addrinfo) {
if (belle_sip_resolver_results_get_addrinfos(results)) {
ms_message("Stun server resolution successful.");
belle_sip_object_ref(results);
policy->resolver_results = results;
} else {
ms_warning("Stun server resolution failed.");
}
policy->stun_addrinfo = addrinfo;
if (policy->stun_resolver_context){
belle_sip_object_unref(policy->stun_resolver_context);
policy->stun_resolver_context = NULL;
......@@ -266,17 +269,17 @@ const struct addrinfo * linphone_nat_policy_get_stun_server_addrinfo(LinphoneNat
* - if no cached value exists, block for a short time; this case must be unprobable because the resolution will be asked each
* time the stun server value is changed.
*/
if (linphone_nat_policy_stun_server_activated(policy) && (policy->stun_addrinfo == NULL)) {
if (linphone_nat_policy_stun_server_activated(policy) && (policy->resolver_results == NULL)) {
int wait_ms = 0;
int wait_limit = 1000;
linphone_nat_policy_resolve_stun_server(policy);
while ((policy->stun_addrinfo == NULL) && (policy->stun_resolver_context != NULL) && (wait_ms < wait_limit)) {
while ((policy->resolver_results == NULL) && (policy->stun_resolver_context != NULL) && (wait_ms < wait_limit)) {
policy->lc->sal->iterate();
ms_usleep(50000);
wait_ms += 50;
}
}
return policy->stun_addrinfo;
return policy->resolver_results ? belle_sip_resolver_results_get_addrinfos(policy->resolver_results) : NULL;
}
LinphoneNatPolicy * linphone_core_create_nat_policy(LinphoneCore *lc) {
......
......@@ -470,7 +470,7 @@ struct _LinphoneNatPolicy {
void *user_data;
LinphoneCore *lc;
belle_sip_resolver_context_t *stun_resolver_context;
struct addrinfo *stun_addrinfo;
belle_sip_resolver_results_t *resolver_results;
char *stun_server;
char *stun_server_username;
char *ref;
......
......@@ -50,9 +50,11 @@ LINPHONE_PUBLIC void linphone_core_use_sound_daemon(LinphoneCore *lc, LinphoneSo
LINPHONE_PUBLIC void linphone_sound_daemon_destroy(LinphoneSoundDaemon *obj);
LINPHONE_DEPRECATED typedef void (*LinphoneEcCalibrationCallback)(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *data);
LINPHONE_DEPRECATED typedef void (*LinphoneEcCalibrationAudioInit)(void *data);
LINPHONE_DEPRECATED typedef void (*LinphoneEcCalibrationAudioUninit)(void *data);
/*These typedefs are deprecated, but we don't mark them LINPHONE_DEPRECATED otherwise we get deprecation warnings with
* the deprecated linphone_core_start_echo_calibration() that make use of them*/
typedef void (*LinphoneEcCalibrationCallback)(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *data);
typedef void (*LinphoneEcCalibrationAudioInit)(void *data);
typedef void (*LinphoneEcCalibrationAudioUninit)(void *data);
/**
* @brief Starts an echo calibration of the sound devices, in order to find adequate settings for the echo canceler automatically.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment