Commit 8f6d6539 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Implement STUN authentication request callback.

parent ef66a8e3
......@@ -1434,11 +1434,11 @@ void linphone_call_free_media_resources(LinphoneCall *call){
int i;
linphone_call_stop_media_streams(call);
linphone_call_delete_upnp_session(call);
linphone_call_delete_ice_session(call);
for (i = 0; i < SAL_MEDIA_DESCRIPTION_MAX_STREAMS; ++i){
ms_media_stream_sessions_uninit(&call->sessions[i]);
}
linphone_call_delete_upnp_session(call);
linphone_call_delete_ice_session(call);
linphone_call_stats_uninit(&call->stats[LINPHONE_CALL_STATS_AUDIO]);
linphone_call_stats_uninit(&call->stats[LINPHONE_CALL_STATS_VIDEO]);
linphone_call_stats_uninit(&call->stats[LINPHONE_CALL_STATS_TEXT]);
......
......@@ -635,6 +635,36 @@ void linphone_core_enable_forced_ice_relay(LinphoneCore *lc, bool_t enable) {
lc->forced_ice_relay = enable;
}
static void stun_auth_requested_cb(LinphoneCall *call, const char *realm, const char *nonce, const char **username, const char **password, const char **ha1) {
LinphoneProxyConfig *proxy = NULL;
const LinphoneAddress *addr = NULL;
const LinphoneAuthInfo *auth_info = NULL;
LinphoneCore *lc = call->core;
const char *user;
// Get the username from the proxy config
if (call->dest_proxy != NULL) proxy = call->dest_proxy;
else proxy = linphone_core_get_default_proxy_config(call->core);
if (proxy == NULL) return;
addr = linphone_proxy_config_get_identity_address(proxy);
if (addr == NULL) return;
user = linphone_address_get_username(addr);
if (user == NULL) return;
auth_info = linphone_core_find_auth_info(lc, realm, user, NULL);
if (auth_info != NULL) {
const char *hash = linphone_auth_info_get_ha1(auth_info);
if (hash != NULL) {
*ha1 = hash;
} else {
*password = linphone_auth_info_get_passwd(auth_info);
}
*username = user;
} else {
ms_warning("No auth info found for STUN auth request");
}
}
int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call){
char local_addr[64];
const struct addrinfo *ai = NULL;
......@@ -697,6 +727,7 @@ int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call){
ms_message("ICE: gathering candidate from [%s] using %s", server, linphone_nat_policy_turn_enabled(nat_policy) ? "TURN" : "STUN");
/* Gather local srflx candidates. */
ice_session_enable_turn(call->ice_session, linphone_nat_policy_turn_enabled(nat_policy));
ice_session_set_stun_auth_requested_cb(call->ice_session, (MSStunAuthRequestedCb)stun_auth_requested_cb, call);
ice_session_gather_candidates(call->ice_session, ai->ai_addr, (socklen_t)ai->ai_addrlen);
return 1;
} else {
......
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