diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index f2917f876..579a5336a 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -602,6 +602,16 @@ static void call_released(SalOp *op){ static void auth_requested(SalOp *h, const char *realm, const char *username){ LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(h)); LinphoneAuthInfo *ai=(LinphoneAuthInfo*)linphone_core_find_auth_info(lc,realm,username); + LinphoneCall *call=is_a_linphone_call(sal_op_get_user_pointer(h)); + + if (call && call->ping_op==h){ + /*don't request authentication for ping requests. Their purpose is just to get any + * answer to get the Via's received and rport parameters. + */ + ms_message("auth_requested(): ignored for ping request."); + return; + } + ms_message("auth_requested() for realm=%s, username=%s",realm,username); if (ai && ai->works==FALSE && ai->usecount>=3){ diff --git a/coreapi/misc.c b/coreapi/misc.c index 607ee6b3f..ea85f1036 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -557,6 +557,19 @@ void linphone_core_run_stun_tests(LinphoneCore *lc, LinphoneCall *call){ } } +LinphoneCall * is_a_linphone_call(void *user_pointer){ + LinphoneCall *call=(LinphoneCall*)user_pointer; + if (call==NULL) return NULL; + return call->magic==linphone_call_magic ? call : NULL; +} + +LinphoneProxyConfig * is_a_linphone_proxy_config(void *user_pointer){ + LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)user_pointer; + if (cfg==NULL) return NULL; + return cfg->magic==linphone_proxy_config_magic ? cfg : NULL; +} + + #ifdef HAVE_GETIFADDRS #include diff --git a/coreapi/private.h b/coreapi/private.h index 10876734b..ab317c981 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -75,8 +75,11 @@ struct _LinphoneCallParams{ }; +static const int linphone_call_magic=0x3343; + struct _LinphoneCall { + int magic; /*used to distinguish from proxy config*/ struct _LinphoneCore *core; SalMediaDescription *localdesc; SalMediaDescription *resultdesc; @@ -238,9 +241,14 @@ extern SalCallbacks linphone_sal_callbacks; void linphone_proxy_config_set_error(LinphoneProxyConfig *cfg, LinphoneReason error); bool_t linphone_core_rtcp_enabled(const LinphoneCore *lc); +LinphoneCall * is_a_linphone_call(void *user_pointer); +LinphoneProxyConfig * is_a_linphone_proxy_config(void *user_pointer); + +static const int linphone_proxy_config_magic=0x7979; struct _LinphoneProxyConfig { + int magic; struct _LinphoneCore *lc; char *reg_proxy; char *reg_identity;